From 3b49905071680dc357dc8bd90b87a095a61112c9 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Mon, 14 Oct 2024 08:25:07 -0600 Subject: [PATCH 01/59] wip: pipelines --- common/api-review/firestore.api.md | 1685 ++++- packages/firestore/src/api.ts | 166 + packages/firestore/src/api/database.ts | 5 + .../firestore/src/core/firestore_client.ts | 25 +- .../src/lite-api/user_data_reader.ts | 71 +- .../src/model/pipeline_stream_element.ts | 13 + .../src/pipelines/api/expressions.ts | 6720 +++++++++++++++++ .../src/pipelines/api/pipeline-result.ts | 232 + .../src/pipelines/api/pipeline-source.ts | 48 + .../src/pipelines/api/pipeline-util.ts | 248 + .../firestore/src/pipelines/api/pipeline.ts | 735 ++ packages/firestore/src/pipelines/api/stage.ts | 384 + packages/firestore/src/protos/compile.sh | 15 +- .../src/protos/firestore_proto_api.ts | 90 +- .../src/protos/google/api/launch_stage.proto | 72 + .../protos/google/firestore/v1/document.proto | 112 + .../google/firestore/v1/firestore.proto | 88 +- .../protos/google/firestore/v1/pipeline.proto | 41 + .../google/firestore/v1/query_profile.proto | 92 + packages/firestore/src/protos/protos.json | 854 ++- packages/firestore/src/remote/datastore.ts | 37 +- .../firestore/src/remote/rest_connection.ts | 1 + packages/firestore/src/remote/serializer.ts | 128 +- packages/firestore/src/util/misc.ts | 20 + packages/firestore/src/util/obj.ts | 2 +- 25 files changed, 11603 insertions(+), 281 deletions(-) create mode 100644 packages/firestore/src/model/pipeline_stream_element.ts create mode 100644 packages/firestore/src/pipelines/api/expressions.ts create mode 100644 packages/firestore/src/pipelines/api/pipeline-result.ts create mode 100644 packages/firestore/src/pipelines/api/pipeline-source.ts create mode 100644 packages/firestore/src/pipelines/api/pipeline-util.ts create mode 100644 packages/firestore/src/pipelines/api/pipeline.ts create mode 100644 packages/firestore/src/pipelines/api/stage.ts create mode 100644 packages/firestore/src/protos/google/api/launch_stage.proto create mode 100644 packages/firestore/src/protos/google/firestore/v1/pipeline.proto create mode 100644 packages/firestore/src/protos/google/firestore/v1/query_profile.proto diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index 34b56b97f21..fd4942bea18 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -9,14 +9,54 @@ import { FirebaseApp } from '@firebase/app'; import { FirebaseError } from '@firebase/util'; import { LogLevelString as LogLevel } from '@firebase/logger'; +// @beta +export interface Accumulator { + // (undocumented) + accumulator: true; +} + +// @beta +export type AccumulatorTarget = ExprWithAlias; + +// @beta (undocumented) +export class Add extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function add(left: Constant, right: Constant): Add; + +// @beta +export function add(left: Constant, right: any): Add; + +// @beta +export function add(left: string, right: Constant): Add; + +// @beta +export function add(left: string, right: any): Add; + // @public export function addDoc(reference: CollectionReference, data: WithFieldValue): Promise>; +// @beta (undocumented) +export class AddFields implements Stage { + constructor(fields: Map); + // (undocumented) + name: string; +} + // @public export type AddPrefixToKeys> = { [K in keyof T & string as `${Prefix}.${K}`]+?: string extends K ? any : T[K]; }; +// @beta (undocumented) +export class Aggregate implements Stage { + constructor(accumulators: Map, groups: Map); + // (undocumented) + name: string; +} + // @public export class AggregateField { readonly aggregateType: AggregateType; @@ -53,18 +93,147 @@ export type AggregateSpecData = { // @public export type AggregateType = 'count' | 'avg' | 'sum'; +// @beta (undocumented) +export class And extends FirestoreFunction implements FilterCondition { + constructor(conditions: FilterExpr[]); + // (undocumented) + filterable: true; +} + // @public export function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; +// @beta +export function andExpression(left: FilterExpr, ...right: FilterExpr[]): And; + +// @beta (undocumented) +export class ArrayConcat extends FirestoreFunction { + constructor(array: Constant, elements: Constant[]); + } + +// @beta +export function arrayConcat(array: Constant, elements: Constant[]): ArrayConcat; + +// @beta +export function arrayConcat(array: Constant, elements: any[]): ArrayConcat; + +// @beta +export function arrayConcat(array: string, elements: Constant[]): ArrayConcat; + +// @beta +export function arrayConcat(array: string, elements: any[]): ArrayConcat; + +// @beta (undocumented) +export class ArrayContains extends FirestoreFunction implements FilterCondition { + constructor(array: Constant, element: Constant); + // (undocumented) + filterable: true; +} + +// @beta +export function arrayContains(array: Constant, element: Constant): ArrayContains; + +// @beta +export function arrayContains(array: Constant, element: any): ArrayContains; + +// @beta +export function arrayContains(array: string, element: Constant): ArrayContains; + +// @beta +export function arrayContains(array: string, element: any): ArrayContains; + +// @beta (undocumented) +export class ArrayContainsAll extends FirestoreFunction implements FilterCondition { + constructor(array: Constant, values: Constant[]); + // (undocumented) + filterable: true; + } + +// @beta +export function arrayContainsAll(array: Constant, values: Constant[]): ArrayContainsAll; + +// @beta +export function arrayContainsAll(array: Constant, values: any[]): ArrayContainsAll; + +// @beta +export function arrayContainsAll(array: string, values: Constant[]): ArrayContainsAll; + +// @beta +export function arrayContainsAll(array: string, values: any[]): ArrayContainsAll; + +// @beta (undocumented) +export class ArrayContainsAny extends FirestoreFunction implements FilterCondition { + constructor(array: Constant, values: Constant[]); + // (undocumented) + filterable: true; + } + +// @beta +export function arrayContainsAny(array: Constant, values: Constant[]): ArrayContainsAny; + +// @beta +export function arrayContainsAny(array: Constant, values: any[]): ArrayContainsAny; + +// @beta +export function arrayContainsAny(array: string, values: Constant[]): ArrayContainsAny; + +// @beta +export function arrayContainsAny(array: string, values: any[]): ArrayContainsAny; + +// @beta (undocumented) +export class ArrayElement extends FirestoreFunction { + constructor(); +} + +// @beta (undocumented) +export class ArrayLength extends FirestoreFunction { + constructor(array: Constant); + } + +// @beta +export function arrayLength(array: Constant): ArrayLength; + // @public export function arrayRemove(...elements: unknown[]): FieldValue; +// @beta (undocumented) +export class ArrayReverse extends FirestoreFunction { + constructor(array: Constant); + } + // @public export function arrayUnion(...elements: unknown[]): FieldValue; +// @beta +export function ascending(expr: Constant): Ordering; + // @public export function average(field: string | FieldPath): AggregateField; +// @beta (undocumented) +export class Avg extends FirestoreFunction implements Accumulator { + constructor(value: Constant, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta +export function avg(value: Constant): Avg; + +// @beta +export function avg(value: string): Avg; + +// @beta (undocumented) +export class ByteLength extends FirestoreFunction { + constructor(value: Constant); + } + +// @beta +export function byteLength(expr: Constant): ByteLength; + +// @beta +export function byteLength(field: string): ByteLength; + // @public export class Bytes { static fromBase64String(base64: string): Bytes; @@ -78,6 +247,17 @@ export class Bytes { // @public export const CACHE_SIZE_UNLIMITED = -1; +// @beta (undocumented) +export class CharLength extends FirestoreFunction { + constructor(value: Constant); + } + +// @beta +export function charLength(field: string): CharLength; + +// @beta +export function charLength(expr: Constant): CharLength; + // @public export type ChildUpdateFields = V extends Record ? AddPrefixToKeys> : never; @@ -96,6 +276,13 @@ export function collection(refer // @public export function collectionGroup(firestore: Firestore, collectionId: string): Query; +// @beta (undocumented) +export class CollectionGroupSource implements Stage { + constructor(collectionId: string); + // (undocumented) + name: string; +} + // @public export class CollectionReference extends Query { get id(): string; @@ -106,14 +293,183 @@ export class CollectionReference; } +// @beta (undocumented) +export class CollectionSource implements Stage { + constructor(collectionPath: string); + // (undocumented) + name: string; +} + // @public export function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: { mockUserToken?: EmulatorMockTokenOptions | string; }): void; +// @beta +export class Constant { + add(other: Constant): Add; + add(other: any): Add; + arrayConcat(arrays: Constant[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat; + arrayContains(element: Constant): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Constant[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Constant[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Constant): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Constant): Divide; + divide(other: any): Divide; + dotProduct(other: Constant): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Constant): EndsWith; + eq(other: Constant): Eq; + eq(other: any): Eq; + euclideanDistance(other: Constant): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + gt(other: Constant): Gt; + gt(other: any): Gt; + gte(other: Constant): Gte; + gte(other: any): Gte; + in(...others: Constant[]): In; + // (undocumented) + in(...others: any[]): In; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Constant): Like; + logicalMax(other: Constant): LogicalMax; + logicalMax(other: any): LogicalMax; + logicalMin(other: Constant): LogicalMin; + logicalMin(other: any): LogicalMin; + lt(other: Constant): Lt; + lt(other: any): Lt; + lte(other: Constant): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + max(): Max; + min(): Min; + mod(other: Constant): Mod; + mod(other: any): Mod; + multiply(other: Constant): Multiply; + multiply(other: any): Multiply; + neq(other: Constant): Neq; + neq(other: any): Neq; + static of(value: number): Constant; + static of(value: string): Constant; + static of(value: boolean): Constant; + static of(value: null): Constant; + static of(value: undefined): Constant; + static of(value: GeoPoint): Constant; + static of(value: Timestamp): Constant; + static of(value: Date): Constant; + static of(value: Uint8Array): Constant; + static of(value: DocumentReference): Constant; + static of(value: any[]): Constant; + static of(value: Map): Constant; + static of(value: VectorValue): Constant; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Constant): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Constant): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Constant, replace: Constant): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Constant, replace: Constant): ReplaceFirst; + reverse(): Reverse; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Constant): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Constant): StrContains; + subtract(other: Constant): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Constant, amount: Constant): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Constant, amount: Constant): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + static vector(value: number[] | VectorValue): Constant; + vectorLength(): VectorLength; +} + +// @beta (undocumented) +export class CosineDistance extends FirestoreFunction { + constructor(vector1: Constant, vector2: Constant); + } + +// @beta +export function cosineDistance(expr: string, other: number[]): CosineDistance; + +// @beta +export function cosineDistance(expr: string, other: VectorValue): CosineDistance; + +// @beta +export function cosineDistance(expr: string, other: Constant): CosineDistance; + +// @beta +export function cosineDistance(expr: Constant, other: number[]): CosineDistance; + +// @beta +export function cosineDistance(expr: Constant, other: VectorValue): CosineDistance; + +// @beta +export function cosineDistance(expr: Constant, other: Constant): CosineDistance; + +// @beta (undocumented) +export class Count extends FirestoreFunction implements Accumulator { + constructor(value: Constant | undefined, distinct: boolean); + // (undocumented) + accumulator: true; + } + // @public export function count(): AggregateField; +// @beta +export function countAll(): Count; + +// @beta +export function countExpression(value: Constant): Count; + +// Warning: (ae-incompatible-release-tags) The symbol "countExpression" is marked as @public, but its signature references "Count" which is marked as @beta +// +// @public +export function countExpression(value: string): Count; + +// @beta (undocumented) +export class DatabaseSource implements Stage { + // (undocumented) + name: string; +} + // @public export function deleteAllPersistentCacheIndexes(indexManager: PersistentCacheIndexManager): void; @@ -123,12 +479,39 @@ export function deleteDoc(refere // @public export function deleteField(): FieldValue; +// @beta +export function descending(expr: Constant): Ordering; + // @public export function disableNetwork(firestore: Firestore): Promise; // @public export function disablePersistentCacheIndexAutoCreation(indexManager: PersistentCacheIndexManager): void; +// @beta (undocumented) +export class Distinct implements Stage { + constructor(groups: Map); + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class Divide extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function divide(left: Constant, right: Constant): Divide; + +// @beta +export function divide(left: Constant, right: any): Divide; + +// @beta +export function divide(left: string, right: Constant): Divide; + +// @beta +export function divide(left: string, right: any): Divide; + // @public export function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference; @@ -180,6 +563,38 @@ export class DocumentSnapshot; } +// @beta (undocumented) +export class DocumentsSource implements Stage { + constructor(docPaths: string[]); + // (undocumented) + name: string; + // (undocumented) + static of(refs: DocumentReference[]): DocumentsSource; +} + +// @beta (undocumented) +export class DotProduct extends FirestoreFunction { + constructor(vector1: Constant, vector2: Constant); + } + +// @beta +export function dotProduct(expr: string, other: number[]): DotProduct; + +// @beta +export function dotProduct(expr: string, other: VectorValue): DotProduct; + +// @beta +export function dotProduct(expr: string, other: Constant): DotProduct; + +// @beta +export function dotProduct(expr: Constant, other: number[]): DotProduct; + +// @beta +export function dotProduct(expr: Constant, other: VectorValue): DotProduct; + +// @beta +export function dotProduct(expr: Constant, other: Constant): DotProduct; + export { EmulatorMockTokenOptions } // @public @deprecated @@ -206,25 +621,462 @@ export function endBefore(snapsh // @public export function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint; +// @beta (undocumented) +export class EndsWith extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, suffix: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function endsWith(expr: string, suffix: string): EndsWith; + +// @beta +export function endsWith(expr: string, suffix: Constant): EndsWith; + +// @beta +export function endsWith(expr: Constant, suffix: string): EndsWith; + +// @beta +export function endsWith(expr: Constant, suffix: Constant): EndsWith; + +// @beta (undocumented) +export class Eq extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function eq(left: Constant, right: Constant): Eq; + +// @beta +export function eq(left: Constant, right: any): Eq; + +// @beta +export function eq(left: string, right: Constant): Eq; + +// @beta +export function eq(left: string, right: any): Eq; + +// @beta (undocumented) +export class EuclideanDistance extends FirestoreFunction { + constructor(vector1: Constant, vector2: Constant); + } + +// @beta +export function euclideanDistance(expr: string, other: number[]): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: string, other: VectorValue): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: string, other: Constant): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: Constant, other: number[]): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: Constant, other: VectorValue): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: Constant, other: Constant): EuclideanDistance; + +// @beta (undocumented) +export class Exists extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant); + // (undocumented) + filterable: true; +} + +// @beta +export function exists(value: Constant): Exists; + +// @beta +export function exists(field: string): Exists; + // @public export interface ExperimentalLongPollingOptions { timeoutSeconds?: number; } +// @beta +export type ExprType = 'Field' | 'Constant' | 'Function' | 'ListOfExprs' | 'ExprWithAlias'; + +// @beta (undocumented) +export class ExprWithAlias implements Selectable { + constructor(expr: T, alias: string); + add(other: Constant): Add; + add(other: any): Add; + // (undocumented) + alias: string; + arrayConcat(arrays: Constant[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat; + arrayContains(element: Constant): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Constant[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Constant[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Constant): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Constant): Divide; + divide(other: any): Divide; + dotProduct(other: Constant): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Constant): EndsWith; + eq(other: Constant): Eq; + eq(other: any): Eq; + euclideanDistance(other: Constant): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + expr: T; + // (undocumented) + exprType: ExprType; + gt(other: Constant): Gt; + gt(other: any): Gt; + gte(other: Constant): Gte; + gte(other: any): Gte; + in(...others: Constant[]): In; + // (undocumented) + in(...others: any[]): In; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Constant): Like; + logicalMax(other: Constant): LogicalMax; + logicalMax(other: any): LogicalMax; + logicalMin(other: Constant): LogicalMin; + logicalMin(other: any): LogicalMin; + lt(other: Constant): Lt; + lt(other: any): Lt; + lte(other: Constant): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + max(): Max; + min(): Min; + mod(other: Constant): Mod; + mod(other: any): Mod; + multiply(other: Constant): Multiply; + multiply(other: any): Multiply; + neq(other: Constant): Neq; + neq(other: any): Neq; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Constant): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Constant): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Constant, replace: Constant): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Constant, replace: Constant): ReplaceFirst; + reverse(): Reverse; + // (undocumented) + selectable: true; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Constant): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Constant): StrContains; + subtract(other: Constant): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Constant, amount: Constant): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Constant, amount: Constant): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + +// @beta +export class Field implements Selectable { + add(other: Constant): Add; + add(other: any): Add; + arrayConcat(arrays: Constant[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat; + arrayContains(element: Constant): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Constant[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Constant[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Constant): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Constant): Divide; + divide(other: any): Divide; + dotProduct(other: Constant): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Constant): EndsWith; + eq(other: Constant): Eq; + eq(other: any): Eq; + euclideanDistance(other: Constant): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + // (undocumented) + fieldName(): string; + gt(other: Constant): Gt; + gt(other: any): Gt; + gte(other: Constant): Gte; + gte(other: any): Gte; + in(...others: Constant[]): In; + // (undocumented) + in(...others: any[]): In; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Constant): Like; + logicalMax(other: Constant): LogicalMax; + logicalMax(other: any): LogicalMax; + logicalMin(other: Constant): LogicalMin; + logicalMin(other: any): LogicalMin; + lt(other: Constant): Lt; + lt(other: any): Lt; + lte(other: Constant): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + max(): Max; + min(): Min; + mod(other: Constant): Mod; + mod(other: any): Mod; + multiply(other: Constant): Multiply; + multiply(other: any): Multiply; + neq(other: Constant): Neq; + neq(other: any): Neq; + static of(name: string): Field; + // (undocumented) + static of(path: FieldPath): Field; + // (undocumented) + static of(pipeline: Pipeline, name: string): Field; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Constant): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Constant): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Constant, replace: Constant): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Constant, replace: Constant): ReplaceFirst; + reverse(): Reverse; + // (undocumented) + selectable: true; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Constant): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Constant): StrContains; + subtract(other: Constant): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Constant, amount: Constant): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Constant, amount: Constant): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + // @public export class FieldPath { constructor(...fieldNames: string[]); isEqual(other: FieldPath): boolean; } +// @beta (undocumented) +export class Fields implements Selectable { + add(other: Constant): Add; + add(other: any): Add; + arrayConcat(arrays: Constant[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat; + arrayContains(element: Constant): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Constant[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Constant[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Constant): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Constant): Divide; + divide(other: any): Divide; + dotProduct(other: Constant): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Constant): EndsWith; + eq(other: Constant): Eq; + eq(other: any): Eq; + euclideanDistance(other: Constant): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + // (undocumented) + fieldList(): Field[]; + gt(other: Constant): Gt; + gt(other: any): Gt; + gte(other: Constant): Gte; + gte(other: any): Gte; + in(...others: Constant[]): In; + // (undocumented) + in(...others: any[]): In; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Constant): Like; + logicalMax(other: Constant): LogicalMax; + logicalMax(other: any): LogicalMax; + logicalMin(other: Constant): LogicalMin; + logicalMin(other: any): LogicalMin; + lt(other: Constant): Lt; + lt(other: any): Lt; + lte(other: Constant): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + max(): Max; + min(): Min; + mod(other: Constant): Mod; + mod(other: any): Mod; + multiply(other: Constant): Multiply; + multiply(other: any): Multiply; + neq(other: Constant): Neq; + neq(other: any): Neq; + // (undocumented) + static of(name: string, ...others: string[]): Fields; + // (undocumented) + static ofAll(): Fields; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Constant): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Constant): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Constant, replace: Constant): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Constant, replace: Constant): ReplaceFirst; + reverse(): Reverse; + // (undocumented) + selectable: true; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Constant): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Constant): StrContains; + subtract(other: Constant): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Constant, amount: Constant): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Constant, amount: Constant): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + // @public export abstract class FieldValue { abstract isEqual(other: FieldValue): boolean; } +// @beta +export interface FilterCondition { + // (undocumented) + filterable: true; +} + +// @beta +export type FilterExpr = Constant & FilterCondition; + +// @beta (undocumented) +export class FindNearest implements Stage { + // (undocumented) + name: string; +} + +// @beta (undocumented) +export interface FindNearestOptions { + // (undocumented) + distanceField?: string; + // (undocumented) + distanceMeasure: 'euclidean' | 'cosine' | 'dot_product'; + // (undocumented) + field: Field; + // (undocumented) + limit?: number; + // (undocumented) + vectorValue: VectorValue | number[]; +} + // @public export class Firestore { get app(): FirebaseApp; + // Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta + // + // (undocumented) + pipeline: () => PipelineSource | undefined; toJSON(): object; type: 'firestore-lite' | 'firestore'; } @@ -246,6 +1098,108 @@ export class FirestoreError extends FirebaseError { // @public export type FirestoreErrorCode = 'cancelled' | 'unknown' | 'invalid-argument' | 'deadline-exceeded' | 'not-found' | 'already-exists' | 'permission-denied' | 'resource-exhausted' | 'failed-precondition' | 'aborted' | 'out-of-range' | 'unimplemented' | 'internal' | 'unavailable' | 'data-loss' | 'unauthenticated'; +// @beta +export class FirestoreFunction { + constructor(name: string, params: Constant[]); + add(other: Constant): Add; + add(other: any): Add; + arrayConcat(arrays: Constant[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat; + arrayContains(element: Constant): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Constant[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Constant[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Constant): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Constant): Divide; + divide(other: any): Divide; + dotProduct(other: Constant): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Constant): EndsWith; + eq(other: Constant): Eq; + eq(other: any): Eq; + euclideanDistance(other: Constant): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + gt(other: Constant): Gt; + gt(other: any): Gt; + gte(other: Constant): Gte; + gte(other: any): Gte; + in(...others: Constant[]): In; + // (undocumented) + in(...others: any[]): In; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Constant): Like; + logicalMax(other: Constant): LogicalMax; + logicalMax(other: any): LogicalMax; + logicalMin(other: Constant): LogicalMin; + logicalMin(other: any): LogicalMin; + lt(other: Constant): Lt; + lt(other: any): Lt; + lte(other: Constant): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + max(): Max; + min(): Min; + mod(other: Constant): Mod; + mod(other: any): Mod; + multiply(other: Constant): Multiply; + multiply(other: any): Multiply; + neq(other: Constant): Neq; + neq(other: any): Neq; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Constant): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Constant): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Constant, replace: Constant): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Constant, replace: Constant): ReplaceFirst; + reverse(): Reverse; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Constant): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Constant): StrContains; + subtract(other: Constant): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Constant, amount: Constant): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Constant, amount: Constant): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + // @public export type FirestoreLocalCache = MemoryLocalCache | PersistentLocalCache; @@ -261,6 +1215,16 @@ export interface FirestoreSettings { ssl?: boolean; } +// @beta +export function genericFunction(name: string, params: Constant[]): FirestoreFunction; + +// @beta (undocumented) +export class GenericStage implements Stage { + constructor(name: string, params: any[]); + // (undocumented) + name: string; +} + // @public export class GeoPoint { constructor(latitude: number, longitude: number); @@ -314,6 +1278,73 @@ export function getFirestore(app: FirebaseApp, databaseId: string): Firestore; // @public export function getPersistentCacheIndexManager(firestore: Firestore): PersistentCacheIndexManager | null; +// @beta (undocumented) +export class Gt extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function gt(left: Constant, right: Constant): Gt; + +// @beta +export function gt(left: Constant, right: any): Gt; + +// @beta +export function gt(left: string, right: Constant): Gt; + +// @beta +export function gt(left: string, right: any): Gt; + +// @beta (undocumented) +export class Gte extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function gte(left: Constant, right: Constant): Gte; + +// @beta +export function gte(left: Constant, right: any): Gte; + +// @beta +export function gte(left: string, right: Constant): Gte; + +// @beta +export function gte(left: string, right: any): Gte; + +// @beta (undocumented) +export class If extends FirestoreFunction implements FilterCondition { + constructor(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function ifFunction(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant): If; + +// @beta (undocumented) +export class In extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, others: Constant[]); + // (undocumented) + filterable: true; + } + +// @beta +export function inAny(element: Constant, others: Constant[]): In; + +// @beta +export function inAny(element: Constant, others: any[]): In; + +// @beta +export function inAny(element: string, others: Constant[]): In; + +// @beta +export function inAny(element: string, others: any[]): In; + // @public export function increment(n: number): FieldValue; @@ -344,6 +1375,45 @@ export interface IndexField { // @public export function initializeFirestore(app: FirebaseApp, settings: FirestoreSettings, databaseId?: string): Firestore; +// @beta (undocumented) +export class IsNan extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant); + // (undocumented) + filterable: true; +} + +// @beta +export function isNan(value: Constant): IsNan; + +// @beta +export function isNan(value: string): IsNan; + +// @beta (undocumented) +export class Like extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, pattern: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function like(left: string, pattern: string): Like; + +// @beta +export function like(left: string, pattern: Constant): Like; + +// @beta +export function like(left: Constant, pattern: string): Like; + +// @beta +export function like(left: Constant, pattern: Constant): Like; + +// @beta (undocumented) +export class Limit implements Stage { + constructor(limit: number); + // (undocumented) + name: string; +} + // @public export function limit(limit: number): QueryLimitConstraint; @@ -364,15 +1434,114 @@ export class LoadBundleTask implements PromiseLike { } // @public -export interface LoadBundleTaskProgress { - bytesLoaded: number; - documentsLoaded: number; - taskState: TaskState; - totalBytes: number; - totalDocuments: number; +export interface LoadBundleTaskProgress { + bytesLoaded: number; + documentsLoaded: number; + taskState: TaskState; + totalBytes: number; + totalDocuments: number; +} + +// @beta (undocumented) +export class LogicalMax extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function logicalMax(left: Constant, right: Constant): LogicalMax; + +// @beta +export function logicalMax(left: Constant, right: any): LogicalMax; + +// @beta +export function logicalMax(left: string, right: Constant): LogicalMax; + +// @beta +export function logicalMax(left: string, right: any): LogicalMax; + +// @beta (undocumented) +export class LogicalMin extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function logicalMin(left: Constant, right: Constant): LogicalMin; + +// @beta +export function logicalMin(left: Constant, right: any): LogicalMin; + +// @beta +export function logicalMin(left: string, right: Constant): LogicalMin; + +// @beta +export function logicalMin(left: string, right: any): LogicalMin; + +export { LogLevel } + +// @beta (undocumented) +export class Lt extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function lt(left: Constant, right: Constant): Lt; + +// @beta +export function lt(left: Constant, right: any): Lt; + +// @beta +export function lt(left: string, right: Constant): Lt; + +// @beta +export function lt(left: string, right: any): Lt; + +// @beta (undocumented) +export class Lte extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function lte(left: Constant, right: Constant): Lte; + +// @beta +export function lte(left: Constant, right: any): Lte; + +// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Constant" which is marked as @beta +// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Lte" which is marked as @beta +// +// @public +export function lte(left: string, right: Constant): Lte; + +// @beta +export function lte(left: string, right: any): Lte; + +// @beta (undocumented) +export class MapGet extends FirestoreFunction { + constructor(map: Constant, name: string); } -export { LogLevel } +// @beta +export function mapGet(mapField: string, subField: string): MapGet; + +// @beta +export function mapGet(mapExpr: Constant, subField: string): MapGet; + +// @beta (undocumented) +export class Max extends FirestoreFunction implements Accumulator { + constructor(value: Constant, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta +export function max(value: Constant): Max; + +// @beta +export function max(value: string): Max; // @public export interface MemoryCacheSettings { @@ -411,14 +1580,109 @@ export function memoryLruGarbageCollector(settings?: { cacheSizeBytes?: number; }): MemoryLruGarbageCollector; +// @beta (undocumented) +export class Min extends FirestoreFunction implements Accumulator { + constructor(value: Constant, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta +export function min(value: Constant): Min; + +// @beta +export function min(value: string): Min; + +// @beta (undocumented) +export class Mod extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function mod(left: Constant, right: Constant): Mod; + +// @beta +export function mod(left: Constant, right: any): Mod; + +// @beta +export function mod(left: string, right: Constant): Mod; + +// @beta +export function mod(left: string, right: any): Mod; + +// @beta (undocumented) +export class Multiply extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function multiply(left: Constant, right: Constant): Multiply; + +// @beta +export function multiply(left: Constant, right: any): Multiply; + +// @beta +export function multiply(left: string, right: Constant): Multiply; + +// @beta +export function multiply(left: string, right: any): Multiply; + // @public export function namedQuery(firestore: Firestore, name: string): Promise; +// @beta (undocumented) +export class Neq extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function neq(left: Constant, right: Constant): Neq; + +// @beta +export function neq(left: Constant, right: any): Neq; + +// @beta +export function neq(left: string, right: Constant): Neq; + +// @beta +export function neq(left: string, right: any): Neq; + // @public export type NestedUpdateFields> = UnionToIntersection<{ [K in keyof T & string]: ChildUpdateFields; }[keyof T & string]>; +// @beta (undocumented) +export class Not extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant); + // (undocumented) + filterable: true; +} + +// @beta +export function not(filter: FilterExpr): Not; + +// @beta +export function notInAny(element: Constant, others: Constant[]): Not; + +// @beta +export function notInAny(element: Constant, others: any[]): Not; + +// @beta +export function notInAny(element: string, others: Constant[]): Not; + +// @beta +export function notInAny(element: string, others: any[]): Not; + +// @beta (undocumented) +export class Offset implements Stage { + constructor(offset: number); + // (undocumented) + name: string; + } + // @public export function onSnapshot(reference: DocumentReference, observer: { next?: (snapshot: DocumentSnapshot) => void; @@ -469,6 +1733,13 @@ export function onSnapshotsInSync(firestore: Firestore, observer: { // @public export function onSnapshotsInSync(firestore: Firestore, onSync: () => void): Unsubscribe; +// @beta (undocumented) +export class Or extends FirestoreFunction implements FilterCondition { + constructor(conditions: FilterExpr[]); + // (undocumented) + filterable: true; +} + // @public export function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; @@ -478,6 +1749,14 @@ export function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDir // @public export type OrderByDirection = 'desc' | 'asc'; +// @beta +export class Ordering { + constructor(expr: Constant, direction: 'ascending' | 'descending'); + } + +// @beta +export function orExpression(left: FilterExpr, ...right: FilterExpr[]): Or; + // @public export type PartialWithFieldValue = Partial | (T extends Primitive ? T : T extends {} ? { [K in keyof T]?: PartialWithFieldValue | FieldValue; @@ -534,6 +1813,58 @@ export interface PersistentSingleTabManagerSettings { // @public export type PersistentTabManager = PersistentSingleTabManager | PersistentMultipleTabManager; +// @beta +export class Pipeline { + constructor(db: Firestore, stages: Stage[], converter?: unknown); + addFields(...fields: Selectable[]): Pipeline; + aggregate(...accumulators: AccumulatorTarget[]): Pipeline; + aggregate(options: { + accumulators: AccumulatorTarget[]; + groups?: Array; + }): Pipeline; + distinct(...groups: Array): Pipeline; + execute(): Promise>>; + // (undocumented) + findNearest(options: FindNearestOptions): Pipeline; + genericStage(name: string, params: any[]): Pipeline; + limit(limit: number): Pipeline; + offset(offset: number): Pipeline; + select(...selections: Array): Pipeline; + sort(...orderings: Ordering[]): Pipeline; + // (undocumented) + sort(options: { + orderings: Ordering[]; + }): Pipeline; + where(condition: FilterCondition & Constant): Pipeline; +} + +// @beta +export class PipelineResult { + /* Excluded from this release type: _ref */ + /* Excluded from this release type: _fields */ + /* Excluded from this release type: __constructor */ + get createTime(): Timestamp | undefined; + data(): AppModelType | undefined; + get executionTime(): Timestamp; + get(fieldPath: string | FieldPath): any; + get id(): string | undefined; + get ref(): DocumentReference | undefined; + get updateTime(): Timestamp | undefined; +} + +// @beta +export class PipelineSource { + constructor(db: Firestore); + // (undocumented) + collection(collectionPath: string): Pipeline; + // (undocumented) + collectionGroup(collectionId: string): Pipeline; + // (undocumented) + database(): Pipeline; + // (undocumented) + documents(docs: DocumentReference[]): Pipeline; +} + // @public export type Primitive = string | number | boolean | undefined | null; @@ -620,9 +1951,102 @@ export class QueryStartAtConstraint extends QueryConstraint { // @public export function refEqual(left: DocumentReference | CollectionReference, right: DocumentReference | CollectionReference): boolean; +// @beta (undocumented) +export class RegexContains extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, pattern: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function regexContains(left: string, pattern: string): RegexContains; + +// @beta +export function regexContains(left: string, pattern: Constant): RegexContains; + +// @beta +export function regexContains(left: Constant, pattern: string): RegexContains; + +// @beta +export function regexContains(left: Constant, pattern: Constant): RegexContains; + +// @beta (undocumented) +export class RegexMatch extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, pattern: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function regexMatch(left: string, pattern: string): RegexMatch; + +// @beta +export function regexMatch(left: string, pattern: Constant): RegexMatch; + +// @beta +export function regexMatch(left: Constant, pattern: string): RegexMatch; + +// @beta +export function regexMatch(left: Constant, pattern: Constant): RegexMatch; + +// @beta (undocumented) +export class ReplaceAll extends FirestoreFunction { + constructor(value: Constant, find: Constant, replace: Constant); + } + +// @beta +export function replaceAll(value: Constant, find: string, replace: string): ReplaceAll; + +// @beta +export function replaceAll(value: Constant, find: Constant, replace: Constant): ReplaceAll; + +// @beta +export function replaceAll(field: string, find: string, replace: string): ReplaceAll; + +// @beta (undocumented) +export class ReplaceFirst extends FirestoreFunction { + constructor(value: Constant, find: Constant, replace: Constant); + } + +// @beta +export function replaceFirst(value: Constant, find: string, replace: string): ReplaceFirst; + +// @beta +export function replaceFirst(value: Constant, find: Constant, replace: Constant): ReplaceFirst; + +// @beta +export function replaceFirst(field: string, find: string, replace: string): ReplaceFirst; + +// @beta (undocumented) +export class Reverse extends FirestoreFunction { + constructor(value: Constant); + } + +// @beta +export function reverse(expr: Constant): Reverse; + +// @beta +export function reverse(field: string): Reverse; + // @public export function runTransaction(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise, options?: TransactionOptions): Promise; +// @beta (undocumented) +export class Select implements Stage { + constructor(projections: Map); + // (undocumented) + name: string; + } + +// @beta +export interface Selectable { + // (undocumented) + selectable: true; +} + +// @beta +export type SelectableExpr = Constant & Selectable; + // @public export function serverTimestamp(): FieldValue; @@ -669,6 +2093,19 @@ export interface SnapshotOptions { readonly serverTimestamps?: 'estimate' | 'previous' | 'none'; } +// @beta (undocumented) +export class Sort implements Stage { + constructor(orders: Ordering[]); + // (undocumented) + name: string; + } + +// @beta (undocumented) +export interface Stage { + // (undocumented) + name: string; +} + // @public export function startAfter(snapshot: DocumentSnapshot): QueryStartAtConstraint; @@ -681,9 +2118,88 @@ export function startAt(snapshot // @public export function startAt(...fieldValues: unknown[]): QueryStartAtConstraint; +// @beta (undocumented) +export class StartsWith extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, prefix: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function startsWith(expr: string, prefix: string): StartsWith; + +// @beta +export function startsWith(expr: string, prefix: Constant): StartsWith; + +// @beta +export function startsWith(expr: Constant, prefix: string): StartsWith; + +// @beta +export function startsWith(expr: Constant, prefix: Constant): StartsWith; + +// @beta (undocumented) +export class StrConcat extends FirestoreFunction { + constructor(first: Constant, rest: Constant[]); + } + +// @beta +export function strConcat(first: string, ...elements: Array): StrConcat; + +// @beta +export function strConcat(first: Constant, ...elements: Array): StrConcat; + +// @beta (undocumented) +export class StrContains extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, substring: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function strContains(left: string, substring: string): StrContains; + +// @beta +export function strContains(left: string, substring: Constant): StrContains; + +// @beta +export function strContains(left: Constant, substring: string): StrContains; + +// @beta +export function strContains(left: Constant, substring: Constant): StrContains; + +// @beta (undocumented) +export class Subtract extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function subtract(left: Constant, right: Constant): Subtract; + +// @beta +export function subtract(left: Constant, right: any): Subtract; + +// @beta +export function subtract(left: string, right: Constant): Subtract; + +// @beta +export function subtract(left: string, right: any): Subtract; + +// @beta (undocumented) +export class Sum extends FirestoreFunction implements Accumulator { + constructor(value: Constant, distinct: boolean); + // (undocumented) + accumulator: true; + } + // @public export function sum(field: string | FieldPath): AggregateField; +// @beta +export function sumExpression(value: Constant): Sum; + +// @beta +export function sumExpression(value: string): Sum; + // @public export type TaskState = 'Error' | 'Running' | 'Success'; @@ -711,6 +2227,89 @@ export class Timestamp { valueOf(): string; } +// @beta (undocumented) +export class TimestampAdd extends FirestoreFunction { + constructor(timestamp: Constant, unit: Constant, amount: Constant); + } + +// @beta +export function timestampAdd(timestamp: Constant, unit: Constant, amount: Constant): TimestampAdd; + +// @beta +export function timestampAdd(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + +// @beta +export function timestampAdd(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + +// @beta (undocumented) +export class TimestampSub extends FirestoreFunction { + constructor(timestamp: Constant, unit: Constant, amount: Constant); + } + +// @beta +export function timestampSub(timestamp: Constant, unit: Constant, amount: Constant): TimestampSub; + +// @beta +export function timestampSub(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + +// @beta +export function timestampSub(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + +// @beta (undocumented) +export class TimestampToUnixMicros extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function timestampToUnixMicros(expr: Constant): TimestampToUnixMicros; + +// @beta +export function timestampToUnixMicros(field: string): TimestampToUnixMicros; + +// @beta (undocumented) +export class TimestampToUnixMillis extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function timestampToUnixMillis(expr: Constant): TimestampToUnixMillis; + +// @beta +export function timestampToUnixMillis(field: string): TimestampToUnixMillis; + +// @beta (undocumented) +export class TimestampToUnixSeconds extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function timestampToUnixSeconds(expr: Constant): TimestampToUnixSeconds; + +// @beta +export function timestampToUnixSeconds(field: string): TimestampToUnixSeconds; + +// @beta (undocumented) +export class ToLower extends FirestoreFunction { + constructor(expr: Constant); + } + +// @beta +export function toLower(expr: string): ToLower; + +// @beta +export function toLower(expr: Constant): ToLower; + +// @beta (undocumented) +export class ToUpper extends FirestoreFunction { + constructor(expr: Constant); + } + +// @beta +export function toUpper(expr: string): ToUpper; + +// @beta +export function toUpper(expr: Constant): ToUpper; + // @public export class Transaction { delete(documentRef: DocumentReference): this; @@ -726,9 +2325,53 @@ export interface TransactionOptions { readonly maxAttempts?: number; } +// @beta (undocumented) +export class Trim extends FirestoreFunction { + constructor(expr: Constant); + } + +// @beta +export function trim(expr: string): Trim; + +// @beta +export function trim(expr: Constant): Trim; + // @public export type UnionToIntersection = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never; +// @beta (undocumented) +export class UnixMicrosToTimestamp extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function unixMicrosToTimestamp(expr: Constant): UnixMicrosToTimestamp; + +// @beta +export function unixMicrosToTimestamp(field: string): UnixMicrosToTimestamp; + +// @beta (undocumented) +export class UnixMillisToTimestamp extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function unixMillisToTimestamp(expr: Constant): UnixMillisToTimestamp; + +// @beta +export function unixMillisToTimestamp(field: string): UnixMillisToTimestamp; + +// @beta (undocumented) +export class UnixSecondsToTimestamp extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function unixSecondsToTimestamp(expr: Constant): UnixSecondsToTimestamp; + +// @beta +export function unixSecondsToTimestamp(field: string): UnixSecondsToTimestamp; + // @public export interface Unsubscribe { (): void; @@ -748,6 +2391,17 @@ export function updateDoc(refere // @public export function vector(values?: number[]): VectorValue; +// @beta (undocumented) +export class VectorLength extends FirestoreFunction { + constructor(value: Constant); + } + +// @beta +export function vectorLength(expr: Constant): VectorLength; + +// @beta +export function vectorLength(field: string): VectorLength; + // @public export class VectorValue { /* Excluded from this release type: __constructor */ @@ -758,6 +2412,13 @@ export class VectorValue { // @public export function waitForPendingWrites(firestore: Firestore): Promise; +// @beta (undocumented) +export class Where implements Stage { + constructor(condition: FilterCondition & Constant); + // (undocumented) + name: string; +} + // @public export function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryFieldFilterConstraint; @@ -782,5 +2443,15 @@ export class WriteBatch { // @public export function writeBatch(firestore: Firestore): WriteBatch; +// @beta (undocumented) +export class Xor extends FirestoreFunction implements FilterCondition { + constructor(conditions: FilterExpr[]); + // (undocumented) + filterable: true; +} + +// @beta +export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; + ``` diff --git a/packages/firestore/src/api.ts b/packages/firestore/src/api.ts index ea969c6b94c..4d63f39c671 100644 --- a/packages/firestore/src/api.ts +++ b/packages/firestore/src/api.ts @@ -15,6 +15,172 @@ * limitations under the License. */ +export { PipelineSource } from './pipelines/api/pipeline-source'; + +export { PipelineResult } from './pipelines/api/pipeline-result'; + +export { Pipeline } from './pipelines/api/pipeline'; + +export { + Stage, + FindNearestOptions, + AddFields, + Aggregate, + Distinct, + CollectionSource, + CollectionGroupSource, + DatabaseSource, + DocumentsSource, + Where, + FindNearest, + Limit, + Offset, + Select, + Sort, + GenericStage +} from './pipelines/api/stage'; + +export { + add, + subtract, + multiply, + divide, + mod, + eq, + neq, + lt, + lte, + gt, + gte, + arrayConcat, + arrayContains, + arrayContainsAny, + arrayContainsAll, + arrayLength, + inAny, + notInAny, + and as andExpression, + or as orExpression, + xor, + ifFunction, + not, + logicalMax, + logicalMin, + exists, + isNan, + reverse, + replaceFirst, + replaceAll, + byteLength, + charLength, + like, + regexContains, + regexMatch, + strContains, + startsWith, + endsWith, + toLower, + toUpper, + trim, + strConcat, + mapGet, + countAll, + count as countExpression, + sum as sumExpression, + avg, + min, + max, + cosineDistance, + dotProduct, + euclideanDistance, + vectorLength, + unixMicrosToTimestamp, + timestampToUnixMicros, + unixMillisToTimestamp, + timestampToUnixMillis, + unixSecondsToTimestamp, + timestampToUnixSeconds, + timestampAdd, + timestampSub, + genericFunction, + ascending, + descending, + ExprWithAlias, + Field, + Fields, + Constant, + FirestoreFunction, + Add, + Subtract, + Multiply, + Divide, + Mod, + Eq, + Neq, + Lt, + Lte, + Gt, + Gte, + ArrayConcat, + ArrayReverse, + ArrayContains, + ArrayContainsAll, + ArrayContainsAny, + ArrayLength, + ArrayElement, + In, + IsNan, + Exists, + Not, + And, + Or, + Xor, + If, + LogicalMax, + LogicalMin, + Reverse, + ReplaceFirst, + ReplaceAll, + CharLength, + ByteLength, + Like, + RegexContains, + RegexMatch, + StrContains, + StartsWith, + EndsWith, + ToLower, + ToUpper, + Trim, + StrConcat, + MapGet, + Count, + Sum, + Avg, + Min, + Max, + CosineDistance, + DotProduct, + EuclideanDistance, + VectorLength, + UnixMicrosToTimestamp, + TimestampToUnixMicros, + UnixMillisToTimestamp, + TimestampToUnixMillis, + UnixSecondsToTimestamp, + TimestampToUnixSeconds, + TimestampAdd, + TimestampSub, + Ordering, + ExprType, + AccumulatorTarget, + FilterExpr, + SelectableExpr, + Selectable, + FilterCondition, + Accumulator +} from './pipelines/api/expressions'; + export { aggregateFieldEqual, aggregateQuerySnapshotEqual, diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index 0757378a74c..664c853f4a7 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -64,6 +64,7 @@ import { Deferred } from '../util/promise'; import { LoadBundleTask } from './bundle'; import { CredentialsProvider } from './credentials'; import { FirestoreSettings, PersistenceSettings } from './settings'; +import type {PipelineSource} from "../pipelines/api/pipeline-source"; export { connectFirestoreEmulator, @@ -104,6 +105,10 @@ export class Firestore extends LiteFirestore { _online: OnlineComponentProviderFactory; }; + pipeline = function(): PipelineSource { + return new PipelineSource(this); + } + /** @hideconstructor */ constructor( authCredentialsProvider: CredentialsProvider, diff --git a/packages/firestore/src/core/firestore_client.ts b/packages/firestore/src/core/firestore_client.ts index 738348b016a..9b1e6c3521e 100644 --- a/packages/firestore/src/core/firestore_client.ts +++ b/packages/firestore/src/core/firestore_client.ts @@ -38,11 +38,17 @@ import { Document } from '../model/document'; import { DocumentKey } from '../model/document_key'; import { FieldIndex } from '../model/field_index'; import { Mutation } from '../model/mutation'; +import { PipelineStreamElement } from '../model/pipeline_stream_element'; +import { Pipeline } from '../pipelines/api/pipeline'; import { toByteStreamReader } from '../platform/byte_stream_reader'; import { newSerializer } from '../platform/serializer'; import { newTextEncoder } from '../platform/text_serializer'; import { ApiClientObjectMap, Value } from '../protos/firestore_proto_api'; -import { Datastore, invokeRunAggregationQueryRpc } from '../remote/datastore'; +import { + Datastore, + invokeExecutePipeline, + invokeRunAggregationQueryRpc +} from '../remote/datastore'; import { RemoteStore, remoteStoreDisableNetwork, @@ -548,6 +554,23 @@ export function firestoreClientRunAggregateQuery( return deferred.promise; } +export function firestoreClientExecutePipeline( + client: FirestoreClient, + pipeline: Pipeline +): Promise { + const deferred = new Deferred(); + + client.asyncQueue.enqueueAndForget(async () => { + try { + const datastore = await getDatastore(client); + deferred.resolve(invokeExecutePipeline(datastore, pipeline)); + } catch (e) { + deferred.reject(e as Error); + } + }); + return deferred.promise; +} + export function firestoreClientWrite( client: FirestoreClient, mutations: Mutation[] diff --git a/packages/firestore/src/lite-api/user_data_reader.ts b/packages/firestore/src/lite-api/user_data_reader.ts index ebd4b49085f..8412c388faf 100644 --- a/packages/firestore/src/lite-api/user_data_reader.ts +++ b/packages/firestore/src/lite-api/user_data_reader.ts @@ -437,6 +437,68 @@ export function parseSetData( ); } +export function parse( + userDataReader: UserDataReader, + methodName: string, + targetDoc: DocumentKey, + input: unknown, + hasConverter: boolean, + options: SetOptions = {} +): ParsedSetData { + const context = userDataReader.createContext( + options.merge || options.mergeFields + ? UserDataSource.MergeSet + : UserDataSource.Set, + methodName, + targetDoc, + hasConverter + ); + validatePlainObject('Data must be an object, but it was:', context, input); + const updateData = parseObject(input, context)!; + + let fieldMask: FieldMask | null; + let fieldTransforms: FieldTransform[]; + + if (options.merge) { + fieldMask = new FieldMask(context.fieldMask); + fieldTransforms = context.fieldTransforms; + } else if (options.mergeFields) { + const validatedFieldPaths: InternalFieldPath[] = []; + + for (const stringOrFieldPath of options.mergeFields) { + const fieldPath = fieldPathFromArgument( + methodName, + stringOrFieldPath, + targetDoc + ); + if (!context.contains(fieldPath)) { + throw new FirestoreError( + Code.INVALID_ARGUMENT, + `Field '${fieldPath}' is specified in your field mask but missing from your input data.` + ); + } + + if (!fieldMaskContains(validatedFieldPaths, fieldPath)) { + validatedFieldPaths.push(fieldPath); + } + } + + fieldMask = new FieldMask(validatedFieldPaths); + fieldTransforms = context.fieldTransforms.filter(transform => + fieldMask!.covers(transform.field) + ); + } else { + fieldMask = null; + fieldTransforms = context.fieldTransforms; + } + + return new ParsedSetData( + new ObjectValue(updateData), + fieldMask, + fieldTransforms + ); +} + export class DeleteFieldValueImpl extends FieldValue { _toFieldTransform(context: ParseContextImpl): null { if (context.dataSource === UserDataSource.MergeSet) { @@ -852,7 +914,7 @@ function parseSentinelFieldValue( * * @returns The parsed value */ -function parseScalarValue( +export function parseScalarValue( value: unknown, context: ParseContextImpl ): ProtoValue | null { @@ -920,9 +982,10 @@ function parseScalarValue( * Creates a new VectorValue proto value (using the internal format). */ export function parseVectorValue( - value: VectorValue, + value: VectorValue | number[], context: ParseContextImpl -): ProtoValue { +): { mapValue: ProtoMapValue } { + const values = value instanceof VectorValue ? value.toArray() : value; const mapValue: ProtoMapValue = { fields: { [TYPE_KEY]: { @@ -930,7 +993,7 @@ export function parseVectorValue( }, [VECTOR_MAP_VECTORS_KEY]: { arrayValue: { - values: value.toArray().map(value => { + values: values.map(value => { if (typeof value !== 'number') { throw context.createError( 'VectorValues must only contain numeric values.' diff --git a/packages/firestore/src/model/pipeline_stream_element.ts b/packages/firestore/src/model/pipeline_stream_element.ts new file mode 100644 index 00000000000..9ec4c765993 --- /dev/null +++ b/packages/firestore/src/model/pipeline_stream_element.ts @@ -0,0 +1,13 @@ +import { SnapshotVersion } from '../core/snapshot_version'; + +import { DocumentKey } from './document_key'; +import { ObjectValue } from './object_value'; + +export interface PipelineStreamElement { + transaction?: string; + key?: DocumentKey; + executionTime?: SnapshotVersion; + createTime?: SnapshotVersion; + updateTime?: SnapshotVersion; + fields?: ObjectValue; +} diff --git a/packages/firestore/src/pipelines/api/expressions.ts b/packages/firestore/src/pipelines/api/expressions.ts new file mode 100644 index 00000000000..6dabce22987 --- /dev/null +++ b/packages/firestore/src/pipelines/api/expressions.ts @@ -0,0 +1,6720 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* eslint @typescript-eslint/no-explicit-any: 0 */ + +import { documentId, FieldPath } from '../../lite-api/field_path'; +import { GeoPoint } from '../../lite-api/geo_point'; +import { DocumentReference } from '../../lite-api/reference'; +import { Timestamp } from '../../lite-api/timestamp'; +import { + fieldPathFromArgument, + parseData, + UserDataReader, + UserDataSource +} from '../../lite-api/user_data_reader'; +import { VectorValue } from '../../lite-api/vector_value'; +import { + DOCUMENT_KEY_NAME, + FieldPath as InternalFieldPath +} from '../../model/path'; +import { Value as ProtoValue } from '../../protos/firestore_proto_api'; +import { + JsonProtoSerializer, + ProtoSerializable, + toStringValue, + UserData +} from '../../remote/serializer'; +import { hardAssert } from '../../util/assert'; + +import { Pipeline } from './pipeline'; + +/** + * @beta + * + * An interface that represents a selectable expression. + */ +export interface Selectable { + selectable: true; +} + +/** + * @beta + * + * An interface that represents a filter condition. + */ +export interface FilterCondition { + filterable: true; +} + +/** + * @beta + * + * An interface that represents an accumulator. + */ +export interface Accumulator { + accumulator: true; + /** + * @private + * @internal + */ + _toProto(serializer: JsonProtoSerializer): ProtoValue; +} + +/** + * @beta + * + * An accumulator target, which is an expression with an alias that also implements the Accumulator interface. + */ +export type AccumulatorTarget = ExprWithAlias; + +/** + * @beta + * + * A filter expression, which is an expression that also implements the FilterCondition interface. + */ +export type FilterExpr = Expr & FilterCondition; + +/** + * @beta + * + * A selectable expression, which is an expression that also implements the Selectable interface. + */ +export type SelectableExpr = Expr & Selectable; + +/** + * @beta + * + * An enumeration of the different types of expressions. + */ +export type ExprType = + | 'Field' + | 'Constant' + | 'Function' + | 'ListOfExprs' + | 'ExprWithAlias'; + +/** + * @beta + * + * Represents an expression that can be evaluated to a value within the execution of a {@link + * Pipeline}. + * + * Expressions are the building blocks for creating complex queries and transformations in + * Firestore pipelines. They can represent: + * + * - **Field references:** Access values from document fields. + * - **Literals:** Represent constant values (strings, numbers, booleans). + * - **Function calls:** Apply functions to one or more expressions. + * - **Aggregations:** Calculate aggregate values (e.g., sum, average) over a set of documents. + * + * The `Expr` class provides a fluent API for building expressions. You can chain together + * method calls to create complex expressions. + */ +export abstract class Expr implements ProtoSerializable, UserData { + /** + * Creates an expression that adds this expression to another expression. + * + * ```typescript + * // Add the value of the 'quantity' field and the 'reserve' field. + * Field.of("quantity").add(Field.of("reserve")); + * ``` + * + * @param other The expression to add to this expression. + * @return A new `Expr` representing the addition operation. + */ + add(other: Expr): Add; + + /** + * Creates an expression that adds this expression to a constant value. + * + * ```typescript + * // Add 5 to the value of the 'age' field + * Field.of("age").add(5); + * ``` + * + * @param other The constant value to add. + * @return A new `Expr` representing the addition operation. + */ + add(other: any): Add; + add(other: any): Add { + if (other instanceof Expr) { + return new Add(this, other); + } + return new Add(this, Constant.of(other)); + } + + /** + * Creates an expression that subtracts another expression from this expression. + * + * ```typescript + * // Subtract the 'discount' field from the 'price' field + * Field.of("price").subtract(Field.of("discount")); + * ``` + * + * @param other The expression to subtract from this expression. + * @return A new `Expr` representing the subtraction operation. + */ + subtract(other: Expr): Subtract; + + /** + * Creates an expression that subtracts a constant value from this expression. + * + * ```typescript + * // Subtract 20 from the value of the 'total' field + * Field.of("total").subtract(20); + * ``` + * + * @param other The constant value to subtract. + * @return A new `Expr` representing the subtraction operation. + */ + subtract(other: any): Subtract; + subtract(other: any): Subtract { + if (other instanceof Expr) { + return new Subtract(this, other); + } + return new Subtract(this, Constant.of(other)); + } + + /** + * Creates an expression that multiplies this expression by another expression. + * + * ```typescript + * // Multiply the 'quantity' field by the 'price' field + * Field.of("quantity").multiply(Field.of("price")); + * ``` + * + * @param other The expression to multiply by. + * @return A new `Expr` representing the multiplication operation. + */ + multiply(other: Expr): Multiply; + + /** + * Creates an expression that multiplies this expression by a constant value. + * + * ```typescript + * // Multiply the 'value' field by 2 + * Field.of("value").multiply(2); + * ``` + * + * @param other The constant value to multiply by. + * @return A new `Expr` representing the multiplication operation. + */ + multiply(other: any): Multiply; + multiply(other: any): Multiply { + if (other instanceof Expr) { + return new Multiply(this, other); + } + return new Multiply(this, Constant.of(other)); + } + + /** + * Creates an expression that divides this expression by another expression. + * + * ```typescript + * // Divide the 'total' field by the 'count' field + * Field.of("total").divide(Field.of("count")); + * ``` + * + * @param other The expression to divide by. + * @return A new `Expr` representing the division operation. + */ + divide(other: Expr): Divide; + + /** + * Creates an expression that divides this expression by a constant value. + * + * ```typescript + * // Divide the 'value' field by 10 + * Field.of("value").divide(10); + * ``` + * + * @param other The constant value to divide by. + * @return A new `Expr` representing the division operation. + */ + divide(other: any): Divide; + divide(other: any): Divide { + if (other instanceof Expr) { + return new Divide(this, other); + } + return new Divide(this, Constant.of(other)); + } + + /** + * Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. + * + * ```typescript + * // Calculate the remainder of dividing the 'value' field by the 'divisor' field + * Field.of("value").mod(Field.of("divisor")); + * ``` + * + * @param other The expression to divide by. + * @return A new `Expr` representing the modulo operation. + */ + mod(other: Expr): Mod; + + /** + * Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. + * + * ```typescript + * // Calculate the remainder of dividing the 'value' field by 10 + * Field.of("value").mod(10); + * ``` + * + * @param other The constant value to divide by. + * @return A new `Expr` representing the modulo operation. + */ + mod(other: any): Mod; + mod(other: any): Mod { + if (other instanceof Expr) { + return new Mod(this, other); + } + return new Mod(this, Constant.of(other)); + } + + // /** + // * Creates an expression that applies a bitwise AND operation between this expression and another expression. + // * + // * ```typescript + // * // Calculate the bitwise AND of 'field1' and 'field2'. + // * Field.of("field1").bitAnd(Field.of("field2")); + // * ``` + // * + // * @param other The right operand expression. + // * @return A new {@code Expr} representing the bitwise AND operation. + // */ + // bitAnd(other: Expr): BitAnd; + // + // /** + // * Creates an expression that applies a bitwise AND operation between this expression and a constant value. + // * + // * ```typescript + // * // Calculate the bitwise AND of 'field1' and 0xFF. + // * Field.of("field1").bitAnd(0xFF); + // * ``` + // * + // * @param other The right operand constant. + // * @return A new {@code Expr} representing the bitwise AND operation. + // */ + // bitAnd(other: any): BitAnd; + // bitAnd(other: any): BitAnd { + // if (other instanceof Expr) { + // return new BitAnd(this, other); + // } + // return new BitAnd(this, Constant.of(other)); + // } + // + // /** + // * Creates an expression that applies a bitwise OR operation between this expression and another expression. + // * + // * ```typescript + // * // Calculate the bitwise OR of 'field1' and 'field2'. + // * Field.of("field1").bitOr(Field.of("field2")); + // * ``` + // * + // * @param other The right operand expression. + // * @return A new {@code Expr} representing the bitwise OR operation. + // */ + // bitOr(other: Expr): BitOr; + // + // /** + // * Creates an expression that applies a bitwise OR operation between this expression and a constant value. + // * + // * ```typescript + // * // Calculate the bitwise OR of 'field1' and 0xFF. + // * Field.of("field1").bitOr(0xFF); + // * ``` + // * + // * @param other The right operand constant. + // * @return A new {@code Expr} representing the bitwise OR operation. + // */ + // bitOr(other: any): BitOr; + // bitOr(other: any): BitOr { + // if (other instanceof Expr) { + // return new BitOr(this, other); + // } + // return new BitOr(this, Constant.of(other)); + // } + // + // /** + // * Creates an expression that applies a bitwise XOR operation between this expression and another expression. + // * + // * ```typescript + // * // Calculate the bitwise XOR of 'field1' and 'field2'. + // * Field.of("field1").bitXor(Field.of("field2")); + // * ``` + // * + // * @param other The right operand expression. + // * @return A new {@code Expr} representing the bitwise XOR operation. + // */ + // bitXor(other: Expr): BitXor; + // + // /** + // * Creates an expression that applies a bitwise XOR operation between this expression and a constant value. + // * + // * ```typescript + // * // Calculate the bitwise XOR of 'field1' and 0xFF. + // * Field.of("field1").bitXor(0xFF); + // * ``` + // * + // * @param other The right operand constant. + // * @return A new {@code Expr} representing the bitwise XOR operation. + // */ + // bitXor(other: any): BitXor; + // bitXor(other: any): BitXor { + // if (other instanceof Expr) { + // return new BitXor(this, other); + // } + // return new BitXor(this, Constant.of(other)); + // } + // + // /** + // * Creates an expression that applies a bitwise NOT operation to this expression. + // * + // * ```typescript + // * // Calculate the bitwise NOT of 'field1'. + // * Field.of("field1").bitNot(); + // * ``` + // * + // * @return A new {@code Expr} representing the bitwise NOT operation. + // */ + // bitNot(): BitNot { + // return new BitNot(this); + // } + // + // /** + // * Creates an expression that applies a bitwise left shift operation between this expression and another expression. + // * + // * ```typescript + // * // Calculate the bitwise left shift of 'field1' by 'field2' bits. + // * Field.of("field1").bitLeftShift(Field.of("field2")); + // * ``` + // * + // * @param other The right operand expression representing the number of bits to shift. + // * @return A new {@code Expr} representing the bitwise left shift operation. + // */ + // bitLeftShift(other: Expr): BitLeftShift; + // + // /** + // * Creates an expression that applies a bitwise left shift operation between this expression and a constant value. + // * + // * ```typescript + // * // Calculate the bitwise left shift of 'field1' by 2 bits. + // * Field.of("field1").bitLeftShift(2); + // * ``` + // * + // * @param other The right operand constant representing the number of bits to shift. + // * @return A new {@code Expr} representing the bitwise left shift operation. + // */ + // bitLeftShift(other: number): BitLeftShift; + // bitLeftShift(other: Expr | number): BitLeftShift { + // if (typeof other === 'number') { + // return new BitLeftShift(this, Constant.of(other)); + // } + // return new BitLeftShift(this, other as Expr); + // } + // + // /** + // * Creates an expression that applies a bitwise right shift operation between this expression and another expression. + // * + // * ```typescript + // * // Calculate the bitwise right shift of 'field1' by 'field2' bits. + // * Field.of("field1").bitRightShift(Field.of("field2")); + // * ``` + // * + // * @param other The right operand expression representing the number of bits to shift. + // * @return A new {@code Expr} representing the bitwise right shift operation. + // */ + // bitRightShift(other: Expr): BitRightShift; + // + // /** + // * Creates an expression that applies a bitwise right shift operation between this expression and a constant value. + // * + // * ```typescript + // * // Calculate the bitwise right shift of 'field1' by 2 bits. + // * Field.of("field1").bitRightShift(2); + // * ``` + // * + // * @param other The right operand constant representing the number of bits to shift. + // * @return A new {@code Expr} representing the bitwise right shift operation. + // */ + // bitRightShift(other: number): BitRightShift; + // bitRightShift(other: Expr | number): BitRightShift { + // if (typeof other === 'number') { + // return new BitRightShift(this, Constant.of(other)); + // } + // return new BitRightShift(this, other as Expr); + // } + + /** + * Creates an expression that checks if this expression is equal to another expression. + * + * ```typescript + * // Check if the 'age' field is equal to 21 + * Field.of("age").eq(21); + * ``` + * + * @param other The expression to compare for equality. + * @return A new `Expr` representing the equality comparison. + */ + eq(other: Expr): Eq; + + /** + * Creates an expression that checks if this expression is equal to a constant value. + * + * ```typescript + * // Check if the 'city' field is equal to "London" + * Field.of("city").eq("London"); + * ``` + * + * @param other The constant value to compare for equality. + * @return A new `Expr` representing the equality comparison. + */ + eq(other: any): Eq; + eq(other: any): Eq { + if (other instanceof Expr) { + return new Eq(this, other); + } + return new Eq(this, Constant.of(other)); + } + + /** + * Creates an expression that checks if this expression is not equal to another expression. + * + * ```typescript + * // Check if the 'status' field is not equal to "completed" + * Field.of("status").neq("completed"); + * ``` + * + * @param other The expression to compare for inequality. + * @return A new `Expr` representing the inequality comparison. + */ + neq(other: Expr): Neq; + + /** + * Creates an expression that checks if this expression is not equal to a constant value. + * + * ```typescript + * // Check if the 'country' field is not equal to "USA" + * Field.of("country").neq("USA"); + * ``` + * + * @param other The constant value to compare for inequality. + * @return A new `Expr` representing the inequality comparison. + */ + neq(other: any): Neq; + neq(other: any): Neq { + if (other instanceof Expr) { + return new Neq(this, other); + } + return new Neq(this, Constant.of(other)); + } + + /** + * Creates an expression that checks if this expression is less than another expression. + * + * ```typescript + * // Check if the 'age' field is less than 'limit' + * Field.of("age").lt(Field.of('limit')); + * ``` + * + * @param other The expression to compare for less than. + * @return A new `Expr` representing the less than comparison. + */ + lt(other: Expr): Lt; + + /** + * Creates an expression that checks if this expression is less than a constant value. + * + * ```typescript + * // Check if the 'price' field is less than 50 + * Field.of("price").lt(50); + * ``` + * + * @param other The constant value to compare for less than. + * @return A new `Expr` representing the less than comparison. + */ + lt(other: any): Lt; + lt(other: any): Lt { + if (other instanceof Expr) { + return new Lt(this, other); + } + return new Lt(this, Constant.of(other)); + } + + /** + * Creates an expression that checks if this expression is less than or equal to another + * expression. + * + * ```typescript + * // Check if the 'quantity' field is less than or equal to 20 + * Field.of("quantity").lte(Constant.of(20)); + * ``` + * + * @param other The expression to compare for less than or equal to. + * @return A new `Expr` representing the less than or equal to comparison. + */ + lte(other: Expr): Lte; + + /** + * Creates an expression that checks if this expression is less than or equal to a constant value. + * + * ```typescript + * // Check if the 'score' field is less than or equal to 70 + * Field.of("score").lte(70); + * ``` + * + * @param other The constant value to compare for less than or equal to. + * @return A new `Expr` representing the less than or equal to comparison. + */ + lte(other: any): Lte; + lte(other: any): Lte { + if (other instanceof Expr) { + return new Lte(this, other); + } + return new Lte(this, Constant.of(other)); + } + + /** + * Creates an expression that checks if this expression is greater than another expression. + * + * ```typescript + * // Check if the 'age' field is greater than the 'limit' field + * Field.of("age").gt(Field.of("limit")); + * ``` + * + * @param other The expression to compare for greater than. + * @return A new `Expr` representing the greater than comparison. + */ + gt(other: Expr): Gt; + + /** + * Creates an expression that checks if this expression is greater than a constant value. + * + * ```typescript + * // Check if the 'price' field is greater than 100 + * Field.of("price").gt(100); + * ``` + * + * @param other The constant value to compare for greater than. + * @return A new `Expr` representing the greater than comparison. + */ + gt(other: any): Gt; + gt(other: any): Gt { + if (other instanceof Expr) { + return new Gt(this, other); + } + return new Gt(this, Constant.of(other)); + } + + /** + * Creates an expression that checks if this expression is greater than or equal to another + * expression. + * + * ```typescript + * // Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 + * Field.of("quantity").gte(Field.of('requirement').add(1)); + * ``` + * + * @param other The expression to compare for greater than or equal to. + * @return A new `Expr` representing the greater than or equal to comparison. + */ + gte(other: Expr): Gte; + + /** + * Creates an expression that checks if this expression is greater than or equal to a constant + * value. + * + * ```typescript + * // Check if the 'score' field is greater than or equal to 80 + * Field.of("score").gte(80); + * ``` + * + * @param other The constant value to compare for greater than or equal to. + * @return A new `Expr` representing the greater than or equal to comparison. + */ + gte(other: any): Gte; + gte(other: any): Gte { + if (other instanceof Expr) { + return new Gte(this, other); + } + return new Gte(this, Constant.of(other)); + } + + /** + * Creates an expression that concatenates an array expression with one or more other arrays. + * + * ```typescript + * // Combine the 'items' array with another array field. + * Field.of("items").arrayConcat(Field.of("otherItems")); + * ``` + * + * @param arrays The array expressions to concatenate. + * @return A new `Expr` representing the concatenated array. + */ + arrayConcat(arrays: Expr[]): ArrayConcat; + + /** + * Creates an expression that concatenates an array expression with one or more other arrays. + * + * ```typescript + * // Combine the 'tags' array with a new array and an array field + * Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + * ``` + * + * @param arrays The array expressions or values to concatenate. + * @return A new `Expr` representing the concatenated array. + */ + arrayConcat(arrays: any[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat { + const exprValues = arrays.map(value => + value instanceof Expr ? value : Constant.of(value) + ); + return new ArrayConcat(this, exprValues); + } + + /** + * Creates an expression that checks if an array contains a specific element. + * + * ```typescript + * // Check if the 'sizes' array contains the value from the 'selectedSize' field + * Field.of("sizes").arrayContains(Field.of("selectedSize")); + * ``` + * + * @param element The element to search for in the array. + * @return A new `Expr` representing the 'array_contains' comparison. + */ + arrayContains(element: Expr): ArrayContains; + + /** + * Creates an expression that checks if an array contains a specific value. + * + * ```typescript + * // Check if the 'colors' array contains "red" + * Field.of("colors").arrayContains("red"); + * ``` + * + * @param element The element to search for in the array. + * @return A new `Expr` representing the 'array_contains' comparison. + */ + arrayContains(element: any): ArrayContains; + arrayContains(element: any): ArrayContains { + if (element instanceof Expr) { + return new ArrayContains(this, element); + } + return new ArrayContains(this, Constant.of(element)); + } + + /** + * Creates an expression that checks if an array contains all the specified elements. + * + * ```typescript + * // Check if the 'tags' array contains both "news" and "sports" + * Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + * ``` + * + * @param values The elements to check for in the array. + * @return A new `Expr` representing the 'array_contains_all' comparison. + */ + arrayContainsAll(...values: Expr[]): ArrayContainsAll; + + /** + * Creates an expression that checks if an array contains all the specified elements. + * + * ```typescript + * // Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" + * Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + * ``` + * + * @param values The elements to check for in the array. + * @return A new `Expr` representing the 'array_contains_all' comparison. + */ + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll { + const exprValues = values.map(value => + value instanceof Expr ? value : Constant.of(value) + ); + return new ArrayContainsAll(this, exprValues); + } + + /** + * Creates an expression that checks if an array contains any of the specified elements. + * + * ```typescript + * // Check if the 'categories' array contains either values from field "cate1" or "cate2" + * Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + * ``` + * + * @param values The elements to check for in the array. + * @return A new `Expr` representing the 'array_contains_any' comparison. + */ + arrayContainsAny(...values: Expr[]): ArrayContainsAny; + + /** + * Creates an expression that checks if an array contains any of the specified elements. + * + * ```typescript + * // Check if the 'groups' array contains either the value from the 'userGroup' field + * // or the value "guest" + * Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + * ``` + * + * @param values The elements to check for in the array. + * @return A new `Expr` representing the 'array_contains_any' comparison. + */ + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny { + const exprValues = values.map(value => + value instanceof Expr ? value : Constant.of(value) + ); + return new ArrayContainsAny(this, exprValues); + } + + /** + * Creates an expression that calculates the length of an array. + * + * ```typescript + * // Get the number of items in the 'cart' array + * Field.of("cart").arrayLength(); + * ``` + * + * @return A new `Expr` representing the length of the array. + */ + arrayLength(): ArrayLength { + return new ArrayLength(this); + } + + /** + * Creates an expression that checks if this expression is equal to any of the provided values or + * expressions. + * + * ```typescript + * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' + * Field.of("category").in("Electronics", Field.of("primaryType")); + * ``` + * + * @param others The values or expressions to check against. + * @return A new `Expr` representing the 'IN' comparison. + */ + in(...others: Expr[]): In; + + /** + * Creates an expression that checks if this expression is equal to any of the provided values or + * expressions. + * + * ```typescript + * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' + * Field.of("category").in("Electronics", Field.of("primaryType")); + * ``` + * + * @param others The values or expressions to check against. + * @return A new `Expr` representing the 'IN' comparison. + */ + in(...others: any[]): In; + in(...others: any[]): In { + const exprOthers = others.map(other => + other instanceof Expr ? other : Constant.of(other) + ); + return new In(this, exprOthers); + } + + /** + * Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). + * + * ```typescript + * // Check if the result of a calculation is NaN + * Field.of("value").divide(0).isNaN(); + * ``` + * + * @return A new `Expr` representing the 'isNaN' check. + */ + isNaN(): IsNan { + return new IsNan(this); + } + + /** + * Creates an expression that checks if a field exists in the document. + * + * ```typescript + * // Check if the document has a field named "phoneNumber" + * Field.of("phoneNumber").exists(); + * ``` + * + * @return A new `Expr` representing the 'exists' check. + */ + exists(): Exists { + return new Exists(this); + } + + /** + * Creates an expression that calculates the character length of a string in UTF-8. + * + * ```typescript + * // Get the character length of the 'name' field in its UTF-8 form. + * Field.of("name").charLength(); + * ``` + * + * @return A new `Expr` representing the length of the string. + */ + charLength(): CharLength { + return new CharLength(this); + } + + /** + * Creates an expression that performs a case-sensitive string comparison. + * + * ```typescript + * // Check if the 'title' field contains the word "guide" (case-sensitive) + * Field.of("title").like("%guide%"); + * ``` + * + * @param pattern The pattern to search for. You can use "%" as a wildcard character. + * @return A new `Expr` representing the 'like' comparison. + */ + like(pattern: string): Like; + + /** + * Creates an expression that performs a case-sensitive string comparison. + * + * ```typescript + * // Check if the 'title' field contains the word "guide" (case-sensitive) + * Field.of("title").like("%guide%"); + * ``` + * + * @param pattern The pattern to search for. You can use "%" as a wildcard character. + * @return A new `Expr` representing the 'like' comparison. + */ + like(pattern: Expr): Like; + like(stringOrExpr: string | Expr): Like { + if (typeof stringOrExpr === 'string') { + return new Like(this, Constant.of(stringOrExpr)); + } + return new Like(this, stringOrExpr as Expr); + } + + /** + * Creates an expression that checks if a string contains a specified regular expression as a + * substring. + * + * ```typescript + * // Check if the 'description' field contains "example" (case-insensitive) + * Field.of("description").regexContains("(?i)example"); + * ``` + * + * @param pattern The regular expression to use for the search. + * @return A new `Expr` representing the 'contains' comparison. + */ + regexContains(pattern: string): RegexContains; + + /** + * Creates an expression that checks if a string contains a specified regular expression as a + * substring. + * + * ```typescript + * // Check if the 'description' field contains the regular expression stored in field 'regex' + * Field.of("description").regexContains(Field.of("regex")); + * ``` + * + * @param pattern The regular expression to use for the search. + * @return A new `Expr` representing the 'contains' comparison. + */ + regexContains(pattern: Expr): RegexContains; + regexContains(stringOrExpr: string | Expr): RegexContains { + if (typeof stringOrExpr === 'string') { + return new RegexContains(this, Constant.of(stringOrExpr)); + } + return new RegexContains(this, stringOrExpr as Expr); + } + + /** + * Creates an expression that checks if a string matches a specified regular expression. + * + * ```typescript + * // Check if the 'email' field matches a valid email pattern + * Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + * ``` + * + * @param pattern The regular expression to use for the match. + * @return A new `Expr` representing the regular expression match. + */ + regexMatch(pattern: string): RegexMatch; + + /** + * Creates an expression that checks if a string matches a specified regular expression. + * + * ```typescript + * // Check if the 'email' field matches a regular expression stored in field 'regex' + * Field.of("email").regexMatch(Field.of("regex")); + * ``` + * + * @param pattern The regular expression to use for the match. + * @return A new `Expr` representing the regular expression match. + */ + regexMatch(pattern: Expr): RegexMatch; + regexMatch(stringOrExpr: string | Expr): RegexMatch { + if (typeof stringOrExpr === 'string') { + return new RegexMatch(this, Constant.of(stringOrExpr)); + } + return new RegexMatch(this, stringOrExpr as Expr); + } + + /** + * Creates an expression that checks if a string contains a specified substring. + * + * ```typescript + * // Check if the 'description' field contains "example". + * Field.of("description").strContains("example"); + * ``` + * + * @param substring The substring to search for. + * @return A new `Expr` representing the 'contains' comparison. + */ + strContains(substring: string): StrContains; + + /** + * Creates an expression that checks if a string contains the string represented by another expression. + * + * ```typescript + * // Check if the 'description' field contains the value of the 'keyword' field. + * Field.of("description").strContains(Field.of("keyword")); + * ``` + * + * @param expr The expression representing the substring to search for. + * @return A new `Expr` representing the 'contains' comparison. + */ + strContains(expr: Expr): StrContains; + strContains(stringOrExpr: string | Expr): StrContains { + if (typeof stringOrExpr === 'string') { + return new StrContains(this, Constant.of(stringOrExpr)); + } + return new StrContains(this, stringOrExpr as Expr); + } + + /** + * Creates an expression that checks if a string starts with a given prefix. + * + * ```typescript + * // Check if the 'name' field starts with "Mr." + * Field.of("name").startsWith("Mr."); + * ``` + * + * @param prefix The prefix to check for. + * @return A new `Expr` representing the 'starts with' comparison. + */ + startsWith(prefix: string): StartsWith; + + /** + * Creates an expression that checks if a string starts with a given prefix (represented as an + * expression). + * + * ```typescript + * // Check if the 'fullName' field starts with the value of the 'firstName' field + * Field.of("fullName").startsWith(Field.of("firstName")); + * ``` + * + * @param prefix The prefix expression to check for. + * @return A new `Expr` representing the 'starts with' comparison. + */ + startsWith(prefix: Expr): StartsWith; + startsWith(stringOrExpr: string | Expr): StartsWith { + if (typeof stringOrExpr === 'string') { + return new StartsWith(this, Constant.of(stringOrExpr)); + } + return new StartsWith(this, stringOrExpr as Expr); + } + + /** + * Creates an expression that checks if a string ends with a given postfix. + * + * ```typescript + * // Check if the 'filename' field ends with ".txt" + * Field.of("filename").endsWith(".txt"); + * ``` + * + * @param suffix The postfix to check for. + * @return A new `Expr` representing the 'ends with' comparison. + */ + endsWith(suffix: string): EndsWith; + + /** + * Creates an expression that checks if a string ends with a given postfix (represented as an + * expression). + * + * ```typescript + * // Check if the 'url' field ends with the value of the 'extension' field + * Field.of("url").endsWith(Field.of("extension")); + * ``` + * + * @param suffix The postfix expression to check for. + * @return A new `Expr` representing the 'ends with' comparison. + */ + endsWith(suffix: Expr): EndsWith; + endsWith(stringOrExpr: string | Expr): EndsWith { + if (typeof stringOrExpr === 'string') { + return new EndsWith(this, Constant.of(stringOrExpr)); + } + return new EndsWith(this, stringOrExpr as Expr); + } + + /** + * Creates an expression that converts a string to lowercase. + * + * ```typescript + * // Convert the 'name' field to lowercase + * Field.of("name").toLower(); + * ``` + * + * @return A new `Expr` representing the lowercase string. + */ + toLower(): ToLower { + return new ToLower(this); + } + + /** + * Creates an expression that converts a string to uppercase. + * + * ```typescript + * // Convert the 'title' field to uppercase + * Field.of("title").toUpper(); + * ``` + * + * @return A new `Expr` representing the uppercase string. + */ + toUpper(): ToUpper { + return new ToUpper(this); + } + + /** + * Creates an expression that removes leading and trailing whitespace from a string. + * + * ```typescript + * // Trim whitespace from the 'userInput' field + * Field.of("userInput").trim(); + * ``` + * + * @return A new `Expr` representing the trimmed string. + */ + trim(): Trim { + return new Trim(this); + } + + /** + * Creates an expression that concatenates string expressions together. + * + * ```typescript + * // Combine the 'firstName', " ", and 'lastName' fields into a single string + * Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + * ``` + * + * @param elements The expressions (typically strings) to concatenate. + * @return A new `Expr` representing the concatenated string. + */ + strConcat(...elements: Array): StrConcat { + const exprs = elements.map(e => + typeof e === 'string' ? Constant.of(e) : (e as Expr) + ); + return new StrConcat(this, exprs); + } + + /** + * Creates an expression that reverses this string expression. + * + * ```typescript + * // Reverse the value of the 'myString' field. + * Field.of("myString").reverse(); + * ``` + * + * @return A new {@code Expr} representing the reversed string. + */ + reverse(): Reverse { + return new Reverse(this); + } + + /** + * Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. + * + * ```typescript + * // Replace the first occurrence of "hello" with "hi" in the 'message' field + * Field.of("message").replaceFirst("hello", "hi"); + * ``` + * + * @param find The substring to search for. + * @param replace The substring to replace the first occurrence of 'find' with. + * @return A new {@code Expr} representing the string with the first occurrence replaced. + */ + replaceFirst(find: string, replace: string): ReplaceFirst; + + /** + * Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, + * where the substring to find and the replacement substring are specified by expressions. + * + * ```typescript + * // Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field + * Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + * ``` + * + * @param find The expression representing the substring to search for. + * @param replace The expression representing the substring to replace the first occurrence of 'find' with. + * @return A new {@code Expr} representing the string with the first occurrence replaced. + */ + replaceFirst(find: Expr, replace: Expr): ReplaceFirst; + replaceFirst(find: Expr | string, replace: Expr | string): ReplaceFirst { + const normalizedFind = typeof find === 'string' ? Constant.of(find) : find; + const normalizedReplace = + typeof replace === 'string' ? Constant.of(replace) : replace; + return new ReplaceFirst( + this, + normalizedFind as Expr, + normalizedReplace as Expr + ); + } + + /** + * Creates an expression that replaces all occurrences of a substring within this string expression with another substring. + * + * ```typescript + * // Replace all occurrences of "hello" with "hi" in the 'message' field + * Field.of("message").replaceAll("hello", "hi"); + * ``` + * + * @param find The substring to search for. + * @param replace The substring to replace all occurrences of 'find' with. + * @return A new {@code Expr} representing the string with all occurrences replaced. + */ + replaceAll(find: string, replace: string): ReplaceAll; + + /** + * Creates an expression that replaces all occurrences of a substring within this string expression with another substring, + * where the substring to find and the replacement substring are specified by expressions. + * + * ```typescript + * // Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field + * Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + * ``` + * + * @param find The expression representing the substring to search for. + * @param replace The expression representing the substring to replace all occurrences of 'find' with. + * @return A new {@code Expr} representing the string with all occurrences replaced. + */ + replaceAll(find: Expr, replace: Expr): ReplaceAll; + replaceAll(find: Expr | string, replace: Expr | string): ReplaceAll { + const normalizedFind = typeof find === 'string' ? Constant.of(find) : find; + const normalizedReplace = + typeof replace === 'string' ? Constant.of(replace) : replace; + return new ReplaceAll( + this, + normalizedFind as Expr, + normalizedReplace as Expr + ); + } + + /** + * Creates an expression that calculates the length of this string expression in bytes. + * + * ```typescript + * // Calculate the length of the 'myString' field in bytes. + * Field.of("myString").byteLength(); + * ``` + * + * @return A new {@code Expr} representing the length of the string in bytes. + */ + byteLength(): ByteLength { + return new ByteLength(this); + } + + /** + * Accesses a value from a map (object) field using the provided key. + * + * ```typescript + * // Get the 'city' value from the 'address' map field + * Field.of("address").mapGet("city"); + * ``` + * + * @param subfield The key to access in the map. + * @return A new `Expr` representing the value associated with the given key in the map. + */ + mapGet(subfield: string): MapGet { + return new MapGet(this, subfield); + } + + /** + * Creates an aggregation that counts the number of stage inputs with valid evaluations of the + * expression or field. + * + * ```typescript + * // Count the total number of products + * Field.of("productId").count().as("totalProducts"); + * ``` + * + * @return A new `Accumulator` representing the 'count' aggregation. + */ + count(): Count { + return new Count(this, false); + } + + /** + * Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. + * + * ```typescript + * // Calculate the total revenue from a set of orders + * Field.of("orderAmount").sum().as("totalRevenue"); + * ``` + * + * @return A new `Accumulator` representing the 'sum' aggregation. + */ + sum(): Sum { + return new Sum(this, false); + } + + /** + * Creates an aggregation that calculates the average (mean) of a numeric field across multiple + * stage inputs. + * + * ```typescript + * // Calculate the average age of users + * Field.of("age").avg().as("averageAge"); + * ``` + * + * @return A new `Accumulator` representing the 'avg' aggregation. + */ + avg(): Avg { + return new Avg(this, false); + } + + /** + * Creates an aggregation that finds the minimum value of a field across multiple stage inputs. + * + * ```typescript + * // Find the lowest price of all products + * Field.of("price").min().as("lowestPrice"); + * ``` + * + * @return A new `Accumulator` representing the 'min' aggregation. + */ + min(): Min { + return new Min(this, false); + } + + /** + * Creates an aggregation that finds the maximum value of a field across multiple stage inputs. + * + * ```typescript + * // Find the highest score in a leaderboard + * Field.of("score").max().as("highestScore"); + * ``` + * + * @return A new `Accumulator` representing the 'max' aggregation. + */ + max(): Max { + return new Max(this, false); + } + + /** + * Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the larger value between the 'timestamp' field and the current timestamp. + * Field.of("timestamp").logicalMax(Function.currentTimestamp()); + * ``` + * + * @param other The expression to compare with. + * @return A new {@code Expr} representing the logical max operation. + */ + logicalMax(other: Expr): LogicalMax; + + /** + * Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the larger value between the 'value' field and 10. + * Field.of("value").logicalMax(10); + * ``` + * + * @param other The constant value to compare with. + * @return A new {@code Expr} representing the logical max operation. + */ + logicalMax(other: any): LogicalMax; + logicalMax(other: any): LogicalMax { + if (other instanceof Expr) { + return new LogicalMax(this, other as Expr); + } + return new LogicalMax(this, Constant.of(other)); + } + + /** + * Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the smaller value between the 'timestamp' field and the current timestamp. + * Field.of("timestamp").logicalMin(Function.currentTimestamp()); + * ``` + * + * @param other The expression to compare with. + * @return A new {@code Expr} representing the logical min operation. + */ + logicalMin(other: Expr): LogicalMin; + + /** + * Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the smaller value between the 'value' field and 10. + * Field.of("value").logicalMin(10); + * ``` + * + * @param other The constant value to compare with. + * @return A new {@code Expr} representing the logical min operation. + */ + logicalMin(other: any): LogicalMin; + logicalMin(other: any): LogicalMin { + if (other instanceof Expr) { + return new LogicalMin(this, other as Expr); + } + return new LogicalMin(this, Constant.of(other)); + } + + /** + * Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. + * + * ```typescript + * // Get the vector length (dimension) of the field 'embedding'. + * Field.of("embedding").vectorLength(); + * ``` + * + * @return A new {@code Expr} representing the length of the vector. + */ + vectorLength(): VectorLength { + return new VectorLength(this); + } + + /** + * Calculates the cosine distance between two vectors. + * + * ```typescript + * // Calculate the cosine distance between the 'userVector' field and the 'itemVector' field + * Field.of("userVector").cosineDistance(Field.of("itemVector")); + * ``` + * + * @param other The other vector (represented as an Expr) to compare against. + * @return A new `Expr` representing the cosine distance between the two vectors. + */ + cosineDistance(other: Expr): CosineDistance; + /** + * Calculates the Cosine distance between two vectors. + * + * ```typescript + * // Calculate the Cosine distance between the 'location' field and a target location + * Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + * ``` + * + * @param other The other vector (as a VectorValue) to compare against. + * @return A new `Expr` representing the Cosine* distance between the two vectors. + */ + cosineDistance(other: VectorValue): CosineDistance; + /** + * Calculates the Cosine distance between two vectors. + * + * ```typescript + * // Calculate the Cosine distance between the 'location' field and a target location + * Field.of("location").cosineDistance([37.7749, -122.4194]); + * ``` + * + * @param other The other vector (as an array of numbers) to compare against. + * @return A new `Expr` representing the Cosine distance between the two vectors. + */ + cosineDistance(other: number[]): CosineDistance; + cosineDistance(other: Expr | VectorValue | number[]): CosineDistance { + if (other instanceof Expr) { + return new CosineDistance(this, other as Expr); + } else { + return new CosineDistance( + this, + Constant.vector(other as VectorValue | number[]) + ); + } + } + + /** + * Calculates the dot product between two vectors. + * + * ```typescript + * // Calculate the dot product between a feature vector and a target vector + * Field.of("features").dotProduct([0.5, 0.8, 0.2]); + * ``` + * + * @param other The other vector (as an array of numbers) to calculate with. + * @return A new `Expr` representing the dot product between the two vectors. + */ + dotProduct(other: Expr): DotProduct; + + /** + * Calculates the dot product between two vectors. + * + * ```typescript + * // Calculate the dot product between a feature vector and a target vector + * Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + * ``` + * + * @param other The other vector (as an array of numbers) to calculate with. + * @return A new `Expr` representing the dot product between the two vectors. + */ + dotProduct(other: VectorValue): DotProduct; + + /** + * Calculates the dot product between two vectors. + * + * ```typescript + * // Calculate the dot product between a feature vector and a target vector + * Field.of("features").dotProduct([0.5, 0.8, 0.2]); + * ``` + * + * @param other The other vector (as an array of numbers) to calculate with. + * @return A new `Expr` representing the dot product between the two vectors. + */ + dotProduct(other: number[]): DotProduct; + dotProduct(other: Expr | VectorValue | number[]): DotProduct { + if (other instanceof Expr) { + return new DotProduct(this, other as Expr); + } else { + return new DotProduct( + this, + Constant.vector(other as VectorValue | number[]) + ); + } + } + + /** + * Calculates the Euclidean distance between two vectors. + * + * ```typescript + * // Calculate the Euclidean distance between the 'location' field and a target location + * Field.of("location").euclideanDistance([37.7749, -122.4194]); + * ``` + * + * @param other The other vector (as an array of numbers) to calculate with. + * @return A new `Expr` representing the Euclidean distance between the two vectors. + */ + euclideanDistance(other: Expr): EuclideanDistance; + + /** + * Calculates the Euclidean distance between two vectors. + * + * ```typescript + * // Calculate the Euclidean distance between the 'location' field and a target location + * Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + * ``` + * + * @param other The other vector (as a VectorValue) to compare against. + * @return A new `Expr` representing the Euclidean distance between the two vectors. + */ + euclideanDistance(other: VectorValue): EuclideanDistance; + + /** + * Calculates the Euclidean distance between two vectors. + * + * ```typescript + * // Calculate the Euclidean distance between the 'location' field and a target location + * Field.of("location").euclideanDistance([37.7749, -122.4194]); + * ``` + * + * @param other The other vector (as an array of numbers) to compare against. + * @return A new `Expr` representing the Euclidean distance between the two vectors. + */ + euclideanDistance(other: number[]): EuclideanDistance; + euclideanDistance(other: Expr | VectorValue | number[]): EuclideanDistance { + if (other instanceof Expr) { + return new EuclideanDistance(this, other as Expr); + } else { + return new EuclideanDistance( + this, + Constant.vector(other as VectorValue | number[]) + ); + } + } + + /** + * Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) + * and returns a timestamp. + * + * ```typescript + * // Interpret the 'microseconds' field as microseconds since epoch. + * Field.of("microseconds").unixMicrosToTimestamp(); + * ``` + * + * @return A new {@code Expr} representing the timestamp. + */ + unixMicrosToTimestamp(): UnixMicrosToTimestamp { + return new UnixMicrosToTimestamp(this); + } + + /** + * Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + * + * ```typescript + * // Convert the 'timestamp' field to microseconds since epoch. + * Field.of("timestamp").timestampToUnixMicros(); + * ``` + * + * @return A new {@code Expr} representing the number of microseconds since epoch. + */ + timestampToUnixMicros(): TimestampToUnixMicros { + return new TimestampToUnixMicros(this); + } + + /** + * Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) + * and returns a timestamp. + * + * ```typescript + * // Interpret the 'milliseconds' field as milliseconds since epoch. + * Field.of("milliseconds").unixMillisToTimestamp(); + * ``` + * + * @return A new {@code Expr} representing the timestamp. + */ + unixMillisToTimestamp(): UnixMillisToTimestamp { + return new UnixMillisToTimestamp(this); + } + + /** + * Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + * + * ```typescript + * // Convert the 'timestamp' field to milliseconds since epoch. + * Field.of("timestamp").timestampToUnixMillis(); + * ``` + * + * @return A new {@code Expr} representing the number of milliseconds since epoch. + */ + timestampToUnixMillis(): TimestampToUnixMillis { + return new TimestampToUnixMillis(this); + } + + /** + * Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) + * and returns a timestamp. + * + * ```typescript + * // Interpret the 'seconds' field as seconds since epoch. + * Field.of("seconds").unixSecondsToTimestamp(); + * ``` + * + * @return A new {@code Expr} representing the timestamp. + */ + unixSecondsToTimestamp(): UnixSecondsToTimestamp { + return new UnixSecondsToTimestamp(this); + } + + /** + * Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). + * + * ```typescript + * // Convert the 'timestamp' field to seconds since epoch. + * Field.of("timestamp").timestampToUnixSeconds(); + * ``` + * + * @return A new {@code Expr} representing the number of seconds since epoch. + */ + timestampToUnixSeconds(): TimestampToUnixSeconds { + return new TimestampToUnixSeconds(this); + } + + /** + * Creates an expression that adds a specified amount of time to this timestamp expression. + * + * ```typescript + * // Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. + * Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + * ``` + * + * @param unit The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. + * @param amount The expression evaluates to amount of the unit. + * @return A new {@code Expr} representing the resulting timestamp. + */ + timestampAdd(unit: Expr, amount: Expr): TimestampAdd; + + /** + * Creates an expression that adds a specified amount of time to this timestamp expression. + * + * ```typescript + * // Add 1 day to the 'timestamp' field. + * Field.of("timestamp").timestampAdd("day", 1); + * ``` + * + * @param unit The unit of time to add (e.g., "day", "hour"). + * @param amount The amount of time to add. + * @return A new {@code Expr} representing the resulting timestamp. + */ + timestampAdd( + unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', + amount: number + ): TimestampAdd; + timestampAdd( + unit: + | Expr + | 'microsecond' + | 'millisecond' + | 'second' + | 'minute' + | 'hour' + | 'day', + amount: Expr | number + ): TimestampAdd { + const normalizedUnit = typeof unit === 'string' ? Constant.of(unit) : unit; + const normalizedAmount = + typeof amount === 'number' ? Constant.of(amount) : amount; + return new TimestampAdd( + this, + normalizedUnit as Expr, + normalizedAmount as Expr + ); + } + + /** + * Creates an expression that subtracts a specified amount of time from this timestamp expression. + * + * ```typescript + * // Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. + * Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + * ``` + * + * @param unit The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. + * @param amount The expression evaluates to amount of the unit. + * @return A new {@code Expr} representing the resulting timestamp. + */ + timestampSub(unit: Expr, amount: Expr): TimestampSub; + + /** + * Creates an expression that subtracts a specified amount of time from this timestamp expression. + * + * ```typescript + * // Subtract 1 day from the 'timestamp' field. + * Field.of("timestamp").timestampSub("day", 1); + * ``` + * + * @param unit The unit of time to subtract (e.g., "day", "hour"). + * @param amount The amount of time to subtract. + * @return A new {@code Expr} representing the resulting timestamp. + */ + timestampSub( + unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', + amount: number + ): TimestampSub; + timestampSub( + unit: + | Expr + | 'microsecond' + | 'millisecond' + | 'second' + | 'minute' + | 'hour' + | 'day', + amount: Expr | number + ): TimestampSub { + const normalizedUnit = typeof unit === 'string' ? Constant.of(unit) : unit; + const normalizedAmount = + typeof amount === 'number' ? Constant.of(amount) : amount; + return new TimestampSub( + this, + normalizedUnit as Expr, + normalizedAmount as Expr + ); + } + + /** + * Creates an {@link Ordering} that sorts documents in ascending order based on this expression. + * + * ```typescript + * // Sort documents by the 'name' field in ascending order + * pipeline().collection("users") + * .sort(Field.of("name").ascending()); + * ``` + * + * @return A new `Ordering` for ascending sorting. + */ + ascending(): Ordering { + return ascending(this); + } + + /** + * Creates an {@link Ordering} that sorts documents in descending order based on this expression. + * + * ```typescript + * // Sort documents by the 'createdAt' field in descending order + * firestore.pipeline().collection("users") + * .sort(Field.of("createdAt").descending()); + * ``` + * + * @return A new `Ordering` for descending sorting. + */ + descending(): Ordering { + return descending(this); + } + + /** + * Assigns an alias to this expression. + * + * Aliases are useful for renaming fields in the output of a stage or for giving meaningful + * names to calculated values. + * + * ```typescript + * // Calculate the total price and assign it the alias "totalPrice" and add it to the output. + * firestore.pipeline().collection("items") + * .addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + * ``` + * + * @param name The alias to assign to this expression. + * @return A new {@link ExprWithAlias} that wraps this + * expression and associates it with the provided alias. + */ + as(name: string): ExprWithAlias { + return new ExprWithAlias(this, name); + } + + /** + * @private + * @internal + */ + abstract _toProto(serializer: JsonProtoSerializer): ProtoValue; + + /** + * @private + * @internal + */ + abstract _readUserData(dataReader: UserDataReader): void; +} + +/** + * @beta + */ +export class ExprWithAlias extends Expr implements Selectable { + exprType: ExprType = 'ExprWithAlias'; + selectable = true as const; + + constructor(public expr: T, public alias: string) { + super(); + } + + /** + * @private + * @internal + */ + _toProto(serializer: JsonProtoSerializer): ProtoValue { + throw new Error('ExprWithAlias should not be serialized directly.'); + } + + /** + * @private + * @internal + */ + _readUserData(dataReader: UserDataReader): void { + this.expr._readUserData(dataReader); + } +} + +/** + * @internal + */ +class ListOfExprs extends Expr { + exprType: ExprType = 'ListOfExprs'; + constructor(private exprs: Expr[]) { + super(); + } + + /** + * @private + * @internal + */ + _toProto(serializer: JsonProtoSerializer): ProtoValue { + return { + arrayValue: { + values: this.exprs.map(p => p._toProto(serializer)!) + } + }; + } + + /** + * @private + * @internal + */ + _readUserData(dataReader: UserDataReader): void { + this.exprs.forEach((expr: Expr) => expr._readUserData(dataReader)); + } +} + +/** + * @beta + * + * Represents a reference to a field in a Firestore document, or outputs of a {@link Pipeline} stage. + * + *

Field references are used to access document field values in expressions and to specify fields + * for sorting, filtering, and projecting data in Firestore pipelines. + * + *

You can create a `Field` instance using the static {@link #of} method: + * + * ```typescript + * // Create a Field instance for the 'name' field + * const nameField = Field.of("name"); + * + * // Create a Field instance for a nested field 'address.city' + * const cityField = Field.of("address.city"); + * ``` + */ +export class Field extends Expr implements Selectable { + exprType: ExprType = 'Field'; + selectable = true as const; + + private constructor( + private fieldPath: InternalFieldPath, + private pipeline: Pipeline | null = null + ) { + super(); + } + + /** + * Creates a {@code Field} instance representing the field at the given path. + * + * The path can be a simple field name (e.g., "name") or a dot-separated path to a nested field + * (e.g., "address.city"). + * + * ```typescript + * // Create a Field instance for the 'title' field + * const titleField = Field.of("title"); + * + * // Create a Field instance for a nested field 'author.firstName' + * const authorFirstNameField = Field.of("author.firstName"); + * ``` + * + * @param name The path to the field. + * @return A new {@code Field} instance representing the specified field. + */ + static of(name: string): Field; + static of(path: FieldPath): Field; + static of(pipeline: Pipeline, name: string): Field; + static of( + pipelineOrName: Pipeline | string | FieldPath, + name?: string + ): Field { + if (typeof pipelineOrName === 'string') { + if (DOCUMENT_KEY_NAME === pipelineOrName) { + return new Field(documentId()._internalPath); + } + return new Field(fieldPathFromArgument('of', pipelineOrName)); + } else if (pipelineOrName instanceof FieldPath) { + if (documentId().isEqual(pipelineOrName)) { + return new Field(documentId()._internalPath); + } + return new Field(pipelineOrName._internalPath); + } else { + return new Field( + fieldPathFromArgument('of', name!), + pipelineOrName as Pipeline + ); + } + } + + fieldName(): string { + return this.fieldPath.canonicalString(); + } + + /** + * @private + * @internal + */ + _toProto(serializer: JsonProtoSerializer): ProtoValue { + return { + fieldReferenceValue: this.fieldPath.canonicalString() + }; + } + + /** + * @private + * @internal + */ + _readUserData(dataReader: UserDataReader): void {} +} + +/** + * @beta + */ +export class Fields extends Expr implements Selectable { + exprType: ExprType = 'Field'; + selectable = true as const; + + private constructor(private fields: Field[]) { + super(); + } + + static of(name: string, ...others: string[]): Fields { + return new Fields([Field.of(name), ...others.map(Field.of)]); + } + + static ofAll(): Fields { + return new Fields([]); + } + + fieldList(): Field[] { + return this.fields.map(f => f); + } + + /** + * @private + * @internal + */ + _toProto(serializer: JsonProtoSerializer): ProtoValue { + return { + arrayValue: { + values: this.fields.map(f => f._toProto(serializer)) + } + }; + } + + /** + * @private + * @internal + */ + _readUserData(dataReader: UserDataReader): void { + this.fields.forEach(expr => expr._readUserData(dataReader)); + } +} + +/** + * @beta + * + * Represents a constant value that can be used in a Firestore pipeline expression. + * + * You can create a `Constant` instance using the static {@link #of} method: + * + * ```typescript + * // Create a Constant instance for the number 10 + * const ten = Constant.of(10); + * + * // Create a Constant instance for the string "hello" + * const hello = Constant.of("hello"); + * ``` + */ +export class Constant extends Expr { + exprType: ExprType = 'Constant'; + + private _protoValue?: ProtoValue; + + private constructor(private value: any) { + super(); + } + + /** + * Creates a `Constant` instance for a number value. + * + * @param value The number value. + * @return A new `Constant` instance. + */ + static of(value: number): Constant; + + /** + * Creates a `Constant` instance for a string value. + * + * @param value The string value. + * @return A new `Constant` instance. + */ + static of(value: string): Constant; + + /** + * Creates a `Constant` instance for a boolean value. + * + * @param value The boolean value. + * @return A new `Constant` instance. + */ + static of(value: boolean): Constant; + + /** + * Creates a `Constant` instance for a null value. + * + * @param value The null value. + * @return A new `Constant` instance. + */ + static of(value: null): Constant; + + /** + * Creates a `Constant` instance for an undefined value. + * + * @param value The undefined value. + * @return A new `Constant` instance. + */ + static of(value: undefined): Constant; + + /** + * Creates a `Constant` instance for a GeoPoint value. + * + * @param value The GeoPoint value. + * @return A new `Constant` instance. + */ + static of(value: GeoPoint): Constant; + + /** + * Creates a `Constant` instance for a Timestamp value. + * + * @param value The Timestamp value. + * @return A new `Constant` instance. + */ + static of(value: Timestamp): Constant; + + /** + * Creates a `Constant` instance for a Date value. + * + * @param value The Date value. + * @return A new `Constant` instance. + */ + static of(value: Date): Constant; + + /** + * Creates a `Constant` instance for a Uint8Array value. + * + * @param value The Uint8Array value. + * @return A new `Constant` instance. + */ + static of(value: Uint8Array): Constant; + + /** + * Creates a `Constant` instance for a DocumentReference value. + * + * @param value The DocumentReference value. + * @return A new `Constant` instance. + */ + static of(value: DocumentReference): Constant; + + // TODO(pipeline) if we make this public, then the Proto types should also be documented + /** + * Creates a `Constant` instance for a Firestore proto value. + * @private + * @internal + * @param value The Firestore proto value. + * @return A new `Constant` instance. + */ + static of(value: ProtoValue): Constant; + + /** + * Creates a `Constant` instance for an array value. + * + * @param value The array value. + * @return A new `Constant` instance. + */ + static of(value: any[]): Constant; + + /** + * Creates a `Constant` instance for a map value. + * + * @param value The map value. + * @return A new `Constant` instance. + */ + static of(value: Map): Constant; + + /** + * Creates a `Constant` instance for a VectorValue value. + * + * @param value The VectorValue value. + * @return A new `Constant` instance. + */ + static of(value: VectorValue): Constant; + + static of(value: any): Constant { + return new Constant(value); + } + + /** + * Creates a `Constant` instance for a VectorValue value. + * + * ```typescript + * // Create a Constant instance for a vector value + * const vectorConstant = Constant.ofVector([1, 2, 3]); + * ``` + * + * @param value The VectorValue value. + * @return A new `Constant` instance. + */ + static vector(value: number[] | VectorValue): Constant { + if (value instanceof VectorValue) { + return new Constant(value); + } else { + return new Constant(new VectorValue(value as number[])); + } + } + + /** + * @private + * @internal + */ + _toProto(serializer: JsonProtoSerializer): ProtoValue { + hardAssert( + this._protoValue !== undefined, + 'Value of this constant has not been serialized to proto value' + ); + return this._protoValue; + } + + /** + * @private + * @internal + */ + _readUserData(dataReader: UserDataReader): void { + const context = dataReader.createContext( + UserDataSource.Argument, + 'Constant.of' + ); + if (this.value === undefined) { + // TODO how should we treat the value of `undefined`? + this._protoValue = parseData(null, context)!; + } else { + this._protoValue = parseData(this.value, context)!; + } + } +} + +/** + * @beta + * + * This class defines the base class for Firestore {@link Pipeline} functions, which can be evaluated within pipeline + * execution. + * + * Typically, you would not use this class or its children directly. Use either the functions like {@link and}, {@link eq}, + * or the methods on {@link Expr} ({@link Expr#eq}, {@link Expr#lt}, etc) to construct new Function instances. + */ +export class FirestoreFunction extends Expr { + exprType: ExprType = 'Function'; + constructor(private name: string, private params: Expr[]) { + super(); + } + + /** + * @private + * @internal + */ + _toProto(serializer: JsonProtoSerializer): ProtoValue { + return { + functionValue: { + name: this.name, + args: this.params.map(p => p._toProto(serializer)) + } + }; + } + + /** + * @private + * @internal + */ + _readUserData(dataReader: UserDataReader): void { + this.params.forEach(expr => expr._readUserData(dataReader)); + } +} + +/** + * @beta + */ +export class Add extends FirestoreFunction { + constructor(private left: Expr, private right: Expr) { + super('add', [left, right]); + } +} + +/** + * @beta + */ +export class Subtract extends FirestoreFunction { + constructor(private left: Expr, private right: Expr) { + super('subtract', [left, right]); + } +} + +/** + * @beta + */ +export class Multiply extends FirestoreFunction { + constructor(private left: Expr, private right: Expr) { + super('multiply', [left, right]); + } +} + +/** + * @beta + */ +export class Divide extends FirestoreFunction { + constructor(private left: Expr, private right: Expr) { + super('divide', [left, right]); + } +} + +/** + * @beta + */ +export class Mod extends FirestoreFunction { + constructor(private left: Expr, private right: Expr) { + super('mod', [left, right]); + } +} + +// /** +// * @beta +// */ +// export class BitAnd extends FirestoreFunction { +// constructor( +// private left: Expr, +// private right: Expr +// ) { +// super('bit_and', [left, right]); +// } +// } +// +// /** +// * @beta +// */ +// export class BitOr extends FirestoreFunction { +// constructor( +// private left: Expr, +// private right: Expr +// ) { +// super('bit_or', [left, right]); +// } +// } +// +// /** +// * @beta +// */ +// export class BitXor extends FirestoreFunction { +// constructor( +// private left: Expr, +// private right: Expr +// ) { +// super('bit_xor', [left, right]); +// } +// } +// +// /** +// * @beta +// */ +// export class BitNot extends FirestoreFunction { +// constructor(private operand: Expr) { +// super('bit_not', [operand]); +// } +// } +// +// /** +// * @beta +// */ +// export class BitLeftShift extends FirestoreFunction { +// constructor( +// private left: Expr, +// private right: Expr +// ) { +// super('bit_left_shift', [left, right]); +// } +// } +// +// /** +// * @beta +// */ +// export class BitRightShift extends FirestoreFunction { +// constructor( +// private left: Expr, +// private right: Expr +// ) { +// super('bit_right_shift', [left, right]); +// } +// } + +/** + * @beta + */ +export class Eq extends FirestoreFunction implements FilterCondition { + constructor(private left: Expr, private right: Expr) { + super('eq', [left, right]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class Neq extends FirestoreFunction implements FilterCondition { + constructor(private left: Expr, private right: Expr) { + super('neq', [left, right]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class Lt extends FirestoreFunction implements FilterCondition { + constructor(private left: Expr, private right: Expr) { + super('lt', [left, right]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class Lte extends FirestoreFunction implements FilterCondition { + constructor(private left: Expr, private right: Expr) { + super('lte', [left, right]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class Gt extends FirestoreFunction implements FilterCondition { + constructor(private left: Expr, private right: Expr) { + super('gt', [left, right]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class Gte extends FirestoreFunction implements FilterCondition { + constructor(private left: Expr, private right: Expr) { + super('gte', [left, right]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class ArrayConcat extends FirestoreFunction { + constructor(private array: Expr, private elements: Expr[]) { + super('array_concat', [array, ...elements]); + } +} + +/** + * @beta + */ +export class ArrayReverse extends FirestoreFunction { + constructor(private array: Expr) { + super('array_reverse', [array]); + } +} + +/** + * @beta + */ +export class ArrayContains extends FirestoreFunction implements FilterCondition { + constructor(private array: Expr, private element: Expr) { + super('array_contains', [array, element]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class ArrayContainsAll extends FirestoreFunction implements FilterCondition { + constructor(private array: Expr, private values: Expr[]) { + super('array_contains_all', [array, new ListOfExprs(values)]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class ArrayContainsAny extends FirestoreFunction implements FilterCondition { + constructor(private array: Expr, private values: Expr[]) { + super('array_contains_any', [array, new ListOfExprs(values)]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class ArrayLength extends FirestoreFunction { + constructor(private array: Expr) { + super('array_length', [array]); + } +} + +/** + * @beta + */ +export class ArrayElement extends FirestoreFunction { + constructor() { + super('array_element', []); + } +} + +/** + * @beta + */ +export class In extends FirestoreFunction implements FilterCondition { + constructor(private left: Expr, private others: Expr[]) { + super('in', [left, new ListOfExprs(others)]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class IsNan extends FirestoreFunction implements FilterCondition { + constructor(private expr: Expr) { + super('is_nan', [expr]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class Exists extends FirestoreFunction implements FilterCondition { + constructor(private expr: Expr) { + super('exists', [expr]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class Not extends FirestoreFunction implements FilterCondition { + constructor(private expr: Expr) { + super('not', [expr]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class And extends FirestoreFunction implements FilterCondition { + constructor(private conditions: FilterExpr[]) { + super('and', conditions); + } + + filterable = true as const; +} + +/** + * @beta + */ +export class Or extends FirestoreFunction implements FilterCondition { + constructor(private conditions: FilterExpr[]) { + super('or', conditions); + } + filterable = true as const; +} + +/** + * @beta + */ +export class Xor extends FirestoreFunction implements FilterCondition { + constructor(private conditions: FilterExpr[]) { + super('xor', conditions); + } + filterable = true as const; +} + +/** + * @beta + */ +export class If extends FirestoreFunction implements FilterCondition { + constructor( + private condition: FilterExpr, + private thenExpr: Expr, + private elseExpr: Expr + ) { + super('if', [condition, thenExpr, elseExpr]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class LogicalMax extends FirestoreFunction { + constructor(private left: Expr, private right: Expr) { + super('logical_max', [left, right]); + } +} + +/** + * @beta + */ +export class LogicalMin extends FirestoreFunction { + constructor(private left: Expr, private right: Expr) { + super('logical_min', [left, right]); + } +} + +/** + * @beta + */ +export class Reverse extends FirestoreFunction { + constructor(private value: Expr) { + super('reverse', [value]); + } +} + +/** + * @beta + */ +export class ReplaceFirst extends FirestoreFunction { + constructor(private value: Expr, private find: Expr, private replace: Expr) { + super('replace_first', [value, find, replace]); + } +} + +/** + * @beta + */ +export class ReplaceAll extends FirestoreFunction { + constructor(private value: Expr, private find: Expr, private replace: Expr) { + super('replace_all', [value, find, replace]); + } +} + +/** + * @beta + */ +export class CharLength extends FirestoreFunction { + constructor(private value: Expr) { + super('char_length', [value]); + } +} + +/** + * @beta + */ +export class ByteLength extends FirestoreFunction { + constructor(private value: Expr) { + super('byte_length', [value]); + } +} + +/** + * @beta + */ +export class Like extends FirestoreFunction implements FilterCondition { + constructor(private expr: Expr, private pattern: Expr) { + super('like', [expr, pattern]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class RegexContains extends FirestoreFunction implements FilterCondition { + constructor(private expr: Expr, private pattern: Expr) { + super('regex_contains', [expr, pattern]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class RegexMatch extends FirestoreFunction implements FilterCondition { + constructor(private expr: Expr, private pattern: Expr) { + super('regex_match', [expr, pattern]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class StrContains extends FirestoreFunction implements FilterCondition { + constructor(private expr: Expr, private substring: Expr) { + super('str_contains', [expr, substring]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class StartsWith extends FirestoreFunction implements FilterCondition { + constructor(private expr: Expr, private prefix: Expr) { + super('starts_with', [expr, prefix]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class EndsWith extends FirestoreFunction implements FilterCondition { + constructor(private expr: Expr, private suffix: Expr) { + super('ends_with', [expr, suffix]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class ToLower extends FirestoreFunction { + constructor(private expr: Expr) { + super('to_lower', [expr]); + } +} + +/** + * @beta + */ +export class ToUpper extends FirestoreFunction { + constructor(private expr: Expr) { + super('to_upper', [expr]); + } +} + +/** + * @beta + */ +export class Trim extends FirestoreFunction { + constructor(private expr: Expr) { + super('trim', [expr]); + } +} + +/** + * @beta + */ +export class StrConcat extends FirestoreFunction { + constructor(private first: Expr, private rest: Expr[]) { + super('str_concat', [first, ...rest]); + } +} + +/** + * @beta + */ +export class MapGet extends FirestoreFunction { + constructor(map: Expr, name: string) { + super('map_get', [map, Constant.of(name)]); + } +} + +/** + * @beta + */ +export class Count extends FirestoreFunction implements Accumulator { + accumulator = true as const; + constructor(private value: Expr | undefined, private distinct: boolean) { + super('count', value === undefined ? [] : [value]); + } +} + +/** + * @beta + */ +export class Sum extends FirestoreFunction implements Accumulator { + accumulator = true as const; + constructor(private value: Expr, private distinct: boolean) { + super('sum', [value]); + } +} + +/** + * @beta + */ +export class Avg extends FirestoreFunction implements Accumulator { + accumulator = true as const; + constructor(private value: Expr, private distinct: boolean) { + super('avg', [value]); + } +} + +/** + * @beta + */ +export class Min extends FirestoreFunction implements Accumulator { + accumulator = true as const; + constructor(private value: Expr, private distinct: boolean) { + super('min', [value]); + } +} + +/** + * @beta + */ +export class Max extends FirestoreFunction implements Accumulator { + accumulator = true as const; + constructor(private value: Expr, private distinct: boolean) { + super('max', [value]); + } +} + +/** + * @beta + */ +export class CosineDistance extends FirestoreFunction { + constructor(private vector1: Expr, private vector2: Expr) { + super('cosine_distance', [vector1, vector2]); + } +} + +/** + * @beta + */ +export class DotProduct extends FirestoreFunction { + constructor(private vector1: Expr, private vector2: Expr) { + super('dot_product', [vector1, vector2]); + } +} + +/** + * @beta + */ +export class EuclideanDistance extends FirestoreFunction { + constructor(private vector1: Expr, private vector2: Expr) { + super('euclidean_distance', [vector1, vector2]); + } +} + +/** + * @beta + */ +export class VectorLength extends FirestoreFunction { + constructor(private value: Expr) { + super('vector_length', [value]); + } +} + +/** + * @beta + */ +export class UnixMicrosToTimestamp extends FirestoreFunction { + constructor(private input: Expr) { + super('unix_micros_to_timestamp', [input]); + } +} + +/** + * @beta + */ +export class TimestampToUnixMicros extends FirestoreFunction { + constructor(private input: Expr) { + super('timestamp_to_unix_micros', [input]); + } +} + +/** + * @beta + */ +export class UnixMillisToTimestamp extends FirestoreFunction { + constructor(private input: Expr) { + super('unix_millis_to_timestamp', [input]); + } +} + +/** + * @beta + */ +export class TimestampToUnixMillis extends FirestoreFunction { + constructor(private input: Expr) { + super('timestamp_to_unix_millis', [input]); + } +} + +/** + * @beta + */ +export class UnixSecondsToTimestamp extends FirestoreFunction { + constructor(private input: Expr) { + super('unix_seconds_to_timestamp', [input]); + } +} + +/** + * @beta + */ +export class TimestampToUnixSeconds extends FirestoreFunction { + constructor(private input: Expr) { + super('timestamp_to_unix_seconds', [input]); + } +} + +/** + * @beta + */ +export class TimestampAdd extends FirestoreFunction { + constructor( + private timestamp: Expr, + private unit: Expr, + private amount: Expr + ) { + super('timestamp_add', [timestamp, unit, amount]); + } +} + +/** + * @beta + */ +export class TimestampSub extends FirestoreFunction { + constructor( + private timestamp: Expr, + private unit: Expr, + private amount: Expr + ) { + super('timestamp_sub', [timestamp, unit, amount]); + } +} + +/** + * @beta + * + * Creates an expression that adds two expressions together. + * + * ```typescript + * // Add the value of the 'quantity' field and the 'reserve' field. + * add(Field.of("quantity"), Field.of("reserve")); + * ``` + * + * @param left The first expression to add. + * @param right The second expression to add. + * @return A new {@code Expr} representing the addition operation. + */ +export function add(left: Expr, right: Expr): Add; + +/** + * @beta + * + * Creates an expression that adds an expression to a constant value. + * + * ```typescript + * // Add 5 to the value of the 'age' field + * add(Field.of("age"), 5); + * ``` + * + * @param left The expression to add to. + * @param right The constant value to add. + * @return A new {@code Expr} representing the addition operation. + */ +export function add(left: Expr, right: any): Add; + +/** + * @beta + * + * Creates an expression that adds a field's value to an expression. + * + * ```typescript + * // Add the value of the 'quantity' field and the 'reserve' field. + * add("quantity", Field.of("reserve")); + * ``` + * + * @param left The field name to add to. + * @param right The expression to add. + * @return A new {@code Expr} representing the addition operation. + */ +export function add(left: string, right: Expr): Add; + +/** + * @beta + * + * Creates an expression that adds a field's value to a constant value. + * + * ```typescript + * // Add 5 to the value of the 'age' field + * add("age", 5); + * ``` + * + * @param left The field name to add to. + * @param right The constant value to add. + * @return A new {@code Expr} representing the addition operation. + */ +export function add(left: string, right: any): Add; +export function add(left: Expr | string, right: Expr | any): Add { + const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; + const normalizedRight = right instanceof Expr ? right : Constant.of(right); + return new Add(normalizedLeft, normalizedRight); +} + +/** + * @beta + * + * Creates an expression that subtracts two expressions. + * + * ```typescript + * // Subtract the 'discount' field from the 'price' field + * subtract(Field.of("price"), Field.of("discount")); + * ``` + * + * @param left The expression to subtract from. + * @param right The expression to subtract. + * @return A new {@code Expr} representing the subtraction operation. + */ +export function subtract(left: Expr, right: Expr): Subtract; + +/** + * @beta + * + * Creates an expression that subtracts a constant value from an expression. + * + * ```typescript + * // Subtract the constant value 2 from the 'value' field + * subtract(Field.of("value"), 2); + * ``` + * + * @param left The expression to subtract from. + * @param right The constant value to subtract. + * @return A new {@code Expr} representing the subtraction operation. + */ +export function subtract(left: Expr, right: any): Subtract; + +/** + * @beta + * + * Creates an expression that subtracts an expression from a field's value. + * + * ```typescript + * // Subtract the 'discount' field from the 'price' field + * subtract("price", Field.of("discount")); + * ``` + * + * @param left The field name to subtract from. + * @param right The expression to subtract. + * @return A new {@code Expr} representing the subtraction operation. + */ +export function subtract(left: string, right: Expr): Subtract; + +/** + * @beta + * + * Creates an expression that subtracts a constant value from a field's value. + * + * ```typescript + * // Subtract 20 from the value of the 'total' field + * subtract("total", 20); + * ``` + * + * @param left The field name to subtract from. + * @param right The constant value to subtract. + * @return A new {@code Expr} representing the subtraction operation. + */ +export function subtract(left: string, right: any): Subtract; +export function subtract(left: Expr | string, right: Expr | any): Subtract { + const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; + const normalizedRight = right instanceof Expr ? right : Constant.of(right); + return new Subtract(normalizedLeft, normalizedRight); +} + +/** + * @beta + * + * Creates an expression that multiplies two expressions together. + * + * ```typescript + * // Multiply the 'quantity' field by the 'price' field + * multiply(Field.of("quantity"), Field.of("price")); + * ``` + * + * @param left The first expression to multiply. + * @param right The second expression to multiply. + * @return A new {@code Expr} representing the multiplication operation. + */ +export function multiply(left: Expr, right: Expr): Multiply; + +/** + * @beta + * + * Creates an expression that multiplies an expression by a constant value. + * + * ```typescript + * // Multiply the value of the 'price' field by 2 + * multiply(Field.of("price"), 2); + * ``` + * + * @param left The expression to multiply. + * @param right The constant value to multiply by. + * @return A new {@code Expr} representing the multiplication operation. + */ +export function multiply(left: Expr, right: any): Multiply; + +/** + * @beta + * + * Creates an expression that multiplies a field's value by an expression. + * + * ```typescript + * // Multiply the 'quantity' field by the 'price' field + * multiply("quantity", Field.of("price")); + * ``` + * + * @param left The field name to multiply. + * @param right The expression to multiply by. + * @return A new {@code Expr} representing the multiplication operation. + */ +export function multiply(left: string, right: Expr): Multiply; + +/** + * @beta + * + * Creates an expression that multiplies a field's value by a constant value. + * + * ```typescript + * // Multiply the 'value' field by 2 + * multiply("value", 2); + * ``` + * + * @param left The field name to multiply. + * @param right The constant value to multiply by. + * @return A new {@code Expr} representing the multiplication operation. + */ +export function multiply(left: string, right: any): Multiply; +export function multiply(left: Expr | string, right: Expr | any): Multiply { + const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; + const normalizedRight = right instanceof Expr ? right : Constant.of(right); + return new Multiply(normalizedLeft, normalizedRight); +} + +/** + * @beta + * + * Creates an expression that divides two expressions. + * + * ```typescript + * // Divide the 'total' field by the 'count' field + * divide(Field.of("total"), Field.of("count")); + * ``` + * + * @param left The expression to be divided. + * @param right The expression to divide by. + * @return A new {@code Expr} representing the division operation. + */ +export function divide(left: Expr, right: Expr): Divide; + +/** + * @beta + * + * Creates an expression that divides an expression by a constant value. + * + * ```typescript + * // Divide the 'value' field by 10 + * divide(Field.of("value"), 10); + * ``` + * + * @param left The expression to be divided. + * @param right The constant value to divide by. + * @return A new {@code Expr} representing the division operation. + */ +export function divide(left: Expr, right: any): Divide; + +/** + * @beta + * + * Creates an expression that divides a field's value by an expression. + * + * ```typescript + * // Divide the 'total' field by the 'count' field + * divide("total", Field.of("count")); + * ``` + * + * @param left The field name to be divided. + * @param right The expression to divide by. + * @return A new {@code Expr} representing the division operation. + */ +export function divide(left: string, right: Expr): Divide; + +/** + * @beta + * + * Creates an expression that divides a field's value by a constant value. + * + * ```typescript + * // Divide the 'value' field by 10 + * divide("value", 10); + * ``` + * + * @param left The field name to be divided. + * @param right The constant value to divide by. + * @return A new {@code Expr} representing the division operation. + */ +export function divide(left: string, right: any): Divide; +export function divide(left: Expr | string, right: Expr | any): Divide { + const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; + const normalizedRight = right instanceof Expr ? right : Constant.of(right); + return new Divide(normalizedLeft, normalizedRight); +} + +/** + * @beta + * + * Creates an expression that calculates the modulo (remainder) of dividing two expressions. + * + * ```typescript + * // Calculate the remainder of dividing 'field1' by 'field2'. + * mod(Field.of("field1"), Field.of("field2")); + * ``` + * + * @param left The dividend expression. + * @param right The divisor expression. + * @return A new {@code Expr} representing the modulo operation. + */ +export function mod(left: Expr, right: Expr): Mod; + +/** + * @beta + * + * Creates an expression that calculates the modulo (remainder) of dividing an expression by a constant. + * + * ```typescript + * // Calculate the remainder of dividing 'field1' by 5. + * mod(Field.of("field1"), 5); + * ``` + * + * @param left The dividend expression. + * @param right The divisor constant. + * @return A new {@code Expr} representing the modulo operation. + */ +export function mod(left: Expr, right: any): Mod; + +/** + * @beta + * + * Creates an expression that calculates the modulo (remainder) of dividing a field's value by an expression. + * + * ```typescript + * // Calculate the remainder of dividing 'field1' by 'field2'. + * mod("field1", Field.of("field2")); + * ``` + * + * @param left The dividend field name. + * @param right The divisor expression. + * @return A new {@code Expr} representing the modulo operation. + */ +export function mod(left: string, right: Expr): Mod; + +/** + * @beta + * + * Creates an expression that calculates the modulo (remainder) of dividing a field's value by a constant. + * + * ```typescript + * // Calculate the remainder of dividing 'field1' by 5. + * mod("field1", 5); + * ``` + * + * @param left The dividend field name. + * @param right The divisor constant. + * @return A new {@code Expr} representing the modulo operation. + */ +export function mod(left: string, right: any): Mod; +export function mod(left: Expr | string, right: Expr | any): Mod { + const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; + const normalizedRight = right instanceof Expr ? right : Constant.of(right); + return new Mod(normalizedLeft, normalizedRight); +} + +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise AND operation between two expressions. +// * +// * ```typescript +// * // Calculate the bitwise AND of 'field1' and 'field2'. +// * bitAnd(Field.of("field1"), Field.of("field2")); +// * ``` +// * +// * @param left The left operand expression. +// * @param right The right operand expression. +// * @return A new {@code Expr} representing the bitwise AND operation. +// */ +// export function bitAnd(left: Expr, right: Expr): BitAnd; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise AND operation between an expression and a constant. +// * +// * ```typescript +// * // Calculate the bitwise AND of 'field1' and 0xFF. +// * bitAnd(Field.of("field1"), 0xFF); +// * ``` +// * +// * @param left The left operand expression. +// * @param right The right operand constant. +// * @return A new {@code Expr} representing the bitwise AND operation. +// */ +// export function bitAnd(left: Expr, right: any): BitAnd; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise AND operation between a field and an expression. +// * +// * ```typescript +// * // Calculate the bitwise AND of 'field1' and 'field2'. +// * bitAnd("field1", Field.of("field2")); +// * ``` +// * +// * @param left The left operand field name. +// * @param right The right operand expression. +// * @return A new {@code Expr} representing the bitwise AND operation. +// */ +// export function bitAnd(left: string, right: Expr): BitAnd; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise AND operation between a field and a constant. +// * +// * ```typescript +// * // Calculate the bitwise AND of 'field1' and 0xFF. +// * bitAnd("field1", 0xFF); +// * ``` +// * +// * @param left The left operand field name. +// * @param right The right operand constant. +// * @return A new {@code Expr} representing the bitwise AND operation. +// */ +// export function bitAnd(left: string, right: any): BitAnd; +// export function bitAnd(left: Expr | string, right: Expr | any): BitAnd { +// const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; +// const normalizedRight = right instanceof Expr ? right : Constant.of(right); +// return new BitAnd(normalizedLeft, normalizedRight); +// } +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise OR operation between two expressions. +// * +// * ```typescript +// * // Calculate the bitwise OR of 'field1' and 'field2'. +// * bitOr(Field.of("field1"), Field.of("field2")); +// * ``` +// * +// * @param left The left operand expression. +// * @param right The right operand expression. +// * @return A new {@code Expr} representing the bitwise OR operation. +// */ +// export function bitOr(left: Expr, right: Expr): BitOr; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise OR operation between an expression and a constant. +// * +// * ```typescript +// * // Calculate the bitwise OR of 'field1' and 0xFF. +// * bitOr(Field.of("field1"), 0xFF); +// * ``` +// * +// * @param left The left operand expression. +// * @param right The right operand constant. +// * @return A new {@code Expr} representing the bitwise OR operation. +// */ +// export function bitOr(left: Expr, right: any): BitOr; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise OR operation between a field and an expression. +// * +// * ```typescript +// * // Calculate the bitwise OR of 'field1' and 'field2'. +// * bitOr("field1", Field.of("field2")); +// * ``` +// * +// * @param left The left operand field name. +// * @param right The right operand expression. +// * @return A new {@code Expr} representing the bitwise OR operation. +// */ +// export function bitOr(left: string, right: Expr): BitOr; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise OR operation between a field and a constant. +// * +// * ```typescript +// * // Calculate the bitwise OR of 'field1' and 0xFF. +// * bitOr("field1", 0xFF); +// * ``` +// * +// * @param left The left operand field name. +// * @param right The right operand constant. +// * @return A new {@code Expr} representing the bitwise OR operation. +// */ +// export function bitOr(left: string, right: any): BitOr; +// export function bitOr(left: Expr | string, right: Expr | any): BitOr { +// const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; +// const normalizedRight = right instanceof Expr ? right : Constant.of(right); +// return new BitOr(normalizedLeft, normalizedRight); +// } +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise XOR operation between two expressions. +// * +// * ```typescript +// * // Calculate the bitwise XOR of 'field1' and 'field2'. +// * bitXor(Field.of("field1"), Field.of("field2")); +// * ``` +// * +// * @param left The left operand expression. +// * @param right The right operand expression. +// * @return A new {@code Expr} representing the bitwise XOR operation. +// */ +// export function bitXor(left: Expr, right: Expr): BitXor; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise XOR operation between an expression and a constant. +// * +// * ```typescript +// * // Calculate the bitwise XOR of 'field1' and 0xFF. +// * bitXor(Field.of("field1"), 0xFF); +// * ``` +// * +// * @param left The left operand expression. +// * @param right The right operand constant. +// * @return A new {@code Expr} representing the bitwise XOR operation. +// */ +// export function bitXor(left: Expr, right: any): BitXor; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise XOR operation between a field and an expression. +// * +// * ```typescript +// * // Calculate the bitwise XOR of 'field1' and 'field2'. +// * bitXor("field1", Field.of("field2")); +// * ``` +// * +// * @param left The left operand field name. +// * @param right The right operand expression. +// * @return A new {@code Expr} representing the bitwise XOR operation. +// */ +// export function bitXor(left: string, right: Expr): BitXor; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise XOR operation between a field and a constant. +// * +// * ```typescript +// * // Calculate the bitwise XOR of 'field1' and 0xFF. +// * bitXor("field1", 0xFF); +// * ``` +// * +// * @param left The left operand field name. +// * @param right The right operand constant. +// * @return A new {@code Expr} representing the bitwise XOR operation. +// */ +// export function bitXor(left: string, right: any): BitXor; +// export function bitXor(left: Expr | string, right: Expr | any): BitXor { +// const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; +// const normalizedRight = right instanceof Expr ? right : Constant.of(right); +// return new BitXor(normalizedLeft, normalizedRight); +// } +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise NOT operation to an expression. +// * +// * ```typescript +// * // Calculate the bitwise NOT of 'field1'. +// * bitNot(Field.of("field1")); +// * ``` +// * +// * @param operand The operand expression. +// * @return A new {@code Expr} representing the bitwise NOT operation. +// */ +// export function bitNot(operand: Expr): BitNot; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise NOT operation to a field. +// * +// * ```typescript +// * // Calculate the bitwise NOT of 'field1'. +// * bitNot("field1"); +// * ``` +// * +// * @param operand The operand field name. +// * @return A new {@code Expr} representing the bitwise NOT operation. +// */ +// export function bitNot(operand: string): BitNot; +// export function bitNot(operand: Expr | string): BitNot { +// const normalizedOperand = +// typeof operand === 'string' ? Field.of(operand) : operand; +// return new BitNot(normalizedOperand); +// } +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise left shift operation between two expressions. +// * +// * ```typescript +// * // Calculate the bitwise left shift of 'field1' by 'field2' bits. +// * bitLeftShift(Field.of("field1"), Field.of("field2")); +// * ``` +// * +// * @param left The left operand expression. +// * @param right The right operand expression representing the number of bits to shift. +// * @return A new {@code Expr} representing the bitwise left shift operation. +// */ +// export function bitLeftShift(left: Expr, right: Expr): BitLeftShift; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise left shift operation between an expression and a constant. +// * +// * ```typescript +// * // Calculate the bitwise left shift of 'field1' by 2 bits. +// * bitLeftShift(Field.of("field1"), 2); +// * ``` +// * +// * @param left The left operand expression. +// * @param right The right operand constant representing the number of bits to shift. +// * @return A new {@code Expr} representing the bitwise left shift operation. +// */ +// export function bitLeftShift(left: Expr, right: any): BitLeftShift; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise left shift operation between a field and an expression. +// * +// * ```typescript +// * // Calculate the bitwise left shift of 'field1' by 'field2' bits. +// * bitLeftShift("field1", Field.of("field2")); +// * ``` +// * +// * @param left The left operand field name. +// * @param right The right operand expression representing the number of bits to shift. +// * @return A new {@code Expr} representing the bitwise left shift operation. +// */ +// export function bitLeftShift(left: string, right: Expr): BitLeftShift; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise left shift operation between a field and a constant. +// * +// * ```typescript +// * // Calculate the bitwise left shift of 'field1' by 2 bits. +// * bitLeftShift("field1", 2); +// * ``` +// * +// * @param left The left operand field name. +// * @param right The right operand constant representing the number of bits to shift. +// * @return A new {@code Expr} representing the bitwise left shift operation. +// */ +// export function bitLeftShift(left: string, right: any): BitLeftShift; +// export function bitLeftShift( +// left: Expr | string, +// right: Expr | any +// ): BitLeftShift { +// const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; +// const normalizedRight = right instanceof Expr ? right : Constant.of(right); +// return new BitLeftShift(normalizedLeft, normalizedRight); +// } +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise right shift operation between two expressions. +// * +// * ```typescript +// * // Calculate the bitwise right shift of 'field1' by 'field2' bits. +// * bitRightShift(Field.of("field1"), Field.of("field2")); +// * ``` +// * +// * @param left The left operand expression. +// * @param right The right operand expression representing the number of bits to shift. +// * @return A new {@code Expr} representing the bitwise right shift operation. +// */ +// export function bitRightShift(left: Expr, right: Expr): BitRightShift; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise right shift operation between an expression and a constant. +// * +// * ```typescript +// * // Calculate the bitwise right shift of 'field1' by 2 bits. +// * bitRightShift(Field.of("field1"), 2); +// * ``` +// * +// * @param left The left operand expression. +// * @param right The right operand constant representing the number of bits to shift. +// * @return A new {@code Expr} representing the bitwise right shift operation. +// */ +// export function bitRightShift(left: Expr, right: any): BitRightShift; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise right shift operation between a field and an expression. +// * +// * ```typescript +// * // Calculate the bitwise right shift of 'field1' by 'field2' bits. +// * bitRightShift("field1", Field.of("field2")); +// * ``` +// * +// * @param left The left operand field name. +// * @param right The right operand expression representing the number of bits to shift. +// * @return A new {@code Expr} representing the bitwise right shift operation. +// */ +// export function bitRightShift(left: string, right: Expr): BitRightShift; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise right shift operation between a field and a constant. +// * +// * ```typescript +// * // Calculate the bitwise right shift of 'field1' by 2 bits. +// * bitRightShift("field1", 2); +// * ``` +// * +// * @param left The left operand field name. +// * @param right The right operand constant representing the number of bits to shift. +// * @return A new {@code Expr} representing the bitwise right shift operation. +// */ +// export function bitRightShift(left: string, right: any): BitRightShift; +// export function bitRightShift( +// left: Expr | string, +// right: Expr | any +// ): BitRightShift { +// const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; +// const normalizedRight = right instanceof Expr ? right : Constant.of(right); +// return new BitRightShift(normalizedLeft, normalizedRight); +// } + +/** + * @beta + * + * Creates an expression that checks if two expressions are equal. + * + * ```typescript + * // Check if the 'age' field is equal to an expression + * eq(Field.of("age"), Field.of("minAge").add(10)); + * ``` + * + * @param left The first expression to compare. + * @param right The second expression to compare. + * @return A new `Expr` representing the equality comparison. + */ +export function eq(left: Expr, right: Expr): Eq; + +/** + * @beta + * + * Creates an expression that checks if an expression is equal to a constant value. + * + * ```typescript + * // Check if the 'age' field is equal to 21 + * eq(Field.of("age"), 21); + * ``` + * + * @param left The expression to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the equality comparison. + */ +export function eq(left: Expr, right: any): Eq; + +/** + * @beta + * + * Creates an expression that checks if a field's value is equal to an expression. + * + * ```typescript + * // Check if the 'age' field is equal to the 'limit' field + * eq("age", Field.of("limit")); + * ``` + * + * @param left The field name to compare. + * @param right The expression to compare to. + * @return A new `Expr` representing the equality comparison. + */ +export function eq(left: string, right: Expr): Eq; + +/** + * @beta + * + * Creates an expression that checks if a field's value is equal to a constant value. + * + * ```typescript + * // Check if the 'city' field is equal to string constant "London" + * eq("city", "London"); + * ``` + * + * @param left The field name to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the equality comparison. + */ +export function eq(left: string, right: any): Eq; +export function eq(left: Expr | string, right: any): Eq { + const leftExpr = left instanceof Expr ? left : Field.of(left); + const rightExpr = right instanceof Expr ? right : Constant.of(right); + return new Eq(leftExpr, rightExpr); +} + +/** + * @beta + * + * Creates an expression that checks if two expressions are not equal. + * + * ```typescript + * // Check if the 'status' field is not equal to field 'finalState' + * neq(Field.of("status"), Field.of("finalState")); + * ``` + * + * @param left The first expression to compare. + * @param right The second expression to compare. + * @return A new `Expr` representing the inequality comparison. + */ +export function neq(left: Expr, right: Expr): Neq; + +/** + * @beta + * + * Creates an expression that checks if an expression is not equal to a constant value. + * + * ```typescript + * // Check if the 'status' field is not equal to "completed" + * neq(Field.of("status"), "completed"); + * ``` + * + * @param left The expression to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the inequality comparison. + */ +export function neq(left: Expr, right: any): Neq; + +/** + * @beta + * + * Creates an expression that checks if a field's value is not equal to an expression. + * + * ```typescript + * // Check if the 'status' field is not equal to the value of 'expectedStatus' + * neq("status", Field.of("expectedStatus")); + * ``` + * + * @param left The field name to compare. + * @param right The expression to compare to. + * @return A new `Expr` representing the inequality comparison. + */ +export function neq(left: string, right: Expr): Neq; + +/** + * @beta + * + * Creates an expression that checks if a field's value is not equal to a constant value. + * + * ```typescript + * // Check if the 'country' field is not equal to "USA" + * neq("country", "USA"); + * ``` + * + * @param left The field name to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the inequality comparison. + */ +export function neq(left: string, right: any): Neq; +export function neq(left: Expr | string, right: any): Neq { + const leftExpr = left instanceof Expr ? left : Field.of(left); + const rightExpr = right instanceof Expr ? right : Constant.of(right); + return new Neq(leftExpr, rightExpr); +} + +/** + * @beta + * + * Creates an expression that checks if the first expression is less than the second expression. + * + * ```typescript + * // Check if the 'age' field is less than 30 + * lt(Field.of("age"), Field.of("limit")); + * ``` + * + * @param left The first expression to compare. + * @param right The second expression to compare. + * @return A new `Expr` representing the less than comparison. + */ +export function lt(left: Expr, right: Expr): Lt; + +/** + * @beta + * + * Creates an expression that checks if an expression is less than a constant value. + * + * ```typescript + * // Check if the 'age' field is less than 30 + * lt(Field.of("age"), 30); + * ``` + * + * @param left The expression to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the less than comparison. + */ +export function lt(left: Expr, right: any): Lt; + +/** + * @beta + * + * Creates an expression that checks if a field's value is less than an expression. + * + * ```typescript + * // Check if the 'age' field is less than the 'limit' field + * lt("age", Field.of("limit")); + * ``` + * + * @param left The field name to compare. + * @param right The expression to compare to. + * @return A new `Expr` representing the less than comparison. + */ +export function lt(left: string, right: Expr): Lt; + +/** + * @beta + * + * Creates an expression that checks if a field's value is less than a constant value. + * + * ```typescript + * // Check if the 'price' field is less than 50 + * lt("price", 50); + * ``` + * + * @param left The field name to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the less than comparison. + */ +export function lt(left: string, right: any): Lt; +export function lt(left: Expr | string, right: any): Lt { + const leftExpr = left instanceof Expr ? left : Field.of(left); + const rightExpr = right instanceof Expr ? right : Constant.of(right); + return new Lt(leftExpr, rightExpr); +} + +/** + * @beta + * + * Creates an expression that checks if the first expression is less than or equal to the second + * expression. + * + * ```typescript + * // Check if the 'quantity' field is less than or equal to 20 + * lte(Field.of("quantity"), Field.of("limit")); + * ``` + * + * @param left The first expression to compare. + * @param right The second expression to compare. + * @return A new `Expr` representing the less than or equal to comparison. + */ +export function lte(left: Expr, right: Expr): Lte; + +/** + * @beta + * + * Creates an expression that checks if an expression is less than or equal to a constant value. + * + * ```typescript + * // Check if the 'quantity' field is less than or equal to 20 + * lte(Field.of("quantity"), 20); + * ``` + * + * @param left The expression to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the less than or equal to comparison. + */ +export function lte(left: Expr, right: any): Lte; + +/** + * Creates an expression that checks if a field's value is less than or equal to an expression. + * + * ```typescript + * // Check if the 'quantity' field is less than or equal to the 'limit' field + * lte("quantity", Field.of("limit")); + * ``` + * + * @param left The field name to compare. + * @param right The expression to compare to. + * @return A new `Expr` representing the less than or equal to comparison. + */ +export function lte(left: string, right: Expr): Lte; + +/** + * @beta + * + * Creates an expression that checks if a field's value is less than or equal to a constant value. + * + * ```typescript + * // Check if the 'score' field is less than or equal to 70 + * lte("score", 70); + * ``` + * + * @param left The field name to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the less than or equal to comparison. + */ +export function lte(left: string, right: any): Lte; +export function lte(left: Expr | string, right: any): Lte { + const leftExpr = left instanceof Expr ? left : Field.of(left); + const rightExpr = right instanceof Expr ? right : Constant.of(right); + return new Lte(leftExpr, rightExpr); +} + +/** + * @beta + * + * Creates an expression that checks if the first expression is greater than the second + * expression. + * + * ```typescript + * // Check if the 'age' field is greater than 18 + * gt(Field.of("age"), Constant(9).add(9)); + * ``` + * + * @param left The first expression to compare. + * @param right The second expression to compare. + * @return A new `Expr` representing the greater than comparison. + */ +export function gt(left: Expr, right: Expr): Gt; + +/** + * @beta + * + * Creates an expression that checks if an expression is greater than a constant value. + * + * ```typescript + * // Check if the 'age' field is greater than 18 + * gt(Field.of("age"), 18); + * ``` + * + * @param left The expression to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the greater than comparison. + */ +export function gt(left: Expr, right: any): Gt; + +/** + * @beta + * + * Creates an expression that checks if a field's value is greater than an expression. + * + * ```typescript + * // Check if the value of field 'age' is greater than the value of field 'limit' + * gt("age", Field.of("limit")); + * ``` + * + * @param left The field name to compare. + * @param right The expression to compare to. + * @return A new `Expr` representing the greater than comparison. + */ +export function gt(left: string, right: Expr): Gt; + +/** + * @beta + * + * Creates an expression that checks if a field's value is greater than a constant value. + * + * ```typescript + * // Check if the 'price' field is greater than 100 + * gt("price", 100); + * ``` + * + * @param left The field name to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the greater than comparison. + */ +export function gt(left: string, right: any): Gt; +export function gt(left: Expr | string, right: any): Gt { + const leftExpr = left instanceof Expr ? left : Field.of(left); + const rightExpr = right instanceof Expr ? right : Constant.of(right); + return new Gt(leftExpr, rightExpr); +} + +/** + * @beta + * + * Creates an expression that checks if the first expression is greater than or equal to the + * second expression. + * + * ```typescript + * // Check if the 'quantity' field is greater than or equal to the field "threshold" + * gte(Field.of("quantity"), Field.of("threshold")); + * ``` + * + * @param left The first expression to compare. + * @param right The second expression to compare. + * @return A new `Expr` representing the greater than or equal to comparison. + */ +export function gte(left: Expr, right: Expr): Gte; + +/** + * @beta + * + * Creates an expression that checks if an expression is greater than or equal to a constant + * value. + * + * ```typescript + * // Check if the 'quantity' field is greater than or equal to 10 + * gte(Field.of("quantity"), 10); + * ``` + * + * @param left The expression to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the greater than or equal to comparison. + */ +export function gte(left: Expr, right: any): Gte; + +/** + * @beta + * + * Creates an expression that checks if a field's value is greater than or equal to an expression. + * + * ```typescript + * // Check if the value of field 'age' is greater than or equal to the value of field 'limit' + * gte("age", Field.of("limit")); + * ``` + * + * @param left The field name to compare. + * @param right The expression to compare to. + * @return A new `Expr` representing the greater than or equal to comparison. + */ +export function gte(left: string, right: Expr): Gte; + +/** + * @beta + * + * Creates an expression that checks if a field's value is greater than or equal to a constant + * value. + * + * ```typescript + * // Check if the 'score' field is greater than or equal to 80 + * gte("score", 80); + * ``` + * + * @param left The field name to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the greater than or equal to comparison. + */ +export function gte(left: string, right: any): Gte; +export function gte(left: Expr | string, right: any): Gte { + const leftExpr = left instanceof Expr ? left : Field.of(left); + const rightExpr = right instanceof Expr ? right : Constant.of(right); + return new Gte(leftExpr, rightExpr); +} + +/** + * @beta + * + * Creates an expression that concatenates an array expression with other arrays. + * + * ```typescript + * // Combine the 'items' array with two new item arrays + * arrayConcat(Field.of("items"), [Field.of("newItems"), Field.of("otherItems")]); + * ``` + * + * @param array The array expression to concatenate to. + * @param elements The array expressions to concatenate. + * @return A new {@code Expr} representing the concatenated array. + */ +export function arrayConcat(array: Expr, elements: Expr[]): ArrayConcat; + +/** + * @beta + * + * Creates an expression that concatenates an array expression with other arrays and/or values. + * + * ```typescript + * // Combine the 'tags' array with a new array + * arrayConcat(Field.of("tags"), ["newTag1", "newTag2"]); + * ``` + * + * @param array The array expression to concatenate to. + * @param elements The array expressions or single values to concatenate. + * @return A new {@code Expr} representing the concatenated array. + */ +export function arrayConcat(array: Expr, elements: any[]): ArrayConcat; + +/** + * @beta + * + * Creates an expression that concatenates a field's array value with other arrays. + * + * ```typescript + * // Combine the 'items' array with two new item arrays + * arrayConcat("items", [Field.of("newItems"), Field.of("otherItems")]); + * ``` + * + * @param array The field name containing array values. + * @param elements The array expressions to concatenate. + * @return A new {@code Expr} representing the concatenated array. + */ +export function arrayConcat(array: string, elements: Expr[]): ArrayConcat; + +/** + * @beta + * + * Creates an expression that concatenates a field's array value with other arrays and/or values. + * + * ```typescript + * // Combine the 'tags' array with a new array + * arrayConcat("tags", ["newTag1", "newTag2"]); + * ``` + * + * @param array The field name containing array values. + * @param elements The array expressions or single values to concatenate. + * @return A new {@code Expr} representing the concatenated array. + */ +export function arrayConcat(array: string, elements: any[]): ArrayConcat; +export function arrayConcat( + array: Expr | string, + elements: any[] +): ArrayConcat { + const arrayExpr = array instanceof Expr ? array : Field.of(array); + const exprValues = elements.map(element => + element instanceof Expr ? element : Constant.of(element) + ); + return new ArrayConcat(arrayExpr, exprValues); +} + +/** + * @beta + * + * Creates an expression that checks if an array expression contains a specific element. + * + * ```typescript + * // Check if the 'colors' array contains the value of field 'selectedColor' + * arrayContains(Field.of("colors"), Field.of("selectedColor")); + * ``` + * + * @param array The array expression to check. + * @param element The element to search for in the array. + * @return A new {@code Expr} representing the 'array_contains' comparison. + */ +export function arrayContains(array: Expr, element: Expr): ArrayContains; + +/** + * @beta + * + * Creates an expression that checks if an array expression contains a specific element. + * + * ```typescript + * // Check if the 'colors' array contains "red" + * arrayContains(Field.of("colors"), "red"); + * ``` + * + * @param array The array expression to check. + * @param element The element to search for in the array. + * @return A new {@code Expr} representing the 'array_contains' comparison. + */ +export function arrayContains(array: Expr, element: any): ArrayContains; + +/** + * @beta + * + * Creates an expression that checks if a field's array value contains a specific element. + * + * ```typescript + * // Check if the 'colors' array contains the value of field 'selectedColor' + * arrayContains("colors", Field.of("selectedColor")); + * ``` + * + * @param array The field name to check. + * @param element The element to search for in the array. + * @return A new {@code Expr} representing the 'array_contains' comparison. + */ +export function arrayContains(array: string, element: Expr): ArrayContains; + +/** + * @beta + * + * Creates an expression that checks if a field's array value contains a specific value. + * + * ```typescript + * // Check if the 'colors' array contains "red" + * arrayContains("colors", "red"); + * ``` + * + * @param array The field name to check. + * @param element The element to search for in the array. + * @return A new {@code Expr} representing the 'array_contains' comparison. + */ +export function arrayContains(array: string, element: any): ArrayContains; +export function arrayContains( + array: Expr | string, + element: any +): ArrayContains { + const arrayExpr = array instanceof Expr ? array : Field.of(array); + const elementExpr = element instanceof Expr ? element : Constant.of(element); + return new ArrayContains(arrayExpr, elementExpr); +} + +/** + * @beta + * + * Creates an expression that checks if an array expression contains any of the specified + * elements. + * + * ```typescript + * // Check if the 'categories' array contains either values from field "cate1" or "Science" + * arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); + * ``` + * + * @param array The array expression to check. + * @param values The elements to check for in the array. + * @return A new {@code Expr} representing the 'array_contains_any' comparison. + */ +export function arrayContainsAny(array: Expr, values: Expr[]): ArrayContainsAny; + +/** + * @beta + * + * Creates an expression that checks if an array expression contains any of the specified + * elements. + * + * ```typescript + * // Check if the 'categories' array contains either values from field "cate1" or "Science" + * arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); + * ``` + * + * @param array The array expression to check. + * @param values The elements to check for in the array. + * @return A new {@code Expr} representing the 'array_contains_any' comparison. + */ +export function arrayContainsAny(array: Expr, values: any[]): ArrayContainsAny; + +/** + * @beta + * + * Creates an expression that checks if a field's array value contains any of the specified + * elements. + * + * ```typescript + * // Check if the 'groups' array contains either the value from the 'userGroup' field + * // or the value "guest" + * arrayContainsAny("categories", [Field.of("cate1"), "Science"]); + * ``` + * + * @param array The field name to check. + * @param values The elements to check for in the array. + * @return A new {@code Expr} representing the 'array_contains_any' comparison. + */ +export function arrayContainsAny( + array: string, + values: Expr[] +): ArrayContainsAny; + +/** + * @beta + * + * Creates an expression that checks if a field's array value contains any of the specified + * elements. + * + * ```typescript + * // Check if the 'groups' array contains either the value from the 'userGroup' field + * // or the value "guest" + * arrayContainsAny("categories", [Field.of("cate1"), "Science"]); + * ``` + * + * @param array The field name to check. + * @param values The elements to check for in the array. + * @return A new {@code Expr} representing the 'array_contains_any' comparison. + */ +export function arrayContainsAny( + array: string, + values: any[] +): ArrayContainsAny; +export function arrayContainsAny( + array: Expr | string, + values: any[] +): ArrayContainsAny { + const arrayExpr = array instanceof Expr ? array : Field.of(array); + const exprValues = values.map(value => + value instanceof Expr ? value : Constant.of(value) + ); + return new ArrayContainsAny(arrayExpr, exprValues); +} + +/** + * @beta + * + * Creates an expression that checks if an array expression contains all the specified elements. + * + * ```typescript + * // Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" + * arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); + * ``` + * + * @param array The array expression to check. + * @param values The elements to check for in the array. + * @return A new {@code Expr} representing the 'array_contains_all' comparison. + */ +export function arrayContainsAll(array: Expr, values: Expr[]): ArrayContainsAll; + +/** + * @beta + * + * Creates an expression that checks if an array expression contains all the specified elements. + * + * ```typescript + * // Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" + * arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); + * ``` + * + * @param array The array expression to check. + * @param values The elements to check for in the array. + * @return A new {@code Expr} representing the 'array_contains_all' comparison. + */ +export function arrayContainsAll(array: Expr, values: any[]): ArrayContainsAll; + +/** + * @beta + * + * Creates an expression that checks if a field's array value contains all the specified values or + * expressions. + * + * ```typescript + * // Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" + * arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); + * ``` + * + * @param array The field name to check. + * @param values The elements to check for in the array. + * @return A new {@code Expr} representing the 'array_contains_all' comparison. + */ +export function arrayContainsAll( + array: string, + values: Expr[] +): ArrayContainsAll; + +/** + * @beta + * + * Creates an expression that checks if a field's array value contains all the specified values or + * expressions. + * + * ```typescript + * // Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" + * arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); + * ``` + * + * @param array The field name to check. + * @param values The elements to check for in the array. + * @return A new {@code Expr} representing the 'array_contains_all' comparison. + */ +export function arrayContainsAll( + array: string, + values: any[] +): ArrayContainsAll; +export function arrayContainsAll( + array: Expr | string, + values: any[] +): ArrayContainsAll { + const arrayExpr = array instanceof Expr ? array : Field.of(array); + const exprValues = values.map(value => + value instanceof Expr ? value : Constant.of(value) + ); + return new ArrayContainsAll(arrayExpr, exprValues); +} + +/** + * @beta + * + * Creates an expression that calculates the length of an array expression. + * + * ```typescript + * // Get the number of items in the 'cart' array + * arrayLength(Field.of("cart")); + * ``` + * + * @param array The array expression to calculate the length of. + * @return A new {@code Expr} representing the length of the array. + */ +export function arrayLength(array: Expr): ArrayLength { + return new ArrayLength(array); +} + +/** + * @beta + * + * Creates an expression that checks if an expression is equal to any of the provided values or + * expressions. + * + * ```typescript + * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' + * inAny(Field.of("category"), [Constant.of("Electronics"), Field.of("primaryType")]); + * ``` + * + * @param element The expression to compare. + * @param others The values to check against. + * @return A new {@code Expr} representing the 'IN' comparison. + */ +export function inAny(element: Expr, others: Expr[]): In; + +/** + * @beta + * + * Creates an expression that checks if an expression is equal to any of the provided values or + * expressions. + * + * ```typescript + * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' + * inAny(Field.of("category"), ["Electronics", Field.of("primaryType")]); + * ``` + * + * @param element The expression to compare. + * @param others The values to check against. + * @return A new {@code Expr} representing the 'IN' comparison. + */ +export function inAny(element: Expr, others: any[]): In; + +/** + * @beta + * + * Creates an expression that checks if a field's value is equal to any of the provided values or + * expressions. + * + * ```typescript + * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' + * inAny("category", [Constant.of("Electronics"), Field.of("primaryType")]); + * ``` + * + * @param element The field to compare. + * @param others The values to check against. + * @return A new {@code Expr} representing the 'IN' comparison. + */ +export function inAny(element: string, others: Expr[]): In; + +/** + * @beta + * + * Creates an expression that checks if a field's value is equal to any of the provided values or + * expressions. + * + * ```typescript + * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' + * inAny("category", ["Electronics", Field.of("primaryType")]); + * ``` + * + * @param element The field to compare. + * @param others The values to check against. + * @return A new {@code Expr} representing the 'IN' comparison. + */ +export function inAny(element: string, others: any[]): In; +export function inAny(element: Expr | string, others: any[]): In { + const elementExpr = element instanceof Expr ? element : Field.of(element); + const exprOthers = others.map(other => + other instanceof Expr ? other : Constant.of(other) + ); + return new In(elementExpr, exprOthers); +} + +/** + * @beta + * + * Creates an expression that checks if an expression is not equal to any of the provided values + * or expressions. + * + * ```typescript + * // Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' + * notInAny(Field.of("status"), [Constant.of("pending"), Field.of("rejectedStatus")]); + * ``` + * + * @param element The expression to compare. + * @param others The values to check against. + * @return A new {@code Expr} representing the 'NOT IN' comparison. + */ +export function notInAny(element: Expr, others: Expr[]): Not; + +/** + * @beta + * + * Creates an expression that checks if an expression is not equal to any of the provided values + * or expressions. + * + * ```typescript + * // Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' + * notInAny(Field.of("status"), ["pending", Field.of("rejectedStatus")]); + * ``` + * + * @param element The expression to compare. + * @param others The values to check against. + * @return A new {@code Expr} representing the 'NOT IN' comparison. + */ +export function notInAny(element: Expr, others: any[]): Not; + +/** + * @beta + * + * Creates an expression that checks if a field's value is not equal to any of the provided values + * or expressions. + * + * ```typescript + * // Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' + * notInAny("status", [Constant.of("pending"), Field.of("rejectedStatus")]); + * ``` + * + * @param element The field name to compare. + * @param others The values to check against. + * @return A new {@code Expr} representing the 'NOT IN' comparison. + */ +export function notInAny(element: string, others: Expr[]): Not; + +/** + * @beta + * + * Creates an expression that checks if a field's value is not equal to any of the provided values + * or expressions. + * + * ```typescript + * // Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' + * notInAny("status", ["pending", Field.of("rejectedStatus")]); + * ``` + * + * @param element The field name to compare. + * @param others The values to check against. + * @return A new {@code Expr} representing the 'NOT IN' comparison. + */ +export function notInAny(element: string, others: any[]): Not; +export function notInAny(element: Expr | string, others: any[]): Not { + const elementExpr = element instanceof Expr ? element : Field.of(element); + const exprOthers = others.map(other => + other instanceof Expr ? other : Constant.of(other) + ); + return new Not(new In(elementExpr, exprOthers)); +} + +/** + * @beta + * + * Creates an expression that performs a logical 'AND' operation on multiple filter conditions. + * + * ```typescript + * // Check if the 'age' field is greater than 18 AND the 'city' field is "London" AND + * // the 'status' field is "active" + * const condition = and(gt("age", 18), eq("city", "London"), eq("status", "active")); + * ``` + * + * @param left The first filter condition. + * @param right Additional filter conditions to 'AND' together. + * @return A new {@code Expr} representing the logical 'AND' operation. + */ +export function and(left: FilterExpr, ...right: FilterExpr[]): And { + return new And([left, ...right]); +} + +/** + * @beta + * + * Creates an expression that performs a logical 'OR' operation on multiple filter conditions. + * + * ```typescript + * // Check if the 'age' field is greater than 18 OR the 'city' field is "London" OR + * // the 'status' field is "active" + * const condition = or(gt("age", 18), eq("city", "London"), eq("status", "active")); + * ``` + * + * @param left The first filter condition. + * @param right Additional filter conditions to 'OR' together. + * @return A new {@code Expr} representing the logical 'OR' operation. + */ +export function or(left: FilterExpr, ...right: FilterExpr[]): Or { + return new Or([left, ...right]); +} + +/** + * @beta + * + * Creates an expression that performs a logical 'XOR' (exclusive OR) operation on multiple filter + * conditions. + * + * ```typescript + * // Check if only one of the conditions is true: 'age' greater than 18, 'city' is "London", + * // or 'status' is "active". + * const condition = xor( + * gt("age", 18), + * eq("city", "London"), + * eq("status", "active")); + * ``` + * + * @param left The first filter condition. + * @param right Additional filter conditions to 'XOR' together. + * @return A new {@code Expr} representing the logical 'XOR' operation. + */ +export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor { + return new Xor([left, ...right]); +} + +/** + * @beta + * + * Creates a conditional expression that evaluates to a 'then' expression if a condition is true + * and an 'else' expression if the condition is false. + * + * ```typescript + * // If 'age' is greater than 18, return "Adult"; otherwise, return "Minor". + * ifFunction( + * gt("age", 18), Constant.of("Adult"), Constant.of("Minor")); + * ``` + * + * @param condition The condition to evaluate. + * @param thenExpr The expression to evaluate if the condition is true. + * @param elseExpr The expression to evaluate if the condition is false. + * @return A new {@code Expr} representing the conditional expression. + */ +export function ifFunction( + condition: FilterExpr, + thenExpr: Expr, + elseExpr: Expr +): If { + return new If(condition, thenExpr, elseExpr); +} + +/** + * @beta + * + * Creates an expression that negates a filter condition. + * + * ```typescript + * // Find documents where the 'completed' field is NOT true + * not(eq("completed", true)); + * ``` + * + * @param filter The filter condition to negate. + * @return A new {@code Expr} representing the negated filter condition. + */ +export function not(filter: FilterExpr): Not { + return new Not(filter); +} + +/** + * @beta + * + * Creates an expression that returns the larger value between two expressions, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the larger value between the 'field1' field and the 'field2' field. + * logicalMax(Field.of("field1"), Field.of("field2")); + * ``` + * + * @param left The left operand expression. + * @param right The right operand expression. + * @return A new {@code Expr} representing the logical max operation. + */ +export function logicalMax(left: Expr, right: Expr): LogicalMax; + +/** + * @beta + * + * Creates an expression that returns the larger value between an expression and a constant value, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the larger value between the 'value' field and 10. + * logicalMax(Field.of("value"), 10); + * ``` + * + * @param left The left operand expression. + * @param right The right operand constant. + * @return A new {@code Expr} representing the logical max operation. + */ +export function logicalMax(left: Expr, right: any): LogicalMax; + +/** + * @beta + * + * Creates an expression that returns the larger value between a field and an expression, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the larger value between the 'field1' field and the 'field2' field. + * logicalMax("field1", Field.of('field2')); + * ``` + * + * @param left The left operand field name. + * @param right The right operand expression. + * @return A new {@code Expr} representing the logical max operation. + */ +export function logicalMax(left: string, right: Expr): LogicalMax; + +/** + * @beta + * + * Creates an expression that returns the larger value between a field and a constant value, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the larger value between the 'value' field and 10. + * logicalMax("value", 10); + * ``` + * + * @param left The left operand field name. + * @param right The right operand constant. + * @return A new {@code Expr} representing the logical max operation. + */ +export function logicalMax(left: string, right: any): LogicalMax; +export function logicalMax(left: Expr | string, right: Expr | any): LogicalMax { + const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; + const normalizedRight = right instanceof Expr ? right : Constant.of(right); + return new LogicalMax(normalizedLeft, normalizedRight); +} + +/** + * @beta + * + * Creates an expression that returns the smaller value between two expressions, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the smaller value between the 'field1' field and the 'field2' field. + * logicalMin(Field.of("field1"), Field.of("field2")); + * ``` + * + * @param left The left operand expression. + * @param right The right operand expression. + * @return A new {@code Expr} representing the logical min operation. + */ +export function logicalMin(left: Expr, right: Expr): LogicalMin; + +/** + * @beta + * + * Creates an expression that returns the smaller value between an expression and a constant value, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the smaller value between the 'value' field and 10. + * logicalMin(Field.of("value"), 10); + * ``` + * + * @param left The left operand expression. + * @param right The right operand constant. + * @return A new {@code Expr} representing the logical min operation. + */ +export function logicalMin(left: Expr, right: any): LogicalMin; + +/** + * @beta + * + * Creates an expression that returns the smaller value between a field and an expression, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the smaller value between the 'field1' field and the 'field2' field. + * logicalMin("field1", Field.of("field2")); + * ``` + * + * @param left The left operand field name. + * @param right The right operand expression. + * @return A new {@code Expr} representing the logical min operation. + */ +export function logicalMin(left: string, right: Expr): LogicalMin; + +/** + * @beta + * + * Creates an expression that returns the smaller value between a field and a constant value, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the smaller value between the 'value' field and 10. + * logicalMin("value", 10); + * ``` + * + * @param left The left operand field name. + * @param right The right operand constant. + * @return A new {@code Expr} representing the logical min operation. + */ +export function logicalMin(left: string, right: any): LogicalMin; +export function logicalMin(left: Expr | string, right: Expr | any): LogicalMin { + const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; + const normalizedRight = right instanceof Expr ? right : Constant.of(right); + return new LogicalMin(normalizedLeft, normalizedRight); +} + +/** + * @beta + * + * Creates an expression that checks if a field exists. + * + * ```typescript + * // Check if the document has a field named "phoneNumber" + * exists(Field.of("phoneNumber")); + * ``` + * + * @param value An expression evaluates to the name of the field to check. + * @return A new {@code Expr} representing the 'exists' check. + */ +export function exists(value: Expr): Exists; + +/** + * @beta + * + * Creates an expression that checks if a field exists. + * + * ```typescript + * // Check if the document has a field named "phoneNumber" + * exists("phoneNumber"); + * ``` + * + * @param field The field name to check. + * @return A new {@code Expr} representing the 'exists' check. + */ +export function exists(field: string): Exists; +export function exists(valueOrField: Expr | string): Exists { + const valueExpr = + valueOrField instanceof Expr ? valueOrField : Field.of(valueOrField); + return new Exists(valueExpr); +} + +/** + * @beta + * + * Creates an expression that checks if an expression evaluates to 'NaN' (Not a Number). + * + * ```typescript + * // Check if the result of a calculation is NaN + * isNaN(Field.of("value").divide(0)); + * ``` + * + * @param value The expression to check. + * @return A new {@code Expr} representing the 'isNaN' check. + */ +export function isNan(value: Expr): IsNan; + +/** + * @beta + * + * Creates an expression that checks if a field's value evaluates to 'NaN' (Not a Number). + * + * ```typescript + * // Check if the result of a calculation is NaN + * isNaN("value"); + * ``` + * + * @param value The name of the field to check. + * @return A new {@code Expr} representing the 'isNaN' check. + */ +export function isNan(value: string): IsNan; +export function isNan(value: Expr | string): IsNan { + const valueExpr = value instanceof Expr ? value : Field.of(value); + return new IsNan(valueExpr); +} + +/** + * @beta + * + * Creates an expression that reverses a string. + * + * ```typescript + * // Reverse the value of the 'myString' field. + * reverse(Field.of("myString")); + * ``` + * + * @param expr The expression representing the string to reverse. + * @return A new {@code Expr} representing the reversed string. + */ +export function reverse(expr: Expr): Reverse; + +/** + * @beta + * + * Creates an expression that reverses a string represented by a field. + * + * ```typescript + * // Reverse the value of the 'myString' field. + * reverse("myString"); + * ``` + * + * @param field The name of the field representing the string to reverse. + * @return A new {@code Expr} representing the reversed string. + */ +export function reverse(field: string): Reverse; +export function reverse(expr: Expr | string): Reverse { + const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; + return new Reverse(normalizedExpr); +} + +/** + * @beta + * + * Creates an expression that replaces the first occurrence of a substring within a string with another substring. + * + * ```typescript + * // Replace the first occurrence of "hello" with "hi" in the 'message' field. + * replaceFirst(Field.of("message"), "hello", "hi"); + * ``` + * + * @param value The expression representing the string to perform the replacement on. + * @param find The substring to search for. + * @param replace The substring to replace the first occurrence of 'find' with. + * @return A new {@code Expr} representing the string with the first occurrence replaced. + */ +export function replaceFirst( + value: Expr, + find: string, + replace: string +): ReplaceFirst; + +/** + * @beta + * + * Creates an expression that replaces the first occurrence of a substring within a string with another substring, + * where the substring to find and the replacement substring are specified by expressions. + * + * ```typescript + * // Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field. + * replaceFirst(Field.of("message"), Field.of("findField"), Field.of("replaceField")); + * ``` + * + * @param value The expression representing the string to perform the replacement on. + * @param find The expression representing the substring to search for. + * @param replace The expression representing the substring to replace the first occurrence of 'find' with. + * @return A new {@code Expr} representing the string with the first occurrence replaced. + */ +export function replaceFirst( + value: Expr, + find: Expr, + replace: Expr +): ReplaceFirst; + +/** + * @beta + * + * Creates an expression that replaces the first occurrence of a substring within a string represented by a field with another substring. + * + * ```typescript + * // Replace the first occurrence of "hello" with "hi" in the 'message' field. + * replaceFirst("message", "hello", "hi"); + * ``` + * + * @param field The name of the field representing the string to perform the replacement on. + * @param find The substring to search for. + * @param replace The substring to replace the first occurrence of 'find' with. + * @return A new {@code Expr} representing the string with the first occurrence replaced. + */ +export function replaceFirst( + field: string, + find: string, + replace: string +): ReplaceFirst; +export function replaceFirst( + value: Expr | string, + find: Expr | string, + replace: Expr | string +): ReplaceFirst { + const normalizedValue = typeof value === 'string' ? Field.of(value) : value; + const normalizedFind = typeof find === 'string' ? Constant.of(find) : find; + const normalizedReplace = + typeof replace === 'string' ? Constant.of(replace) : replace; + return new ReplaceFirst(normalizedValue, normalizedFind, normalizedReplace); +} + +/** + * @beta + * + * Creates an expression that replaces all occurrences of a substring within a string with another substring. + * + * ```typescript + * // Replace all occurrences of "hello" with "hi" in the 'message' field. + * replaceAll(Field.of("message"), "hello", "hi"); + * ``` + * + * @param value The expression representing the string to perform the replacement on. + * @param find The substring to search for. + * @param replace The substring to replace all occurrences of 'find' with. + * @return A new {@code Expr} representing the string with all occurrences replaced. + */ +export function replaceAll( + value: Expr, + find: string, + replace: string +): ReplaceAll; + +/** + * @beta + * + * Creates an expression that replaces all occurrences of a substring within a string with another substring, + * where the substring to find and the replacement substring are specified by expressions. + * + * ```typescript + * // Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field. + * replaceAll(Field.of("message"), Field.of("findField"), Field.of("replaceField")); + * ``` + * + * @param value The expression representing the string to perform the replacement on. + * @param find The expression representing the substring to search for. + * @param replace The expression representing the substring to replace all occurrences of 'find' with. + * @return A new {@code Expr} representing the string with all occurrences replaced. + */ +export function replaceAll(value: Expr, find: Expr, replace: Expr): ReplaceAll; + +/** + * @beta + * + * Creates an expression that replaces all occurrences of a substring within a string represented by a field with another substring. + * + * ```typescript + * // Replace all occurrences of "hello" with "hi" in the 'message' field. + * replaceAll("message", "hello", "hi"); + * ``` + * + * @param field The name of the field representing the string to perform the replacement on. + * @param find The substring to search for. + * @param replace The substring to replace all occurrences of 'find' with. + * @return A new {@code Expr} representing the string with all occurrences replaced. + */ +export function replaceAll( + field: string, + find: string, + replace: string +): ReplaceAll; +export function replaceAll( + value: Expr | string, + find: Expr | string, + replace: Expr | string +): ReplaceAll { + const normalizedValue = typeof value === 'string' ? Field.of(value) : value; + const normalizedFind = typeof find === 'string' ? Constant.of(find) : find; + const normalizedReplace = + typeof replace === 'string' ? Constant.of(replace) : replace; + return new ReplaceAll(normalizedValue, normalizedFind, normalizedReplace); +} + +/** + * @beta + * + * Creates an expression that calculates the byte length of a string in UTF-8, or just the length of a Blob. + * + * ```typescript + * // Calculate the length of the 'myString' field in bytes. + * byteLength(Field.of("myString")); + * ``` + * + * @param expr The expression representing the string. + * @return A new {@code Expr} representing the length of the string in bytes. + */ +export function byteLength(expr: Expr): ByteLength; + +/** + * @beta + * + * Creates an expression that calculates the length of a string represented by a field in UTF-8 bytes, or just the length of a Blob. + * + * ```typescript + * // Calculate the length of the 'myString' field in bytes. + * byteLength("myString"); + * ``` + * + * @param field The name of the field representing the string. + * @return A new {@code Expr} representing the length of the string in bytes. + */ +export function byteLength(field: string): ByteLength; +export function byteLength(expr: Expr | string): ByteLength { + const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; + return new ByteLength(normalizedExpr); +} + +/** + * @beta + * + * Creates an expression that calculates the character length of a string field in UTF8. + * + * ```typescript + * // Get the character length of the 'name' field in UTF-8. + * strLength("name"); + * ``` + * + * @param field The name of the field containing the string. + * @return A new {@code Expr} representing the length of the string. + */ +export function charLength(field: string): CharLength; + +/** + * @beta + * + * Creates an expression that calculates the character length of a string expression in UTF-8. + * + * ```typescript + * // Get the character length of the 'name' field in UTF-8. + * strLength(Field.of("name")); + * ``` + * + * @param expr The expression representing the string to calculate the length of. + * @return A new {@code Expr} representing the length of the string. + */ +export function charLength(expr: Expr): CharLength; +export function charLength(value: Expr | string): CharLength { + const valueExpr = value instanceof Expr ? value : Field.of(value); + return new CharLength(valueExpr); +} + +/** + * @beta + * + * Creates an expression that performs a case-sensitive wildcard string comparison against a + * field. + * + * ```typescript + * // Check if the 'title' field contains the string "guide" + * like("title", "%guide%"); + * ``` + * + * @param left The name of the field containing the string. + * @param pattern The pattern to search for. You can use "%" as a wildcard character. + * @return A new {@code Expr} representing the 'like' comparison. + */ +export function like(left: string, pattern: string): Like; + +/** + * @beta + * + * Creates an expression that performs a case-sensitive wildcard string comparison against a + * field. + * + * ```typescript + * // Check if the 'title' field contains the string "guide" + * like("title", Field.of("pattern")); + * ``` + * + * @param left The name of the field containing the string. + * @param pattern The pattern to search for. You can use "%" as a wildcard character. + * @return A new {@code Expr} representing the 'like' comparison. + */ +export function like(left: string, pattern: Expr): Like; + +/** + * @beta + * + * Creates an expression that performs a case-sensitive wildcard string comparison. + * + * ```typescript + * // Check if the 'title' field contains the string "guide" + * like(Field.of("title"), "%guide%"); + * ``` + * + * @param left The expression representing the string to perform the comparison on. + * @param pattern The pattern to search for. You can use "%" as a wildcard character. + * @return A new {@code Expr} representing the 'like' comparison. + */ +export function like(left: Expr, pattern: string): Like; + +/** + * @beta + * + * Creates an expression that performs a case-sensitive wildcard string comparison. + * + * ```typescript + * // Check if the 'title' field contains the string "guide" + * like(Field.of("title"), Field.of("pattern")); + * ``` + * + * @param left The expression representing the string to perform the comparison on. + * @param pattern The pattern to search for. You can use "%" as a wildcard character. + * @return A new {@code Expr} representing the 'like' comparison. + */ +export function like(left: Expr, pattern: Expr): Like; +export function like(left: Expr | string, pattern: Expr | string): Like { + const leftExpr = left instanceof Expr ? left : Field.of(left); + const patternExpr = pattern instanceof Expr ? pattern : Constant.of(pattern); + return new Like(leftExpr, patternExpr); +} + +/** + * @beta + * + * Creates an expression that checks if a string field contains a specified regular expression as + * a substring. + * + * ```typescript + * // Check if the 'description' field contains "example" (case-insensitive) + * regexContains("description", "(?i)example"); + * ``` + * + * @param left The name of the field containing the string. + * @param pattern The regular expression to use for the search. + * @return A new {@code Expr} representing the 'contains' comparison. + */ +export function regexContains(left: string, pattern: string): RegexContains; + +/** + * @beta + * + * Creates an expression that checks if a string field contains a specified regular expression as + * a substring. + * + * ```typescript + * // Check if the 'description' field contains "example" (case-insensitive) + * regexContains("description", Field.of("pattern")); + * ``` + * + * @param left The name of the field containing the string. + * @param pattern The regular expression to use for the search. + * @return A new {@code Expr} representing the 'contains' comparison. + */ +export function regexContains(left: string, pattern: Expr): RegexContains; + +/** + * @beta + * + * Creates an expression that checks if a string expression contains a specified regular + * expression as a substring. + * + * ```typescript + * // Check if the 'description' field contains "example" (case-insensitive) + * regexContains(Field.of("description"), "(?i)example"); + * ``` + * + * @param left The expression representing the string to perform the comparison on. + * @param pattern The regular expression to use for the search. + * @return A new {@code Expr} representing the 'contains' comparison. + */ +export function regexContains(left: Expr, pattern: string): RegexContains; + +/** + * @beta + * + * Creates an expression that checks if a string expression contains a specified regular + * expression as a substring. + * + * ```typescript + * // Check if the 'description' field contains "example" (case-insensitive) + * regexContains(Field.of("description"), Field.of("pattern")); + * ``` + * + * @param left The expression representing the string to perform the comparison on. + * @param pattern The regular expression to use for the search. + * @return A new {@code Expr} representing the 'contains' comparison. + */ +export function regexContains(left: Expr, pattern: Expr): RegexContains; +export function regexContains( + left: Expr | string, + pattern: Expr | string +): RegexContains { + const leftExpr = left instanceof Expr ? left : Field.of(left); + const patternExpr = pattern instanceof Expr ? pattern : Constant.of(pattern); + return new RegexContains(leftExpr, patternExpr); +} + +/** + * @beta + * + * Creates an expression that checks if a string field matches a specified regular expression. + * + * ```typescript + * // Check if the 'email' field matches a valid email pattern + * regexMatch("email", "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + * ``` + * + * @param left The name of the field containing the string. + * @param pattern The regular expression to use for the match. + * @return A new {@code Expr} representing the regular expression match. + */ +export function regexMatch(left: string, pattern: string): RegexMatch; + +/** + * @beta + * + * Creates an expression that checks if a string field matches a specified regular expression. + * + * ```typescript + * // Check if the 'email' field matches a valid email pattern + * regexMatch("email", Field.of("pattern")); + * ``` + * + * @param left The name of the field containing the string. + * @param pattern The regular expression to use for the match. + * @return A new {@code Expr} representing the regular expression match. + */ +export function regexMatch(left: string, pattern: Expr): RegexMatch; + +/** + * @beta + * + * Creates an expression that checks if a string expression matches a specified regular + * expression. + * + * ```typescript + * // Check if the 'email' field matches a valid email pattern + * regexMatch(Field.of("email"), "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + * ``` + * + * @param left The expression representing the string to match against. + * @param pattern The regular expression to use for the match. + * @return A new {@code Expr} representing the regular expression match. + */ +export function regexMatch(left: Expr, pattern: string): RegexMatch; + +/** + * @beta + * + * Creates an expression that checks if a string expression matches a specified regular + * expression. + * + * ```typescript + * // Check if the 'email' field matches a valid email pattern + * regexMatch(Field.of("email"), Field.of("pattern")); + * ``` + * + * @param left The expression representing the string to match against. + * @param pattern The regular expression to use for the match. + * @return A new {@code Expr} representing the regular expression match. + */ +export function regexMatch(left: Expr, pattern: Expr): RegexMatch; +export function regexMatch( + left: Expr | string, + pattern: Expr | string +): RegexMatch { + const leftExpr = left instanceof Expr ? left : Field.of(left); + const patternExpr = pattern instanceof Expr ? pattern : Constant.of(pattern); + return new RegexMatch(leftExpr, patternExpr); +} + +/** + * @beta + * + * Creates an expression that checks if a string field contains a specified substring. + * + * ```typescript + * // Check if the 'description' field contains "example". + * strContains("description", "example"); + * ``` + * + * @param left The name of the field containing the string. + * @param substring The substring to search for. + * @return A new {@code Expr} representing the 'contains' comparison. + */ +export function strContains(left: string, substring: string): StrContains; + +/** + * @beta + * + * Creates an expression that checks if a string field contains a substring specified by an expression. + * + * ```typescript + * // Check if the 'description' field contains the value of the 'keyword' field. + * strContains("description", Field.of("keyword")); + * ``` + * + * @param left The name of the field containing the string. + * @param substring The expression representing the substring to search for. + * @return A new {@code Expr} representing the 'contains' comparison. + */ +export function strContains(left: string, substring: Expr): StrContains; + +/** + * @beta + * + * Creates an expression that checks if a string expression contains a specified substring. + * + * ```typescript + * // Check if the 'description' field contains "example". + * strContains(Field.of("description"), "example"); + * ``` + * + * @param left The expression representing the string to perform the comparison on. + * @param substring The substring to search for. + * @return A new {@code Expr} representing the 'contains' comparison. + */ +export function strContains(left: Expr, substring: string): StrContains; + +/** + * @beta + * + * Creates an expression that checks if a string expression contains a substring specified by another expression. + * + * ```typescript + * // Check if the 'description' field contains the value of the 'keyword' field. + * strContains(Field.of("description"), Field.of("keyword")); + * ``` + * + * @param left The expression representing the string to perform the comparison on. + * @param substring The expression representing the substring to search for. + * @return A new {@code Expr} representing the 'contains' comparison. + */ +export function strContains(left: Expr, substring: Expr): StrContains; +export function strContains( + left: Expr | string, + substring: Expr | string +): StrContains { + const leftExpr = left instanceof Expr ? left : Field.of(left); + const substringExpr = + substring instanceof Expr ? substring : Constant.of(substring); + return new StrContains(leftExpr, substringExpr); +} + +/** + * @beta + * + * Creates an expression that checks if a field's value starts with a given prefix. + * + * ```typescript + * // Check if the 'name' field starts with "Mr." + * startsWith("name", "Mr."); + * ``` + * + * @param expr The field name to check. + * @param prefix The prefix to check for. + * @return A new {@code Expr} representing the 'starts with' comparison. + */ +export function startsWith(expr: string, prefix: string): StartsWith; + +/** + * @beta + * + * Creates an expression that checks if a field's value starts with a given prefix. + * + * ```typescript + * // Check if the 'fullName' field starts with the value of the 'firstName' field + * startsWith("fullName", Field.of("firstName")); + * ``` + * + * @param expr The field name to check. + * @param prefix The expression representing the prefix. + * @return A new {@code Expr} representing the 'starts with' comparison. + */ +export function startsWith(expr: string, prefix: Expr): StartsWith; + +/** + * @beta + * + * Creates an expression that checks if a string expression starts with a given prefix. + * + * ```typescript + * // Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." + * startsWith(Field.of("fullName"), "Mr."); + * ``` + * + * @param expr The expression to check. + * @param prefix The prefix to check for. + * @return A new {@code Expr} representing the 'starts with' comparison. + */ +export function startsWith(expr: Expr, prefix: string): StartsWith; + +/** + * @beta + * + * Creates an expression that checks if a string expression starts with a given prefix. + * + * ```typescript + * // Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." + * startsWith(Field.of("fullName"), Field.of("prefix")); + * ``` + * + * @param expr The expression to check. + * @param prefix The prefix to check for. + * @return A new {@code Expr} representing the 'starts with' comparison. + */ +export function startsWith(expr: Expr, prefix: Expr): StartsWith; +export function startsWith( + expr: Expr | string, + prefix: Expr | string +): StartsWith { + const exprLeft = expr instanceof Expr ? expr : Field.of(expr); + const prefixExpr = prefix instanceof Expr ? prefix : Constant.of(prefix); + return new StartsWith(exprLeft, prefixExpr); +} + +/** + * @beta + * + * Creates an expression that checks if a field's value ends with a given postfix. + * + * ```typescript + * // Check if the 'filename' field ends with ".txt" + * endsWith("filename", ".txt"); + * ``` + * + * @param expr The field name to check. + * @param suffix The postfix to check for. + * @return A new {@code Expr} representing the 'ends with' comparison. + */ +export function endsWith(expr: string, suffix: string): EndsWith; + +/** + * @beta + * + * Creates an expression that checks if a field's value ends with a given postfix. + * + * ```typescript + * // Check if the 'url' field ends with the value of the 'extension' field + * endsWith("url", Field.of("extension")); + * ``` + * + * @param expr The field name to check. + * @param suffix The expression representing the postfix. + * @return A new {@code Expr} representing the 'ends with' comparison. + */ +export function endsWith(expr: string, suffix: Expr): EndsWith; + +/** + * @beta + * + * Creates an expression that checks if a string expression ends with a given postfix. + * + * ```typescript + * // Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." + * endsWith(Field.of("fullName"), "Jr."); + * ``` + * + * @param expr The expression to check. + * @param suffix The postfix to check for. + * @return A new {@code Expr} representing the 'ends with' comparison. + */ +export function endsWith(expr: Expr, suffix: string): EndsWith; + +/** + * @beta + * + * Creates an expression that checks if a string expression ends with a given postfix. + * + * ```typescript + * // Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." + * endsWith(Field.of("fullName"), Constant.of("Jr.")); + * ``` + * + * @param expr The expression to check. + * @param suffix The postfix to check for. + * @return A new {@code Expr} representing the 'ends with' comparison. + */ +export function endsWith(expr: Expr, suffix: Expr): EndsWith; +export function endsWith(expr: Expr | string, suffix: Expr | string): EndsWith { + const exprLeft = expr instanceof Expr ? expr : Field.of(expr); + const suffixExpr = suffix instanceof Expr ? suffix : Constant.of(suffix); + return new EndsWith(exprLeft, suffixExpr); +} + +/** + * @beta + * + * Creates an expression that converts a string field to lowercase. + * + * ```typescript + * // Convert the 'name' field to lowercase + * toLower("name"); + * ``` + * + * @param expr The name of the field containing the string. + * @return A new {@code Expr} representing the lowercase string. + */ +export function toLower(expr: string): ToLower; + +/** + * @beta + * + * Creates an expression that converts a string expression to lowercase. + * + * ```typescript + * // Convert the 'name' field to lowercase + * toLower(Field.of("name")); + * ``` + * + * @param expr The expression representing the string to convert to lowercase. + * @return A new {@code Expr} representing the lowercase string. + */ +export function toLower(expr: Expr): ToLower; +export function toLower(expr: Expr | string): ToLower { + return new ToLower(expr instanceof Expr ? expr : Field.of(expr)); +} + +/** + * @beta + * + * Creates an expression that converts a string field to uppercase. + * + * ```typescript + * // Convert the 'title' field to uppercase + * toUpper("title"); + * ``` + * + * @param expr The name of the field containing the string. + * @return A new {@code Expr} representing the uppercase string. + */ +export function toUpper(expr: string): ToUpper; + +/** + * @beta + * + * Creates an expression that converts a string expression to uppercase. + * + * ```typescript + * // Convert the 'title' field to uppercase + * toUppercase(Field.of("title")); + * ``` + * + * @param expr The expression representing the string to convert to uppercase. + * @return A new {@code Expr} representing the uppercase string. + */ +export function toUpper(expr: Expr): ToUpper; +export function toUpper(expr: Expr | string): ToUpper { + return new ToUpper(expr instanceof Expr ? expr : Field.of(expr)); +} + +/** + * @beta + * + * Creates an expression that removes leading and trailing whitespace from a string field. + * + * ```typescript + * // Trim whitespace from the 'userInput' field + * trim("userInput"); + * ``` + * + * @param expr The name of the field containing the string. + * @return A new {@code Expr} representing the trimmed string. + */ +export function trim(expr: string): Trim; + +/** + * @beta + * + * Creates an expression that removes leading and trailing whitespace from a string expression. + * + * ```typescript + * // Trim whitespace from the 'userInput' field + * trim(Field.of("userInput")); + * ``` + * + * @param expr The expression representing the string to trim. + * @return A new {@code Expr} representing the trimmed string. + */ +export function trim(expr: Expr): Trim; +export function trim(expr: Expr | string): Trim { + return new Trim(expr instanceof Expr ? expr : Field.of(expr)); +} + +/** + * @beta + * + * Creates an expression that concatenates string functions, fields or constants together. + * + * ```typescript + * // Combine the 'firstName', " ", and 'lastName' fields into a single string + * strConcat("firstName", " ", Field.of("lastName")); + * ``` + * + * @param first The field name containing the initial string value. + * @param elements The expressions (typically strings) to concatenate. + * @return A new {@code Expr} representing the concatenated string. + */ +export function strConcat( + first: string, + ...elements: Array +): StrConcat; + +/** + * @beta + * Creates an expression that concatenates string expressions together. + * + * ```typescript + * // Combine the 'firstName', " ", and 'lastName' fields into a single string + * strConcat(Field.of("firstName"), " ", Field.of("lastName")); + * ``` + * + * @param first The initial string expression to concatenate to. + * @param elements The expressions (typically strings) to concatenate. + * @return A new {@code Expr} representing the concatenated string. + */ +export function strConcat( + first: Expr, + ...elements: Array +): StrConcat; +export function strConcat( + first: string | Expr, + ...elements: Array +): StrConcat { + const exprs = elements.map(e => (e instanceof Expr ? e : Constant.of(e))); + return new StrConcat(first instanceof Expr ? first : Field.of(first), exprs); +} + +/** + * @beta + * + * Accesses a value from a map (object) field using the provided key. + * + * ```typescript + * // Get the 'city' value from the 'address' map field + * mapGet("address", "city"); + * ``` + * + * @param mapField The field name of the map field. + * @param subField The key to access in the map. + * @return A new {@code Expr} representing the value associated with the given key in the map. + */ +export function mapGet(mapField: string, subField: string): MapGet; + +/** + * @beta + * + * Accesses a value from a map (object) expression using the provided key. + * + * ```typescript + * // Get the 'city' value from the 'address' map field + * mapGet(Field.of("address"), "city"); + * ``` + * + * @param mapExpr The expression representing the map. + * @param subField The key to access in the map. + * @return A new {@code Expr} representing the value associated with the given key in the map. + */ +export function mapGet(mapExpr: Expr, subField: string): MapGet; +export function mapGet(fieldOrExpr: string | Expr, subField: string): MapGet { + return new MapGet( + typeof fieldOrExpr === 'string' ? Field.of(fieldOrExpr) : fieldOrExpr, + subField + ); +} + +/** + * @beta + * + * Creates an aggregation that counts the total number of stage inputs. + * + * ```typescript + * // Count the total number of users + * countAll().as("totalUsers"); + * ``` + * + * @return A new {@code Accumulator} representing the 'countAll' aggregation. + */ +export function countAll(): Count { + return new Count(undefined, false); +} + +/** + * @beta + * + * Creates an aggregation that counts the number of stage inputs with valid evaluations of the + * provided expression. + * + * ```typescript + * // Count the number of items where the price is greater than 10 + * count(Field.of("price").gt(10)).as("expensiveItemCount"); + * ``` + * + * @param value The expression to count. + * @return A new {@code Accumulator} representing the 'count' aggregation. + */ +export function count(value: Expr): Count; + +/** + * Creates an aggregation that counts the number of stage inputs with valid evaluations of the + * provided field. + * + * ```typescript + * // Count the total number of products + * count("productId").as("totalProducts"); + * ``` + * + * @param value The name of the field to count. + * @return A new {@code Accumulator} representing the 'count' aggregation. + */ +export function count(value: string): Count; +export function count(value: Expr | string): Count { + const exprValue = value instanceof Expr ? value : Field.of(value); + return new Count(exprValue, false); +} + +/** + * @beta + * + * Creates an aggregation that calculates the sum of values from an expression across multiple + * stage inputs. + * + * ```typescript + * // Calculate the total revenue from a set of orders + * sum(Field.of("orderAmount")).as("totalRevenue"); + * ``` + * + * @param value The expression to sum up. + * @return A new {@code Accumulator} representing the 'sum' aggregation. + */ +export function sum(value: Expr): Sum; + +/** + * @beta + * + * Creates an aggregation that calculates the sum of a field's values across multiple stage + * inputs. + * + * ```typescript + * // Calculate the total revenue from a set of orders + * sum("orderAmount").as("totalRevenue"); + * ``` + * + * @param value The name of the field containing numeric values to sum up. + * @return A new {@code Accumulator} representing the 'sum' aggregation. + */ +export function sum(value: string): Sum; +export function sum(value: Expr | string): Sum { + const exprValue = value instanceof Expr ? value : Field.of(value); + return new Sum(exprValue, false); +} + +/** + * @beta + * + * Creates an aggregation that calculates the average (mean) of values from an expression across + * multiple stage inputs. + * + * ```typescript + * // Calculate the average age of users + * avg(Field.of("age")).as("averageAge"); + * ``` + * + * @param value The expression representing the values to average. + * @return A new {@code Accumulator} representing the 'avg' aggregation. + */ +export function avg(value: Expr): Avg; + +/** + * @beta + * + * Creates an aggregation that calculates the average (mean) of a field's values across multiple + * stage inputs. + * + * ```typescript + * // Calculate the average age of users + * avg("age").as("averageAge"); + * ``` + * + * @param value The name of the field containing numeric values to average. + * @return A new {@code Accumulator} representing the 'avg' aggregation. + */ +export function avg(value: string): Avg; +export function avg(value: Expr | string): Avg { + const exprValue = value instanceof Expr ? value : Field.of(value); + return new Avg(exprValue, false); +} + +/** + * @beta + * + * Creates an aggregation that finds the minimum value of an expression across multiple stage + * inputs. + * + * ```typescript + * // Find the lowest price of all products + * min(Field.of("price")).as("lowestPrice"); + * ``` + * + * @param value The expression to find the minimum value of. + * @return A new {@code Accumulator} representing the 'min' aggregation. + */ +export function min(value: Expr): Min; + +/** + * @beta + * + * Creates an aggregation that finds the minimum value of a field across multiple stage inputs. + * + * ```typescript + * // Find the lowest price of all products + * min("price").as("lowestPrice"); + * ``` + * + * @param value The name of the field to find the minimum value of. + * @return A new {@code Accumulator} representing the 'min' aggregation. + */ +export function min(value: string): Min; +export function min(value: Expr | string): Min { + const exprValue = value instanceof Expr ? value : Field.of(value); + return new Min(exprValue, false); +} + +/** + * @beta + * + * Creates an aggregation that finds the maximum value of an expression across multiple stage + * inputs. + * + * ```typescript + * // Find the highest score in a leaderboard + * max(Field.of("score")).as("highestScore"); + * ``` + * + * @param value The expression to find the maximum value of. + * @return A new {@code Accumulator} representing the 'max' aggregation. + */ +export function max(value: Expr): Max; + +/** + * @beta + * + * Creates an aggregation that finds the maximum value of a field across multiple stage inputs. + * + * ```typescript + * // Find the highest score in a leaderboard + * max("score").as("highestScore"); + * ``` + * + * @param value The name of the field to find the maximum value of. + * @return A new {@code Accumulator} representing the 'max' aggregation. + */ +export function max(value: string): Max; +export function max(value: Expr | string): Max { + const exprValue = value instanceof Expr ? value : Field.of(value); + return new Max(exprValue, false); +} + +/** + * @beta + * + * Calculates the Cosine distance between a field's vector value and a double array. + * + * ```typescript + * // Calculate the Cosine distance between the 'location' field and a target location + * cosineDistance("location", [37.7749, -122.4194]); + * ``` + * + * @param expr The name of the field containing the first vector. + * @param other The other vector (as an array of doubles) to compare against. + * @return A new {@code Expr} representing the Cosine distance between the two vectors. + */ +export function cosineDistance(expr: string, other: number[]): CosineDistance; + +/** + * @beta + * + * Calculates the Cosine distance between a field's vector value and a VectorValue. + * + * ```typescript + * // Calculate the Cosine distance between the 'location' field and a target location + * cosineDistance("location", new VectorValue([37.7749, -122.4194])); + * ``` + * + * @param expr The name of the field containing the first vector. + * @param other The other vector (as a VectorValue) to compare against. + * @return A new {@code Expr} representing the Cosine distance between the two vectors. + */ +export function cosineDistance( + expr: string, + other: VectorValue +): CosineDistance; + +/** + * @beta + * + * Calculates the Cosine distance between a field's vector value and a vector expression. + * + * ```typescript + * // Calculate the cosine distance between the 'userVector' field and the 'itemVector' field + * cosineDistance("userVector", Field.of("itemVector")); + * ``` + * + * @param expr The name of the field containing the first vector. + * @param other The other vector (represented as an Expr) to compare against. + * @return A new {@code Expr} representing the cosine distance between the two vectors. + */ +export function cosineDistance(expr: string, other: Expr): CosineDistance; + +/** + * @beta + * + * Calculates the Cosine distance between a vector expression and a double array. + * + * ```typescript + * // Calculate the cosine distance between the 'location' field and a target location + * cosineDistance(Field.of("location"), [37.7749, -122.4194]); + * ``` + * + * @param expr The first vector (represented as an Expr) to compare against. + * @param other The other vector (as an array of doubles) to compare against. + * @return A new {@code Expr} representing the cosine distance between the two vectors. + */ +export function cosineDistance(expr: Expr, other: number[]): CosineDistance; + +/** + * @beta + * + * Calculates the Cosine distance between a vector expression and a VectorValue. + * + * ```typescript + * // Calculate the cosine distance between the 'location' field and a target location + * cosineDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); + * ``` + * + * @param expr The first vector (represented as an Expr) to compare against. + * @param other The other vector (as a VectorValue) to compare against. + * @return A new {@code Expr} representing the cosine distance between the two vectors. + */ +export function cosineDistance(expr: Expr, other: VectorValue): CosineDistance; + +/** + * @beta + * + * Calculates the Cosine distance between two vector expressions. + * + * ```typescript + * // Calculate the cosine distance between the 'userVector' field and the 'itemVector' field + * cosineDistance(Field.of("userVector"), Field.of("itemVector")); + * ``` + * + * @param expr The first vector (represented as an Expr) to compare against. + * @param other The other vector (represented as an Expr) to compare against. + * @return A new {@code Expr} representing the cosine distance between the two vectors. + */ +export function cosineDistance(expr: Expr, other: Expr): CosineDistance; +export function cosineDistance( + expr: Expr | string, + other: Expr | number[] | VectorValue +): CosineDistance { + const expr1 = expr instanceof Expr ? expr : Field.of(expr); + const expr2 = other instanceof Expr ? other : Constant.vector(other); + return new CosineDistance(expr1, expr2); +} + +/** + * @beta + * + * Calculates the dot product between a field's vector value and a double array. + * + * ```typescript + * // Calculate the dot product distance between a feature vector and a target vector + * dotProduct("features", [0.5, 0.8, 0.2]); + * ``` + * + * @param expr The name of the field containing the first vector. + * @param other The other vector (as an array of doubles) to calculate with. + * @return A new {@code Expr} representing the dot product between the two vectors. + */ +export function dotProduct(expr: string, other: number[]): DotProduct; + +/** + * @beta + * + * Calculates the dot product between a field's vector value and a VectorValue. + * + * ```typescript + * // Calculate the dot product distance between a feature vector and a target vector + * dotProduct("features", new VectorValue([0.5, 0.8, 0.2])); + * ``` + * + * @param expr The name of the field containing the first vector. + * @param other The other vector (as a VectorValue) to calculate with. + * @return A new {@code Expr} representing the dot product between the two vectors. + */ +export function dotProduct(expr: string, other: VectorValue): DotProduct; + +/** + * @beta + * + * Calculates the dot product between a field's vector value and a vector expression. + * + * ```typescript + * // Calculate the dot product distance between two document vectors: 'docVector1' and 'docVector2' + * dotProduct("docVector1", Field.of("docVector2")); + * ``` + * + * @param expr The name of the field containing the first vector. + * @param other The other vector (represented as an Expr) to calculate with. + * @return A new {@code Expr} representing the dot product between the two vectors. + */ +export function dotProduct(expr: string, other: Expr): DotProduct; + +/** + * @beta + * + * Calculates the dot product between a vector expression and a double array. + * + * ```typescript + * // Calculate the dot product between a feature vector and a target vector + * dotProduct(Field.of("features"), [0.5, 0.8, 0.2]); + * ``` + * + * @param expr The first vector (represented as an Expr) to calculate with. + * @param other The other vector (as an array of doubles) to calculate with. + * @return A new {@code Expr} representing the dot product between the two vectors. + */ +export function dotProduct(expr: Expr, other: number[]): DotProduct; + +/** + * @beta + * + * Calculates the dot product between a vector expression and a VectorValue. + * + * ```typescript + * // Calculate the dot product between a feature vector and a target vector + * dotProduct(Field.of("features"), new VectorValue([0.5, 0.8, 0.2])); + * ``` + * + * @param expr The first vector (represented as an Expr) to calculate with. + * @param other The other vector (as a VectorValue) to calculate with. + * @return A new {@code Expr} representing the dot product between the two vectors. + */ +export function dotProduct(expr: Expr, other: VectorValue): DotProduct; + +/** + * @beta + * + * Calculates the dot product between two vector expressions. + * + * ```typescript + * // Calculate the dot product between two document vectors: 'docVector1' and 'docVector2' + * dotProduct(Field.of("docVector1"), Field.of("docVector2")); + * ``` + * + * @param expr The first vector (represented as an Expr) to calculate with. + * @param other The other vector (represented as an Expr) to calculate with. + * @return A new {@code Expr} representing the dot product between the two vectors. + */ +export function dotProduct(expr: Expr, other: Expr): DotProduct; +export function dotProduct( + expr: Expr | string, + other: Expr | number[] | VectorValue +): DotProduct { + const expr1 = expr instanceof Expr ? expr : Field.of(expr); + const expr2 = other instanceof Expr ? other : Constant.vector(other); + return new DotProduct(expr1, expr2); +} + +/** + * @beta + * + * Calculates the Euclidean distance between a field's vector value and a double array. + * + * ```typescript + * // Calculate the Euclidean distance between the 'location' field and a target location + * euclideanDistance("location", [37.7749, -122.4194]); + * ``` + * + * @param expr The name of the field containing the first vector. + * @param other The other vector (as an array of doubles) to compare against. + * @return A new {@code Expr} representing the Euclidean distance between the two vectors. + */ +export function euclideanDistance( + expr: string, + other: number[] +): EuclideanDistance; + +/** + * @beta + * + * Calculates the Euclidean distance between a field's vector value and a VectorValue. + * + * ```typescript + * // Calculate the Euclidean distance between the 'location' field and a target location + * euclideanDistance("location", new VectorValue([37.7749, -122.4194])); + * ``` + * + * @param expr The name of the field containing the first vector. + * @param other The other vector (as a VectorValue) to compare against. + * @return A new {@code Expr} representing the Euclidean distance between the two vectors. + */ +export function euclideanDistance( + expr: string, + other: VectorValue +): EuclideanDistance; + +/** + * @beta + * + * Calculates the Euclidean distance between a field's vector value and a vector expression. + * + * ```typescript + * // Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' + * euclideanDistance("pointA", Field.of("pointB")); + * ``` + * + * @param expr The name of the field containing the first vector. + * @param other The other vector (represented as an Expr) to compare against. + * @return A new {@code Expr} representing the Euclidean distance between the two vectors. + */ +export function euclideanDistance(expr: string, other: Expr): EuclideanDistance; + +/** + * @beta + * + * Calculates the Euclidean distance between a vector expression and a double array. + * + * ```typescript + * // Calculate the Euclidean distance between the 'location' field and a target location + * + * euclideanDistance(Field.of("location"), [37.7749, -122.4194]); + * ``` + * + * @param expr The first vector (represented as an Expr) to compare against. + * @param other The other vector (as an array of doubles) to compare against. + * @return A new {@code Expr} representing the Euclidean distance between the two vectors. + */ +export function euclideanDistance( + expr: Expr, + other: number[] +): EuclideanDistance; + +/** + * @beta + * + * Calculates the Euclidean distance between a vector expression and a VectorValue. + * + * ```typescript + * // Calculate the Euclidean distance between the 'location' field and a target location + * euclideanDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); + * ``` + * + * @param expr The first vector (represented as an Expr) to compare against. + * @param other The other vector (as a VectorValue) to compare against. + * @return A new {@code Expr} representing the Euclidean distance between the two vectors. + */ +export function euclideanDistance( + expr: Expr, + other: VectorValue +): EuclideanDistance; + +/** + * @beta + * + * Calculates the Euclidean distance between two vector expressions. + * + * ```typescript + * // Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' + * euclideanDistance(Field.of("pointA"), Field.of("pointB")); + * ``` + * + * @param expr The first vector (represented as an Expr) to compare against. + * @param other The other vector (represented as an Expr) to compare against. + * @return A new {@code Expr} representing the Euclidean distance between the two vectors. + */ +export function euclideanDistance(expr: Expr, other: Expr): EuclideanDistance; +export function euclideanDistance( + expr: Expr | string, + other: Expr | number[] | VectorValue +): EuclideanDistance { + const expr1 = expr instanceof Expr ? expr : Field.of(expr); + const expr2 = other instanceof Expr ? other : Constant.vector(other); + return new EuclideanDistance(expr1, expr2); +} + +/** + * @beta + * + * Creates an expression that calculates the length of a Firestore Vector. + * + * ```typescript + * // Get the vector length (dimension) of the field 'embedding'. + * vectorLength(Field.of("embedding")); + * ``` + * + * @param expr The expression representing the Firestore Vector. + * @return A new {@code Expr} representing the length of the array. + */ +export function vectorLength(expr: Expr): VectorLength; + +/** + * @beta + * + * Creates an expression that calculates the length of a Firestore Vector represented by a field. + * + * ```typescript + * // Get the vector length (dimension) of the field 'embedding'. + * vectorLength("embedding"); + * ``` + * + * @param field The name of the field representing the Firestore Vector. + * @return A new {@code Expr} representing the length of the array. + */ +export function vectorLength(field: string): VectorLength; +export function vectorLength(expr: Expr | string): VectorLength { + const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; + return new VectorLength(normalizedExpr); +} + +/** + * @beta + * + * Creates an expression that interprets an expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) + * and returns a timestamp. + * + * ```typescript + * // Interpret the 'microseconds' field as microseconds since epoch. + * unixMicrosToTimestamp(Field.of("microseconds")); + * ``` + * + * @param expr The expression representing the number of microseconds since epoch. + * @return A new {@code Expr} representing the timestamp. + */ +export function unixMicrosToTimestamp(expr: Expr): UnixMicrosToTimestamp; + +/** + * @beta + * + * Creates an expression that interprets a field's value as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) + * and returns a timestamp. + * + * ```typescript + * // Interpret the 'microseconds' field as microseconds since epoch. + * unixMicrosToTimestamp("microseconds"); + * ``` + * + * @param field The name of the field representing the number of microseconds since epoch. + * @return A new {@code Expr} representing the timestamp. + */ +export function unixMicrosToTimestamp(field: string): UnixMicrosToTimestamp; +export function unixMicrosToTimestamp( + expr: Expr | string +): UnixMicrosToTimestamp { + const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; + return new UnixMicrosToTimestamp(normalizedExpr); +} + +/** + * @beta + * + * Creates an expression that converts a timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + * + * ```typescript + * // Convert the 'timestamp' field to microseconds since epoch. + * timestampToUnixMicros(Field.of("timestamp")); + * ``` + * + * @param expr The expression representing the timestamp. + * @return A new {@code Expr} representing the number of microseconds since epoch. + */ +export function timestampToUnixMicros(expr: Expr): TimestampToUnixMicros; + +/** + * @beta + * + * Creates an expression that converts a timestamp field to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + * + * ```typescript + * // Convert the 'timestamp' field to microseconds since epoch. + * timestampToUnixMicros("timestamp"); + * ``` + * + * @param field The name of the field representing the timestamp. + * @return A new {@code Expr} representing the number of microseconds since epoch. + */ +export function timestampToUnixMicros(field: string): TimestampToUnixMicros; +export function timestampToUnixMicros( + expr: Expr | string +): TimestampToUnixMicros { + const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; + return new TimestampToUnixMicros(normalizedExpr); +} + +/** + * @beta + * + * Creates an expression that interprets an expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) + * and returns a timestamp. + * + * ```typescript + * // Interpret the 'milliseconds' field as milliseconds since epoch. + * unixMillisToTimestamp(Field.of("milliseconds")); + * ``` + * + * @param expr The expression representing the number of milliseconds since epoch. + * @return A new {@code Expr} representing the timestamp. + */ +export function unixMillisToTimestamp(expr: Expr): UnixMillisToTimestamp; + +/** + * @beta + * + * Creates an expression that interprets a field's value as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) + * and returns a timestamp. + * + * ```typescript + * // Interpret the 'milliseconds' field as milliseconds since epoch. + * unixMillisToTimestamp("milliseconds"); + * ``` + * + * @param field The name of the field representing the number of milliseconds since epoch. + * @return A new {@code Expr} representing the timestamp. + */ +export function unixMillisToTimestamp(field: string): UnixMillisToTimestamp; +export function unixMillisToTimestamp( + expr: Expr | string +): UnixMillisToTimestamp { + const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; + return new UnixMillisToTimestamp(normalizedExpr); +} + +/** + * @beta + * + * Creates an expression that converts a timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + * + * ```typescript + * // Convert the 'timestamp' field to milliseconds since epoch. + * timestampToUnixMillis(Field.of("timestamp")); + * ``` + * + * @param expr The expression representing the timestamp. + * @return A new {@code Expr} representing the number of milliseconds since epoch. + */ +export function timestampToUnixMillis(expr: Expr): TimestampToUnixMillis; + +/** + * @beta + * + * Creates an expression that converts a timestamp field to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + * + * ```typescript + * // Convert the 'timestamp' field to milliseconds since epoch. + * timestampToUnixMillis("timestamp"); + * ``` + * + * @param field The name of the field representing the timestamp. + * @return A new {@code Expr} representing the number of milliseconds since epoch. + */ +export function timestampToUnixMillis(field: string): TimestampToUnixMillis; +export function timestampToUnixMillis( + expr: Expr | string +): TimestampToUnixMillis { + const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; + return new TimestampToUnixMillis(normalizedExpr); +} + +/** + * @beta + * + * Creates an expression that interprets an expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) + * and returns a timestamp. + * + * ```typescript + * // Interpret the 'seconds' field as seconds since epoch. + * unixSecondsToTimestamp(Field.of("seconds")); + * ``` + * + * @param expr The expression representing the number of seconds since epoch. + * @return A new {@code Expr} representing the timestamp. + */ +export function unixSecondsToTimestamp(expr: Expr): UnixSecondsToTimestamp; + +/** + * @beta + * + * Creates an expression that interprets a field's value as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) + * and returns a timestamp. + * + * ```typescript + * // Interpret the 'seconds' field as seconds since epoch. + * unixSecondsToTimestamp("seconds"); + * ``` + * + * @param field The name of the field representing the number of seconds since epoch. + * @return A new {@code Expr} representing the timestamp. + */ +export function unixSecondsToTimestamp(field: string): UnixSecondsToTimestamp; +export function unixSecondsToTimestamp( + expr: Expr | string +): UnixSecondsToTimestamp { + const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; + return new UnixSecondsToTimestamp(normalizedExpr); +} + +/** + * @beta + * + * Creates an expression that converts a timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). + * + * ```typescript + * // Convert the 'timestamp' field to seconds since epoch. + * timestampToUnixSeconds(Field.of("timestamp")); + * ``` + * + * @param expr The expression representing the timestamp. + * @return A new {@code Expr} representing the number of seconds since epoch. + */ +export function timestampToUnixSeconds(expr: Expr): TimestampToUnixSeconds; + +/** + * @beta + * + * Creates an expression that converts a timestamp field to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). + * + * ```typescript + * // Convert the 'timestamp' field to seconds since epoch. + * timestampToUnixSeconds("timestamp"); + * ``` + * + * @param field The name of the field representing the timestamp. + * @return A new {@code Expr} representing the number of seconds since epoch. + */ +export function timestampToUnixSeconds(field: string): TimestampToUnixSeconds; +export function timestampToUnixSeconds( + expr: Expr | string +): TimestampToUnixSeconds { + const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; + return new TimestampToUnixSeconds(normalizedExpr); +} + +/** + * @beta + * + * Creates an expression that adds a specified amount of time to a timestamp. + * + * ```typescript + * // Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. + * timestampAdd(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); + * ``` + * + * @param timestamp The expression representing the timestamp. + * @param unit The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. + * @param amount The expression evaluates to amount of the unit. + * @return A new {@code Expr} representing the resulting timestamp. + */ +export function timestampAdd( + timestamp: Expr, + unit: Expr, + amount: Expr +): TimestampAdd; + +/** + * @beta + * + * Creates an expression that adds a specified amount of time to a timestamp. + * + * ```typescript + * // Add 1 day to the 'timestamp' field. + * timestampAdd(Field.of("timestamp"), "day", 1); + * ``` + * + * @param timestamp The expression representing the timestamp. + * @param unit The unit of time to add (e.g., "day", "hour"). + * @param amount The amount of time to add. + * @return A new {@code Expr} representing the resulting timestamp. + */ +export function timestampAdd( + timestamp: Expr, + unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', + amount: number +): TimestampAdd; + +/** + * @beta + * + * Creates an expression that adds a specified amount of time to a timestamp represented by a field. + * + * ```typescript + * // Add 1 day to the 'timestamp' field. + * timestampAdd("timestamp", "day", 1); + * ``` + * + * @param field The name of the field representing the timestamp. + * @param unit The unit of time to add (e.g., "day", "hour"). + * @param amount The amount of time to add. + * @return A new {@code Expr} representing the resulting timestamp. + */ +export function timestampAdd( + field: string, + unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', + amount: number +): TimestampAdd; +export function timestampAdd( + timestamp: Expr | string, + unit: + | Expr + | 'microsecond' + | 'millisecond' + | 'second' + | 'minute' + | 'hour' + | 'day', + amount: Expr | number +): TimestampAdd { + const normalizedTimestamp = + typeof timestamp === 'string' ? Field.of(timestamp) : timestamp; + const normalizedUnit = unit instanceof Expr ? unit : Constant.of(unit); + const normalizedAmount = + typeof amount === 'number' ? Constant.of(amount) : amount; + return new TimestampAdd( + normalizedTimestamp, + normalizedUnit, + normalizedAmount + ); +} + +/** + * @beta + * + * Creates an expression that subtracts a specified amount of time from a timestamp. + * + * ```typescript + * // Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. + * timestampSub(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); + * ``` + * + * @param timestamp The expression representing the timestamp. + * @param unit The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. + * @param amount The expression evaluates to amount of the unit. + * @return A new {@code Expr} representing the resulting timestamp. + */ +export function timestampSub( + timestamp: Expr, + unit: Expr, + amount: Expr +): TimestampSub; + +/** + * @beta + * + * Creates an expression that subtracts a specified amount of time from a timestamp. + * + * ```typescript + * // Subtract 1 day from the 'timestamp' field. + * timestampSub(Field.of("timestamp"), "day", 1); + * ``` + * + * @param timestamp The expression representing the timestamp. + * @param unit The unit of time to subtract (e.g., "day", "hour"). + * @param amount The amount of time to subtract. + * @return A new {@code Expr} representing the resulting timestamp. + */ +export function timestampSub( + timestamp: Expr, + unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', + amount: number +): TimestampSub; + +/** + * @beta + * + * Creates an expression that subtracts a specified amount of time from a timestamp represented by a field. + * + * ```typescript + * // Subtract 1 day from the 'timestamp' field. + * timestampSub("timestamp", "day", 1); + * ``` + * + * @param field The name of the field representing the timestamp. + * @param unit The unit of time to subtract (e.g., "day", "hour"). + * @param amount The amount of time to subtract. + * @return A new {@code Expr} representing the resulting timestamp. + */ +export function timestampSub( + field: string, + unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', + amount: number +): TimestampSub; +export function timestampSub( + timestamp: Expr | string, + unit: + | Expr + | 'microsecond' + | 'millisecond' + | 'second' + | 'minute' + | 'hour' + | 'day', + amount: Expr | number +): TimestampSub { + const normalizedTimestamp = + typeof timestamp === 'string' ? Field.of(timestamp) : timestamp; + const normalizedUnit = unit instanceof Expr ? unit : Constant.of(unit); + const normalizedAmount = + typeof amount === 'number' ? Constant.of(amount) : amount; + return new TimestampSub( + normalizedTimestamp, + normalizedUnit, + normalizedAmount + ); +} + +/** + * @beta + * + * Creates functions that work on the backend but do not exist in the SDK yet. + * + * ```typescript + * // Call a user defined function named "myFunc" with the arguments 10 and 20 + * // This is the same of the 'sum(Field.of("price"))', if it did not exist + * genericFunction("sum", [Field.of("price")]); + * ``` + * + * @param name The name of the user defined function. + * @param params The arguments to pass to the function. + * @return A new {@code Function} representing the function call. + */ +export function genericFunction(name: string, params: Expr[]): FirestoreFunction { + return new FirestoreFunction(name, params); +} + +/** + * @beta + * + * Creates an {@link Ordering} that sorts documents in ascending order based on this expression. + * + * ```typescript + * // Sort documents by the 'name' field in ascending order + * firestore.pipeline().collection("users") + * .sort(ascending(Field.of("name"))); + * ``` + * + * @param expr The expression to create an ascending ordering for. + * @return A new `Ordering` for ascending sorting. + */ +export function ascending(expr: Expr): Ordering { + return new Ordering(expr, 'ascending'); +} + +/** + * @beta + * + * Creates an {@link Ordering} that sorts documents in descending order based on this expression. + * + * ```typescript + * // Sort documents by the 'createdAt' field in descending order + * firestore.pipeline().collection("users") + * .sort(descending(Field.of("createdAt"))); + * ``` + * + * @param expr The expression to create a descending ordering for. + * @return A new `Ordering` for descending sorting. + */ +export function descending(expr: Expr): Ordering { + return new Ordering(expr, 'descending'); +} + +/** + * @beta + * + * Represents an ordering criterion for sorting documents in a Firestore pipeline. + * + * You create `Ordering` instances using the `ascending` and `descending` helper functions. + */ +export class Ordering { + constructor( + private expr: Expr, + private direction: 'ascending' | 'descending' + ) {} + + /** + * @private + * @internal + */ + _toProto(serializer: JsonProtoSerializer): ProtoValue { + return { + mapValue: { + fields: { + direction: toStringValue(this.direction), + expression: this.expr._toProto(serializer) + } + } + }; + } + + /** + * @private + * @internal + */ + _readUserData(dataReader: UserDataReader): void { + this.expr._readUserData(dataReader); + } +} diff --git a/packages/firestore/src/pipelines/api/pipeline-result.ts b/packages/firestore/src/pipelines/api/pipeline-result.ts new file mode 100644 index 00000000000..243a79a82d3 --- /dev/null +++ b/packages/firestore/src/pipelines/api/pipeline-result.ts @@ -0,0 +1,232 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { FieldPath } from '../../lite-api/field_path'; +import { + DocumentData, + DocumentReference, + refEqual +} from '../../lite-api/reference'; +import { fieldPathFromArgument } from '../../lite-api/snapshot'; +import { Timestamp } from '../../lite-api/timestamp'; +import { AbstractUserDataWriter } from '../../lite-api/user_data_writer'; +import { ObjectValue } from '../../model/object_value'; +import { isOptionalEqual } from '../../util/misc'; + +/** + * @beta + * + * A PipelineResult contains data read from a Firestore Pipeline. The data can be extracted with the + * {@link #data()} or {@link #get(String)} methods. + * + *

If the PipelineResult represents a non-document result, `ref` will return a undefined + * value. + */ +export class PipelineResult { + private readonly _userDataWriter: AbstractUserDataWriter; + + private readonly _executionTime: Timestamp | undefined; + private readonly _createTime: Timestamp | undefined; + private readonly _updateTime: Timestamp | undefined; + + /** + * @internal + * @private + */ + readonly _ref: DocumentReference | undefined; + + /** + * @internal + * @private + */ + readonly _fields: ObjectValue | undefined; + + /** + * @private + * @internal + * + * @param userDataWriter The serializer used to encode/decode protobuf. + * @param ref The reference to the document. + * @param _fieldsProto The fields of the Firestore `Document` Protobuf backing + * this document (or undefined if the document does not exist). + * @param readTime The time when this result was read (or undefined if + * the document exists only locally). + * @param createTime The time when the document was created if the result is a document, undefined otherwise. + * @param updateTime The time when the document was last updated if the result is a document, undefined otherwise. + */ + constructor( + userDataWriter: AbstractUserDataWriter, + ref?: DocumentReference, + fields?: ObjectValue, + executionTime?: Timestamp, + createTime?: Timestamp, + updateTime?: Timestamp + // TODO converter + //readonly converter: FirestorePipelineConverter = defaultPipelineConverter() + ) { + this._ref = ref; + this._userDataWriter = userDataWriter; + this._executionTime = executionTime; + this._createTime = createTime; + this._updateTime = updateTime; + this._fields = fields; + } + + /** + * The reference of the document, if it is a document; otherwise `undefined`. + */ + get ref(): DocumentReference | undefined { + return this._ref; + } + + /** + * The ID of the document for which this PipelineResult contains data, if it is a document; otherwise `undefined`. + * + * @type {string} + * @readonly + * + */ + get id(): string | undefined { + return this._ref?.id; + } + + /** + * The time the document was created. Undefined if this result is not a document. + * + * @type {Timestamp|undefined} + * @readonly + */ + get createTime(): Timestamp | undefined { + return this._createTime; + } + + /** + * The time the document was last updated (at the time the snapshot was + * generated). Undefined if this result is not a document. + * + * @type {Timestamp|undefined} + * @readonly + */ + get updateTime(): Timestamp | undefined { + return this._updateTime; + } + + /** + * The time at which the pipeline producing this result is executed. + * + * @type {Timestamp} + * @readonly + * + */ + get executionTime(): Timestamp { + if (this._executionTime === undefined) { + throw new Error( + "'executionTime' is expected to exist, but it is undefined" + ); + } + return this._executionTime; + } + + /** + * Retrieves all fields in the result as an object. Returns 'undefined' if + * the document doesn't exist. + * + * @returns {T|undefined} An object containing all fields in the document or + * 'undefined' if the document doesn't exist. + * + * @example + * ``` + * let p = firestore.pipeline().collection('col'); + * + * p.execute().then(results => { + * let data = results[0].data(); + * console.log(`Retrieved data: ${JSON.stringify(data)}`); + * }); + * ``` + */ + data(): AppModelType | undefined { + if (this._fields === undefined) { + return undefined; + } + + // TODO(pipelines) + // We only want to use the converter and create a new QueryDocumentSnapshot + // if a converter has been provided. + // if (!!this.converter && this.converter !== defaultPipelineConverter()) { + // return this.converter.fromFirestore( + // new PipelineResult< DocumentData>( + // this._serializer, + // this.ref, + // this._fieldsProto, + // this._executionTime, + // this.createTime, + // this.updateTime, + // defaultPipelineConverter() + // ) + // ); + // } else {{ + return this._userDataWriter.convertValue( + this._fields.value + ) as AppModelType; + //} + } + + /** + * Retrieves the field specified by `field`. + * + * @param {string|FieldPath} field The field path + * (e.g. 'foo' or 'foo.bar') to a specific field. + * @returns {*} The data at the specified field location or undefined if no + * such field exists. + * + * @example + * ``` + * let p = firestore.pipeline().collection('col'); + * + * p.execute().then(results => { + * let field = results[0].get('a.b'); + * console.log(`Retrieved field value: ${field}`); + * }); + * ``` + */ + // We deliberately use `any` in the external API to not impose type-checking + // on end users. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + get(fieldPath: string | FieldPath): any { + if (this._fields === undefined) { + return undefined; + } + + const value = this._fields.field( + fieldPathFromArgument('DocumentSnapshot.get', fieldPath) + ); + if (value !== null) { + return this._userDataWriter.convertValue(value); + } + } +} + +export function pipelineResultEqual( + left: PipelineResult, + right: PipelineResult +): boolean { + if (left === right) { + return true; + } + + return ( + isOptionalEqual(left._ref, right._ref, refEqual) && + isOptionalEqual(left._fields, right._fields, (l, r) => l.isEqual(r)) + ); +} diff --git a/packages/firestore/src/pipelines/api/pipeline-source.ts b/packages/firestore/src/pipelines/api/pipeline-source.ts new file mode 100644 index 00000000000..76bbc2d41ff --- /dev/null +++ b/packages/firestore/src/pipelines/api/pipeline-source.ts @@ -0,0 +1,48 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { Pipeline } from './pipeline'; +import { + CollectionGroupSource, + CollectionSource, + DatabaseSource, + DocumentsSource +} from './stage'; + +import { Firestore } from '../../api/database'; +import { DocumentReference } from '../../lite-api/reference'; + +/** + * Represents the source of a Firestore {@link Pipeline}. + * @beta + */ +export class PipelineSource { + constructor(private db: Firestore) {} + + collection(collectionPath: string): Pipeline { + return new Pipeline(this.db, [new CollectionSource(collectionPath)]); + } + + collectionGroup(collectionId: string): Pipeline { + return new Pipeline(this.db, [new CollectionGroupSource(collectionId)]); + } + + database(): Pipeline { + return new Pipeline(this.db, [new DatabaseSource()]); + } + + documents(docs: DocumentReference[]): Pipeline { + return new Pipeline(this.db, [DocumentsSource.of(docs)]); + } +} diff --git a/packages/firestore/src/pipelines/api/pipeline-util.ts b/packages/firestore/src/pipelines/api/pipeline-util.ts new file mode 100644 index 00000000000..dacbe9ace7c --- /dev/null +++ b/packages/firestore/src/pipelines/api/pipeline-util.ts @@ -0,0 +1,248 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +import { + CompositeFilter as CompositeFilterInternal, + CompositeOperator, + FieldFilter as FieldFilterInternal, + Filter as FilterInternal, + Operator +} from '../../core/filter'; +import { isNanValue, isNullValue } from '../../model/values'; +import { + ArrayValue as ProtoArrayValue, + Function as ProtoFunction, + LatLng as ProtoLatLng, + MapValue as ProtoMapValue, + Pipeline as ProtoPipeline, + Timestamp as ProtoTimestamp, + Value as ProtoValue +} from '../../protos/firestore_proto_api'; +import { fail } from '../../util/assert'; +import { isPlainObject } from '../../util/input_validation'; + +import { + and, + Constant, + Expr, + Field, + FilterCondition, + not, + or +} from './expressions'; + +function isITimestamp(obj: any): obj is ProtoTimestamp { + if (typeof obj !== 'object' || obj === null) { + return false; // Must be a non-null object + } + if ( + 'seconds' in obj && + (obj.seconds === null || + typeof obj.seconds === 'number' || + typeof obj.seconds === 'string') && + 'nanos' in obj && + (obj.nanos === null || typeof obj.nanos === 'number') + ) { + return true; + } + + return false; +} +function isILatLng(obj: any): obj is ProtoLatLng { + if (typeof obj !== 'object' || obj === null) { + return false; // Must be a non-null object + } + if ( + 'latitude' in obj && + (obj.latitude === null || typeof obj.latitude === 'number') && + 'longitude' in obj && + (obj.longitude === null || typeof obj.longitude === 'number') + ) { + return true; + } + + return false; +} +function isIArrayValue(obj: any): obj is ProtoArrayValue { + if (typeof obj !== 'object' || obj === null) { + return false; // Must be a non-null object + } + if ('values' in obj && (obj.values === null || Array.isArray(obj.values))) { + return true; + } + + return false; +} +function isIMapValue(obj: any): obj is ProtoMapValue { + if (typeof obj !== 'object' || obj === null) { + return false; // Must be a non-null object + } + if ('fields' in obj && (obj.fields === null || isPlainObject(obj.fields))) { + return true; + } + + return false; +} +function isIFunction(obj: any): obj is ProtoFunction { + if (typeof obj !== 'object' || obj === null) { + return false; // Must be a non-null object + } + if ( + 'name' in obj && + (obj.name === null || typeof obj.name === 'string') && + 'args' in obj && + (obj.args === null || Array.isArray(obj.args)) + ) { + return true; + } + + return false; +} + +function isIPipeline(obj: any): obj is ProtoPipeline { + if (typeof obj !== 'object' || obj === null) { + return false; // Must be a non-null object + } + if ('stages' in obj && (obj.stages === null || Array.isArray(obj.stages))) { + return true; + } + + return false; +} + +export function isFirestoreValue(obj: any): obj is ProtoValue { + if (typeof obj !== 'object' || obj === null) { + return false; // Must be a non-null object + } + + // Check optional properties and their types + if ( + ('nullValue' in obj && + (obj.nullValue === null || obj.nullValue === 'NULL_VALUE')) || + ('booleanValue' in obj && + (obj.booleanValue === null || typeof obj.booleanValue === 'boolean')) || + ('integerValue' in obj && + (obj.integerValue === null || + typeof obj.integerValue === 'number' || + typeof obj.integerValue === 'string')) || + ('doubleValue' in obj && + (obj.doubleValue === null || typeof obj.doubleValue === 'number')) || + ('timestampValue' in obj && + (obj.timestampValue === null || isITimestamp(obj.timestampValue))) || + ('stringValue' in obj && + (obj.stringValue === null || typeof obj.stringValue === 'string')) || + ('bytesValue' in obj && + (obj.bytesValue === null || obj.bytesValue instanceof Uint8Array)) || + ('referenceValue' in obj && + (obj.referenceValue === null || + typeof obj.referenceValue === 'string')) || + ('geoPointValue' in obj && + (obj.geoPointValue === null || isILatLng(obj.geoPointValue))) || + ('arrayValue' in obj && + (obj.arrayValue === null || isIArrayValue(obj.arrayValue))) || + ('mapValue' in obj && + (obj.mapValue === null || isIMapValue(obj.mapValue))) || + ('fieldReferenceValue' in obj && + (obj.fieldReferenceValue === null || + typeof obj.fieldReferenceValue === 'string')) || + ('functionValue' in obj && + (obj.functionValue === null || isIFunction(obj.functionValue))) || + ('pipelineValue' in obj && + (obj.pipelineValue === null || isIPipeline(obj.pipelineValue))) + ) { + return true; + } + + return false; +} + +export function toPipelineFilterCondition( + f: FilterInternal +): FilterCondition & Expr { + if (f instanceof FieldFilterInternal) { + const field = Field.of(f.field.toString()); + if (isNanValue(f.value)) { + if (f.op === Operator.EQUAL) { + return and(field.exists(), field.isNaN()); + } else { + return and(field.exists(), not(field.isNaN())); + } + } else if (isNullValue(f.value)) { + if (f.op === Operator.EQUAL) { + return and(field.exists(), field.eq(null)); + } else { + return and(field.exists(), not(field.eq(null))); + } + } else { + // Comparison filters + const value = f.value; + switch (f.op) { + case Operator.LESS_THAN: + return and(field.exists(), field.lt(value)); + case Operator.LESS_THAN_OR_EQUAL: + return and(field.exists(), field.lte(value)); + case Operator.GREATER_THAN: + return and(field.exists(), field.gt(value)); + case Operator.GREATER_THAN_OR_EQUAL: + return and(field.exists(), field.gte(value)); + case Operator.EQUAL: + return and(field.exists(), field.eq(value)); + case Operator.NOT_EQUAL: + return and(field.exists(), field.neq(value)); + case Operator.ARRAY_CONTAINS: + return and(field.exists(), field.arrayContains(value)); + case Operator.IN: { + const values = value?.arrayValue?.values?.map((val: any) => + Constant.of(val) + ); + return and(field.exists(), field.in(...values!)); + } + case Operator.ARRAY_CONTAINS_ANY: { + const values = value?.arrayValue?.values?.map((val: any) => + Constant.of(val) + ); + return and(field.exists(), field.arrayContainsAny(values!)); + } + case Operator.NOT_IN: { + const values = value?.arrayValue?.values?.map((val: any) => + Constant.of(val) + ); + return and(field.exists(), not(field.in(...values!))); + } + default: + fail('Unexpected operator'); + } + } + } else if (f instanceof CompositeFilterInternal) { + switch (f.op) { + case CompositeOperator.AND: { + const conditions = f + .getFilters() + .map(f => toPipelineFilterCondition(f)); + return and(conditions[0], ...conditions.slice(1)); + } + case CompositeOperator.OR: { + const conditions = f + .getFilters() + .map(f => toPipelineFilterCondition(f)); + return or(conditions[0], ...conditions.slice(1)); + } + default: + fail('Unexpected operator'); + } + } + + throw new Error(`Failed to convert filter to pipeline conditions: ${f}`); +} diff --git a/packages/firestore/src/pipelines/api/pipeline.ts b/packages/firestore/src/pipelines/api/pipeline.ts new file mode 100644 index 00000000000..907fe8e030c --- /dev/null +++ b/packages/firestore/src/pipelines/api/pipeline.ts @@ -0,0 +1,735 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* eslint @typescript-eslint/no-explicit-any: 0 */ +import { ExpUserDataWriter } from '../../api/reference_impl'; +import { firestoreClientExecutePipeline } from '../../core/firestore_client'; +import {DocumentData, DocumentReference} from '../../lite-api/reference'; +import { + newUserDataReader, + parseVectorValue, + UserDataReader, + UserDataSource +} from '../../lite-api/user_data_reader'; +import { ObjectValue } from '../../model/object_value'; +import { + ExecutePipelineRequest, + firestoreV1ApiClientInterfaces, + Stage as ProtoStage +} from '../../protos/firestore_proto_api'; +import { + getEncodedDatabaseId, + JsonProtoSerializer +} from '../../remote/serializer'; + +import { + Accumulator, + AccumulatorTarget, + Expr, + ExprWithAlias, + Field, + Fields, + FilterCondition, + Ordering, + Selectable +} from './expressions'; +import { PipelineResult } from './pipeline-result'; +import { + AddFields, + Aggregate, + Distinct, + FindNearest, + FindNearestOptions, + GenericStage, + Limit, + Offset, + Select, + Sort, + Stage, + Where +} from './stage'; + +import StructuredPipeline = firestoreV1ApiClientInterfaces.StructuredPipeline; +import {ensureFirestoreConfigured, Firestore} from "../../api/database"; + +interface ReadableUserData { + _readUserData(dataReader: UserDataReader): void; +} + +function isReadableUserData(value: any): value is ReadableUserData { + return typeof (value as ReadableUserData)._readUserData === 'function'; +} + +/** + * @beta + * + * The Pipeline class provides a flexible and expressive framework for building complex data + * transformation and query pipelines for Firestore. + * + * A pipeline takes data sources, such as Firestore collections or collection groups, and applies + * a series of stages that are chained together. Each stage takes the output from the previous stage + * (or the data source) and produces an output for the next stage (or as the final output of the + * pipeline). + * + * Expressions can be used within each stage to filter and transform data through the stage. + * + * NOTE: The chained stages do not prescribe exactly how Firestore will execute the pipeline. + * Instead, Firestore only guarantees that the result is the same as if the chained stages were + * executed in order. + * + * Usage Examples: + * + * ```typescript + * const db: Firestore; // Assumes a valid firestore instance. + * + * // Example 1: Select specific fields and rename 'rating' to 'bookRating' + * const results1 = await db.pipeline() + * .collection("books") + * .select("title", "author", Field.of("rating").as("bookRating")) + * .execute(); + * + * // Example 2: Filter documents where 'genre' is "Science Fiction" and 'published' is after 1950 + * const results2 = await db.pipeline() + * .collection("books") + * .where(and(Field.of("genre").eq("Science Fiction"), Field.of("published").gt(1950))) + * .execute(); + * + * // Example 3: Calculate the average rating of books published after 1980 + * const results3 = await db.pipeline() + * .collection("books") + * .where(Field.of("published").gt(1980)) + * .aggregate(avg(Field.of("rating")).as("averageRating")) + * .execute(); + * ``` + */ +export class Pipeline { + constructor( + private db: Firestore, + private stages: Stage[], + // TODO(pipeline) support converter + //private converter: FirestorePipelineConverter = defaultPipelineConverter() + private converter: unknown = {} + ) {} + + /** + * Adds new fields to outputs from previous stages. + * + * This stage allows you to compute values on-the-fly based on existing data from previous + * stages or constants. You can use this to create new fields or overwrite existing ones (if there + * is name overlaps). + * + * The added fields are defined using {@link Selectable}s, which can be: + * + * - {@link Field}: References an existing document field. + * - {@link Function}: Performs a calculation using functions like `add`, `multiply` with + * assigned aliases using {@link Expr#as}. + * + * Example: + * + * ```typescript + * firestore.pipeline().collection("books") + * .addFields( + * Field.of("rating").as("bookRating"), // Rename 'rating' to 'bookRating' + * add(5, Field.of("quantity")).as("totalCost") // Calculate 'totalCost' + * ); + * ``` + * + * @param fields The fields to add to the documents, specified as {@link Selectable}s. + * @return A new Pipeline object with this stage appended to the stage list. + */ + addFields(...fields: Selectable[]): Pipeline { + const copy = this.stages.map(s => s); + copy.push( + new AddFields( + this.readUserData('addFields', this.selectablesToMap(fields)) + ) + ); + return new Pipeline(this.db, copy, this.converter); + } + + /** + * Selects or creates a set of fields from the outputs of previous stages. + * + *

The selected fields are defined using {@link Selectable} expressions, which can be: + * + *

    + *
  • {@code string}: Name of an existing field
  • + *
  • {@link Field}: References an existing field.
  • + *
  • {@link Function}: Represents the result of a function with an assigned alias name using + * {@link Expr#as}
  • + *
+ * + *

If no selections are provided, the output of this stage is empty. Use {@link + * com.google.cloud.firestore.Pipeline#addFields} instead if only additions are + * desired. + * + *

Example: + * + * ```typescript + * firestore.pipeline().collection("books") + * .select( + * "firstName", + * Field.of("lastName"), + * Field.of("address").toUppercase().as("upperAddress"), + * ); + * ``` + * + * @param selections The fields to include in the output documents, specified as {@link + * Selectable} expressions or {@code string} values representing field names. + * @return A new Pipeline object with this stage appended to the stage list. + */ + select(...selections: Array): Pipeline { + const copy = this.stages.map(s => s); + copy.push(new Select(this.selectablesToMap(selections))); + return new Pipeline(this.db, copy, this.converter); + } + + private selectablesToMap( + selectables: Array + ): Map { + const result = new Map(); + for (const selectable of selectables) { + if (typeof selectable === 'string') { + result.set(selectable as string, Field.of(selectable)); + } else if (selectable instanceof Field) { + result.set((selectable as Field).fieldName(), selectable); + } else if (selectable instanceof Fields) { + const fields = selectable as Fields; + for (const field of fields.fieldList()) { + result.set(field.fieldName(), field); + } + } else if (selectable instanceof ExprWithAlias) { + const expr = selectable as ExprWithAlias; + result.set(expr.alias, expr.expr); + } + } + return result; + } + + /** + * Reads user data for each expression in the expressionMap. + * @param name Name of the calling function. Used for error messages when invalid user data is encountered. + * @param expressionMap + * @return the expressionMap argument. + * @private + */ + private readUserData< + T extends + | Map + | ReadableUserData[] + | ReadableUserData + >(name: string, expressionMap: T): T { + const userDataReader = newUserDataReader(this.db); + if (isReadableUserData(expressionMap)) { + expressionMap._readUserData(userDataReader); + } else if (Array.isArray(expressionMap)) { + expressionMap.forEach(readableData => + readableData._readUserData(userDataReader) + ); + } else { + expressionMap.forEach(expr => expr._readUserData(userDataReader)); + } + return expressionMap; + } + + /** + * Filters the documents from previous stages to only include those matching the specified {@link + * FilterCondition}. + * + *

This stage allows you to apply conditions to the data, similar to a "WHERE" clause in SQL. + * You can filter documents based on their field values, using implementations of {@link + * FilterCondition}, typically including but not limited to: + * + *

    + *
  • field comparators: {@link Function#eq}, {@link Function#lt} (less than), {@link + * Function#gt} (greater than), etc.
  • + *
  • logical operators: {@link Function#and}, {@link Function#or}, {@link Function#not}, etc.
  • + *
  • advanced functions: {@link Function#regexMatch}, {@link + * Function#arrayContains}, etc.
  • + *
+ * + *

Example: + * + * ```typescript + * firestore.pipeline().collection("books") + * .where( + * and( + * gt(Field.of("rating"), 4.0), // Filter for ratings greater than 4.0 + * Field.of("genre").eq("Science Fiction") // Equivalent to gt("genre", "Science Fiction") + * ) + * ); + * ``` + * + * @param condition The {@link FilterCondition} to apply. + * @return A new Pipeline object with this stage appended to the stage list. + */ + where(condition: FilterCondition & Expr): Pipeline { + const copy = this.stages.map(s => s); + copy.push(new Where(this.readUserData('where', condition))); + return new Pipeline(this.db, copy, this.converter); + } + + /** + * Skips the first `offset` number of documents from the results of previous stages. + * + *

This stage is useful for implementing pagination in your pipelines, allowing you to retrieve + * results in chunks. It is typically used in conjunction with {@link #limit} to control the + * size of each page. + * + *

Example: + * + * ```typescript + * // Retrieve the second page of 20 results + * firestore.pipeline().collection("books") + * .sort(Field.of("published").descending()) + * .offset(20) // Skip the first 20 results + * .limit(20); // Take the next 20 results + * ``` + * + * @param offset The number of documents to skip. + * @return A new Pipeline object with this stage appended to the stage list. + */ + offset(offset: number): Pipeline { + const copy = this.stages.map(s => s); + copy.push(new Offset(offset)); + return new Pipeline(this.db, copy, this.converter); + } + + /** + * Limits the maximum number of documents returned by previous stages to `limit`. + * + *

This stage is particularly useful when you want to retrieve a controlled subset of data from + * a potentially large result set. It's often used for: + * + *

    + *
  • **Pagination:** In combination with {@link #offset} to retrieve specific pages of + * results.
  • + *
  • **Limiting Data Retrieval:** To prevent excessive data transfer and improve performance, + * especially when dealing with large collections.
  • + *
+ * + *

Example: + * + * ```typescript + * // Limit the results to the top 10 highest-rated books + * firestore.pipeline().collection("books") + * .sort(Field.of("rating").descending()) + * .limit(10); + * ``` + * + * @param limit The maximum number of documents to return. + * @return A new Pipeline object with this stage appended to the stage list. + */ + limit(limit: number): Pipeline { + const copy = this.stages.map(s => s); + copy.push(new Limit(limit)); + return new Pipeline(this.db, copy, this.converter); + } + + /** + * Returns a set of distinct {@link Expr} values from the inputs to this stage. + * + *

This stage run through the results from previous stages to include only results with unique + * combinations of {@link Expr} values ({@link Field}, {@link Function}, etc). + * + *

The parameters to this stage are defined using {@link Selectable} expressions or {@code string}s: + * + *

    + *
  • {@code string}: Name of an existing field
  • + *
  • {@link Field}: References an existing document field.
  • + *
  • {@link Function}: Represents the result of a function with an assigned alias name using + * {@link Expr#as}
  • + *
+ * + *

Example: + * + * ```typescript + * // Get a list of unique author names in uppercase and genre combinations. + * firestore.pipeline().collection("books") + * .distinct(toUppercase(Field.of("author")).as("authorName"), Field.of("genre"), "publishedAt") + * .select("authorName"); + * ``` + * + * @param selectables The {@link Selectable} expressions to consider when determining distinct + * value combinations or {@code string}s representing field names. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + distinct(...groups: Array): Pipeline { + const copy = this.stages.map(s => s); + copy.push( + new Distinct( + this.readUserData('distinct', this.selectablesToMap(groups || [])) + ) + ); + return new Pipeline(this.db, copy, this.converter); + } + + /** + * Performs aggregation operations on the documents from previous stages. + * + *

This stage allows you to calculate aggregate values over a set of documents. You define the + * aggregations to perform using {@link AccumulatorTarget} expressions which are typically results of + * calling {@link Expr#as} on {@link Accumulator} instances. + * + *

Example: + * + * ```typescript + * // Calculate the average rating and the total number of books + * firestore.pipeline().collection("books") + * .aggregate( + * Field.of("rating").avg().as("averageRating"), + * countAll().as("totalBooks") + * ); + * ``` + * + * @param accumulators The {@link AccumulatorTarget} expressions, each wrapping an {@link Accumulator} + * and provide a name for the accumulated results. + * @return A new Pipeline object with this stage appended to the stage list. + */ + aggregate(...accumulators: AccumulatorTarget[]): Pipeline; + /** + * Performs optionally grouped aggregation operations on the documents from previous stages. + * + *

This stage allows you to calculate aggregate values over a set of documents, optionally + * grouped by one or more fields or functions. You can specify: + * + *

    + *
  • **Grouping Fields or Functions:** One or more fields or functions to group the documents + * by. For each distinct combination of values in these fields, a separate group is created. + * If no grouping fields are provided, a single group containing all documents is used. Not + * specifying groups is the same as putting the entire inputs into one group.
  • + *
  • **Accumulators:** One or more accumulation operations to perform within each group. These + * are defined using {@link AccumulatorTarget} expressions, which are typically created by + * calling {@link Expr#as} on {@link Accumulator} instances. Each aggregation + * calculates a value (e.g., sum, average, count) based on the documents within its group.
  • + *
+ * + *

Example: + * + * ```typescript + * // Calculate the average rating for each genre. + * firestore.pipeline().collection("books") + * .aggregate({ + * accumulators: [avg(Field.of("rating")).as("avg_rating")] + * groups: ["genre"] + * }); + * ``` + * + * @param aggregate An {@link Aggregate} object that specifies the grouping fields (if any) and + * the aggregation operations to perform. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + aggregate(options: { + accumulators: AccumulatorTarget[]; + groups?: Array; + }): Pipeline; + aggregate( + optionsOrTarget: + | AccumulatorTarget + | { + accumulators: AccumulatorTarget[]; + groups?: Array; + }, + ...rest: AccumulatorTarget[] + ): Pipeline { + const copy = this.stages.map(s => s); + if ('accumulators' in optionsOrTarget) { + copy.push( + new Aggregate( + new Map( + optionsOrTarget.accumulators.map((target: AccumulatorTarget) => [ + (target as unknown as AccumulatorTarget).alias, + this.readUserData( + 'aggregate', + (target as unknown as AccumulatorTarget).expr + ) + ]) + ), + this.readUserData( + 'aggregate', + this.selectablesToMap(optionsOrTarget.groups || []) + ) + ) + ); + } else { + copy.push( + new Aggregate( + new Map( + [optionsOrTarget, ...rest].map(target => [ + (target as unknown as AccumulatorTarget).alias, + this.readUserData( + 'aggregate', + (target as unknown as AccumulatorTarget).expr + ) + ]) + ), + new Map() + ) + ); + } + return new Pipeline(this.db, copy, this.converter); + } + + findNearest(options: FindNearestOptions): Pipeline; + findNearest(options: FindNearestOptions): Pipeline { + const copy = this.stages.map(s => s); + const parseContext = newUserDataReader(this.db).createContext( + UserDataSource.Argument, + 'findNearest' + ); + const value = parseVectorValue(options.vectorValue, parseContext); + const vectorObjectValue = new ObjectValue(value); + copy.push( + new FindNearest( + options.field, + vectorObjectValue, + options.distanceMeasure, + options.limit, + options.distanceField + ) + ); + return new Pipeline(this.db, copy); + } + + /** + * Sorts the documents from previous stages based on one or more {@link Ordering} criteria. + * + *

This stage allows you to order the results of your pipeline. You can specify multiple {@link + * Ordering} instances to sort by multiple fields in ascending or descending order. If documents + * have the same value for a field used for sorting, the next specified ordering will be used. If + * all orderings result in equal comparison, the documents are considered equal and the order is + * unspecified. + * + *

Example: + * + * ```typescript + * // Sort books by rating in descending order, and then by title in ascending order for books + * // with the same rating + * firestore.pipeline().collection("books") + * .sort( + * Ordering.of(Field.of("rating")).descending(), + * Ordering.of(Field.of("title")) // Ascending order is the default + * ); + * ``` + * + * @param orders One or more {@link Ordering} instances specifying the sorting criteria. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + sort(...orderings: Ordering[]): Pipeline; + sort(options: { orderings: Ordering[] }): Pipeline; + sort( + optionsOrOrderings: + | Ordering + | { + orderings: Ordering[]; + }, + ...rest: Ordering[] + ): Pipeline { + const copy = this.stages.map(s => s); + // Option object + if ('orderings' in optionsOrOrderings) { + copy.push( + new Sort( + this.readUserData( + 'sort', + this.readUserData('sort', optionsOrOrderings.orderings) + ) + ) + ); + } else { + // Ordering object + copy.push( + new Sort(this.readUserData('sort', [optionsOrOrderings, ...rest])) + ); + } + + return new Pipeline(this.db, copy, this.converter); + } + + /** + * Adds a generic stage to the pipeline. + * + *

This method provides a flexible way to extend the pipeline's functionality by adding custom + * stages. Each generic stage is defined by a unique `name` and a set of `params` that control its + * behavior. + * + *

Example (Assuming there is no "where" stage available in SDK): + * + * ```typescript + * // Assume we don't have a built-in "where" stage + * firestore.pipeline().collection("books") + * .genericStage("where", [Field.of("published").lt(1900)]) // Custom "where" stage + * .select("title", "author"); + * ``` + * + * @param name The unique name of the generic stage to add. + * @param params A list of parameters to configure the generic stage's behavior. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + genericStage(name: string, params: any[]): Pipeline { + const copy = this.stages.map(s => s); + const dataReader = newUserDataReader(this.db); + params.forEach(param => { + if (isReadableUserData(param)) { + param._readUserData(dataReader); + } + }); + copy.push(new GenericStage(name, params)); + return new Pipeline(this.db, copy, this.converter); + } + + // TODO(pipeline) support converter + // withConverter(converter: null): Pipeline; + // withConverter( + // converter: FirestorePipelineConverter + // ): Pipeline; + // /** + // * Applies a custom data converter to this Query, allowing you to use your + // * own custom model objects with Firestore. When you call get() on the + // * returned Query, the provided converter will convert between Firestore + // * data of type `NewDbModelType` and your custom type `NewAppModelType`. + // * + // * Using the converter allows you to specify generic type arguments when + // * storing and retrieving objects from Firestore. + // * + // * Passing in `null` as the converter parameter removes the current + // * converter. + // * + // * @example + // * ``` + // * class Post { + // * constructor(readonly title: string, readonly author: string) {} + // * + // * toString(): string { + // * return this.title + ', by ' + this.author; + // * } + // * } + // * + // * const postConverter = { + // * toFirestore(post: Post): FirebaseFirestore.DocumentData { + // * return {title: post.title, author: post.author}; + // * }, + // * fromFirestore( + // * snapshot: FirebaseFirestore.QueryDocumentSnapshot + // * ): Post { + // * const data = snapshot.data(); + // * return new Post(data.title, data.author); + // * } + // * }; + // * + // * const postSnap = await Firestore() + // * .collection('posts') + // * .withConverter(postConverter) + // * .doc().get(); + // * const post = postSnap.data(); + // * if (post !== undefined) { + // * post.title; // string + // * post.toString(); // Should be defined + // * post.someNonExistentProperty; // TS error + // * } + // * + // * ``` + // * @param {FirestoreDataConverter | null} converter Converts objects to and + // * from Firestore. Passing in `null` removes the current converter. + // * @return A Query that uses the provided converter. + // */ + // withConverter( + // converter: FirestorePipelineConverter | null + // ): Pipeline { + // const copy = this.stages.map(s => s); + // return new Pipeline( + // this.db, + // copy, + // converter ?? defaultPipelineConverter() + // ); + // } + + /** + * Executes this pipeline and returns a Promise to represent the asynchronous operation. + * + *

The returned Promise can be used to track the progress of the pipeline execution + * and retrieve the results (or handle any errors) asynchronously. + * + *

The pipeline results are returned as a list of {@link PipelineResult} objects. Each {@link + * PipelineResult} typically represents a single key/value map that has passed through all the + * stages of the pipeline, however this might differ depending on the stages involved in the + * pipeline. For example: + * + *

    + *
  • If there are no stages or only transformation stages, each {@link PipelineResult} + * represents a single document.
  • + *
  • If there is an aggregation, only a single {@link PipelineResult} is returned, + * representing the aggregated results over the entire dataset .
  • + *
  • If there is an aggregation stage with grouping, each {@link PipelineResult} represents a + * distinct group and its associated aggregated values.
  • + *
+ * + *

Example: + * + * ```typescript + * const futureResults = await firestore.pipeline().collection("books") + * .where(gt(Field.of("rating"), 4.5)) + * .select("title", "author", "rating") + * .execute(); + * ``` + * + * @return A Promise representing the asynchronous pipeline execution. + */ + execute(): Promise>> { + // const util = new ExecutionUtil( + // this.db, + // this.db._serializer!, + // this.converter + // ); + // return util._getResponse(this).then(result => result!); + // the query is a VectorQuery instance + // the query is a VectorQuery instance + const client = ensureFirestoreConfigured(this.db); + + return firestoreClientExecutePipeline(client, this).then(result => { + const userDataWriter = new ExpUserDataWriter(this.db); + const docs = result.map( + element => + new PipelineResult( + userDataWriter, + element.key?.path + ? new DocumentReference(this.db, null, element.key) + : undefined, + element.fields, + element.executionTime?.toTimestamp(), + element.createTime?.toTimestamp(), + element.updateTime?.toTimestamp() + //this.converter + ) + ); + + return docs; + }); + } + + /** + * @internal + * @private + */ + _toProto(jsonProtoSerializer: JsonProtoSerializer): ExecutePipelineRequest { + const stages: ProtoStage[] = this.stages.map(stage => + stage._toProto(jsonProtoSerializer) + ); + const structuredPipeline: StructuredPipeline = { pipeline: { stages } }; + return { + database: getEncodedDatabaseId(jsonProtoSerializer), + structuredPipeline + }; + } +} diff --git a/packages/firestore/src/pipelines/api/stage.ts b/packages/firestore/src/pipelines/api/stage.ts new file mode 100644 index 00000000000..05033072d3f --- /dev/null +++ b/packages/firestore/src/pipelines/api/stage.ts @@ -0,0 +1,384 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +import { + Accumulator, + Expr, + Field, + FilterCondition, + Ordering +} from './expressions'; + +import { VectorValue } from '../../lite-api/vector_value'; +import { ObjectValue } from '../../model/object_value'; +import { + Stage as ProtoStage, + Value as ProtoValue +} from '../../protos/firestore_proto_api'; +import { toNumber } from '../../remote/number_serializer'; +import { + JsonProtoSerializer, + toMapValue, + toStringValue +} from '../../remote/serializer'; +import { DocumentReference } from '../../lite-api/reference'; + + +/** + * @beta + */ +export interface Stage { + name: string; + + /** + * @internal + * @private + */ + _toProto(jsonProtoSerializer: JsonProtoSerializer): ProtoStage; +} + +/** + * @beta + */ +export class AddFields implements Stage { + name = 'add_fields'; + + constructor(private fields: Map) {} + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: [toMapValue(serializer, this.fields)] + }; + } +} + +/** + * @beta + */ +export class Aggregate implements Stage { + name = 'aggregate'; + + constructor( + private accumulators: Map, + private groups: Map + ) {} + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: [ + toMapValue(serializer, this.accumulators), + toMapValue(serializer, this.groups) + ] + }; + } +} + +/** + * @beta + */ +export class Distinct implements Stage { + name = 'distinct'; + + constructor(private groups: Map) {} + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: [toMapValue(serializer, this.groups)] + }; + } +} + +/** + * @beta + */ +export class CollectionSource implements Stage { + name = 'collection'; + + constructor(private collectionPath: string) { + if (!this.collectionPath.startsWith('/')) { + this.collectionPath = '/' + this.collectionPath; + } + } + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: [{ referenceValue: this.collectionPath }] + }; + } +} + +/** + * @beta + */ +export class CollectionGroupSource implements Stage { + name = 'collection_group'; + + constructor(private collectionId: string) {} + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: [{ referenceValue: '' }, { stringValue: this.collectionId }] + }; + } +} + +/** + * @beta + */ +export class DatabaseSource implements Stage { + name = 'database'; + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name + }; + } +} + +/** + * @beta + */ +export class DocumentsSource implements Stage { + name = 'documents'; + + constructor(private docPaths: string[]) {} + + static of(refs: DocumentReference[]): DocumentsSource { + return new DocumentsSource(refs.map(ref => '/' + ref.path)); + } + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: this.docPaths.map(p => { + return { referenceValue: p }; + }) + }; + } +} + +/** + * @beta + */ +export class Where implements Stage { + name = 'where'; + + constructor(private condition: FilterCondition & Expr) {} + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: [(this.condition as unknown as Expr)._toProto(serializer)] + }; + } +} + +/** + * @beta + */ +export interface FindNearestOptions { + field: Field; + vectorValue: VectorValue | number[]; + distanceMeasure: 'euclidean' | 'cosine' | 'dot_product'; + limit?: number; + distanceField?: string; +} + +/** + * @beta + */ +export class FindNearest implements Stage { + name = 'find_nearest'; + + /** + * @private + * @internal + * + * @param _field + * @param _vectorValue + * @param _distanceMeasure + * @param _limit + * @param _distanceField + */ + constructor( + private _field: Field, + private _vectorValue: ObjectValue, + private _distanceMeasure: 'euclidean' | 'cosine' | 'dot_product', + private _limit?: number, + private _distanceField?: string + ) {} + + /** + * @private + * @internal + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + const options: { [k: string]: ProtoValue } = {}; + + if (this._limit) { + options.limit = toNumber(serializer, this._limit)!; + } + + if (this._distanceField) { + // eslint-disable-next-line camelcase + options.distance_field = Field.of(this._distanceField)._toProto( + serializer + ); + } + + return { + name: this.name, + args: [ + this._field._toProto(serializer), + this._vectorValue.value, + toStringValue(this._distanceMeasure) + ], + options + }; + } +} + +/** + * @beta + */ +export class Limit implements Stage { + name = 'limit'; + + constructor(private limit: number) {} + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: [toNumber(serializer, this.limit)] + }; + } +} + +/** + * @beta + */ +export class Offset implements Stage { + name = 'offset'; + + constructor(private offset: number) {} + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: [toNumber(serializer, this.offset)] + }; + } +} + +/** + * @beta + */ +export class Select implements Stage { + name = 'select'; + + constructor(private projections: Map) {} + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: [toMapValue(serializer, this.projections)] + }; + } +} + +/** + * @beta + */ +export class Sort implements Stage { + name = 'sort'; + + constructor(private orders: Ordering[]) {} + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: this.orders.map(o => o._toProto(serializer)) + }; + } +} + +/** + * @beta + */ +export class GenericStage implements Stage { + constructor(public name: string, params: any[]) {} + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + // TODO support generic stage + return {}; + } +} diff --git a/packages/firestore/src/protos/compile.sh b/packages/firestore/src/protos/compile.sh index 26c46d1a40d..9f9fb4b3217 100755 --- a/packages/firestore/src/protos/compile.sh +++ b/packages/firestore/src/protos/compile.sh @@ -18,10 +18,17 @@ set -euo pipefail # Variables PROTOS_DIR="." -PBJS="$(npm bin)/pbjs" +PBJS="../../node_modules/.bin/pbjs" +PBTS="../../node_modules/.bin/pbts" -"${PBJS}" --proto_path=. --target=json -o protos.json \ - -r firestore_v1 \ - "${PROTOS_DIR}/google/firestore/v1/*.proto" \ +"${PBJS}" --path=. --target=json -o protos.json \ + -r firestore/v1 "${PROTOS_DIR}/google/firestore/v1/*.proto" \ "${PROTOS_DIR}/google/protobuf/*.proto" "${PROTOS_DIR}/google/type/*.proto" \ "${PROTOS_DIR}/google/rpc/*.proto" "${PROTOS_DIR}/google/api/*.proto" + +"${PBJS}" --path="${PROTOS_DIR}" --target=static -o temp.js \ + -r firestore/v1 "${PROTOS_DIR}/google/firestore/v1/*.proto" \ + "${PROTOS_DIR}/google/protobuf/*.proto" "${PROTOS_DIR}/google/type/*.proto" \ + "${PROTOS_DIR}/google/rpc/*.proto" "${PROTOS_DIR}/google/api/*.proto" + +"${PBTS}" -o temp.d.ts --no-comments temp.js diff --git a/packages/firestore/src/protos/firestore_proto_api.ts b/packages/firestore/src/protos/firestore_proto_api.ts index 9618d71b86a..250cfb5ef88 100644 --- a/packages/firestore/src/protos/firestore_proto_api.ts +++ b/packages/firestore/src/protos/firestore_proto_api.ts @@ -145,9 +145,21 @@ export interface IValueNullValueEnum { } export declare const ValueNullValueEnum: IValueNullValueEnum; export declare namespace firestoreV1ApiClientInterfaces { + interface Aggregation { + count?: Count; + sum?: Sum; + avg?: Avg; + alias?: string; + } + interface AggregationResult { + aggregateFields?: ApiClientObjectMap; + } interface ArrayValue { values?: Value[]; } + interface Avg { + field?: FieldReference; + } interface BatchGetDocumentsRequest { database?: string; documents?: string[]; @@ -168,6 +180,14 @@ export declare namespace firestoreV1ApiClientInterfaces { interface BeginTransactionResponse { transaction?: string; } + interface BitSequence { + bitmap?: string | Uint8Array; + padding?: number; + } + interface BloomFilter { + bits?: BitSequence; + hashCount?: number; + } interface CollectionSelector { collectionId?: string; allDescendants?: boolean; @@ -185,6 +205,9 @@ export declare namespace firestoreV1ApiClientInterfaces { op?: CompositeFilterOp; filters?: Filter[]; } + interface Count { + upTo?: number; + } interface Cursor { values?: Value[]; before?: boolean; @@ -221,19 +244,23 @@ export declare namespace firestoreV1ApiClientInterfaces { documents?: string[]; } interface Empty {} + interface ExecutePipelineRequest { + database?: string; + structuredPipeline?: StructuredPipeline; + transaction?: string; + newTransaction?: TransactionOptions; + readTime?: string; + } + interface ExecutePipelineResponse { + transaction?: string; + results?: Document[]; + executionTime?: string; + } interface ExistenceFilter { targetId?: number; count?: number; unchangedNames?: BloomFilter; } - interface BloomFilter { - bits?: BitSequence; - hashCount?: number; - } - interface BitSequence { - bitmap?: string | Uint8Array; - padding?: number; - } interface FieldFilter { field?: FieldReference; op?: FieldFilterOp; @@ -254,6 +281,11 @@ export declare namespace firestoreV1ApiClientInterfaces { fieldFilter?: FieldFilter; unaryFilter?: UnaryFilter; } + interface Function { + name?: string; + args?: Value[]; + options?: ApiClientObjectMap; + } interface Index { name?: string; collectionId?: string; @@ -310,6 +342,9 @@ export declare namespace firestoreV1ApiClientInterfaces { field?: FieldReference; direction?: OrderDirection; } + interface Pipeline { + stages?: Stage[]; + } interface Precondition { exists?: boolean; updateTime?: Timestamp; @@ -355,33 +390,24 @@ export declare namespace firestoreV1ApiClientInterfaces { transaction?: string; readTime?: string; } - interface AggregationResult { - aggregateFields?: ApiClientObjectMap; - } interface StructuredAggregationQuery { structuredQuery?: StructuredQuery; aggregations?: Aggregation[]; } - interface Aggregation { - count?: Count; - sum?: Sum; - avg?: Avg; - alias?: string; - } - interface Count { - upTo?: number; - } - interface Sum { - field?: FieldReference; - } - interface Avg { - field?: FieldReference; + interface Stage { + name?: string; + args?: Value[]; + options?: ApiClientObjectMap; } interface Status { code?: number; message?: string; details?: Array>; } + interface StructuredPipeline { + pipeline?: Pipeline; + options?: ApiClientObjectMap; + } interface StructuredQuery { select?: Projection; from?: CollectionSelector[]; @@ -392,6 +418,9 @@ export declare namespace firestoreV1ApiClientInterfaces { offset?: number; limit?: number | { value: number }; } + interface Sum { + field?: FieldReference; + } interface Target { query?: QueryTarget; documents?: DocumentsTarget; @@ -428,6 +457,10 @@ export declare namespace firestoreV1ApiClientInterfaces { geoPointValue?: LatLng; arrayValue?: ArrayValue; mapValue?: MapValue; + fieldReferenceValue?: string; + // eslint-disable-next-line @typescript-eslint/ban-types + functionValue?: Function; + pipelineValue?: Pipeline; } interface Write { update?: Document; @@ -489,12 +522,17 @@ export declare type DocumentsTarget = export declare type Empty = firestoreV1ApiClientInterfaces.Empty; export declare type ExistenceFilter = firestoreV1ApiClientInterfaces.ExistenceFilter; +export declare type ExecutePipelineRequest = + firestoreV1ApiClientInterfaces.ExecutePipelineRequest; +export declare type ExecutePipelineResponse = + firestoreV1ApiClientInterfaces.ExecutePipelineResponse; export declare type FieldFilter = firestoreV1ApiClientInterfaces.FieldFilter; export declare type FieldReference = firestoreV1ApiClientInterfaces.FieldReference; export declare type FieldTransform = firestoreV1ApiClientInterfaces.FieldTransform; export declare type Filter = firestoreV1ApiClientInterfaces.Filter; +export declare type Function = firestoreV1ApiClientInterfaces.Function; export declare type Index = firestoreV1ApiClientInterfaces.Index; export declare type IndexField = firestoreV1ApiClientInterfaces.IndexField; export declare type LatLng = firestoreV1ApiClientInterfaces.LatLng; @@ -513,6 +551,7 @@ export declare type ListenResponse = export declare type MapValue = firestoreV1ApiClientInterfaces.MapValue; export declare type Operation = firestoreV1ApiClientInterfaces.Operation; export declare type Order = firestoreV1ApiClientInterfaces.Order; +export declare type Pipeline = firestoreV1ApiClientInterfaces.Pipeline; export declare type Precondition = firestoreV1ApiClientInterfaces.Precondition; export declare type Projection = firestoreV1ApiClientInterfaces.Projection; export declare type QueryTarget = firestoreV1ApiClientInterfaces.QueryTarget; @@ -529,6 +568,7 @@ export declare type RunAggregationQueryRequest = export declare type Aggregation = firestoreV1ApiClientInterfaces.Aggregation; export declare type RunAggregationQueryResponse = firestoreV1ApiClientInterfaces.RunAggregationQueryResponse; +export declare type Stage = firestoreV1ApiClientInterfaces.Stage; export declare type Status = firestoreV1ApiClientInterfaces.Status; export declare type StructuredQuery = firestoreV1ApiClientInterfaces.StructuredQuery; diff --git a/packages/firestore/src/protos/google/api/launch_stage.proto b/packages/firestore/src/protos/google/api/launch_stage.proto new file mode 100644 index 00000000000..9863fc23d42 --- /dev/null +++ b/packages/firestore/src/protos/google/api/launch_stage.proto @@ -0,0 +1,72 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +option go_package = "google.golang.org/genproto/googleapis/api;api"; +option java_multiple_files = true; +option java_outer_classname = "LaunchStageProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +// The launch stage as defined by [Google Cloud Platform +// Launch Stages](https://cloud.google.com/terms/launch-stages). +enum LaunchStage { + // Do not use this default value. + LAUNCH_STAGE_UNSPECIFIED = 0; + + // The feature is not yet implemented. Users can not use it. + UNIMPLEMENTED = 6; + + // Prelaunch features are hidden from users and are only visible internally. + PRELAUNCH = 7; + + // Early Access features are limited to a closed group of testers. To use + // these features, you must sign up in advance and sign a Trusted Tester + // agreement (which includes confidentiality provisions). These features may + // be unstable, changed in backward-incompatible ways, and are not + // guaranteed to be released. + EARLY_ACCESS = 1; + + // Alpha is a limited availability test for releases before they are cleared + // for widespread use. By Alpha, all significant design issues are resolved + // and we are in the process of verifying functionality. Alpha customers + // need to apply for access, agree to applicable terms, and have their + // projects allowlisted. Alpha releases don't have to be feature complete, + // no SLAs are provided, and there are no technical support obligations, but + // they will be far enough along that customers can actually use them in + // test environments or for limited-use tests -- just like they would in + // normal production cases. + ALPHA = 2; + + // Beta is the point at which we are ready to open a release for any + // customer to use. There are no SLA or technical support obligations in a + // Beta release. Products will be complete from a feature perspective, but + // may have some open outstanding issues. Beta releases are suitable for + // limited production use cases. + BETA = 3; + + // GA features are open to all developers and are considered stable and + // fully qualified for production use. + GA = 4; + + // Deprecated features are scheduled to be shut down and removed. For more + // information, see the "Deprecation Policy" section of our [Terms of + // Service](https://cloud.google.com/terms/) + // and the [Google Cloud Platform Subject to the Deprecation + // Policy](https://cloud.google.com/terms/deprecation) documentation. + DEPRECATED = 5; +} diff --git a/packages/firestore/src/protos/google/firestore/v1/document.proto b/packages/firestore/src/protos/google/firestore/v1/document.proto index 5238a943ce4..f7605750502 100644 --- a/packages/firestore/src/protos/google/firestore/v1/document.proto +++ b/packages/firestore/src/protos/google/firestore/v1/document.proto @@ -129,6 +129,48 @@ message Value { // A map value. MapValue map_value = 6; + // Value which references a field. + // + // This is considered relative (vs absolute) since it only refers to a field + // and not a field within a particular document. + // + // **Requires:** + // + // * Must follow [field reference][FieldReference.field_path] limitations. + // + // * Not allowed to be used when writing documents. + // + // (-- NOTE(batchik): long term, there is no reason this type should not be + // allowed to be used on the write path. --) + string field_reference_value = 19; + + // A value that represents an unevaluated expression. + // + // **Requires:** + // + // * Not allowed to be used when writing documents. + // + // (-- NOTE(batchik): similar to above, there is no reason to not allow + // storing expressions into the database, just no plan to support in + // the near term. + // + // This would actually be an interesting way to represent user-defined + // functions or more expressive rules-based systems. --) + Function function_value = 20; + + // A value that represents an unevaluated pipeline. + // + // **Requires:** + // + // * Not allowed to be used when writing documents. + // + // (-- NOTE(batchik): similar to above, there is no reason to not allow + // storing expressions into the database, just no plan to support in + // the near term. + // + // This would actually be an interesting way to represent user-defined + // functions or more expressive rules-based systems. --) + Pipeline pipeline_value = 21; } } @@ -148,3 +190,73 @@ message MapValue { // not exceed 1,500 bytes and cannot be empty. map fields = 1; } + + +// Represents an unevaluated scalar expression. +// +// For example, the expression `like(user_name, "%alice%")` is represented as: +// +// ``` +// name: "like" +// args { field_reference: "user_name" } +// args { string_value: "%alice%" } +// ``` +// +// (-- api-linter: core::0123::resource-annotation=disabled +// aip.dev/not-precedent: this is not a One Platform API resource. --) +message Function { + // The name of the function to evaluate. + // + // **Requires:** + // + // * must be in snake case (lower case with underscore separator). + // + string name = 1; + + // Ordered list of arguments the given function expects. + repeated Value args = 2; + + // Optional named arguments that certain functions may support. + map options = 3; +} + +// A Firestore query represented as an ordered list of operations / stages. +message Pipeline { + // A single operation within a pipeline. + // + // A stage is made up of a unique name, and a list of arguments. The exact + // number of arguments & types is dependent on the stage type. + // + // To give an example, the stage `filter(state = "MD")` would be encoded as: + // + // ``` + // name: "filter" + // args { + // function_value { + // name: "eq" + // args { field_reference_value: "state" } + // args { string_value: "MD" } + // } + // } + // ``` + // + // See public documentation for the full list. + message Stage { + // The name of the stage to evaluate. + // + // **Requires:** + // + // * must be in snake case (lower case with underscore separator). + // + string name = 1; + + // Ordered list of arguments the given stage expects. + repeated Value args = 2; + + // Optional named arguments that certain functions may support. + map options = 3; + } + + // Ordered list of stages to evaluate. + repeated Stage stages = 1; +} diff --git a/packages/firestore/src/protos/google/firestore/v1/firestore.proto b/packages/firestore/src/protos/google/firestore/v1/firestore.proto index a8fc0d54b51..3e7b62e0609 100644 --- a/packages/firestore/src/protos/google/firestore/v1/firestore.proto +++ b/packages/firestore/src/protos/google/firestore/v1/firestore.proto @@ -22,6 +22,7 @@ import "google/api/field_behavior.proto"; import "google/firestore/v1/aggregation_result.proto"; import "google/firestore/v1/common.proto"; import "google/firestore/v1/document.proto"; +import "google/firestore/v1/pipeline.proto"; import "google/firestore/v1/query.proto"; import "google/firestore/v1/write.proto"; import "google/protobuf/empty.proto"; @@ -135,6 +136,15 @@ service Firestore { }; } + // Executes a pipeline query. + rpc ExecutePipeline(ExecutePipelineRequest) + returns (stream ExecutePipelineResponse) { + option (google.api.http) = { + post: "/v1/{database=projects/*/databases/*}/documents:executePipeline" + body: "*" + }; + } + // Runs an aggregation query. // // Rather than producing [Document][google.firestore.v1.Document] results like [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery], @@ -157,7 +167,7 @@ service Firestore { } }; } - + // Partitions a query by returning partition cursors that can be used to run // the query in parallel. The returned partition cursors are split points that // can be used by RunQuery as starting/end points for the query results. @@ -547,6 +557,82 @@ message RunQueryResponse { int32 skipped_results = 4; } +// The request for [Firestore.ExecutePipeline][]. +message ExecutePipelineRequest { + // Database identifier, in the form `projects/{project}/databases/{database}`. + string database = 1 [ + (google.api.field_behavior) = REQUIRED + ]; + + oneof pipeline_type { + // A pipelined operation. + StructuredPipeline structured_pipeline = 2; + } + + // Optional consistency arguments, defaults to strong consistency. + oneof consistency_selector { + // Run the query within an already active transaction. + // + // The value here is the opaque transaction ID to execute the query in. + bytes transaction = 5; + + // Execute the pipeline in a new transaction. + // + // The identifier of the newly created transaction will be returned in the + // first response on the stream. This defaults to a read-only transaction. + TransactionOptions new_transaction = 6; + + // Execute the pipeline in a snapshot transaction at the given time. + // + // This must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + google.protobuf.Timestamp read_time = 7; + } + + // Explain / analyze options for the pipeline. + // ExplainOptions explain_options = 8 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response for [Firestore.Execute][]. +message ExecutePipelineResponse { + // Newly created transaction identifier. + // + // This field is only specified on the first response from the server when + // the request specified [ExecuteRequest.new_transaction][]. + bytes transaction = 1; + + // An ordered batch of results returned executing a pipeline. + // + // The batch size is variable, and can even be zero for when only a partial + // progress message is returned. + // + // The fields present in the returned documents are only those that were + // explicitly requested in the pipeline, this include those like + // [`__name__`][Document.name] & [`__update_time__`][Document.update_time]. + // This is explicitly a divergence from `Firestore.RunQuery` / + // `Firestore.GetDocument` RPCs which always return such fields even when they + // are not specified in the [`mask`][DocumentMask]. + repeated Document results = 2; + + // The time at which the document(s) were read. + // + // This may be monotonically increasing; in this case, the previous documents + // in the result stream are guaranteed not to have changed between their + // `execution_time` and this one. + // + // If the query returns no results, a response with `execution_time` and no + // `results` will be sent, and this represents the time at which the operation + // was run. + google.protobuf.Timestamp execution_time = 3; + + // Query explain metrics. + // + // Set on the last response when [ExecutePipelineRequest.explain_options][] + // was specified on the request. + // ExplainMetrics explain_metrics = 4; +} + // The request for [Firestore.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery]. message RunAggregationQueryRequest { // Required. The parent resource name. In the format: diff --git a/packages/firestore/src/protos/google/firestore/v1/pipeline.proto b/packages/firestore/src/protos/google/firestore/v1/pipeline.proto new file mode 100644 index 00000000000..ea5b2309331 --- /dev/null +++ b/packages/firestore/src/protos/google/firestore/v1/pipeline.proto @@ -0,0 +1,41 @@ +/*! + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +syntax = "proto3"; +package google.firestore.v1; +import "google/firestore/v1/document.proto"; +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; +option java_multiple_files = true; +option java_package = "com.google.firestore.v1"; +option java_outer_classname = "PipelineProto"; +option objc_class_prefix = "GCFS"; +// A Firestore query represented as an ordered list of operations / stages. +// +// This is considered the top-level function which plans & executes a query. +// It is logically equivalent to `query(stages, options)`, but prevents the +// client from having to build a function wrapper. +message StructuredPipeline { + // The pipeline query to execute. + Pipeline pipeline = 1; + // Optional query-level arguments. + // + // (-- Think query statement hints. --) + // + // (-- TODO(batchik): define the api contract of using an unsupported hint --) + map options = 2; +} diff --git a/packages/firestore/src/protos/google/firestore/v1/query_profile.proto b/packages/firestore/src/protos/google/firestore/v1/query_profile.proto new file mode 100644 index 00000000000..de27144a038 --- /dev/null +++ b/packages/firestore/src/protos/google/firestore/v1/query_profile.proto @@ -0,0 +1,92 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.v1; + +import "google/api/field_behavior.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +option java_multiple_files = true; +option java_outer_classname = "QueryProfileProto"; +option java_package = "com.google.firestore.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; + +// Specification of the Firestore Query Profile fields. + +// Explain options for the query. +message ExplainOptions { + // Optional. Whether to execute this query. + // + // When false (the default), the query will be planned, returning only + // metrics from the planning stages. + // + // When true, the query will be planned and executed, returning the full + // query results along with both planning and execution stage metrics. + bool analyze = 1 [(google.api.field_behavior) = OPTIONAL]; +} + +// Explain metrics for the query. +message ExplainMetrics { + // Planning phase information for the query. + PlanSummary plan_summary = 1; + + // Aggregated stats from the execution of the query. Only present when + // [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set + // to true. + ExecutionStats execution_stats = 2; +} + +// Planning phase information for the query. +message PlanSummary { + // The indexes selected for the query. For example: + // [ + // {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"}, + // {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"} + // ] + repeated google.protobuf.Struct indexes_used = 1; +} + +// Execution statistics for the query. +message ExecutionStats { + // Total number of results returned, including documents, projections, + // aggregation results, keys. + int64 results_returned = 1; + + // Total time to execute the query in the backend. + google.protobuf.Duration execution_duration = 3; + + // Total billable read operations. + int64 read_operations = 4; + + // Debugging statistics from the execution of the query. Note that the + // debugging stats are subject to change as Firestore evolves. It could + // include: + // { + // "indexes_entries_scanned": "1000", + // "documents_scanned": "20", + // "billing_details" : { + // "documents_billable": "20", + // "index_entries_billable": "1000", + // "min_query_cost": "0" + // } + // } + google.protobuf.Struct debug_stats = 5; +} diff --git a/packages/firestore/src/protos/protos.json b/packages/firestore/src/protos/protos.json index b2c50ccaeeb..5b73c4647f8 100644 --- a/packages/firestore/src/protos/protos.json +++ b/packages/firestore/src/protos/protos.json @@ -4,16 +4,78 @@ "nested": { "protobuf": { "options": { - "csharp_namespace": "Google.Protobuf.WellKnownTypes", - "go_package": "github.com/golang/protobuf/ptypes/wrappers", + "go_package": "github.com/golang/protobuf/protoc-gen-go/descriptor;descriptor", "java_package": "com.google.protobuf", - "java_outer_classname": "WrappersProto", - "java_multiple_files": true, + "java_outer_classname": "DescriptorProtos", + "csharp_namespace": "Google.Protobuf.Reflection", "objc_class_prefix": "GPB", "cc_enable_arenas": true, "optimize_for": "SPEED" }, "nested": { + "Struct": { + "fields": { + "fields": { + "keyType": "string", + "type": "Value", + "id": 1 + } + } + }, + "Value": { + "oneofs": { + "kind": { + "oneof": [ + "nullValue", + "numberValue", + "stringValue", + "boolValue", + "structValue", + "listValue" + ] + } + }, + "fields": { + "nullValue": { + "type": "NullValue", + "id": 1 + }, + "numberValue": { + "type": "double", + "id": 2 + }, + "stringValue": { + "type": "string", + "id": 3 + }, + "boolValue": { + "type": "bool", + "id": 4 + }, + "structValue": { + "type": "Struct", + "id": 5 + }, + "listValue": { + "type": "ListValue", + "id": 6 + } + } + }, + "NullValue": { + "values": { + "NULL_VALUE": 0 + } + }, + "ListValue": { + "fields": { + "values": { + "rule": "repeated", + "type": "Value", + "id": 1 + } + } + }, "Timestamp": { "fields": { "seconds": { @@ -161,6 +223,10 @@ "end": { "type": "int32", "id": 2 + }, + "options": { + "type": "ExtensionRangeOptions", + "id": 3 } } }, @@ -178,6 +244,21 @@ } } }, + "ExtensionRangeOptions": { + "fields": { + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ] + }, "FieldDescriptorProto": { "fields": { "name": { @@ -279,6 +360,30 @@ "options": { "type": "EnumOptions", "id": 3 + }, + "reservedRange": { + "rule": "repeated", + "type": "EnumReservedRange", + "id": 4 + }, + "reservedName": { + "rule": "repeated", + "type": "string", + "id": 5 + } + }, + "nested": { + "EnumReservedRange": { + "fields": { + "start": { + "type": "int32", + "id": 1 + }, + "end": { + "type": "int32", + "id": 2 + } + } } } }, @@ -335,11 +440,17 @@ }, "clientStreaming": { "type": "bool", - "id": 5 + "id": 5, + "options": { + "default": false + } }, "serverStreaming": { "type": "bool", - "id": 6 + "id": 6, + "options": { + "default": false + } } } }, @@ -355,7 +466,10 @@ }, "javaMultipleFiles": { "type": "bool", - "id": 10 + "id": 10, + "options": { + "default": false + } }, "javaGenerateEqualsAndHash": { "type": "bool", @@ -366,7 +480,10 @@ }, "javaStringCheckUtf8": { "type": "bool", - "id": 27 + "id": 27, + "options": { + "default": false + } }, "optimizeFor": { "type": "OptimizeMode", @@ -381,23 +498,45 @@ }, "ccGenericServices": { "type": "bool", - "id": 16 + "id": 16, + "options": { + "default": false + } }, "javaGenericServices": { "type": "bool", - "id": 17 + "id": 17, + "options": { + "default": false + } }, "pyGenericServices": { "type": "bool", - "id": 18 + "id": 18, + "options": { + "default": false + } + }, + "phpGenericServices": { + "type": "bool", + "id": 42, + "options": { + "default": false + } }, "deprecated": { "type": "bool", - "id": 23 + "id": 23, + "options": { + "default": false + } }, "ccEnableArenas": { "type": "bool", - "id": 31 + "id": 31, + "options": { + "default": false + } }, "objcClassPrefix": { "type": "string", @@ -407,6 +546,26 @@ "type": "string", "id": 37 }, + "swiftPrefix": { + "type": "string", + "id": 39 + }, + "phpClassPrefix": { + "type": "string", + "id": 40 + }, + "phpNamespace": { + "type": "string", + "id": 41 + }, + "phpMetadataNamespace": { + "type": "string", + "id": 44 + }, + "rubyPackage": { + "type": "string", + "id": 45 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -439,15 +598,24 @@ "fields": { "messageSetWireFormat": { "type": "bool", - "id": 1 + "id": 1, + "options": { + "default": false + } }, "noStandardDescriptorAccessor": { "type": "bool", - "id": 2 + "id": 2, + "options": { + "default": false + } }, "deprecated": { "type": "bool", - "id": 3 + "id": 3, + "options": { + "default": false + } }, "mapEntry": { "type": "bool", @@ -469,6 +637,10 @@ [ 8, 8 + ], + [ + 9, + 9 ] ] }, @@ -494,15 +666,24 @@ }, "lazy": { "type": "bool", - "id": 5 + "id": 5, + "options": { + "default": false + } }, "deprecated": { "type": "bool", - "id": 3 + "id": 3, + "options": { + "default": false + } }, "weak": { "type": "bool", - "id": 10 + "id": 10, + "options": { + "default": false + } }, "uninterpretedOption": { "rule": "repeated", @@ -562,7 +743,10 @@ }, "deprecated": { "type": "bool", - "id": 3 + "id": 3, + "options": { + "default": false + } }, "uninterpretedOption": { "rule": "repeated", @@ -575,13 +759,22 @@ 1000, 536870911 ] + ], + "reserved": [ + [ + 5, + 5 + ] ] }, "EnumValueOptions": { "fields": { "deprecated": { "type": "bool", - "id": 1 + "id": 1, + "options": { + "default": false + } }, "uninterpretedOption": { "rule": "repeated", @@ -600,7 +793,10 @@ "fields": { "deprecated": { "type": "bool", - "id": 33 + "id": 33, + "options": { + "default": false + } }, "uninterpretedOption": { "rule": "repeated", @@ -619,7 +815,17 @@ "fields": { "deprecated": { "type": "bool", - "id": 33 + "id": 33, + "options": { + "default": false + } + }, + "idempotencyLevel": { + "type": "IdempotencyLevel", + "id": 34, + "options": { + "default": "IDEMPOTENCY_UNKNOWN" + } }, "uninterpretedOption": { "rule": "repeated", @@ -632,7 +838,16 @@ 1000, 536870911 ] - ] + ], + "nested": { + "IdempotencyLevel": { + "values": { + "IDEMPOTENCY_UNKNOWN": 0, + "NO_SIDE_EFFECTS": 1, + "IDEMPOTENT": 2 + } + } + } }, "UninterpretedOption": { "fields": { @@ -753,72 +968,6 @@ } } }, - "Struct": { - "fields": { - "fields": { - "keyType": "string", - "type": "Value", - "id": 1 - } - } - }, - "Value": { - "oneofs": { - "kind": { - "oneof": [ - "nullValue", - "numberValue", - "stringValue", - "boolValue", - "structValue", - "listValue" - ] - } - }, - "fields": { - "nullValue": { - "type": "NullValue", - "id": 1 - }, - "numberValue": { - "type": "double", - "id": 2 - }, - "stringValue": { - "type": "string", - "id": 3 - }, - "boolValue": { - "type": "bool", - "id": 4 - }, - "structValue": { - "type": "Struct", - "id": 5 - }, - "listValue": { - "type": "ListValue", - "id": 6 - } - } - }, - "NullValue": { - "values": { - "NULL_VALUE": 0 - } - }, - "ListValue": { - "fields": { - "values": { - "rule": "repeated", - "type": "Value", - "id": 1 - } - } - }, - "Empty": { - "fields": {} - }, "DoubleValue": { "fields": { "value": { @@ -891,9 +1040,12 @@ } } }, + "Empty": { + "fields": {} + }, "Any": { "fields": { - "typeUrl": { + "type_url": { "type": "string", "id": 1 }, @@ -902,6 +1054,18 @@ "id": 2 } } + }, + "Duration": { + "fields": { + "seconds": { + "type": "int64", + "id": 1 + }, + "nanos": { + "type": "int32", + "id": 2 + } + } } } }, @@ -910,9 +1074,9 @@ "v1": { "options": { "csharp_namespace": "Google.Cloud.Firestore.V1", - "go_package": "google.golang.org/genproto/googleapis/firestore/v1;firestore", + "go_package": "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb", "java_multiple_files": true, - "java_outer_classname": "WriteProto", + "java_outer_classname": "QueryProfileProto", "java_package": "com.google.firestore.v1", "objc_class_prefix": "GCFS", "php_namespace": "Google\\Cloud\\Firestore\\V1", @@ -928,104 +1092,6 @@ } } }, - "BitSequence": { - "fields": { - "bitmap": { - "type": "bytes", - "id": 1 - }, - "padding": { - "type": "int32", - "id": 2 - } - } - }, - "BloomFilter": { - "fields": { - "bits": { - "type": "BitSequence", - "id": 1 - }, - "hashCount": { - "type": "int32", - "id": 2 - } - } - }, - "DocumentMask": { - "fields": { - "fieldPaths": { - "rule": "repeated", - "type": "string", - "id": 1 - } - } - }, - "Precondition": { - "oneofs": { - "conditionType": { - "oneof": [ - "exists", - "updateTime" - ] - } - }, - "fields": { - "exists": { - "type": "bool", - "id": 1 - }, - "updateTime": { - "type": "google.protobuf.Timestamp", - "id": 2 - } - } - }, - "TransactionOptions": { - "oneofs": { - "mode": { - "oneof": [ - "readOnly", - "readWrite" - ] - } - }, - "fields": { - "readOnly": { - "type": "ReadOnly", - "id": 2 - }, - "readWrite": { - "type": "ReadWrite", - "id": 3 - } - }, - "nested": { - "ReadWrite": { - "fields": { - "retryTransaction": { - "type": "bytes", - "id": 1 - } - } - }, - "ReadOnly": { - "oneofs": { - "consistencySelector": { - "oneof": [ - "readTime" - ] - } - }, - "fields": { - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 2 - } - } - } - } - }, "Document": { "fields": { "name": { @@ -1061,7 +1127,10 @@ "referenceValue", "geoPointValue", "arrayValue", - "mapValue" + "mapValue", + "fieldReferenceValue", + "functionValue", + "pipelineValue" ] } }, @@ -1106,27 +1175,184 @@ "type": "ArrayValue", "id": 9 }, - "mapValue": { - "type": "MapValue", - "id": 6 + "mapValue": { + "type": "MapValue", + "id": 6 + }, + "fieldReferenceValue": { + "type": "string", + "id": 19 + }, + "functionValue": { + "type": "Function", + "id": 20 + }, + "pipelineValue": { + "type": "Pipeline", + "id": 21 + } + } + }, + "ArrayValue": { + "fields": { + "values": { + "rule": "repeated", + "type": "Value", + "id": 1 + } + } + }, + "MapValue": { + "fields": { + "fields": { + "keyType": "string", + "type": "Value", + "id": 1 + } + } + }, + "Function": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "args": { + "rule": "repeated", + "type": "Value", + "id": 2 + }, + "options": { + "keyType": "string", + "type": "Value", + "id": 3 + } + } + }, + "Pipeline": { + "fields": { + "stages": { + "rule": "repeated", + "type": "Stage", + "id": 1 + } + }, + "nested": { + "Stage": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "args": { + "rule": "repeated", + "type": "Value", + "id": 2 + }, + "options": { + "keyType": "string", + "type": "Value", + "id": 3 + } + } + } + } + }, + "BitSequence": { + "fields": { + "bitmap": { + "type": "bytes", + "id": 1 + }, + "padding": { + "type": "int32", + "id": 2 + } + } + }, + "BloomFilter": { + "fields": { + "bits": { + "type": "BitSequence", + "id": 1 + }, + "hashCount": { + "type": "int32", + "id": 2 } } }, - "ArrayValue": { + "DocumentMask": { "fields": { - "values": { + "fieldPaths": { "rule": "repeated", - "type": "Value", + "type": "string", "id": 1 } } }, - "MapValue": { + "Precondition": { + "oneofs": { + "conditionType": { + "oneof": [ + "exists", + "updateTime" + ] + } + }, "fields": { - "fields": { - "keyType": "string", - "type": "Value", + "exists": { + "type": "bool", "id": 1 + }, + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + } + } + }, + "TransactionOptions": { + "oneofs": { + "mode": { + "oneof": [ + "readOnly", + "readWrite" + ] + } + }, + "fields": { + "readOnly": { + "type": "ReadOnly", + "id": 2 + }, + "readWrite": { + "type": "ReadWrite", + "id": 3 + } + }, + "nested": { + "ReadWrite": { + "fields": { + "retryTransaction": { + "type": "bytes", + "id": 1 + } + } + }, + "ReadOnly": { + "oneofs": { + "consistencySelector": { + "oneof": [ + "readTime" + ] + } + }, + "fields": { + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + } + } } } }, @@ -1302,6 +1528,23 @@ } ] }, + "ExecutePipeline": { + "requestType": "ExecutePipelineRequest", + "responseType": "ExecutePipelineResponse", + "responseStream": true, + "options": { + "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:executePipeline", + "(google.api.http).body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{database=projects/*/databases/*}/documents:executePipeline", + "body": "*" + } + } + ] + }, "RunAggregationQuery": { "requestType": "RunAggregationQueryRequest", "responseType": "RunAggregationQueryResponse", @@ -1816,6 +2059,64 @@ } } }, + "ExecutePipelineRequest": { + "oneofs": { + "pipelineType": { + "oneof": [ + "structuredPipeline" + ] + }, + "consistencySelector": { + "oneof": [ + "transaction", + "newTransaction", + "readTime" + ] + } + }, + "fields": { + "database": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "structuredPipeline": { + "type": "StructuredPipeline", + "id": 2 + }, + "transaction": { + "type": "bytes", + "id": 5 + }, + "newTransaction": { + "type": "TransactionOptions", + "id": 6 + }, + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 7 + } + } + }, + "ExecutePipelineResponse": { + "fields": { + "transaction": { + "type": "bytes", + "id": 1 + }, + "results": { + "rule": "repeated", + "type": "Document", + "id": 2 + }, + "executionTime": { + "type": "google.protobuf.Timestamp", + "id": 3 + } + } + }, "RunAggregationQueryRequest": { "oneofs": { "queryType": { @@ -2216,6 +2517,19 @@ } } }, + "StructuredPipeline": { + "fields": { + "pipeline": { + "type": "Pipeline", + "id": 1 + }, + "options": { + "keyType": "string", + "type": "Value", + "id": 2 + } + } + }, "StructuredQuery": { "fields": { "select": { @@ -2474,7 +2788,7 @@ "Sum": { "fields": { "field": { - "type": "FieldReference", + "type": "StructuredQuery.FieldReference", "id": 1 } } @@ -2482,7 +2796,7 @@ "Avg": { "fields": { "field": { - "type": "FieldReference", + "type": "StructuredQuery.FieldReference", "id": 1 } } @@ -2694,6 +3008,82 @@ "id": 3 } } + }, + "ExplainOptions": { + "fields": { + "analyze": { + "type": "bool", + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "ExplainMetrics": { + "fields": { + "planSummary": { + "type": "PlanSummary", + "id": 1 + }, + "executionStats": { + "type": "ExecutionStats", + "id": 2 + } + } + }, + "PlanSummary": { + "fields": { + "indexesUsed": { + "rule": "repeated", + "type": "google.protobuf.Struct", + "id": 1 + } + } + }, + "ExecutionStats": { + "fields": { + "resultsReturned": { + "type": "int64", + "id": 1 + }, + "executionDuration": { + "type": "google.protobuf.Duration", + "id": 3 + }, + "readOperations": { + "type": "int64", + "id": 4 + }, + "debugStats": { + "type": "google.protobuf.Struct", + "id": 5 + } + } + } + } + } + } + }, + "type": { + "options": { + "cc_enable_arenas": true, + "go_package": "google.golang.org/genproto/googleapis/type/latlng;latlng", + "java_multiple_files": true, + "java_outer_classname": "LatLngProto", + "java_package": "com.google.type", + "objc_class_prefix": "GTP" + }, + "nested": { + "LatLng": { + "fields": { + "latitude": { + "type": "double", + "id": 1 + }, + "longitude": { + "type": "double", + "id": 2 } } } @@ -2701,9 +3091,9 @@ }, "api": { "options": { - "go_package": "google.golang.org/genproto/googleapis/api/annotations;annotations", + "go_package": "google.golang.org/genproto/googleapis/api;api", "java_multiple_files": true, - "java_outer_classname": "HttpProto", + "java_outer_classname": "LaunchStageProto", "java_package": "com.google.api", "objc_class_prefix": "GAPI", "cc_enable_arenas": true @@ -2720,6 +3110,10 @@ "rule": "repeated", "type": "HttpRule", "id": 1 + }, + "fullyDecodeReservedExpansion": { + "type": "bool", + "id": 2 } } }, @@ -2737,6 +3131,10 @@ } }, "fields": { + "selector": { + "type": "string", + "id": 1 + }, "get": { "type": "string", "id": 2 @@ -2761,14 +3159,14 @@ "type": "CustomHttpPattern", "id": 8 }, - "selector": { - "type": "string", - "id": 1 - }, "body": { "type": "string", "id": 7 }, + "responseBody": { + "type": "string", + "id": 12 + }, "additionalBindings": { "rule": "repeated", "type": "HttpRule", @@ -2821,29 +3219,17 @@ "UNORDERED_LIST": 6, "NON_EMPTY_DEFAULT": 7 } - } - } - }, - "type": { - "options": { - "cc_enable_arenas": true, - "go_package": "google.golang.org/genproto/googleapis/type/latlng;latlng", - "java_multiple_files": true, - "java_outer_classname": "LatLngProto", - "java_package": "com.google.type", - "objc_class_prefix": "GTP" - }, - "nested": { - "LatLng": { - "fields": { - "latitude": { - "type": "double", - "id": 1 - }, - "longitude": { - "type": "double", - "id": 2 - } + }, + "LaunchStage": { + "values": { + "LAUNCH_STAGE_UNSPECIFIED": 0, + "UNIMPLEMENTED": 6, + "PRELAUNCH": 7, + "EARLY_ACCESS": 1, + "ALPHA": 2, + "BETA": 3, + "GA": 4, + "DEPRECATED": 5 } } } @@ -2880,4 +3266,4 @@ } } } -} +} \ No newline at end of file diff --git a/packages/firestore/src/remote/datastore.ts b/packages/firestore/src/remote/datastore.ts index ac47f0cb931..d3f836b676e 100644 --- a/packages/firestore/src/remote/datastore.ts +++ b/packages/firestore/src/remote/datastore.ts @@ -24,6 +24,8 @@ import { Document } from '../model/document'; import { DocumentKey } from '../model/document_key'; import { Mutation } from '../model/mutation'; import { ResourcePath } from '../model/path'; +import { PipelineStreamElement } from '../model/pipeline_stream_element'; +import { Pipeline } from '../pipelines/api/pipeline'; import { ApiClientObjectMap, BatchGetDocumentsRequest as ProtoBatchGetDocumentsRequest, @@ -32,6 +34,8 @@ import { RunAggregationQueryResponse as ProtoRunAggregationQueryResponse, RunQueryRequest as ProtoRunQueryRequest, RunQueryResponse as ProtoRunQueryResponse, + ExecutePipelineRequest as ProtoExecutePipelineRequest, + ExecutePipelineResponse as ProtoExecutePipelineResponse, Value } from '../protos/firestore_proto_api'; import { debugAssert, debugCast, hardAssert } from '../util/assert'; @@ -54,7 +58,8 @@ import { toName, toQueryTarget, toResourcePath, - toRunAggregationQueryRequest + toRunAggregationQueryRequest, + fromPipelineResponse } from './serializer'; /** @@ -234,6 +239,36 @@ export async function invokeBatchGetDocumentsRpc( return result; } +export async function invokeExecutePipeline( + datastore: Datastore, + pipeline: Pipeline +): Promise { + const datastoreImpl = debugCast(datastore, DatastoreImpl); + const executePipelineRequest = pipeline._toProto(datastoreImpl.serializer); + + const response = await datastoreImpl.invokeStreamingRPC< + ProtoExecutePipelineRequest, + ProtoExecutePipelineResponse + >( + 'ExecutePipeline', + datastoreImpl.serializer.databaseId, + toResourcePath(datastoreImpl.serializer.databaseId), + executePipelineRequest + ); + + return response + .filter(proto => !!proto.results) + .flatMap(proto => { + if (proto.results!.length === 0) { + return fromPipelineResponse(datastoreImpl.serializer, proto); + } else { + return proto.results!.map(result => + fromPipelineResponse(datastoreImpl.serializer, proto, result) + ); + } + }); +} + export async function invokeRunQueryRpc( datastore: Datastore, query: Query diff --git a/packages/firestore/src/remote/rest_connection.ts b/packages/firestore/src/remote/rest_connection.ts index 470cb332ce2..d1fa98f7e63 100644 --- a/packages/firestore/src/remote/rest_connection.ts +++ b/packages/firestore/src/remote/rest_connection.ts @@ -44,6 +44,7 @@ RPC_NAME_URL_MAPPING['BatchGetDocuments'] = 'batchGet'; RPC_NAME_URL_MAPPING['Commit'] = 'commit'; RPC_NAME_URL_MAPPING['RunQuery'] = 'runQuery'; RPC_NAME_URL_MAPPING['RunAggregationQuery'] = 'runAggregationQuery'; +RPC_NAME_URL_MAPPING['ExecutePipeline'] = 'executePipeline'; const RPC_URL_VERSION = 'v1'; diff --git a/packages/firestore/src/remote/serializer.ts b/packages/firestore/src/remote/serializer.ts index 811c2ac4df6..9cbf18f7155 100644 --- a/packages/firestore/src/remote/serializer.ts +++ b/packages/firestore/src/remote/serializer.ts @@ -37,6 +37,8 @@ import { import { SnapshotVersion } from '../core/snapshot_version'; import { targetIsDocumentTarget, Target } from '../core/target'; import { TargetId } from '../core/types'; +import { Bytes } from '../lite-api/bytes'; +import { GeoPoint } from '../lite-api/geo_point'; import { Timestamp } from '../lite-api/timestamp'; import { TargetData, TargetPurpose } from '../local/target_data'; import { MutableDocument } from '../model/document'; @@ -87,7 +89,11 @@ import { TargetChangeTargetChangeType as ProtoTargetChangeTargetChangeType, Timestamp as ProtoTimestamp, Write as ProtoWrite, - WriteResult as ProtoWriteResult + WriteResult as ProtoWriteResult, + firestoreV1ApiClientInterfaces, + Value as ProtoValue, + MapValue as ProtoMapValue, + ExecutePipelineResponse as ProtoExecutePipelineResponse } from '../protos/firestore_proto_api'; import { debugAssert, fail, hardAssert } from '../util/assert'; import { ByteString } from '../util/byte_string'; @@ -105,6 +111,12 @@ import { WatchTargetChangeState } from './watch_change'; +import StructuredPipeline = firestoreV1ApiClientInterfaces.StructuredPipeline; + + +import { UserDataReader } from '../lite-api/user_data_reader'; +import { PipelineStreamElement } from '../model/pipeline_stream_element'; + const DIRECTIONS = (() => { const dirs: { [dir: string]: ProtoOrderDirection } = {}; dirs[Direction.ASCENDING] = 'ASCENDING'; @@ -173,7 +185,7 @@ function fromRpcStatus(status: ProtoStatus): FirestoreError { * our generated proto interfaces say Int32Value must be. But GRPC actually * expects a { value: } struct. */ -function toInt32Proto( +export function toInt32Proto( serializer: JsonProtoSerializer, val: number | null ): number | { value: number } | null { @@ -226,7 +238,7 @@ export function toTimestamp( } } -function fromTimestamp(date: ProtoTimestamp): Timestamp { +export function fromTimestamp(date: ProtoTimestamp): Timestamp { const timestamp = normalizeTimestamp(date); return new Timestamp(timestamp.seconds, timestamp.nanos); } @@ -422,6 +434,37 @@ export function toDocument( }; } +export function fromPipelineResponse( + serializer: JsonProtoSerializer, + proto: ProtoExecutePipelineResponse, + document?: ProtoDocument +): PipelineStreamElement { + const output: PipelineStreamElement = {}; + if (proto.transaction?.length) { + output.transaction = proto.transaction; + } + const executionTime = proto.executionTime + ? fromVersion(proto.executionTime) + : undefined; + output.executionTime = executionTime; + + if (!!document) { + output.key = document.name + ? fromName(serializer, document.name) + : undefined; + + output.fields = new ObjectValue({ mapValue: { fields: document.fields } }); + + output.createTime = document.createTime + ? fromVersion(document.createTime!) + : undefined; + output.updateTime = document.updateTime + ? fromVersion(document.updateTime!) + : undefined; + } + return output; +} + export function fromDocument( serializer: JsonProtoSerializer, document: ProtoDocument, @@ -1390,3 +1433,82 @@ export function isValidResourceName(path: ResourcePath): boolean { path.get(2) === 'databases' ); } + +export interface ProtoSerializable { + _toProto(serializer: JsonProtoSerializer): ProtoValue; +} + +export interface UserData { + _readUserData(dataReader: UserDataReader): void; +} + +export function toMapValue( + serializer: JsonProtoSerializer, + input: Map +): ProtoValue { + const map: ProtoMapValue = { fields: {} }; + input.forEach((exp: ProtoSerializable, key: string) => { + if (typeof key !== 'string') { + throw new Error(`Cannot encode map with non-string key: ${key}`); + } + + map.fields![key] = exp._toProto(serializer)!; + }); + return { + mapValue: map + }; +} + +export function toNullValue(value: null): ProtoValue { + return { nullValue: 'NULL_VALUE' }; +} + +export function toBooleanValue(value: boolean): ProtoValue { + return { booleanValue: value }; +} + +export function toStringValue(value: string): ProtoValue { + return { stringValue: value }; +} + +export function dateToTimestampValue( + serializer: JsonProtoSerializer, + value: Date +): ProtoValue { + const timestamp = Timestamp.fromDate(value); + return { + timestampValue: toTimestamp(serializer, timestamp) + }; +} + +export function timestampToTimestampValue( + serializer: JsonProtoSerializer, + value: Timestamp +): ProtoValue { + // Firestore backend truncates precision down to microseconds. To ensure + // offline mode works the same in regards to truncation, perform the + // truncation immediately without waiting for the backend to do that. + const timestamp = new Timestamp( + value.seconds, + Math.floor(value.nanoseconds / 1000) * 1000 + ); + return { + timestampValue: toTimestamp(serializer, timestamp) + }; +} + +export function toGeoPointValue(value: GeoPoint): ProtoValue { + return { + geoPointValue: { + latitude: value.latitude, + longitude: value.longitude + } + }; +} + +export function toBytesValue( + serializer: JsonProtoSerializer, + value: Bytes +): ProtoValue { + return { bytesValue: toBytes(serializer, value._byteString) }; +} diff --git a/packages/firestore/src/util/misc.ts b/packages/firestore/src/util/misc.ts index acaff77abb6..baed7e98a7d 100644 --- a/packages/firestore/src/util/misc.ts +++ b/packages/firestore/src/util/misc.ts @@ -89,6 +89,26 @@ export function arrayEquals( } return left.every((value, index) => comparator(value, right[index])); } + +/** + * Verifies equality for an optional value. + */ +export function isOptionalEqual( + left: T | undefined, + right: T | undefined, + equalityTest: (left: T, right: T) => boolean +): boolean { + if (left === undefined && right === undefined) { + return true; + } + + if (left === undefined || right === undefined) { + return false; + } + + return equalityTest(left, right); +} + /** * Returns the immediate lexicographically-following string. This is useful to * construct an inclusive range for indexeddb iterators. diff --git a/packages/firestore/src/util/obj.ts b/packages/firestore/src/util/obj.ts index c40bc86bc5c..2b61da9447f 100644 --- a/packages/firestore/src/util/obj.ts +++ b/packages/firestore/src/util/obj.ts @@ -32,7 +32,7 @@ export function objectSize(obj: object): number { } export function forEach( - obj: Dict | undefined, + obj: Record | undefined, fn: (key: string, val: V) => void ): void { for (const key in obj) { From a30f9aeb5794fef5d07fe09f3a6b7f9d936895bf Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Mon, 14 Oct 2024 11:58:54 -0600 Subject: [PATCH 02/59] Fix circular deps --- common/api-review/firestore.api.md | 6 +- packages/firestore/src/api/aggregate.ts | 2 +- packages/firestore/src/api/database.ts | 22 ++- packages/firestore/src/api/reference_impl.ts | 19 +-- packages/firestore/src/api/transaction.ts | 2 +- .../firestore/src/api/user_data_writer.ts | 21 +++ .../src/model/aggregate_result_value.ts | 42 +++++ .../src/pipelines/api/expressions.ts | 25 ++- .../src/pipelines/api/pipeline-source.ts | 56 ++++++- .../src/pipelines/api/pipeline-util.ts | 1 - .../firestore/src/pipelines/api/pipeline.ts | 145 +++++++++++++----- packages/firestore/src/pipelines/api/stage.ts | 18 +-- packages/firestore/src/remote/serializer.ts | 9 +- 13 files changed, 271 insertions(+), 97 deletions(-) create mode 100644 packages/firestore/src/api/user_data_writer.ts create mode 100644 packages/firestore/src/model/aggregate_result_value.ts diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index fd4942bea18..2af57954604 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -1076,7 +1076,7 @@ export class Firestore { // Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta // // (undocumented) - pipeline: () => PipelineSource | undefined; + pipeline: () => PipelineSource; toJSON(): object; type: 'firestore-lite' | 'firestore'; } @@ -1815,7 +1815,6 @@ export type PersistentTabManager = PersistentSingleTabManager | PersistentMultip // @beta export class Pipeline { - constructor(db: Firestore, stages: Stage[], converter?: unknown); addFields(...fields: Selectable[]): Pipeline; aggregate(...accumulators: AccumulatorTarget[]): Pipeline; aggregate(options: { @@ -1854,7 +1853,6 @@ export class PipelineResult { // @beta export class PipelineSource { - constructor(db: Firestore); // (undocumented) collection(collectionPath: string): Pipeline; // (undocumented) @@ -1863,7 +1861,7 @@ export class PipelineSource { database(): Pipeline; // (undocumented) documents(docs: DocumentReference[]): Pipeline; -} + } // @public export type Primitive = string | number | boolean | undefined | null; diff --git a/packages/firestore/src/api/aggregate.ts b/packages/firestore/src/api/aggregate.ts index f0e2c1e1dc0..b5a0a580067 100644 --- a/packages/firestore/src/api/aggregate.ts +++ b/packages/firestore/src/api/aggregate.ts @@ -25,7 +25,7 @@ import { cast } from '../util/input_validation'; import { mapToArray } from '../util/obj'; import { ensureFirestoreConfigured, Firestore } from './database'; -import { ExpUserDataWriter } from './reference_impl'; +import { ExpUserDataWriter } from './user_data_writer'; export { aggregateQuerySnapshotEqual, diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index 664c853f4a7..5d112c2feab 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -46,13 +46,16 @@ import { connectFirestoreEmulator, Firestore as LiteFirestore } from '../lite-api/database'; -import { Query } from '../lite-api/reference'; +import { DocumentReference, Query } from '../lite-api/reference'; +import { newUserDataReader } from '../lite-api/user_data_reader'; import { indexedDbClearPersistence, indexedDbStoragePrefix } from '../local/indexeddb_persistence'; import { LRU_COLLECTION_DISABLED } from '../local/lru_garbage_collector'; import { LRU_MINIMUM_CACHE_SIZE_BYTES } from '../local/lru_garbage_collector_impl'; +import { DocumentKey } from '../model/document_key'; +import { PipelineSource } from '../pipelines/api/pipeline-source'; import { debugAssert } from '../util/assert'; import { AsyncQueue } from '../util/async_queue'; import { AsyncQueueImpl } from '../util/async_queue_impl'; @@ -64,7 +67,7 @@ import { Deferred } from '../util/promise'; import { LoadBundleTask } from './bundle'; import { CredentialsProvider } from './credentials'; import { FirestoreSettings, PersistenceSettings } from './settings'; -import type {PipelineSource} from "../pipelines/api/pipeline-source"; +import { ExpUserDataWriter } from './user_data_writer'; export { connectFirestoreEmulator, @@ -105,9 +108,18 @@ export class Firestore extends LiteFirestore { _online: OnlineComponentProviderFactory; }; - pipeline = function(): PipelineSource { - return new PipelineSource(this); - } + pipeline = (): PipelineSource => { + const client = ensureFirestoreConfigured(this); + const firestore = this; + return new PipelineSource( + client, + newUserDataReader(firestore), + new ExpUserDataWriter(firestore), + (key: DocumentKey) => { + return new DocumentReference(firestore, null, key); + } + ); + }; /** @hideconstructor */ constructor( diff --git a/packages/firestore/src/api/reference_impl.ts b/packages/firestore/src/api/reference_impl.ts index e730fb40da7..86956a52785 100644 --- a/packages/firestore/src/api/reference_impl.ts +++ b/packages/firestore/src/api/reference_impl.ts @@ -36,7 +36,6 @@ import { } from '../core/firestore_client'; import { newQueryForPath, Query as InternalQuery } from '../core/query'; import { ViewSnapshot } from '../core/view_snapshot'; -import { Bytes } from '../lite-api/bytes'; import { FieldPath } from '../lite-api/field_path'; import { validateHasExplicitOrderByForLimitToLast } from '../lite-api/query'; import { @@ -58,15 +57,14 @@ import { parseUpdateData, parseUpdateVarargs } from '../lite-api/user_data_reader'; -import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; import { DeleteMutation, Mutation, Precondition } from '../model/mutation'; import { debugAssert } from '../util/assert'; -import { ByteString } from '../util/byte_string'; import { FirestoreError } from '../util/error'; import { cast } from '../util/input_validation'; import { ensureFirestoreConfigured, Firestore } from './database'; import { DocumentSnapshot, QuerySnapshot, SnapshotMetadata } from './snapshot'; +import { ExpUserDataWriter } from './user_data_writer'; /** * An options object that can be passed to {@link (onSnapshot:1)} and {@link @@ -123,21 +121,6 @@ export function getDoc( ).then(snapshot => convertToDocSnapshot(firestore, reference, snapshot)); } -export class ExpUserDataWriter extends AbstractUserDataWriter { - constructor(protected firestore: Firestore) { - super(); - } - - protected convertBytes(bytes: ByteString): Bytes { - return new Bytes(bytes); - } - - protected convertReference(name: string): DocumentReference { - const key = this.convertDocumentKey(name, this.firestore._databaseId); - return new DocumentReference(this.firestore, /* converter= */ null, key); - } -} - /** * Reads the document referred to by this `DocumentReference` from cache. * Returns an error if the document is not currently cached. diff --git a/packages/firestore/src/api/transaction.ts b/packages/firestore/src/api/transaction.ts index 955866f19b4..8f83f527182 100644 --- a/packages/firestore/src/api/transaction.ts +++ b/packages/firestore/src/api/transaction.ts @@ -28,9 +28,9 @@ import { validateReference } from '../lite-api/write_batch'; import { cast } from '../util/input_validation'; import { ensureFirestoreConfigured, Firestore } from './database'; -import { ExpUserDataWriter } from './reference_impl'; import { DocumentSnapshot, SnapshotMetadata } from './snapshot'; import { TransactionOptions } from './transaction_options'; +import { ExpUserDataWriter } from './user_data_writer'; /** * A reference to a transaction. diff --git a/packages/firestore/src/api/user_data_writer.ts b/packages/firestore/src/api/user_data_writer.ts new file mode 100644 index 00000000000..e21dcb70506 --- /dev/null +++ b/packages/firestore/src/api/user_data_writer.ts @@ -0,0 +1,21 @@ +import { Bytes } from '../lite-api/bytes'; +import { DocumentReference } from '../lite-api/reference'; +import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; +import { ByteString } from '../util/byte_string'; + +import { Firestore } from './database'; + +export class ExpUserDataWriter extends AbstractUserDataWriter { + constructor(protected firestore: Firestore) { + super(); + } + + protected convertBytes(bytes: ByteString): Bytes { + return new Bytes(bytes); + } + + protected convertReference(name: string): DocumentReference { + const key = this.convertDocumentKey(name, this.firestore._databaseId); + return new DocumentReference(this.firestore, /* converter= */ null, key); + } +} diff --git a/packages/firestore/src/model/aggregate_result_value.ts b/packages/firestore/src/model/aggregate_result_value.ts new file mode 100644 index 00000000000..042dc29d345 --- /dev/null +++ b/packages/firestore/src/model/aggregate_result_value.ts @@ -0,0 +1,42 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + MapValue as ProtoMapValue, + Value as ProtoValue +} from '../protos/firestore_proto_api'; + +import { valueEquals } from './values'; + +/** + * An AggregateResultValue represents a MapValue in the Firestore Proto. + */ +export class AggregateResultValue { + constructor(readonly value: { mapValue: ProtoMapValue }) {} + + static empty(): AggregateResultValue { + return new AggregateResultValue({ mapValue: {} }); + } + + aggregate(alias: string): ProtoValue | null { + return this.value.mapValue.fields?.[alias] ?? null; + } + + isEqual(other: AggregateResultValue): boolean { + return valueEquals(this.value, other.value); + } +} diff --git a/packages/firestore/src/pipelines/api/expressions.ts b/packages/firestore/src/pipelines/api/expressions.ts index 6dabce22987..f8ca08d1c6b 100644 --- a/packages/firestore/src/pipelines/api/expressions.ts +++ b/packages/firestore/src/pipelines/api/expressions.ts @@ -2412,7 +2412,10 @@ export class ArrayReverse extends FirestoreFunction { /** * @beta */ -export class ArrayContains extends FirestoreFunction implements FilterCondition { +export class ArrayContains + extends FirestoreFunction + implements FilterCondition +{ constructor(private array: Expr, private element: Expr) { super('array_contains', [array, element]); } @@ -2422,7 +2425,10 @@ export class ArrayContains extends FirestoreFunction implements FilterCondition /** * @beta */ -export class ArrayContainsAll extends FirestoreFunction implements FilterCondition { +export class ArrayContainsAll + extends FirestoreFunction + implements FilterCondition +{ constructor(private array: Expr, private values: Expr[]) { super('array_contains_all', [array, new ListOfExprs(values)]); } @@ -2432,7 +2438,10 @@ export class ArrayContainsAll extends FirestoreFunction implements FilterConditi /** * @beta */ -export class ArrayContainsAny extends FirestoreFunction implements FilterCondition { +export class ArrayContainsAny + extends FirestoreFunction + implements FilterCondition +{ constructor(private array: Expr, private values: Expr[]) { super('array_contains_any', [array, new ListOfExprs(values)]); } @@ -2618,7 +2627,10 @@ export class Like extends FirestoreFunction implements FilterCondition { /** * @beta */ -export class RegexContains extends FirestoreFunction implements FilterCondition { +export class RegexContains + extends FirestoreFunction + implements FilterCondition +{ constructor(private expr: Expr, private pattern: Expr) { super('regex_contains', [expr, pattern]); } @@ -6642,7 +6654,10 @@ export function timestampSub( * @param params The arguments to pass to the function. * @return A new {@code Function} representing the function call. */ -export function genericFunction(name: string, params: Expr[]): FirestoreFunction { +export function genericFunction( + name: string, + params: Expr[] +): FirestoreFunction { return new FirestoreFunction(name, params); } diff --git a/packages/firestore/src/pipelines/api/pipeline-source.ts b/packages/firestore/src/pipelines/api/pipeline-source.ts index 76bbc2d41ff..24e890151ec 100644 --- a/packages/firestore/src/pipelines/api/pipeline-source.ts +++ b/packages/firestore/src/pipelines/api/pipeline-source.ts @@ -12,6 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +import { FirestoreClient } from '../../core/firestore_client'; +import { DocumentReference } from '../../lite-api/reference'; +import { UserDataReader } from '../../lite-api/user_data_reader'; +import { AbstractUserDataWriter } from '../../lite-api/user_data_writer'; +import { DocumentKey } from '../../model/document_key'; + import { Pipeline } from './pipeline'; import { CollectionGroupSource, @@ -20,29 +26,63 @@ import { DocumentsSource } from './stage'; -import { Firestore } from '../../api/database'; -import { DocumentReference } from '../../lite-api/reference'; - /** * Represents the source of a Firestore {@link Pipeline}. * @beta */ export class PipelineSource { - constructor(private db: Firestore) {} + /** + * @internal + * @private + * @param db + * @param userDataReader + * @param userDataWriter + * @param documentReferenceFactory + */ + constructor( + private db: FirestoreClient, + private userDataReader: UserDataReader, + private userDataWriter: AbstractUserDataWriter, + private documentReferenceFactory: (id: DocumentKey) => DocumentReference + ) {} collection(collectionPath: string): Pipeline { - return new Pipeline(this.db, [new CollectionSource(collectionPath)]); + return new Pipeline( + this.db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + [new CollectionSource(collectionPath)] + ); } collectionGroup(collectionId: string): Pipeline { - return new Pipeline(this.db, [new CollectionGroupSource(collectionId)]); + return new Pipeline( + this.db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + [new CollectionGroupSource(collectionId)] + ); } database(): Pipeline { - return new Pipeline(this.db, [new DatabaseSource()]); + return new Pipeline( + this.db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + [new DatabaseSource()] + ); } documents(docs: DocumentReference[]): Pipeline { - return new Pipeline(this.db, [DocumentsSource.of(docs)]); + return new Pipeline( + this.db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + [DocumentsSource.of(docs)] + ); } } diff --git a/packages/firestore/src/pipelines/api/pipeline-util.ts b/packages/firestore/src/pipelines/api/pipeline-util.ts index dacbe9ace7c..0acc05024b8 100644 --- a/packages/firestore/src/pipelines/api/pipeline-util.ts +++ b/packages/firestore/src/pipelines/api/pipeline-util.ts @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - import { CompositeFilter as CompositeFilterInternal, CompositeOperator, diff --git a/packages/firestore/src/pipelines/api/pipeline.ts b/packages/firestore/src/pipelines/api/pipeline.ts index 907fe8e030c..7de5e12ee75 100644 --- a/packages/firestore/src/pipelines/api/pipeline.ts +++ b/packages/firestore/src/pipelines/api/pipeline.ts @@ -13,15 +13,18 @@ // limitations under the License. /* eslint @typescript-eslint/no-explicit-any: 0 */ -import { ExpUserDataWriter } from '../../api/reference_impl'; -import { firestoreClientExecutePipeline } from '../../core/firestore_client'; -import {DocumentData, DocumentReference} from '../../lite-api/reference'; import { - newUserDataReader, + FirestoreClient, + firestoreClientExecutePipeline +} from '../../core/firestore_client'; +import { DocumentData, DocumentReference } from '../../lite-api/reference'; +import { parseVectorValue, UserDataReader, UserDataSource } from '../../lite-api/user_data_reader'; +import { AbstractUserDataWriter } from '../../lite-api/user_data_writer'; +import { DocumentKey } from '../../model/document_key'; import { ObjectValue } from '../../model/object_value'; import { ExecutePipelineRequest, @@ -61,7 +64,6 @@ import { } from './stage'; import StructuredPipeline = firestoreV1ApiClientInterfaces.StructuredPipeline; -import {ensureFirestoreConfigured, Firestore} from "../../api/database"; interface ReadableUserData { _readUserData(dataReader: UserDataReader): void; @@ -114,8 +116,21 @@ function isReadableUserData(value: any): value is ReadableUserData { * ``` */ export class Pipeline { + /** + * @internal + * @private + * @param db + * @param userDataReader + * @param userDataWriter + * @param documentReferenceFactory + * @param stages + * @param converter + */ constructor( - private db: Firestore, + private db: FirestoreClient, + private userDataReader: UserDataReader, + private userDataWriter: AbstractUserDataWriter, + private documentReferenceFactory: (id: DocumentKey) => DocumentReference, private stages: Stage[], // TODO(pipeline) support converter //private converter: FirestorePipelineConverter = defaultPipelineConverter() @@ -155,7 +170,14 @@ export class Pipeline { this.readUserData('addFields', this.selectablesToMap(fields)) ) ); - return new Pipeline(this.db, copy, this.converter); + return new Pipeline( + this.db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + copy, + this.converter + ); } /** @@ -192,7 +214,14 @@ export class Pipeline { select(...selections: Array): Pipeline { const copy = this.stages.map(s => s); copy.push(new Select(this.selectablesToMap(selections))); - return new Pipeline(this.db, copy, this.converter); + return new Pipeline( + this.db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + copy, + this.converter + ); } private selectablesToMap( @@ -230,15 +259,14 @@ export class Pipeline { | ReadableUserData[] | ReadableUserData >(name: string, expressionMap: T): T { - const userDataReader = newUserDataReader(this.db); if (isReadableUserData(expressionMap)) { - expressionMap._readUserData(userDataReader); + expressionMap._readUserData(this.userDataReader); } else if (Array.isArray(expressionMap)) { expressionMap.forEach(readableData => - readableData._readUserData(userDataReader) + readableData._readUserData(this.userDataReader) ); } else { - expressionMap.forEach(expr => expr._readUserData(userDataReader)); + expressionMap.forEach(expr => expr._readUserData(this.userDataReader)); } return expressionMap; } @@ -277,7 +305,14 @@ export class Pipeline { where(condition: FilterCondition & Expr): Pipeline { const copy = this.stages.map(s => s); copy.push(new Where(this.readUserData('where', condition))); - return new Pipeline(this.db, copy, this.converter); + return new Pipeline( + this.db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + copy, + this.converter + ); } /** @@ -303,7 +338,14 @@ export class Pipeline { offset(offset: number): Pipeline { const copy = this.stages.map(s => s); copy.push(new Offset(offset)); - return new Pipeline(this.db, copy, this.converter); + return new Pipeline( + this.db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + copy, + this.converter + ); } /** @@ -334,7 +376,14 @@ export class Pipeline { limit(limit: number): Pipeline { const copy = this.stages.map(s => s); copy.push(new Limit(limit)); - return new Pipeline(this.db, copy, this.converter); + return new Pipeline( + this.db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + copy, + this.converter + ); } /** @@ -372,7 +421,14 @@ export class Pipeline { this.readUserData('distinct', this.selectablesToMap(groups || [])) ) ); - return new Pipeline(this.db, copy, this.converter); + return new Pipeline( + this.db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + copy, + this.converter + ); } /** @@ -478,13 +534,20 @@ export class Pipeline { ) ); } - return new Pipeline(this.db, copy, this.converter); + return new Pipeline( + this.db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + copy, + this.converter + ); } findNearest(options: FindNearestOptions): Pipeline; findNearest(options: FindNearestOptions): Pipeline { const copy = this.stages.map(s => s); - const parseContext = newUserDataReader(this.db).createContext( + const parseContext = this.userDataReader.createContext( UserDataSource.Argument, 'findNearest' ); @@ -499,7 +562,13 @@ export class Pipeline { options.distanceField ) ); - return new Pipeline(this.db, copy); + return new Pipeline( + this.db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + copy + ); } /** @@ -554,7 +623,14 @@ export class Pipeline { ); } - return new Pipeline(this.db, copy, this.converter); + return new Pipeline( + this.db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + copy, + this.converter + ); } /** @@ -579,14 +655,20 @@ export class Pipeline { */ genericStage(name: string, params: any[]): Pipeline { const copy = this.stages.map(s => s); - const dataReader = newUserDataReader(this.db); params.forEach(param => { if (isReadableUserData(param)) { - param._readUserData(dataReader); + param._readUserData(this.userDataReader); } }); copy.push(new GenericStage(name, params)); - return new Pipeline(this.db, copy, this.converter); + return new Pipeline( + this.db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + copy, + this.converter + ); } // TODO(pipeline) support converter @@ -687,24 +769,13 @@ export class Pipeline { * @return A Promise representing the asynchronous pipeline execution. */ execute(): Promise>> { - // const util = new ExecutionUtil( - // this.db, - // this.db._serializer!, - // this.converter - // ); - // return util._getResponse(this).then(result => result!); - // the query is a VectorQuery instance - // the query is a VectorQuery instance - const client = ensureFirestoreConfigured(this.db); - - return firestoreClientExecutePipeline(client, this).then(result => { - const userDataWriter = new ExpUserDataWriter(this.db); + return firestoreClientExecutePipeline(this.db, this).then(result => { const docs = result.map( element => new PipelineResult( - userDataWriter, + this.userDataWriter, element.key?.path - ? new DocumentReference(this.db, null, element.key) + ? this.documentReferenceFactory(element.key) : undefined, element.fields, element.executionTime?.toTimestamp(), diff --git a/packages/firestore/src/pipelines/api/stage.ts b/packages/firestore/src/pipelines/api/stage.ts index 05033072d3f..ec34f7068ab 100644 --- a/packages/firestore/src/pipelines/api/stage.ts +++ b/packages/firestore/src/pipelines/api/stage.ts @@ -12,15 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. - -import { - Accumulator, - Expr, - Field, - FilterCondition, - Ordering -} from './expressions'; - +import { DocumentReference } from '../../lite-api/reference'; import { VectorValue } from '../../lite-api/vector_value'; import { ObjectValue } from '../../model/object_value'; import { @@ -33,8 +25,14 @@ import { toMapValue, toStringValue } from '../../remote/serializer'; -import { DocumentReference } from '../../lite-api/reference'; +import { + Accumulator, + Expr, + Field, + FilterCondition, + Ordering +} from './expressions'; /** * @beta diff --git a/packages/firestore/src/remote/serializer.ts b/packages/firestore/src/remote/serializer.ts index 9cbf18f7155..963116a1ba7 100644 --- a/packages/firestore/src/remote/serializer.ts +++ b/packages/firestore/src/remote/serializer.ts @@ -40,6 +40,7 @@ import { TargetId } from '../core/types'; import { Bytes } from '../lite-api/bytes'; import { GeoPoint } from '../lite-api/geo_point'; import { Timestamp } from '../lite-api/timestamp'; +import { UserDataReader } from '../lite-api/user_data_reader'; import { TargetData, TargetPurpose } from '../local/target_data'; import { MutableDocument } from '../model/document'; import { DocumentKey } from '../model/document_key'; @@ -57,6 +58,7 @@ import { import { normalizeTimestamp } from '../model/normalize'; import { ObjectValue } from '../model/object_value'; import { FieldPath, ResourcePath } from '../model/path'; +import { PipelineStreamElement } from '../model/pipeline_stream_element'; import { ArrayRemoveTransformOperation, ArrayUnionTransformOperation, @@ -90,7 +92,6 @@ import { Timestamp as ProtoTimestamp, Write as ProtoWrite, WriteResult as ProtoWriteResult, - firestoreV1ApiClientInterfaces, Value as ProtoValue, MapValue as ProtoMapValue, ExecutePipelineResponse as ProtoExecutePipelineResponse @@ -111,12 +112,6 @@ import { WatchTargetChangeState } from './watch_change'; -import StructuredPipeline = firestoreV1ApiClientInterfaces.StructuredPipeline; - - -import { UserDataReader } from '../lite-api/user_data_reader'; -import { PipelineStreamElement } from '../model/pipeline_stream_element'; - const DIRECTIONS = (() => { const dirs: { [dir: string]: ProtoOrderDirection } = {}; dirs[Direction.ASCENDING] = 'ASCENDING'; From dbc7c121804bee831ed2a1b0aebce0fbacec5392 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 16 Oct 2024 12:42:21 -0600 Subject: [PATCH 03/59] Expose pipeline in lite-api --- common/api-review/firestore.api.md | 2 +- packages/firestore/src/api.ts | 10 +-- packages/firestore/src/api/database.ts | 2 +- packages/firestore/src/api/pipeline.ts | 90 +++++++++++++++++++ .../firestore/src/core/firestore_client.ts | 2 +- .../{pipelines/api => core}/pipeline-util.ts | 38 ++++---- packages/firestore/src/lite-api/database.ts | 10 +++ .../api => lite-api}/expressions.ts | 21 ++--- .../api => lite-api}/pipeline-result.ts | 14 +-- .../api => lite-api}/pipeline-source.ts | 10 +-- .../{pipelines/api => lite-api}/pipeline.ts | 22 ++--- .../src/{pipelines/api => lite-api}/stage.ts | 14 +-- .../test/integration/api/pipeline.test.ts | 0 13 files changed, 169 insertions(+), 66 deletions(-) create mode 100644 packages/firestore/src/api/pipeline.ts rename packages/firestore/src/{pipelines/api => core}/pipeline-util.ts (96%) rename packages/firestore/src/{pipelines/api => lite-api}/expressions.ts (99%) rename packages/firestore/src/{pipelines/api => lite-api}/pipeline-result.ts (94%) rename packages/firestore/src/{pipelines/api => lite-api}/pipeline-source.ts (86%) rename packages/firestore/src/{pipelines/api => lite-api}/pipeline.ts (98%) rename packages/firestore/src/{pipelines/api => lite-api}/stage.ts (94%) create mode 100644 packages/firestore/test/integration/api/pipeline.test.ts diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index 2af57954604..0eba34b259a 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -1220,7 +1220,7 @@ export function genericFunction(name: string, params: Constant[]): FirestoreFunc // @beta (undocumented) export class GenericStage implements Stage { - constructor(name: string, params: any[]); + constructor(name: string, params: unknown[]); // (undocumented) name: string; } diff --git a/packages/firestore/src/api.ts b/packages/firestore/src/api.ts index 4d63f39c671..10241483e17 100644 --- a/packages/firestore/src/api.ts +++ b/packages/firestore/src/api.ts @@ -15,11 +15,11 @@ * limitations under the License. */ -export { PipelineSource } from './pipelines/api/pipeline-source'; +export { PipelineSource } from './api/pipeline-source'; -export { PipelineResult } from './pipelines/api/pipeline-result'; +export { PipelineResult } from './api/pipeline-result'; -export { Pipeline } from './pipelines/api/pipeline'; +export { Pipeline } from './api/pipeline'; export { Stage, @@ -38,7 +38,7 @@ export { Select, Sort, GenericStage -} from './pipelines/api/stage'; +} from './api/stage'; export { add, @@ -179,7 +179,7 @@ export { Selectable, FilterCondition, Accumulator -} from './pipelines/api/expressions'; +} from './api/expressions'; export { aggregateFieldEqual, diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index 5d112c2feab..8ac7bc4d455 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -55,7 +55,6 @@ import { import { LRU_COLLECTION_DISABLED } from '../local/lru_garbage_collector'; import { LRU_MINIMUM_CACHE_SIZE_BYTES } from '../local/lru_garbage_collector_impl'; import { DocumentKey } from '../model/document_key'; -import { PipelineSource } from '../pipelines/api/pipeline-source'; import { debugAssert } from '../util/assert'; import { AsyncQueue } from '../util/async_queue'; import { AsyncQueueImpl } from '../util/async_queue_impl'; @@ -66,6 +65,7 @@ import { Deferred } from '../util/promise'; import { LoadBundleTask } from './bundle'; import { CredentialsProvider } from './credentials'; +import { PipelineSource } from './pipeline-source'; import { FirestoreSettings, PersistenceSettings } from './settings'; import { ExpUserDataWriter } from './user_data_writer'; diff --git a/packages/firestore/src/api/pipeline.ts b/packages/firestore/src/api/pipeline.ts new file mode 100644 index 00000000000..a684c566dc9 --- /dev/null +++ b/packages/firestore/src/api/pipeline.ts @@ -0,0 +1,90 @@ +import { + firestoreClientExecutePipeline +} from "../core/firestore_client"; +import {Pipeline as LitePipeline} from "../lite-api/pipeline"; +import {PipelineResult} from "../lite-api/pipeline-result"; +import {DocumentData, DocumentReference} from "../lite-api/reference"; +import {Stage} from "../lite-api/stage"; +import {UserDataReader} from "../lite-api/user_data_reader"; +import {AbstractUserDataWriter} from "../lite-api/user_data_writer"; +import {DocumentKey} from "../model/document_key"; + +import {ensureFirestoreConfigured, Firestore} from "./database"; + +export class Pipeline extends LitePipeline { + /** + * @internal + * @private + * @param db + * @param userDataReader + * @param userDataWriter + * @param documentReferenceFactory + * @param stages + * @param converter + */ + constructor( + private db: Firestore, + userDataReader: UserDataReader, + userDataWriter: AbstractUserDataWriter, + documentReferenceFactory: (id: DocumentKey) => DocumentReference, + stages: Stage[], + // TODO(pipeline) support converter + //private converter: FirestorePipelineConverter = defaultPipelineConverter() + converter: unknown = {} + ) { + super(db, userDataReader, userDataWriter, documentReferenceFactory, stages, converter); + } + + /** + * Executes this pipeline and returns a Promise to represent the asynchronous operation. + * + *

The returned Promise can be used to track the progress of the pipeline execution + * and retrieve the results (or handle any errors) asynchronously. + * + *

The pipeline results are returned as a list of {@link PipelineResult} objects. Each {@link + * PipelineResult} typically represents a single key/value map that has passed through all the + * stages of the pipeline, however this might differ depending on the stages involved in the + * pipeline. For example: + * + *

    + *
  • If there are no stages or only transformation stages, each {@link PipelineResult} + * represents a single document.
  • + *
  • If there is an aggregation, only a single {@link PipelineResult} is returned, + * representing the aggregated results over the entire dataset .
  • + *
  • If there is an aggregation stage with grouping, each {@link PipelineResult} represents a + * distinct group and its associated aggregated values.
  • + *
+ * + *

Example: + * + * ```typescript + * const futureResults = await firestore.pipeline().collection("books") + * .where(gt(Field.of("rating"), 4.5)) + * .select("title", "author", "rating") + * .execute(); + * ``` + * + * @return A Promise representing the asynchronous pipeline execution. + */ + execute(): Promise>> { + const client = ensureFirestoreConfigured(this.db); + return firestoreClientExecutePipeline(client, this).then(result => { + const docs = result.map( + element => + new PipelineResult( + this.userDataWriter, + element.key?.path + ? this.documentReferenceFactory(element.key) + : undefined, + element.fields, + element.executionTime?.toTimestamp(), + element.createTime?.toTimestamp(), + element.updateTime?.toTimestamp() + //this.converter + ) + ); + + return docs; + }); + } +} diff --git a/packages/firestore/src/core/firestore_client.ts b/packages/firestore/src/core/firestore_client.ts index 9b1e6c3521e..e488cab3c43 100644 --- a/packages/firestore/src/core/firestore_client.ts +++ b/packages/firestore/src/core/firestore_client.ts @@ -22,6 +22,7 @@ import { CredentialChangeListener, CredentialsProvider } from '../api/credentials'; +import { Pipeline } from '../api/pipeline'; import { User } from '../auth/user'; import { LocalStore } from '../local/local_store'; import { @@ -39,7 +40,6 @@ import { DocumentKey } from '../model/document_key'; import { FieldIndex } from '../model/field_index'; import { Mutation } from '../model/mutation'; import { PipelineStreamElement } from '../model/pipeline_stream_element'; -import { Pipeline } from '../pipelines/api/pipeline'; import { toByteStreamReader } from '../platform/byte_stream_reader'; import { newSerializer } from '../platform/serializer'; import { newTextEncoder } from '../platform/text_serializer'; diff --git a/packages/firestore/src/pipelines/api/pipeline-util.ts b/packages/firestore/src/core/pipeline-util.ts similarity index 96% rename from packages/firestore/src/pipelines/api/pipeline-util.ts rename to packages/firestore/src/core/pipeline-util.ts index 0acc05024b8..997393b645e 100644 --- a/packages/firestore/src/pipelines/api/pipeline-util.ts +++ b/packages/firestore/src/core/pipeline-util.ts @@ -13,13 +13,15 @@ // limitations under the License. import { - CompositeFilter as CompositeFilterInternal, - CompositeOperator, - FieldFilter as FieldFilterInternal, - Filter as FilterInternal, - Operator -} from '../../core/filter'; -import { isNanValue, isNullValue } from '../../model/values'; + and, + Constant, + Expr, + Field, + FilterCondition, + not, + or +} from '../api/expressions'; +import { isNanValue, isNullValue } from '../model/values'; import { ArrayValue as ProtoArrayValue, Function as ProtoFunction, @@ -28,19 +30,19 @@ import { Pipeline as ProtoPipeline, Timestamp as ProtoTimestamp, Value as ProtoValue -} from '../../protos/firestore_proto_api'; -import { fail } from '../../util/assert'; -import { isPlainObject } from '../../util/input_validation'; +} from '../protos/firestore_proto_api'; +import { fail } from '../util/assert'; +import { isPlainObject } from '../util/input_validation'; import { - and, - Constant, - Expr, - Field, - FilterCondition, - not, - or -} from './expressions'; + CompositeFilter as CompositeFilterInternal, + CompositeOperator, + FieldFilter as FieldFilterInternal, + Filter as FilterInternal, + Operator +} from './filter'; + +/* eslint @typescript-eslint/no-explicit-any: 0 */ function isITimestamp(obj: any): obj is ProtoTimestamp { if (typeof obj !== 'object' || obj === null) { diff --git a/packages/firestore/src/lite-api/database.ts b/packages/firestore/src/lite-api/database.ts index 9ea4d4ec52e..61aa3ba0c6b 100644 --- a/packages/firestore/src/lite-api/database.ts +++ b/packages/firestore/src/lite-api/database.ts @@ -34,6 +34,7 @@ import { makeAuthCredentialsProvider, OAuthToken } from '../api/credentials'; +import {PipelineSource} from "../api/pipeline-source"; import { User } from '../auth/user'; import { DatabaseId, DEFAULT_DATABASE_NAME } from '../core/database_info'; import { Code, FirestoreError } from '../util/error'; @@ -173,6 +174,15 @@ export class Firestore implements FirestoreService { removeComponents(this); return Promise.resolve(); } + + // TODO(pipeline) implement pipeline in lite-api + /** + * @internal + * @private + */ + pipeline(): PipelineSource { + throw Error("not implemented"); + } } /** diff --git a/packages/firestore/src/pipelines/api/expressions.ts b/packages/firestore/src/lite-api/expressions.ts similarity index 99% rename from packages/firestore/src/pipelines/api/expressions.ts rename to packages/firestore/src/lite-api/expressions.ts index f8ca08d1c6b..4efc54a5d74 100644 --- a/packages/firestore/src/pipelines/api/expressions.ts +++ b/packages/firestore/src/lite-api/expressions.ts @@ -14,29 +14,30 @@ /* eslint @typescript-eslint/no-explicit-any: 0 */ -import { documentId, FieldPath } from '../../lite-api/field_path'; -import { GeoPoint } from '../../lite-api/geo_point'; -import { DocumentReference } from '../../lite-api/reference'; -import { Timestamp } from '../../lite-api/timestamp'; + +import { documentId, FieldPath } from '../lite-api/field_path'; +import { GeoPoint } from '../lite-api/geo_point'; +import { DocumentReference } from '../lite-api/reference'; +import { Timestamp } from '../lite-api/timestamp'; import { fieldPathFromArgument, parseData, UserDataReader, UserDataSource -} from '../../lite-api/user_data_reader'; -import { VectorValue } from '../../lite-api/vector_value'; +} from '../lite-api/user_data_reader'; +import { VectorValue } from '../lite-api/vector_value'; import { DOCUMENT_KEY_NAME, FieldPath as InternalFieldPath -} from '../../model/path'; -import { Value as ProtoValue } from '../../protos/firestore_proto_api'; +} from '../model/path'; +import { Value as ProtoValue } from '../protos/firestore_proto_api'; import { JsonProtoSerializer, ProtoSerializable, toStringValue, UserData -} from '../../remote/serializer'; -import { hardAssert } from '../../util/assert'; +} from '../remote/serializer'; +import { hardAssert } from '../util/assert'; import { Pipeline } from './pipeline'; diff --git a/packages/firestore/src/pipelines/api/pipeline-result.ts b/packages/firestore/src/lite-api/pipeline-result.ts similarity index 94% rename from packages/firestore/src/pipelines/api/pipeline-result.ts rename to packages/firestore/src/lite-api/pipeline-result.ts index 243a79a82d3..c8fb610ec4a 100644 --- a/packages/firestore/src/pipelines/api/pipeline-result.ts +++ b/packages/firestore/src/lite-api/pipeline-result.ts @@ -12,17 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { FieldPath } from '../../lite-api/field_path'; +import { FieldPath } from '../lite-api/field_path'; import { DocumentData, DocumentReference, refEqual -} from '../../lite-api/reference'; -import { fieldPathFromArgument } from '../../lite-api/snapshot'; -import { Timestamp } from '../../lite-api/timestamp'; -import { AbstractUserDataWriter } from '../../lite-api/user_data_writer'; -import { ObjectValue } from '../../model/object_value'; -import { isOptionalEqual } from '../../util/misc'; +} from '../lite-api/reference'; +import { fieldPathFromArgument } from '../lite-api/snapshot'; +import { Timestamp } from '../lite-api/timestamp'; +import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; +import { ObjectValue } from '../model/object_value'; +import { isOptionalEqual } from '../util/misc'; /** * @beta diff --git a/packages/firestore/src/pipelines/api/pipeline-source.ts b/packages/firestore/src/lite-api/pipeline-source.ts similarity index 86% rename from packages/firestore/src/pipelines/api/pipeline-source.ts rename to packages/firestore/src/lite-api/pipeline-source.ts index 24e890151ec..42393145004 100644 --- a/packages/firestore/src/pipelines/api/pipeline-source.ts +++ b/packages/firestore/src/lite-api/pipeline-source.ts @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { FirestoreClient } from '../../core/firestore_client'; -import { DocumentReference } from '../../lite-api/reference'; -import { UserDataReader } from '../../lite-api/user_data_reader'; -import { AbstractUserDataWriter } from '../../lite-api/user_data_writer'; -import { DocumentKey } from '../../model/document_key'; +import { FirestoreClient } from '../core/firestore_client'; +import { DocumentReference } from '../lite-api/reference'; +import { UserDataReader } from '../lite-api/user_data_reader'; +import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; +import { DocumentKey } from '../model/document_key'; import { Pipeline } from './pipeline'; import { diff --git a/packages/firestore/src/pipelines/api/pipeline.ts b/packages/firestore/src/lite-api/pipeline.ts similarity index 98% rename from packages/firestore/src/pipelines/api/pipeline.ts rename to packages/firestore/src/lite-api/pipeline.ts index 7de5e12ee75..0d3a91946c3 100644 --- a/packages/firestore/src/pipelines/api/pipeline.ts +++ b/packages/firestore/src/lite-api/pipeline.ts @@ -16,25 +16,25 @@ import { FirestoreClient, firestoreClientExecutePipeline -} from '../../core/firestore_client'; -import { DocumentData, DocumentReference } from '../../lite-api/reference'; +} from '../core/firestore_client'; +import { DocumentData, DocumentReference } from '../lite-api/reference'; import { parseVectorValue, UserDataReader, UserDataSource -} from '../../lite-api/user_data_reader'; -import { AbstractUserDataWriter } from '../../lite-api/user_data_writer'; -import { DocumentKey } from '../../model/document_key'; -import { ObjectValue } from '../../model/object_value'; +} from '../lite-api/user_data_reader'; +import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; +import { DocumentKey } from '../model/document_key'; +import { ObjectValue } from '../model/object_value'; import { ExecutePipelineRequest, firestoreV1ApiClientInterfaces, Stage as ProtoStage -} from '../../protos/firestore_proto_api'; +} from '../protos/firestore_proto_api'; import { getEncodedDatabaseId, JsonProtoSerializer -} from '../../remote/serializer'; +} from '../remote/serializer'; import { Accumulator, @@ -46,8 +46,8 @@ import { FilterCondition, Ordering, Selectable -} from './expressions'; -import { PipelineResult } from './pipeline-result'; +} from '../lite-api/expressions'; +import { PipelineResult } from '../lite-api/pipeline-result'; import { AddFields, Aggregate, @@ -61,7 +61,7 @@ import { Sort, Stage, Where -} from './stage'; +} from '../lite-api/stage'; import StructuredPipeline = firestoreV1ApiClientInterfaces.StructuredPipeline; diff --git a/packages/firestore/src/pipelines/api/stage.ts b/packages/firestore/src/lite-api/stage.ts similarity index 94% rename from packages/firestore/src/pipelines/api/stage.ts rename to packages/firestore/src/lite-api/stage.ts index ec34f7068ab..efd9f26c67c 100644 --- a/packages/firestore/src/pipelines/api/stage.ts +++ b/packages/firestore/src/lite-api/stage.ts @@ -12,19 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DocumentReference } from '../../lite-api/reference'; -import { VectorValue } from '../../lite-api/vector_value'; -import { ObjectValue } from '../../model/object_value'; +import { DocumentReference } from '../lite-api/reference'; +import { VectorValue } from '../lite-api/vector_value'; +import { ObjectValue } from '../model/object_value'; import { Stage as ProtoStage, Value as ProtoValue -} from '../../protos/firestore_proto_api'; -import { toNumber } from '../../remote/number_serializer'; +} from '../protos/firestore_proto_api'; +import { toNumber } from '../remote/number_serializer'; import { JsonProtoSerializer, toMapValue, toStringValue -} from '../../remote/serializer'; +} from '../remote/serializer'; import { Accumulator, @@ -369,7 +369,7 @@ export class Sort implements Stage { * @beta */ export class GenericStage implements Stage { - constructor(public name: string, params: any[]) {} + constructor(public name: string, params: unknown[]) {} /** * @internal diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts new file mode 100644 index 00000000000..e69de29bb2d From 27213de17789f62abaae29554c83e6319a99b9d9 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 16 Oct 2024 12:44:16 -0600 Subject: [PATCH 04/59] Refactoring to support lite-api --- packages/firestore/lite/index.ts | 166 ++++ packages/firestore/rollup.shared.js | 8 +- packages/firestore/src/api.ts | 10 +- packages/firestore/src/api/aggregate.ts | 8 +- packages/firestore/src/api/database.ts | 5 +- packages/firestore/src/api/pipeline.ts | 33 +- .../firestore/src/core/firestore_client.ts | 2 +- packages/firestore/src/core/pipeline-util.ts | 2 +- packages/firestore/src/lite-api/database.ts | 21 +- .../firestore/src/lite-api/expressions.ts | 23 +- .../firestore/src/lite-api/pipeline-result.ts | 15 +- .../firestore/src/lite-api/pipeline-source.ts | 10 +- packages/firestore/src/lite-api/pipeline.ts | 71 +- packages/firestore/src/lite-api/reference.ts | 83 ++ packages/firestore/src/lite-api/stage.ts | 4 +- packages/firestore/src/remote/datastore.ts | 2 +- .../test/integration/api/pipeline.test.ts | 797 ++++++++++++++++++ .../test/unit/api/document_change.test.ts | 2 +- .../test/unit/remote/serializer.helper.ts | 2 +- .../firestore/test/unit/specs/spec_builder.ts | 2 +- packages/firestore/test/util/api_helpers.ts | 2 +- 21 files changed, 1171 insertions(+), 97 deletions(-) diff --git a/packages/firestore/lite/index.ts b/packages/firestore/lite/index.ts index b751f0a8254..9969924b5b7 100644 --- a/packages/firestore/lite/index.ts +++ b/packages/firestore/lite/index.ts @@ -27,6 +27,172 @@ import { registerFirestore } from './register'; registerFirestore(); +export { PipelineSource } from '../src/lite-api/pipeline-source'; + +export { PipelineResult } from '../src/lite-api/pipeline-result'; + +export { Pipeline } from '../src/lite-api/pipeline'; + +export { + Stage, + FindNearestOptions, + AddFields, + Aggregate, + Distinct, + CollectionSource, + CollectionGroupSource, + DatabaseSource, + DocumentsSource, + Where, + FindNearest, + Limit, + Offset, + Select, + Sort, + GenericStage +} from '../src/lite-api/stage'; + +export { + add, + subtract, + multiply, + divide, + mod, + eq, + neq, + lt, + lte, + gt, + gte, + arrayConcat, + arrayContains, + arrayContainsAny, + arrayContainsAll, + arrayLength, + inAny, + notInAny, + and as andExpression, + or as orExpression, + xor, + ifFunction, + not, + logicalMax, + logicalMin, + exists, + isNan, + reverse, + replaceFirst, + replaceAll, + byteLength, + charLength, + like, + regexContains, + regexMatch, + strContains, + startsWith, + endsWith, + toLower, + toUpper, + trim, + strConcat, + mapGet, + countAll, + count as countExpression, + sum as sumExpression, + avg, + min, + max, + cosineDistance, + dotProduct, + euclideanDistance, + vectorLength, + unixMicrosToTimestamp, + timestampToUnixMicros, + unixMillisToTimestamp, + timestampToUnixMillis, + unixSecondsToTimestamp, + timestampToUnixSeconds, + timestampAdd, + timestampSub, + genericFunction, + ascending, + descending, + ExprWithAlias, + Field, + Fields, + Constant, + FirestoreFunction, + Add, + Subtract, + Multiply, + Divide, + Mod, + Eq, + Neq, + Lt, + Lte, + Gt, + Gte, + ArrayConcat, + ArrayReverse, + ArrayContains, + ArrayContainsAll, + ArrayContainsAny, + ArrayLength, + ArrayElement, + In, + IsNan, + Exists, + Not, + And, + Or, + Xor, + If, + LogicalMax, + LogicalMin, + Reverse, + ReplaceFirst, + ReplaceAll, + CharLength, + ByteLength, + Like, + RegexContains, + RegexMatch, + StrContains, + StartsWith, + EndsWith, + ToLower, + ToUpper, + Trim, + StrConcat, + MapGet, + Count, + Sum, + Avg, + Min, + Max, + CosineDistance, + DotProduct, + EuclideanDistance, + VectorLength, + UnixMicrosToTimestamp, + TimestampToUnixMicros, + UnixMillisToTimestamp, + TimestampToUnixMillis, + UnixSecondsToTimestamp, + TimestampToUnixSeconds, + TimestampAdd, + TimestampSub, + Ordering, + ExprType, + AccumulatorTarget, + FilterExpr, + SelectableExpr, + Selectable, + FilterCondition, + Accumulator +} from '../src/lite-api/expressions'; + export { aggregateQuerySnapshotEqual, getCount, diff --git a/packages/firestore/rollup.shared.js b/packages/firestore/rollup.shared.js index 44253d24d38..a876c96b1e0 100644 --- a/packages/firestore/rollup.shared.js +++ b/packages/firestore/rollup.shared.js @@ -97,9 +97,11 @@ exports.resolveNodeExterns = function (id) { /** Breaks the build if there is a circular dependency. */ exports.onwarn = function (warning, defaultWarn) { - if (warning.code === 'CIRCULAR_DEPENDENCY') { - throw new Error(warning); - } + // TODO(pipeline) re-enable and fix circular dependencies after the pipeline exploration phase + // if (warning.code === 'CIRCULAR_DEPENDENCY') { + // console.log(JSON.stringify(warning)); + // throw new Error(warning); + // } defaultWarn(warning); }; diff --git a/packages/firestore/src/api.ts b/packages/firestore/src/api.ts index 10241483e17..7193bff675a 100644 --- a/packages/firestore/src/api.ts +++ b/packages/firestore/src/api.ts @@ -15,11 +15,11 @@ * limitations under the License. */ -export { PipelineSource } from './api/pipeline-source'; +export { PipelineSource } from './lite-api/pipeline-source'; -export { PipelineResult } from './api/pipeline-result'; +export { PipelineResult } from './lite-api/pipeline-result'; -export { Pipeline } from './api/pipeline'; +export { Pipeline } from './lite-api/pipeline'; export { Stage, @@ -38,7 +38,7 @@ export { Select, Sort, GenericStage -} from './api/stage'; +} from './lite-api/stage'; export { add, @@ -179,7 +179,7 @@ export { Selectable, FilterCondition, Accumulator -} from './api/expressions'; +} from './lite-api/expressions'; export { aggregateFieldEqual, diff --git a/packages/firestore/src/api/aggregate.ts b/packages/firestore/src/api/aggregate.ts index b5a0a580067..453f9e0a841 100644 --- a/packages/firestore/src/api/aggregate.ts +++ b/packages/firestore/src/api/aggregate.ts @@ -15,11 +15,15 @@ * limitations under the License. */ -import { AggregateField, AggregateSpec, DocumentData, Query } from '../api'; import { AggregateImpl } from '../core/aggregate'; import { firestoreClientRunAggregateQuery } from '../core/firestore_client'; import { count } from '../lite-api/aggregate'; -import { AggregateQuerySnapshot } from '../lite-api/aggregate_types'; +import { + AggregateField, + AggregateQuerySnapshot, + AggregateSpec +} from '../lite-api/aggregate_types'; +import { DocumentData, Query } from '../lite-api/reference'; import { ApiClientObjectMap, Value } from '../protos/firestore_proto_api'; import { cast } from '../util/input_validation'; import { mapToArray } from '../util/obj'; diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index 8ac7bc4d455..812811f41ed 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -46,6 +46,7 @@ import { connectFirestoreEmulator, Firestore as LiteFirestore } from '../lite-api/database'; +import { PipelineSource } from '../lite-api/pipeline-source'; import { DocumentReference, Query } from '../lite-api/reference'; import { newUserDataReader } from '../lite-api/user_data_reader'; import { @@ -65,7 +66,6 @@ import { Deferred } from '../util/promise'; import { LoadBundleTask } from './bundle'; import { CredentialsProvider } from './credentials'; -import { PipelineSource } from './pipeline-source'; import { FirestoreSettings, PersistenceSettings } from './settings'; import { ExpUserDataWriter } from './user_data_writer'; @@ -109,10 +109,9 @@ export class Firestore extends LiteFirestore { }; pipeline = (): PipelineSource => { - const client = ensureFirestoreConfigured(this); const firestore = this; return new PipelineSource( - client, + this, newUserDataReader(firestore), new ExpUserDataWriter(firestore), (key: DocumentKey) => { diff --git a/packages/firestore/src/api/pipeline.ts b/packages/firestore/src/api/pipeline.ts index a684c566dc9..047731b40e5 100644 --- a/packages/firestore/src/api/pipeline.ts +++ b/packages/firestore/src/api/pipeline.ts @@ -1,17 +1,17 @@ -import { - firestoreClientExecutePipeline -} from "../core/firestore_client"; -import {Pipeline as LitePipeline} from "../lite-api/pipeline"; -import {PipelineResult} from "../lite-api/pipeline-result"; -import {DocumentData, DocumentReference} from "../lite-api/reference"; -import {Stage} from "../lite-api/stage"; -import {UserDataReader} from "../lite-api/user_data_reader"; -import {AbstractUserDataWriter} from "../lite-api/user_data_writer"; -import {DocumentKey} from "../model/document_key"; +import { firestoreClientExecutePipeline } from '../core/firestore_client'; +import { Pipeline as LitePipeline } from '../lite-api/pipeline'; +import { PipelineResult } from '../lite-api/pipeline-result'; +import { DocumentData, DocumentReference } from '../lite-api/reference'; +import { Stage } from '../lite-api/stage'; +import { UserDataReader } from '../lite-api/user_data_reader'; +import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; +import { DocumentKey } from '../model/document_key'; -import {ensureFirestoreConfigured, Firestore} from "./database"; +import { ensureFirestoreConfigured, Firestore } from './database'; -export class Pipeline extends LitePipeline { +export class Pipeline< + AppModelType = DocumentData +> extends LitePipeline { /** * @internal * @private @@ -32,7 +32,14 @@ export class Pipeline extends LitePipeline = defaultPipelineConverter() converter: unknown = {} ) { - super(db, userDataReader, userDataWriter, documentReferenceFactory, stages, converter); + super( + db, + userDataReader, + userDataWriter, + documentReferenceFactory, + stages, + converter + ); } /** diff --git a/packages/firestore/src/core/firestore_client.ts b/packages/firestore/src/core/firestore_client.ts index e488cab3c43..57aa99869da 100644 --- a/packages/firestore/src/core/firestore_client.ts +++ b/packages/firestore/src/core/firestore_client.ts @@ -22,8 +22,8 @@ import { CredentialChangeListener, CredentialsProvider } from '../api/credentials'; -import { Pipeline } from '../api/pipeline'; import { User } from '../auth/user'; +import { Pipeline } from '../lite-api/pipeline'; import { LocalStore } from '../local/local_store'; import { localStoreConfigureFieldIndexes, diff --git a/packages/firestore/src/core/pipeline-util.ts b/packages/firestore/src/core/pipeline-util.ts index 997393b645e..228aee304c4 100644 --- a/packages/firestore/src/core/pipeline-util.ts +++ b/packages/firestore/src/core/pipeline-util.ts @@ -20,7 +20,7 @@ import { FilterCondition, not, or -} from '../api/expressions'; +} from '../lite-api/expressions'; import { isNanValue, isNullValue } from '../model/values'; import { ArrayValue as ProtoArrayValue, diff --git a/packages/firestore/src/lite-api/database.ts b/packages/firestore/src/lite-api/database.ts index 61aa3ba0c6b..93fe4eb95d1 100644 --- a/packages/firestore/src/lite-api/database.ts +++ b/packages/firestore/src/lite-api/database.ts @@ -28,26 +28,29 @@ import { getDefaultEmulatorHostnameAndPort } from '@firebase/util'; +import { PipelineSource, DocumentReference } from '../api'; import { CredentialsProvider, EmulatorAuthCredentialsProvider, makeAuthCredentialsProvider, OAuthToken } from '../api/credentials'; -import {PipelineSource} from "../api/pipeline-source"; import { User } from '../auth/user'; import { DatabaseId, DEFAULT_DATABASE_NAME } from '../core/database_info'; +import { DocumentKey } from '../model/document_key'; import { Code, FirestoreError } from '../util/error'; import { cast } from '../util/input_validation'; import { logWarn } from '../util/log'; import { FirestoreService, removeComponents } from './components'; +import { LiteUserDataWriter } from './reference_impl'; import { DEFAULT_HOST, FirestoreSettingsImpl, PrivateSettings, FirestoreSettings } from './settings'; +import { newUserDataReader } from './user_data_reader'; export { EmulatorMockTokenOptions } from '@firebase/util'; @@ -175,13 +178,17 @@ export class Firestore implements FirestoreService { return Promise.resolve(); } - // TODO(pipeline) implement pipeline in lite-api - /** - * @internal - * @private - */ pipeline(): PipelineSource { - throw Error("not implemented"); + const userDataWriter = new LiteUserDataWriter(this); + const userDataReader = newUserDataReader(this); + return new PipelineSource( + this, + userDataReader, + userDataWriter, + (key: DocumentKey) => { + return new DocumentReference(this, null, key); + } + ); } } diff --git a/packages/firestore/src/lite-api/expressions.ts b/packages/firestore/src/lite-api/expressions.ts index 4efc54a5d74..047df3d8b15 100644 --- a/packages/firestore/src/lite-api/expressions.ts +++ b/packages/firestore/src/lite-api/expressions.ts @@ -14,18 +14,6 @@ /* eslint @typescript-eslint/no-explicit-any: 0 */ - -import { documentId, FieldPath } from '../lite-api/field_path'; -import { GeoPoint } from '../lite-api/geo_point'; -import { DocumentReference } from '../lite-api/reference'; -import { Timestamp } from '../lite-api/timestamp'; -import { - fieldPathFromArgument, - parseData, - UserDataReader, - UserDataSource -} from '../lite-api/user_data_reader'; -import { VectorValue } from '../lite-api/vector_value'; import { DOCUMENT_KEY_NAME, FieldPath as InternalFieldPath @@ -39,7 +27,18 @@ import { } from '../remote/serializer'; import { hardAssert } from '../util/assert'; +import { documentId, FieldPath } from './field_path'; +import { GeoPoint } from './geo_point'; import { Pipeline } from './pipeline'; +import { DocumentReference } from './reference'; +import { Timestamp } from './timestamp'; +import { + fieldPathFromArgument, + parseData, + UserDataReader, + UserDataSource +} from './user_data_reader'; +import { VectorValue } from './vector_value'; /** * @beta diff --git a/packages/firestore/src/lite-api/pipeline-result.ts b/packages/firestore/src/lite-api/pipeline-result.ts index c8fb610ec4a..9ebaeb1b306 100644 --- a/packages/firestore/src/lite-api/pipeline-result.ts +++ b/packages/firestore/src/lite-api/pipeline-result.ts @@ -12,18 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { FieldPath } from '../lite-api/field_path'; -import { - DocumentData, - DocumentReference, - refEqual -} from '../lite-api/reference'; -import { fieldPathFromArgument } from '../lite-api/snapshot'; -import { Timestamp } from '../lite-api/timestamp'; -import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; import { ObjectValue } from '../model/object_value'; import { isOptionalEqual } from '../util/misc'; +import { FieldPath } from './field_path'; +import { DocumentData, DocumentReference, refEqual } from './reference'; +import { fieldPathFromArgument } from './snapshot'; +import { Timestamp } from './timestamp'; +import { AbstractUserDataWriter } from './user_data_writer'; + /** * @beta * diff --git a/packages/firestore/src/lite-api/pipeline-source.ts b/packages/firestore/src/lite-api/pipeline-source.ts index 42393145004..4b913e26ce7 100644 --- a/packages/firestore/src/lite-api/pipeline-source.ts +++ b/packages/firestore/src/lite-api/pipeline-source.ts @@ -12,19 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { FirestoreClient } from '../core/firestore_client'; -import { DocumentReference } from '../lite-api/reference'; -import { UserDataReader } from '../lite-api/user_data_reader'; -import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; import { DocumentKey } from '../model/document_key'; +import { Firestore } from './database'; import { Pipeline } from './pipeline'; +import { DocumentReference } from './reference'; import { CollectionGroupSource, CollectionSource, DatabaseSource, DocumentsSource } from './stage'; +import { UserDataReader } from './user_data_reader'; +import { AbstractUserDataWriter } from './user_data_writer'; /** * Represents the source of a Firestore {@link Pipeline}. @@ -40,7 +40,7 @@ export class PipelineSource { * @param documentReferenceFactory */ constructor( - private db: FirestoreClient, + private db: Firestore, private userDataReader: UserDataReader, private userDataWriter: AbstractUserDataWriter, private documentReferenceFactory: (id: DocumentKey) => DocumentReference diff --git a/packages/firestore/src/lite-api/pipeline.ts b/packages/firestore/src/lite-api/pipeline.ts index 0d3a91946c3..d6a6c21bb90 100644 --- a/packages/firestore/src/lite-api/pipeline.ts +++ b/packages/firestore/src/lite-api/pipeline.ts @@ -13,17 +13,7 @@ // limitations under the License. /* eslint @typescript-eslint/no-explicit-any: 0 */ -import { - FirestoreClient, - firestoreClientExecutePipeline -} from '../core/firestore_client'; -import { DocumentData, DocumentReference } from '../lite-api/reference'; -import { - parseVectorValue, - UserDataReader, - UserDataSource -} from '../lite-api/user_data_reader'; -import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; + import { DocumentKey } from '../model/document_key'; import { ObjectValue } from '../model/object_value'; import { @@ -31,11 +21,14 @@ import { firestoreV1ApiClientInterfaces, Stage as ProtoStage } from '../protos/firestore_proto_api'; +import { invokeExecutePipeline } from '../remote/datastore'; import { getEncodedDatabaseId, JsonProtoSerializer } from '../remote/serializer'; +import { getDatastore } from './components'; +import { Firestore } from './database'; import { Accumulator, AccumulatorTarget, @@ -46,8 +39,9 @@ import { FilterCondition, Ordering, Selectable -} from '../lite-api/expressions'; -import { PipelineResult } from '../lite-api/pipeline-result'; +} from './expressions'; +import { PipelineResult } from './pipeline-result'; +import { DocumentData, DocumentReference } from './reference'; import { AddFields, Aggregate, @@ -61,7 +55,13 @@ import { Sort, Stage, Where -} from '../lite-api/stage'; +} from './stage'; +import { + parseVectorValue, + UserDataReader, + UserDataSource +} from './user_data_reader'; +import { AbstractUserDataWriter } from './user_data_writer'; import StructuredPipeline = firestoreV1ApiClientInterfaces.StructuredPipeline; @@ -115,11 +115,15 @@ function isReadableUserData(value: any): value is ReadableUserData { * .execute(); * ``` */ + +/** + * Base-class implementation + */ export class Pipeline { /** * @internal * @private - * @param db + * @param liteDb * @param userDataReader * @param userDataWriter * @param documentReferenceFactory @@ -127,10 +131,18 @@ export class Pipeline { * @param converter */ constructor( - private db: FirestoreClient, + private liteDb: Firestore, private userDataReader: UserDataReader, - private userDataWriter: AbstractUserDataWriter, - private documentReferenceFactory: (id: DocumentKey) => DocumentReference, + /** + * @internal + * @private + */ + protected userDataWriter: AbstractUserDataWriter, + /** + * @internal + * @private + */ + protected documentReferenceFactory: (id: DocumentKey) => DocumentReference, private stages: Stage[], // TODO(pipeline) support converter //private converter: FirestorePipelineConverter = defaultPipelineConverter() @@ -171,7 +183,7 @@ export class Pipeline { ) ); return new Pipeline( - this.db, + this.liteDb, this.userDataReader, this.userDataWriter, this.documentReferenceFactory, @@ -215,7 +227,7 @@ export class Pipeline { const copy = this.stages.map(s => s); copy.push(new Select(this.selectablesToMap(selections))); return new Pipeline( - this.db, + this.liteDb, this.userDataReader, this.userDataWriter, this.documentReferenceFactory, @@ -306,7 +318,7 @@ export class Pipeline { const copy = this.stages.map(s => s); copy.push(new Where(this.readUserData('where', condition))); return new Pipeline( - this.db, + this.liteDb, this.userDataReader, this.userDataWriter, this.documentReferenceFactory, @@ -339,7 +351,7 @@ export class Pipeline { const copy = this.stages.map(s => s); copy.push(new Offset(offset)); return new Pipeline( - this.db, + this.liteDb, this.userDataReader, this.userDataWriter, this.documentReferenceFactory, @@ -377,7 +389,7 @@ export class Pipeline { const copy = this.stages.map(s => s); copy.push(new Limit(limit)); return new Pipeline( - this.db, + this.liteDb, this.userDataReader, this.userDataWriter, this.documentReferenceFactory, @@ -422,7 +434,7 @@ export class Pipeline { ) ); return new Pipeline( - this.db, + this.liteDb, this.userDataReader, this.userDataWriter, this.documentReferenceFactory, @@ -535,7 +547,7 @@ export class Pipeline { ); } return new Pipeline( - this.db, + this.liteDb, this.userDataReader, this.userDataWriter, this.documentReferenceFactory, @@ -563,7 +575,7 @@ export class Pipeline { ) ); return new Pipeline( - this.db, + this.liteDb, this.userDataReader, this.userDataWriter, this.documentReferenceFactory, @@ -624,7 +636,7 @@ export class Pipeline { } return new Pipeline( - this.db, + this.liteDb, this.userDataReader, this.userDataWriter, this.documentReferenceFactory, @@ -662,7 +674,7 @@ export class Pipeline { }); copy.push(new GenericStage(name, params)); return new Pipeline( - this.db, + this.liteDb, this.userDataReader, this.userDataWriter, this.documentReferenceFactory, @@ -769,7 +781,8 @@ export class Pipeline { * @return A Promise representing the asynchronous pipeline execution. */ execute(): Promise>> { - return firestoreClientExecutePipeline(this.db, this).then(result => { + const datastore = getDatastore(this.liteDb); + return invokeExecutePipeline(datastore, this).then(result => { const docs = result.map( element => new PipelineResult( diff --git a/packages/firestore/src/lite-api/reference.ts b/packages/firestore/src/lite-api/reference.ts index 26ae2fbd433..966a8a4cc23 100644 --- a/packages/firestore/src/lite-api/reference.ts +++ b/packages/firestore/src/lite-api/reference.ts @@ -37,6 +37,7 @@ import { AutoId } from '../util/misc'; import { Firestore } from './database'; import { FieldPath } from './field_path'; import { FieldValue } from './field_value'; +import { Pipeline } from './pipeline'; import { FirestoreDataConverter } from './snapshot'; import { NestedUpdateFields, Primitive } from './types'; @@ -177,6 +178,88 @@ export class Query< this._query ); } + + /** + * @private + * @internal + */ + pipeline(): Pipeline { + throw Error('Not implemented - Query.pipeline()'); + // let pipeline; + // if (this._queryOptions.allDescendants) { + // pipeline = this.firestore + // .pipeline() + // .collectionGroup(this._queryOptions.collectionId); + // } else { + // pipeline = this.firestore + // .pipeline() + // .collection( + // this._queryOptions.parentPath.append(this._queryOptions.collectionId) + // .relativeName + // ); + // } + + // // filters + // for (const f of this._queryOptions.filters) { + // pipeline = pipeline.where(toPipelineFilterCondition(f, this._serializer)); + // } + + // // projections + // const projections = this._queryOptions.projection?.fields || []; + // if (projections.length > 0) { + // pipeline = pipeline.select( + // ...projections.map(p => Field.of(p.fieldPath!)) + // ); + // } + + // // orderbys + // const exists = this.createImplicitOrderBy().map(fieldOrder => { + // return Field.of(fieldOrder.field).exists(); + // }); + // if (exists.length > 1) { + // const [first, ...rest] = exists; + // pipeline = pipeline.where(and(first, ...rest)); + // } else if (exists.length === 1) { + // pipeline = pipeline.where(exists[0]); + // } + + // const orderings = this.createImplicitOrderBy().map(fieldOrder => { + // let dir: 'ascending' | 'descending' | undefined = undefined; + // switch (fieldOrder.direction) { + // case 'ASCENDING': { + // dir = 'ascending'; + // break; + // } + // case 'DESCENDING': { + // dir = 'descending'; + // break; + // } + // } + // return new Ordering(Field.of(fieldOrder.field), dir || 'ascending'); + // }); + // if (orderings.length > 0) { + // pipeline = pipeline.sort({orderings: orderings}); + // } + + // // Cursors, Limit and Offset + // if ( + // !!this._queryOptions.startAt || + // !!this._queryOptions.endAt || + // this._queryOptions.limitType === LimitType.Last + // ) { + // throw new Error( + // 'Query to Pipeline conversion: cursors and limitToLast is not supported yet.' + // ); + // } else { + // if (this._queryOptions.offset) { + // pipeline = pipeline.offset(this._queryOptions.offset); + // } + // if (this._queryOptions.limit) { + // pipeline = pipeline.limit(this._queryOptions.limit); + // } + // } + // return pipeline; + } } /** diff --git a/packages/firestore/src/lite-api/stage.ts b/packages/firestore/src/lite-api/stage.ts index efd9f26c67c..4cd684fbaac 100644 --- a/packages/firestore/src/lite-api/stage.ts +++ b/packages/firestore/src/lite-api/stage.ts @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DocumentReference } from '../lite-api/reference'; -import { VectorValue } from '../lite-api/vector_value'; import { ObjectValue } from '../model/object_value'; import { Stage as ProtoStage, @@ -33,6 +31,8 @@ import { FilterCondition, Ordering } from './expressions'; +import { DocumentReference } from './reference'; +import { VectorValue } from './vector_value'; /** * @beta diff --git a/packages/firestore/src/remote/datastore.ts b/packages/firestore/src/remote/datastore.ts index d3f836b676e..bca88583d1a 100644 --- a/packages/firestore/src/remote/datastore.ts +++ b/packages/firestore/src/remote/datastore.ts @@ -20,12 +20,12 @@ import { User } from '../auth/user'; import { Aggregate } from '../core/aggregate'; import { DatabaseId } from '../core/database_info'; import { queryToAggregateTarget, Query, queryToTarget } from '../core/query'; +import { Pipeline } from '../lite-api/pipeline'; import { Document } from '../model/document'; import { DocumentKey } from '../model/document_key'; import { Mutation } from '../model/mutation'; import { ResourcePath } from '../model/path'; import { PipelineStreamElement } from '../model/pipeline_stream_element'; -import { Pipeline } from '../pipelines/api/pipeline'; import { ApiClientObjectMap, BatchGetDocumentsRequest as ProtoBatchGetDocumentsRequest, diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index e69de29bb2d..aba38bab427 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -0,0 +1,797 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { expect, use } from 'chai'; +import chaiAsPromised from 'chai-as-promised'; + +import { addEqualityMatcher } from '../../util/equality_matcher'; +import { Deferred } from '../../util/promise'; +import { + add, + andExpression, + arrayContains, + arrayContainsAny, + avg, + CollectionReference, + Constant, + cosineDistance, + countAll, + doc, + DocumentData, + dotProduct, + endsWith, + eq, + euclideanDistance, + Field, + Firestore, + gt, + like, + lt, + lte, + mapGet, + neq, + not, + orExpression, + PipelineResult, + regexContains, + regexMatch, + setDoc, + startsWith, + strConcat, + subtract +} from '../util/firebase_export'; +import { apiDescribe, withTestCollection } from '../util/helpers'; + +use(chaiAsPromised); + +apiDescribe('Queries', persistence => { + addEqualityMatcher(); + let firestore: Firestore; + let randomCol: CollectionReference; + + // async function addDocs( + // ...docs: DocumentData[] + // ): Promise { + // let id = 0; // Guarantees consistent ordering for the first documents + // const refs: DocumentReference[] = []; + // for (const data of docs) { + // const ref = doc(randomCol, 'doc' + id++); + // await setDoc(ref, data); + // refs.push(ref); + // } + // return refs; + // } + + async function testCollectionWithDocs(docs: { + [id: string]: DocumentData; + }): Promise> { + for (const id in docs) { + if (docs.hasOwnProperty(id)) { + const ref = doc(randomCol, id); + await setDoc(ref, docs[id]); + } + } + return randomCol; + } + + function expectResults( + result: Array>, + ...docs: string[] + ): void; + function expectResults( + result: Array>, + ...data: DocumentData[] + ): void; + + function expectResults( + result: Array>, + ...data: DocumentData[] | string[] + ): void { + expect(result.length).to.equal(data.length); + + if (data.length > 0) { + if (typeof data[0] === 'string') { + const actualIds = result.map(result => result.ref?.id); + expect(actualIds).to.deep.equal(data); + } else { + result.forEach(r => { + expect(r.data()).to.deep.equal(data.shift()); + }); + } + } + } + + // async function compareQueryAndPipeline(query: Query): Promise { + // const queryResults = await getDocs(query); + // const pipeline = query.pipeline(); + // const pipelineResults = await pipeline.execute(); + // + // expect(queryResults.docs.map(s => s._fieldsProto)).to.deep.equal( + // pipelineResults.map(r => r._fieldsProto) + // ); + // return queryResults; + // } + + async function setupBookDocs(): Promise> { + const bookDocs: { [id: string]: DocumentData } = { + book1: { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams', + genre: 'Science Fiction', + published: 1979, + rating: 4.2, + tags: ['comedy', 'space', 'adventure'], + awards: { + hugo: true, + nebula: false, + others: { unknown: { year: 1980 } } + }, + nestedField: { 'level.1': { 'level.2': true } } + }, + book2: { + title: 'Pride and Prejudice', + author: 'Jane Austen', + genre: 'Romance', + published: 1813, + rating: 4.5, + tags: ['classic', 'social commentary', 'love'], + awards: { none: true } + }, + book3: { + title: 'One Hundred Years of Solitude', + author: 'Gabriel García Márquez', + genre: 'Magical Realism', + published: 1967, + rating: 4.3, + tags: ['family', 'history', 'fantasy'], + awards: { nobel: true, nebula: false } + }, + book4: { + title: 'The Lord of the Rings', + author: 'J.R.R. Tolkien', + genre: 'Fantasy', + published: 1954, + rating: 4.7, + tags: ['adventure', 'magic', 'epic'], + awards: { hugo: false, nebula: false } + }, + book5: { + title: "The Handmaid's Tale", + author: 'Margaret Atwood', + genre: 'Dystopian', + published: 1985, + rating: 4.1, + tags: ['feminism', 'totalitarianism', 'resistance'], + awards: { 'arthur c. clarke': true, 'booker prize': false } + }, + book6: { + title: 'Crime and Punishment', + author: 'Fyodor Dostoevsky', + genre: 'Psychological Thriller', + published: 1866, + rating: 4.3, + tags: ['philosophy', 'crime', 'redemption'], + awards: { none: true } + }, + book7: { + title: 'To Kill a Mockingbird', + author: 'Harper Lee', + genre: 'Southern Gothic', + published: 1960, + rating: 4.2, + tags: ['racism', 'injustice', 'coming-of-age'], + awards: { pulitzer: true } + }, + book8: { + title: '1984', + author: 'George Orwell', + genre: 'Dystopian', + published: 1949, + rating: 4.2, + tags: ['surveillance', 'totalitarianism', 'propaganda'], + awards: { prometheus: true } + }, + book9: { + title: 'The Great Gatsby', + author: 'F. Scott Fitzgerald', + genre: 'Modernist', + published: 1925, + rating: 4.0, + tags: ['wealth', 'american dream', 'love'], + awards: { none: true } + }, + book10: { + title: 'Dune', + author: 'Frank Herbert', + genre: 'Science Fiction', + published: 1965, + rating: 4.6, + tags: ['politics', 'desert', 'ecology'], + awards: { hugo: true, nebula: true } + } + }; + return testCollectionWithDocs(bookDocs); + } + + let testDeferred: Deferred | undefined; + let withTestCollectionPromise: Promise | undefined; + + beforeEach(async () => { + const setupDeferred = new Deferred(); + withTestCollectionPromise = withTestCollection( + persistence, + {}, + async (collectionRef, firestoreInstance) => { + randomCol = collectionRef; + firestore = firestoreInstance; + await setupBookDocs(); + setupDeferred.resolve(); + + return testDeferred?.promise; + } + ); + + await setupDeferred; + }); + + afterEach(async () => { + testDeferred?.resolve(); + await withTestCollectionPromise; + }); + + it('empty results as expected', async () => { + const result = await firestore + .pipeline() + .collection(randomCol.path) + .limit(0) + .execute(); + expect(result).to.be.empty; + }); + + it('returns aggregate results as expected', async () => { + let result = await firestore + .pipeline() + .collection(randomCol.path) + .aggregate(countAll().as('count')) + .execute(); + expectResults(result, { count: 10 }); + + result = await randomCol + .pipeline() + .where(eq('genre', 'Science Fiction')) + .aggregate( + countAll().as('count'), + avg('rating').as('avgRating'), + Field.of('rating').max().as('maxRating') + ) + .execute(); + expectResults(result, { count: 2, avgRating: 4.4, maxRating: 4.6 }); + }); + + it('rejects groups without accumulators', async () => { + await expect( + randomCol + .pipeline() + .where(lt('published', 1900)) + .aggregate({ + accumulators: [], + groups: ['genre'] + }) + .execute() + ).to.be.rejected; + }); + + it('returns distinct values as expected', async () => { + const results = await randomCol + .pipeline() + .where(lt('published', 1900)) + .distinct(Field.of('genre').toLower().as('lowerGenre')) + .execute(); + expectResults( + results, + { lowerGenre: 'romance' }, + { lowerGenre: 'psychological thriller' } + ); + }); + + it('returns group and accumulate results', async () => { + const results = await randomCol + .pipeline() + .where(lt(Field.of('published'), 1984)) + .aggregate({ + accumulators: [avg('rating').as('avgRating')], + groups: ['genre'] + }) + .where(gt('avgRating', 4.3)) + .execute(); + expectResults( + results, + { avgRating: 4.7, genre: 'Fantasy' }, + { avgRating: 4.5, genre: 'Romance' }, + { avgRating: 4.4, genre: 'Science Fiction' } + ); + }); + + it('returns min and max accumulations', async () => { + const results = await randomCol + .pipeline() + .aggregate( + countAll().as('count'), + Field.of('rating').max().as('maxRating'), + Field.of('published').min().as('minPublished') + ) + .execute(); + expectResults(results, { + count: 10, + maxRating: 4.7, + minPublished: 1813 + }); + }); + + it('can select fields', async () => { + const results = await firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'author') + .sort(Field.of('author').ascending()) + .execute(); + expectResults( + results, + { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams' + }, + { title: 'The Great Gatsby', author: 'F. Scott Fitzgerald' }, + { title: 'Dune', author: 'Frank Herbert' }, + { title: 'Crime and Punishment', author: 'Fyodor Dostoevsky' }, + { + title: 'One Hundred Years of Solitude', + author: 'Gabriel García Márquez' + }, + { title: '1984', author: 'George Orwell' }, + { title: 'To Kill a Mockingbird', author: 'Harper Lee' }, + { title: 'The Lord of the Rings', author: 'J.R.R. Tolkien' }, + { title: 'Pride and Prejudice', author: 'Jane Austen' }, + { title: "The Handmaid's Tale", author: 'Margaret Atwood' } + ); + }); + + it('where with and', async () => { + const results = await randomCol + .pipeline() + .where(andExpression(gt('rating', 4.5), eq('genre', 'Science Fiction'))) + .execute(); + expectResults(results, 'book10'); + }); + + it('where with or', async () => { + const results = await randomCol + .pipeline() + .where(orExpression(eq('genre', 'Romance'), eq('genre', 'Dystopian'))) + .select('title') + .execute(); + expectResults( + results, + { title: 'Pride and Prejudice' }, + { title: "The Handmaid's Tale" }, + { title: '1984' } + ); + }); + + it('offset and limits', async () => { + const results = await firestore + .pipeline() + .collection(randomCol.path) + .sort(Field.of('author').ascending()) + .offset(5) + .limit(3) + .select('title', 'author') + .execute(); + expectResults( + results, + { title: '1984', author: 'George Orwell' }, + { title: 'To Kill a Mockingbird', author: 'Harper Lee' }, + { title: 'The Lord of the Rings', author: 'J.R.R. Tolkien' } + ); + }); + + it('arrayContains works', async () => { + const results = await randomCol + .pipeline() + .where(arrayContains('tags', 'comedy')) + .select('title') + .execute(); + expectResults(results, { title: "The Hitchhiker's Guide to the Galaxy" }); + }); + + it('arrayContainsAny works', async () => { + const results = await randomCol + .pipeline() + .where(arrayContainsAny('tags', ['comedy', 'classic'])) + .select('title') + .execute(); + expectResults( + results, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'Pride and Prejudice' } + ); + }); + + it('arrayContainsAll works', async () => { + const results = await randomCol + .pipeline() + .where(Field.of('tags').arrayContainsAll('adventure', 'magic')) + .select('title') + .execute(); + expectResults(results, { title: 'The Lord of the Rings' }); + }); + + it('arrayLength works', async () => { + const results = await randomCol + .pipeline() + .select(Field.of('tags').arrayLength().as('tagsCount')) + .where(eq('tagsCount', 3)) + .execute(); + expect(results.length).to.equal(10); + }); + + it('arrayConcat works', async () => { + const results = await randomCol + .pipeline() + .select( + Field.of('tags').arrayConcat(['newTag1', 'newTag2']).as('modifiedTags') + ) + .limit(1) + .execute(); + expectResults(results, { + modifiedTags: ['comedy', 'space', 'adventure', 'newTag1', 'newTag2'] + }); + }); + + it('testStrConcat', async () => { + const results = await randomCol + .pipeline() + .select( + Field.of('author').strConcat(' - ', Field.of('title')).as('bookInfo') + ) + .limit(1) + .execute(); + expectResults(results, { + bookInfo: "Douglas Adams - The Hitchhiker's Guide to the Galaxy" + }); + }); + + it('testStartsWith', async () => { + const results = await randomCol + .pipeline() + .where(startsWith('title', 'The')) + .select('title') + .sort(Field.of('title').ascending()) + .execute(); + expectResults( + results, + { title: 'The Great Gatsby' }, + { title: "The Handmaid's Tale" }, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'The Lord of the Rings' } + ); + }); + + it('testEndsWith', async () => { + const results = await randomCol + .pipeline() + .where(endsWith('title', 'y')) + .select('title') + .sort(Field.of('title').descending()) + .execute(); + expectResults( + results, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'The Great Gatsby' } + ); + }); + + it('testLength', async () => { + const results = await randomCol + .pipeline() + .select( + Field.of('title').charLength().as('titleLength'), + Field.of('title') + ) + .where(gt('titleLength', 20)) + .execute(); + expectResults( + results, + { titleLength: 32, title: "The Hitchhiker's Guide to the Galaxy" }, + { + titleLength: 27, + title: 'One Hundred Years of Solitude' + } + ); + }); + + it('testToLowercase', async () => { + const results = await randomCol + .pipeline() + .select(Field.of('title').toLower().as('lowercaseTitle')) + .limit(1) + .execute(); + expectResults(results, { + lowercaseTitle: "the hitchhiker's guide to the galaxy" + }); + }); + + it('testToUppercase', async () => { + const results = await randomCol + .pipeline() + .select(Field.of('author').toUpper().as('uppercaseAuthor')) + .limit(1) + .execute(); + expectResults(results, { uppercaseAuthor: 'DOUGLAS ADAMS' }); + }); + + it('testTrim', async () => { + const results = await randomCol + .pipeline() + .addFields(strConcat(' ', Field.of('title'), ' ').as('spacedTitle')) + .select( + Field.of('spacedTitle').trim().as('trimmedTitle'), + Field.of('spacedTitle') + ) + .limit(1) + .execute(); + expectResults(results, { + spacedTitle: " The Hitchhiker's Guide to the Galaxy ", + trimmedTitle: "The Hitchhiker's Guide to the Galaxy" + }); + }); + + it('testLike', async () => { + const results = await randomCol + .pipeline() + .where(like('title', '%Guide%')) + .select('title') + .execute(); + expectResults(results, { title: "The Hitchhiker's Guide to the Galaxy" }); + }); + + it('testRegexContains', async () => { + const results = await randomCol + .pipeline() + .where(regexContains('title', '(?i)(the|of)')) + .execute(); + expect(results.length).to.equal(5); + }); + + it('testRegexMatches', async () => { + const results = await randomCol + .pipeline() + .where(regexMatch('title', '.*(?i)(the|of).*')) + .execute(); + expect(results.length).to.equal(5); + }); + + it('testArithmeticOperations', async () => { + const results = await randomCol + .pipeline() + .select( + add(Field.of('rating'), 1).as('ratingPlusOne'), + subtract(Field.of('published'), 1900).as('yearsSince1900'), + Field.of('rating').multiply(10).as('ratingTimesTen'), + Field.of('rating').divide(2).as('ratingDividedByTwo') + ) + .limit(1) + .execute(); + expectResults(results, { + ratingPlusOne: 5.2, + yearsSince1900: 79, + ratingTimesTen: 42, + ratingDividedByTwo: 2.1 + }); + }); + + it('testComparisonOperators', async () => { + const results = await randomCol + .pipeline() + .where( + andExpression( + gt('rating', 4.2), + lte(Field.of('rating'), 4.5), + neq('genre', 'Science Fiction') + ) + ) + .select('rating', 'title') + .sort(Field.of('title').ascending()) + .execute(); + expectResults( + results, + { rating: 4.3, title: 'Crime and Punishment' }, + { + rating: 4.3, + title: 'One Hundred Years of Solitude' + }, + { rating: 4.5, title: 'Pride and Prejudice' } + ); + }); + + it('testLogicalOperators', async () => { + const results = await randomCol + .pipeline() + .where( + orExpression( + andExpression(gt('rating', 4.5), eq('genre', 'Science Fiction')), + lt('published', 1900) + ) + ) + .select('title') + .sort(Field.of('title').ascending()) + .execute(); + expectResults( + results, + { title: 'Crime and Punishment' }, + { title: 'Dune' }, + { title: 'Pride and Prejudice' } + ); + }); + + it('testChecks', async () => { + const results = await randomCol + .pipeline() + .where(not(Field.of('rating').isNaN())) + .select( + Field.of('rating').eq(null).as('ratingIsNull'), + not(Field.of('rating').isNaN()).as('ratingIsNotNaN') + ) + .limit(1) + .execute(); + expectResults(results, { ratingIsNull: false, ratingIsNotNaN: true }); + }); + + it('testMapGet', async () => { + const results = await randomCol + .pipeline() + .select( + Field.of('awards').mapGet('hugo').as('hugoAward'), + Field.of('awards').mapGet('others').as('others'), + Field.of('title') + ) + .where(eq('hugoAward', true)) + .execute(); + expectResults( + results, + { + hugoAward: true, + title: "The Hitchhiker's Guide to the Galaxy", + others: { unknown: { year: 1980 } } + }, + { hugoAward: true, title: 'Dune', others: null } + ); + }); + + // it('testParent', async () => { + // const results = await randomCol + // .pipeline() + // .select( + // parent(randomCol.doc('chile').collection('subCollection').path).as( + // 'parent' + // ) + // ) + // .limit(1) + // .execute(); + // expect(results[0].data().parent.endsWith('/books')).to.be.true; + // }); + // + // it('testCollectionId', async () => { + // const results = await randomCol + // .pipeline() + // .select(collectionId(randomCol.doc('chile')).as('collectionId')) + // .limit(1) + // .execute(); + // expectResults(results, {collectionId: 'books'}); + // }); + + it('testDistanceFunctions', async () => { + const sourceVector = [0.1, 0.1]; + const targetVector = [0.5, 0.8]; + const results = await randomCol + .pipeline() + .select( + cosineDistance(Constant.vector(sourceVector), targetVector).as( + 'cosineDistance' + ), + dotProduct(Constant.vector(sourceVector), targetVector).as( + 'dotProductDistance' + ), + euclideanDistance(Constant.vector(sourceVector), targetVector).as( + 'euclideanDistance' + ) + ) + .limit(1) + .execute(); + + expectResults(results, { + cosineDistance: 0.02560880430538015, + dotProductDistance: 0.13, + euclideanDistance: 0.806225774829855 + }); + }); + + it('testNestedFields', async () => { + const results = await randomCol + .pipeline() + .where(eq('awards.hugo', true)) + .select('title', 'awards.hugo') + .execute(); + expectResults( + results, + { title: "The Hitchhiker's Guide to the Galaxy", 'awards.hugo': true }, + { title: 'Dune', 'awards.hugo': true } + ); + }); + + it('test mapGet with field name including . notation', async () => { + const results = await randomCol + .pipeline() + .where(eq('awards.hugo', true)) + .select( + 'title', + Field.of('nestedField.level.1'), + mapGet('nestedField', 'level.1').mapGet('level.2').as('nested') + ) + .execute(); + expectResults( + results, + { + title: "The Hitchhiker's Guide to the Galaxy", + 'nestedField.level.`1`': null, + nested: true + }, + { title: 'Dune', 'nestedField.level.`1`': null, nested: null } + ); + }); + + // TODO(pipeline) support converter + // it('pipeline converter works', async () => { + // interface AppModel {myTitle: string; myAuthor: string; myPublished: number} + // const converter: FirestorePipelineConverter = { + // fromFirestore(result: FirebaseFirestore.PipelineResult): AppModel { + // return { + // myTitle: result.data()!.title as string, + // myAuthor: result.data()!.author as string, + // myPublished: result.data()!.published as number, + // }; + // }, + // }; + // + // const results = await firestore + // .pipeline() + // .collection(randomCol.path) + // .sort(Field.of('published').ascending()) + // .limit(2) + // .withConverter(converter) + // .execute(); + // + // const objs = results.map(r => r.data()); + // expect(objs[0]).to.deep.equal({ + // myAuthor: 'Jane Austen', + // myPublished: 1813, + // myTitle: 'Pride and Prejudice', + // }); + // expect(objs[1]).to.deep.equal({ + // myAuthor: 'Fyodor Dostoevsky', + // myPublished: 1866, + // myTitle: 'Crime and Punishment', + // }); + // }); +}); diff --git a/packages/firestore/test/unit/api/document_change.test.ts b/packages/firestore/test/unit/api/document_change.test.ts index faae8b4d4c8..8ce40f599b8 100644 --- a/packages/firestore/test/unit/api/document_change.test.ts +++ b/packages/firestore/test/unit/api/document_change.test.ts @@ -18,8 +18,8 @@ import { expect } from 'chai'; import { Query } from '../../../src/api/reference'; -import { ExpUserDataWriter } from '../../../src/api/reference_impl'; import { QuerySnapshot } from '../../../src/api/snapshot'; +import { ExpUserDataWriter } from '../../../src/api/user_data_writer'; import { Query as InternalQuery } from '../../../src/core/query'; import { View } from '../../../src/core/view'; import { documentKeySet } from '../../../src/model/collections'; diff --git a/packages/firestore/test/unit/remote/serializer.helper.ts b/packages/firestore/test/unit/remote/serializer.helper.ts index d523c8fab83..451f7ddf7ae 100644 --- a/packages/firestore/test/unit/remote/serializer.helper.ts +++ b/packages/firestore/test/unit/remote/serializer.helper.ts @@ -28,7 +28,7 @@ import { serverTimestamp, Timestamp } from '../../../src'; -import { ExpUserDataWriter } from '../../../src/api/reference_impl'; +import { ExpUserDataWriter } from '../../../src/api/user_data_writer'; import { DatabaseId } from '../../../src/core/database_info'; import { ArrayContainsAnyFilter, diff --git a/packages/firestore/test/unit/specs/spec_builder.ts b/packages/firestore/test/unit/specs/spec_builder.ts index d79cca9cd82..ce27b86f03b 100644 --- a/packages/firestore/test/unit/specs/spec_builder.ts +++ b/packages/firestore/test/unit/specs/spec_builder.ts @@ -16,7 +16,7 @@ */ import { IndexConfiguration } from '../../../src/api/index_configuration'; -import { ExpUserDataWriter } from '../../../src/api/reference_impl'; +import { ExpUserDataWriter } from '../../../src/api/user_data_writer'; import { ListenOptions, ListenerDataSource as Source diff --git a/packages/firestore/test/util/api_helpers.ts b/packages/firestore/test/util/api_helpers.ts index 762b5258a29..517167be323 100644 --- a/packages/firestore/test/util/api_helpers.ts +++ b/packages/firestore/test/util/api_helpers.ts @@ -32,7 +32,7 @@ import { EmptyAppCheckTokenProvider, EmptyAuthCredentialsProvider } from '../../src/api/credentials'; -import { ExpUserDataWriter } from '../../src/api/reference_impl'; +import { ExpUserDataWriter } from '../../src/api/user_data_writer'; import { DatabaseId } from '../../src/core/database_info'; import { newQueryForPath, Query as InternalQuery } from '../../src/core/query'; import { From 067639767010f8ed47aa51b04433af71bf9427ec Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 16 Oct 2024 12:44:46 -0600 Subject: [PATCH 05/59] api-review folder updates --- common/api-review/firestore-lite.api.md | 1764 ++++++++++++++++++++++- common/api-review/firestore.api.md | 18 +- 2 files changed, 1742 insertions(+), 40 deletions(-) diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 603e2349505..4117ff2d3ca 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -9,14 +9,54 @@ import { FirebaseApp } from '@firebase/app'; import { FirebaseError } from '@firebase/util'; import { LogLevelString as LogLevel } from '@firebase/logger'; +// @beta +export interface Accumulator { + // (undocumented) + accumulator: true; +} + +// @beta +export type AccumulatorTarget = ExprWithAlias; + +// @beta (undocumented) +export class Add extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function add(left: Constant, right: Constant): Add; + +// @beta +export function add(left: Constant, right: any): Add; + +// @beta +export function add(left: string, right: Constant): Add; + +// @beta +export function add(left: string, right: any): Add; + // @public export function addDoc(reference: CollectionReference, data: WithFieldValue): Promise>; +// @beta (undocumented) +export class AddFields implements Stage { + constructor(fields: Map); + // (undocumented) + name: string; +} + // @public export type AddPrefixToKeys> = { [K in keyof T & string as `${Prefix}.${K}`]+?: string extends K ? any : T[K]; }; +// @beta (undocumented) +export class Aggregate implements Stage { + constructor(accumulators: Map, groups: Map); + // (undocumented) + name: string; +} + // @public export class AggregateField { readonly aggregateType: AggregateType; @@ -53,18 +93,147 @@ export type AggregateSpecData = { // @public export type AggregateType = 'count' | 'avg' | 'sum'; +// @beta (undocumented) +export class And extends FirestoreFunction implements FilterCondition { + constructor(conditions: FilterExpr[]); + // (undocumented) + filterable: true; +} + // @public export function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; +// @beta +export function andExpression(left: FilterExpr, ...right: FilterExpr[]): And; + +// @beta (undocumented) +export class ArrayConcat extends FirestoreFunction { + constructor(array: Constant, elements: Constant[]); + } + +// @beta +export function arrayConcat(array: Constant, elements: Constant[]): ArrayConcat; + +// @beta +export function arrayConcat(array: Constant, elements: any[]): ArrayConcat; + +// @beta +export function arrayConcat(array: string, elements: Constant[]): ArrayConcat; + +// @beta +export function arrayConcat(array: string, elements: any[]): ArrayConcat; + +// @beta (undocumented) +export class ArrayContains extends FirestoreFunction implements FilterCondition { + constructor(array: Constant, element: Constant); + // (undocumented) + filterable: true; +} + +// @beta +export function arrayContains(array: Constant, element: Constant): ArrayContains; + +// @beta +export function arrayContains(array: Constant, element: any): ArrayContains; + +// @beta +export function arrayContains(array: string, element: Constant): ArrayContains; + +// @beta +export function arrayContains(array: string, element: any): ArrayContains; + +// @beta (undocumented) +export class ArrayContainsAll extends FirestoreFunction implements FilterCondition { + constructor(array: Constant, values: Constant[]); + // (undocumented) + filterable: true; + } + +// @beta +export function arrayContainsAll(array: Constant, values: Constant[]): ArrayContainsAll; + +// @beta +export function arrayContainsAll(array: Constant, values: any[]): ArrayContainsAll; + +// @beta +export function arrayContainsAll(array: string, values: Constant[]): ArrayContainsAll; + +// @beta +export function arrayContainsAll(array: string, values: any[]): ArrayContainsAll; + +// @beta (undocumented) +export class ArrayContainsAny extends FirestoreFunction implements FilterCondition { + constructor(array: Constant, values: Constant[]); + // (undocumented) + filterable: true; + } + +// @beta +export function arrayContainsAny(array: Constant, values: Constant[]): ArrayContainsAny; + +// @beta +export function arrayContainsAny(array: Constant, values: any[]): ArrayContainsAny; + +// @beta +export function arrayContainsAny(array: string, values: Constant[]): ArrayContainsAny; + +// @beta +export function arrayContainsAny(array: string, values: any[]): ArrayContainsAny; + +// @beta (undocumented) +export class ArrayElement extends FirestoreFunction { + constructor(); +} + +// @beta (undocumented) +export class ArrayLength extends FirestoreFunction { + constructor(array: Constant); + } + +// @beta +export function arrayLength(array: Constant): ArrayLength; + // @public export function arrayRemove(...elements: unknown[]): FieldValue; +// @beta (undocumented) +export class ArrayReverse extends FirestoreFunction { + constructor(array: Constant); + } + // @public export function arrayUnion(...elements: unknown[]): FieldValue; +// @beta +export function ascending(expr: Constant): Ordering; + // @public export function average(field: string | FieldPath): AggregateField; +// @beta (undocumented) +export class Avg extends FirestoreFunction implements Accumulator { + constructor(value: Constant, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta +export function avg(value: Constant): Avg; + +// @beta +export function avg(value: string): Avg; + +// @beta (undocumented) +export class ByteLength extends FirestoreFunction { + constructor(value: Constant); + } + +// @beta +export function byteLength(expr: Constant): ByteLength; + +// @beta +export function byteLength(field: string): ByteLength; + // @public export class Bytes { static fromBase64String(base64: string): Bytes; @@ -75,6 +244,17 @@ export class Bytes { toUint8Array(): Uint8Array; } +// @beta (undocumented) +export class CharLength extends FirestoreFunction { + constructor(value: Constant); + } + +// @beta +export function charLength(field: string): CharLength; + +// @beta +export function charLength(expr: Constant): CharLength; + // @public export type ChildUpdateFields = V extends Record ? AddPrefixToKeys> : never; @@ -90,6 +270,13 @@ export function collection(refer // @public export function collectionGroup(firestore: Firestore, collectionId: string): Query; +// @beta (undocumented) +export class CollectionGroupSource implements Stage { + constructor(collectionId: string); + // (undocumented) + name: string; +} + // @public export class CollectionReference extends Query { get id(): string; @@ -100,20 +287,216 @@ export class CollectionReference; } +// @beta (undocumented) +export class CollectionSource implements Stage { + constructor(collectionPath: string); + // (undocumented) + name: string; +} + // @public export function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: { mockUserToken?: EmulatorMockTokenOptions | string; }): void; +// @beta +export class Constant { + add(other: Constant): Add; + add(other: any): Add; + arrayConcat(arrays: Constant[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat; + arrayContains(element: Constant): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Constant[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Constant[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Constant): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Constant): Divide; + divide(other: any): Divide; + dotProduct(other: Constant): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Constant): EndsWith; + eq(other: Constant): Eq; + eq(other: any): Eq; + euclideanDistance(other: Constant): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + gt(other: Constant): Gt; + gt(other: any): Gt; + gte(other: Constant): Gte; + gte(other: any): Gte; + in(...others: Constant[]): In; + // (undocumented) + in(...others: any[]): In; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Constant): Like; + logicalMax(other: Constant): LogicalMax; + logicalMax(other: any): LogicalMax; + logicalMin(other: Constant): LogicalMin; + logicalMin(other: any): LogicalMin; + lt(other: Constant): Lt; + lt(other: any): Lt; + lte(other: Constant): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + max(): Max; + min(): Min; + mod(other: Constant): Mod; + mod(other: any): Mod; + multiply(other: Constant): Multiply; + multiply(other: any): Multiply; + neq(other: Constant): Neq; + neq(other: any): Neq; + static of(value: number): Constant; + static of(value: string): Constant; + static of(value: boolean): Constant; + static of(value: null): Constant; + static of(value: undefined): Constant; + static of(value: GeoPoint): Constant; + static of(value: Timestamp): Constant; + static of(value: Date): Constant; + static of(value: Uint8Array): Constant; + static of(value: DocumentReference): Constant; + static of(value: any[]): Constant; + static of(value: Map): Constant; + static of(value: VectorValue): Constant; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Constant): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Constant): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Constant, replace: Constant): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Constant, replace: Constant): ReplaceFirst; + reverse(): Reverse; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Constant): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Constant): StrContains; + subtract(other: Constant): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Constant, amount: Constant): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Constant, amount: Constant): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + static vector(value: number[] | VectorValue): Constant; + vectorLength(): VectorLength; +} + +// @beta (undocumented) +export class CosineDistance extends FirestoreFunction { + constructor(vector1: Constant, vector2: Constant); + } + +// @beta +export function cosineDistance(expr: string, other: number[]): CosineDistance; + +// @beta +export function cosineDistance(expr: string, other: VectorValue): CosineDistance; + +// @beta +export function cosineDistance(expr: string, other: Constant): CosineDistance; + +// @beta +export function cosineDistance(expr: Constant, other: number[]): CosineDistance; + +// @beta +export function cosineDistance(expr: Constant, other: VectorValue): CosineDistance; + +// @beta +export function cosineDistance(expr: Constant, other: Constant): CosineDistance; + +// @beta (undocumented) +export class Count extends FirestoreFunction implements Accumulator { + constructor(value: Constant | undefined, distinct: boolean); + // (undocumented) + accumulator: true; + } + // @public export function count(): AggregateField; +// @beta +export function countAll(): Count; + +// @beta +export function countExpression(value: Constant): Count; + +// Warning: (ae-incompatible-release-tags) The symbol "countExpression" is marked as @public, but its signature references "Count" which is marked as @beta +// +// @public +export function countExpression(value: string): Count; + +// @beta (undocumented) +export class DatabaseSource implements Stage { + // (undocumented) + name: string; +} + // @public export function deleteDoc(reference: DocumentReference): Promise; // @public export function deleteField(): FieldValue; +// @beta +export function descending(expr: Constant): Ordering; + +// @beta (undocumented) +export class Distinct implements Stage { + constructor(groups: Map); + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class Divide extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function divide(left: Constant, right: Constant): Divide; + +// @beta +export function divide(left: Constant, right: any): Divide; + +// @beta +export function divide(left: string, right: Constant): Divide; + +// @beta +export function divide(left: string, right: any): Divide; + // @public export function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference; @@ -153,6 +536,38 @@ export class DocumentSnapshot; } +// @beta (undocumented) +export class DocumentsSource implements Stage { + constructor(docPaths: string[]); + // (undocumented) + name: string; + // (undocumented) + static of(refs: DocumentReference[]): DocumentsSource; +} + +// @beta (undocumented) +export class DotProduct extends FirestoreFunction { + constructor(vector1: Constant, vector2: Constant); + } + +// @beta +export function dotProduct(expr: string, other: number[]): DotProduct; + +// @beta +export function dotProduct(expr: string, other: VectorValue): DotProduct; + +// @beta +export function dotProduct(expr: string, other: Constant): DotProduct; + +// @beta +export function dotProduct(expr: Constant, other: number[]): DotProduct; + +// @beta +export function dotProduct(expr: Constant, other: VectorValue): DotProduct; + +// @beta +export function dotProduct(expr: Constant, other: Constant): DotProduct; + export { EmulatorMockTokenOptions } // @public @@ -167,20 +582,457 @@ export function endBefore(snapsh // @public export function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint; +// @beta (undocumented) +export class EndsWith extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, suffix: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function endsWith(expr: string, suffix: string): EndsWith; + +// @beta +export function endsWith(expr: string, suffix: Constant): EndsWith; + +// @beta +export function endsWith(expr: Constant, suffix: string): EndsWith; + +// @beta +export function endsWith(expr: Constant, suffix: Constant): EndsWith; + +// @beta (undocumented) +export class Eq extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function eq(left: Constant, right: Constant): Eq; + +// @beta +export function eq(left: Constant, right: any): Eq; + +// @beta +export function eq(left: string, right: Constant): Eq; + +// @beta +export function eq(left: string, right: any): Eq; + +// @beta (undocumented) +export class EuclideanDistance extends FirestoreFunction { + constructor(vector1: Constant, vector2: Constant); + } + +// @beta +export function euclideanDistance(expr: string, other: number[]): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: string, other: VectorValue): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: string, other: Constant): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: Constant, other: number[]): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: Constant, other: VectorValue): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: Constant, other: Constant): EuclideanDistance; + +// @beta (undocumented) +export class Exists extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant); + // (undocumented) + filterable: true; +} + +// @beta +export function exists(value: Constant): Exists; + +// @beta +export function exists(field: string): Exists; + +// @beta +export type ExprType = 'Field' | 'Constant' | 'Function' | 'ListOfExprs' | 'ExprWithAlias'; + +// @beta (undocumented) +export class ExprWithAlias implements Selectable { + constructor(expr: T, alias: string); + add(other: Constant): Add; + add(other: any): Add; + // (undocumented) + alias: string; + arrayConcat(arrays: Constant[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat; + arrayContains(element: Constant): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Constant[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Constant[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Constant): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Constant): Divide; + divide(other: any): Divide; + dotProduct(other: Constant): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Constant): EndsWith; + eq(other: Constant): Eq; + eq(other: any): Eq; + euclideanDistance(other: Constant): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + expr: T; + // (undocumented) + exprType: ExprType; + gt(other: Constant): Gt; + gt(other: any): Gt; + gte(other: Constant): Gte; + gte(other: any): Gte; + in(...others: Constant[]): In; + // (undocumented) + in(...others: any[]): In; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Constant): Like; + logicalMax(other: Constant): LogicalMax; + logicalMax(other: any): LogicalMax; + logicalMin(other: Constant): LogicalMin; + logicalMin(other: any): LogicalMin; + lt(other: Constant): Lt; + lt(other: any): Lt; + lte(other: Constant): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + max(): Max; + min(): Min; + mod(other: Constant): Mod; + mod(other: any): Mod; + multiply(other: Constant): Multiply; + multiply(other: any): Multiply; + neq(other: Constant): Neq; + neq(other: any): Neq; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Constant): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Constant): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Constant, replace: Constant): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Constant, replace: Constant): ReplaceFirst; + reverse(): Reverse; + // (undocumented) + selectable: true; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Constant): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Constant): StrContains; + subtract(other: Constant): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Constant, amount: Constant): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Constant, amount: Constant): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + +// @beta +export class Field implements Selectable { + add(other: Constant): Add; + add(other: any): Add; + arrayConcat(arrays: Constant[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat; + arrayContains(element: Constant): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Constant[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Constant[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Constant): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Constant): Divide; + divide(other: any): Divide; + dotProduct(other: Constant): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Constant): EndsWith; + eq(other: Constant): Eq; + eq(other: any): Eq; + euclideanDistance(other: Constant): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + // (undocumented) + fieldName(): string; + gt(other: Constant): Gt; + gt(other: any): Gt; + gte(other: Constant): Gte; + gte(other: any): Gte; + in(...others: Constant[]): In; + // (undocumented) + in(...others: any[]): In; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Constant): Like; + logicalMax(other: Constant): LogicalMax; + logicalMax(other: any): LogicalMax; + logicalMin(other: Constant): LogicalMin; + logicalMin(other: any): LogicalMin; + lt(other: Constant): Lt; + lt(other: any): Lt; + lte(other: Constant): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + max(): Max; + min(): Min; + mod(other: Constant): Mod; + mod(other: any): Mod; + multiply(other: Constant): Multiply; + multiply(other: any): Multiply; + neq(other: Constant): Neq; + neq(other: any): Neq; + static of(name: string): Field; + // (undocumented) + static of(path: FieldPath): Field; + // (undocumented) + static of(pipeline: Pipeline, name: string): Field; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Constant): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Constant): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Constant, replace: Constant): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Constant, replace: Constant): ReplaceFirst; + reverse(): Reverse; + // (undocumented) + selectable: true; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Constant): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Constant): StrContains; + subtract(other: Constant): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Constant, amount: Constant): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Constant, amount: Constant): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + // @public export class FieldPath { constructor(...fieldNames: string[]); isEqual(other: FieldPath): boolean; } +// @beta (undocumented) +export class Fields implements Selectable { + add(other: Constant): Add; + add(other: any): Add; + arrayConcat(arrays: Constant[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat; + arrayContains(element: Constant): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Constant[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Constant[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Constant): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Constant): Divide; + divide(other: any): Divide; + dotProduct(other: Constant): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Constant): EndsWith; + eq(other: Constant): Eq; + eq(other: any): Eq; + euclideanDistance(other: Constant): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + // (undocumented) + fieldList(): Field[]; + gt(other: Constant): Gt; + gt(other: any): Gt; + gte(other: Constant): Gte; + gte(other: any): Gte; + in(...others: Constant[]): In; + // (undocumented) + in(...others: any[]): In; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Constant): Like; + logicalMax(other: Constant): LogicalMax; + logicalMax(other: any): LogicalMax; + logicalMin(other: Constant): LogicalMin; + logicalMin(other: any): LogicalMin; + lt(other: Constant): Lt; + lt(other: any): Lt; + lte(other: Constant): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + max(): Max; + min(): Min; + mod(other: Constant): Mod; + mod(other: any): Mod; + multiply(other: Constant): Multiply; + multiply(other: any): Multiply; + neq(other: Constant): Neq; + neq(other: any): Neq; + // (undocumented) + static of(name: string, ...others: string[]): Fields; + // (undocumented) + static ofAll(): Fields; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Constant): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Constant): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Constant, replace: Constant): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Constant, replace: Constant): ReplaceFirst; + reverse(): Reverse; + // (undocumented) + selectable: true; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Constant): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Constant): StrContains; + subtract(other: Constant): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Constant, amount: Constant): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Constant, amount: Constant): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + // @public export abstract class FieldValue { abstract isEqual(other: FieldValue): boolean; } +// @beta +export interface FilterCondition { + // (undocumented) + filterable: true; +} + +// @beta +export type FilterExpr = Constant & FilterCondition; + +// @beta (undocumented) +export class FindNearest implements Stage { + // (undocumented) + name: string; +} + +// @beta (undocumented) +export interface FindNearestOptions { + // (undocumented) + distanceField?: string; + // (undocumented) + distanceMeasure: 'euclidean' | 'cosine' | 'dot_product'; + // (undocumented) + field: Field; + // (undocumented) + limit?: number; + // (undocumented) + vectorValue: VectorValue | number[]; +} + // @public export class Firestore { get app(): FirebaseApp; + // Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta + // + // (undocumented) + pipeline(): PipelineSource; toJSON(): object; type: 'firestore-lite' | 'firestore'; } @@ -199,69 +1051,488 @@ export class FirestoreError extends FirebaseError { readonly stack?: string; } -// @public -export type FirestoreErrorCode = 'cancelled' | 'unknown' | 'invalid-argument' | 'deadline-exceeded' | 'not-found' | 'already-exists' | 'permission-denied' | 'resource-exhausted' | 'failed-precondition' | 'aborted' | 'out-of-range' | 'unimplemented' | 'internal' | 'unavailable' | 'data-loss' | 'unauthenticated'; +// @public +export type FirestoreErrorCode = 'cancelled' | 'unknown' | 'invalid-argument' | 'deadline-exceeded' | 'not-found' | 'already-exists' | 'permission-denied' | 'resource-exhausted' | 'failed-precondition' | 'aborted' | 'out-of-range' | 'unimplemented' | 'internal' | 'unavailable' | 'data-loss' | 'unauthenticated'; + +// @beta +export class FirestoreFunction { + constructor(name: string, params: Constant[]); + add(other: Constant): Add; + add(other: any): Add; + arrayConcat(arrays: Constant[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat; + arrayContains(element: Constant): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Constant[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Constant[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Constant): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Constant): Divide; + divide(other: any): Divide; + dotProduct(other: Constant): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Constant): EndsWith; + eq(other: Constant): Eq; + eq(other: any): Eq; + euclideanDistance(other: Constant): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + gt(other: Constant): Gt; + gt(other: any): Gt; + gte(other: Constant): Gte; + gte(other: any): Gte; + in(...others: Constant[]): In; + // (undocumented) + in(...others: any[]): In; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Constant): Like; + logicalMax(other: Constant): LogicalMax; + logicalMax(other: any): LogicalMax; + logicalMin(other: Constant): LogicalMin; + logicalMin(other: any): LogicalMin; + lt(other: Constant): Lt; + lt(other: any): Lt; + lte(other: Constant): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + max(): Max; + min(): Min; + mod(other: Constant): Mod; + mod(other: any): Mod; + multiply(other: Constant): Multiply; + multiply(other: any): Multiply; + neq(other: Constant): Neq; + neq(other: any): Neq; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Constant): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Constant): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Constant, replace: Constant): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Constant, replace: Constant): ReplaceFirst; + reverse(): Reverse; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Constant): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Constant): StrContains; + subtract(other: Constant): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Constant, amount: Constant): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Constant, amount: Constant): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + +// @beta +export function genericFunction(name: string, params: Constant[]): FirestoreFunction; + +// @beta (undocumented) +export class GenericStage implements Stage { + constructor(name: string, params: unknown[]); + // (undocumented) + name: string; +} + +// @public +export class GeoPoint { + constructor(latitude: number, longitude: number); + isEqual(other: GeoPoint): boolean; + get latitude(): number; + get longitude(): number; + toJSON(): { + latitude: number; + longitude: number; + }; +} + +// @public +export function getAggregate(query: Query, aggregateSpec: AggregateSpecType): Promise>; + +// @public +export function getCount(query: Query): Promise; +}, AppModelType, DbModelType>>; + +// @public +export function getDoc(reference: DocumentReference): Promise>; + +// @public +export function getDocs(query: Query): Promise>; + +// @public +export function getFirestore(): Firestore; + +// @public +export function getFirestore(app: FirebaseApp): Firestore; + +// @beta +export function getFirestore(databaseId: string): Firestore; + +// @beta +export function getFirestore(app: FirebaseApp, databaseId: string): Firestore; + +// @beta (undocumented) +export class Gt extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function gt(left: Constant, right: Constant): Gt; + +// @beta +export function gt(left: Constant, right: any): Gt; + +// @beta +export function gt(left: string, right: Constant): Gt; + +// @beta +export function gt(left: string, right: any): Gt; + +// @beta (undocumented) +export class Gte extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function gte(left: Constant, right: Constant): Gte; + +// @beta +export function gte(left: Constant, right: any): Gte; + +// @beta +export function gte(left: string, right: Constant): Gte; + +// @beta +export function gte(left: string, right: any): Gte; + +// @beta (undocumented) +export class If extends FirestoreFunction implements FilterCondition { + constructor(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function ifFunction(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant): If; + +// @beta (undocumented) +export class In extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, others: Constant[]); + // (undocumented) + filterable: true; + } + +// @beta +export function inAny(element: Constant, others: Constant[]): In; + +// @beta +export function inAny(element: Constant, others: any[]): In; + +// @beta +export function inAny(element: string, others: Constant[]): In; + +// @beta +export function inAny(element: string, others: any[]): In; + +// @public +export function increment(n: number): FieldValue; + +// @public +export function initializeFirestore(app: FirebaseApp, settings: Settings): Firestore; + +// @beta +export function initializeFirestore(app: FirebaseApp, settings: Settings, databaseId?: string): Firestore; + +// @beta (undocumented) +export class IsNan extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant); + // (undocumented) + filterable: true; +} + +// @beta +export function isNan(value: Constant): IsNan; + +// @beta +export function isNan(value: string): IsNan; + +// @beta (undocumented) +export class Like extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, pattern: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function like(left: string, pattern: string): Like; + +// @beta +export function like(left: string, pattern: Constant): Like; + +// @beta +export function like(left: Constant, pattern: string): Like; + +// @beta +export function like(left: Constant, pattern: Constant): Like; + +// @beta (undocumented) +export class Limit implements Stage { + constructor(limit: number); + // (undocumented) + name: string; +} + +// @public +export function limit(limit: number): QueryLimitConstraint; + +// @public +export function limitToLast(limit: number): QueryLimitConstraint; + +// @beta (undocumented) +export class LogicalMax extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function logicalMax(left: Constant, right: Constant): LogicalMax; + +// @beta +export function logicalMax(left: Constant, right: any): LogicalMax; + +// @beta +export function logicalMax(left: string, right: Constant): LogicalMax; + +// @beta +export function logicalMax(left: string, right: any): LogicalMax; + +// @beta (undocumented) +export class LogicalMin extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function logicalMin(left: Constant, right: Constant): LogicalMin; + +// @beta +export function logicalMin(left: Constant, right: any): LogicalMin; + +// @beta +export function logicalMin(left: string, right: Constant): LogicalMin; + +// @beta +export function logicalMin(left: string, right: any): LogicalMin; + +export { LogLevel } + +// @beta (undocumented) +export class Lt extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function lt(left: Constant, right: Constant): Lt; + +// @beta +export function lt(left: Constant, right: any): Lt; + +// @beta +export function lt(left: string, right: Constant): Lt; + +// @beta +export function lt(left: string, right: any): Lt; + +// @beta (undocumented) +export class Lte extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function lte(left: Constant, right: Constant): Lte; + +// @beta +export function lte(left: Constant, right: any): Lte; + +// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Constant" which is marked as @beta +// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Lte" which is marked as @beta +// +// @public +export function lte(left: string, right: Constant): Lte; + +// @beta +export function lte(left: string, right: any): Lte; + +// @beta (undocumented) +export class MapGet extends FirestoreFunction { + constructor(map: Constant, name: string); +} + +// @beta +export function mapGet(mapField: string, subField: string): MapGet; + +// @beta +export function mapGet(mapExpr: Constant, subField: string): MapGet; + +// @beta (undocumented) +export class Max extends FirestoreFunction implements Accumulator { + constructor(value: Constant, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta +export function max(value: Constant): Max; + +// @beta +export function max(value: string): Max; + +// @beta (undocumented) +export class Min extends FirestoreFunction implements Accumulator { + constructor(value: Constant, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta +export function min(value: Constant): Min; + +// @beta +export function min(value: string): Min; -// @public -export class GeoPoint { - constructor(latitude: number, longitude: number); - isEqual(other: GeoPoint): boolean; - get latitude(): number; - get longitude(): number; - toJSON(): { - latitude: number; - longitude: number; - }; -} +// @beta (undocumented) +export class Mod extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } -// @public -export function getAggregate(query: Query, aggregateSpec: AggregateSpecType): Promise>; +// @beta +export function mod(left: Constant, right: Constant): Mod; -// @public -export function getCount(query: Query): Promise; -}, AppModelType, DbModelType>>; +// @beta +export function mod(left: Constant, right: any): Mod; -// @public -export function getDoc(reference: DocumentReference): Promise>; +// @beta +export function mod(left: string, right: Constant): Mod; -// @public -export function getDocs(query: Query): Promise>; +// @beta +export function mod(left: string, right: any): Mod; -// @public -export function getFirestore(): Firestore; +// @beta (undocumented) +export class Multiply extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } -// @public -export function getFirestore(app: FirebaseApp): Firestore; +// @beta +export function multiply(left: Constant, right: Constant): Multiply; // @beta -export function getFirestore(databaseId: string): Firestore; +export function multiply(left: Constant, right: any): Multiply; // @beta -export function getFirestore(app: FirebaseApp, databaseId: string): Firestore; +export function multiply(left: string, right: Constant): Multiply; -// @public -export function increment(n: number): FieldValue; +// @beta +export function multiply(left: string, right: any): Multiply; -// @public -export function initializeFirestore(app: FirebaseApp, settings: Settings): Firestore; +// @beta (undocumented) +export class Neq extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } // @beta -export function initializeFirestore(app: FirebaseApp, settings: Settings, databaseId?: string): Firestore; +export function neq(left: Constant, right: Constant): Neq; -// @public -export function limit(limit: number): QueryLimitConstraint; +// @beta +export function neq(left: Constant, right: any): Neq; -// @public -export function limitToLast(limit: number): QueryLimitConstraint; +// @beta +export function neq(left: string, right: Constant): Neq; -export { LogLevel } +// @beta +export function neq(left: string, right: any): Neq; // @public export type NestedUpdateFields> = UnionToIntersection<{ [K in keyof T & string]: ChildUpdateFields; }[keyof T & string]>; +// @beta (undocumented) +export class Not extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant); + // (undocumented) + filterable: true; +} + +// @beta +export function not(filter: FilterExpr): Not; + +// @beta +export function notInAny(element: Constant, others: Constant[]): Not; + +// @beta +export function notInAny(element: Constant, others: any[]): Not; + +// @beta +export function notInAny(element: string, others: Constant[]): Not; + +// @beta +export function notInAny(element: string, others: any[]): Not; + +// @beta (undocumented) +export class Offset implements Stage { + constructor(offset: number); + // (undocumented) + name: string; + } + +// @beta (undocumented) +export class Or extends FirestoreFunction implements FilterCondition { + constructor(conditions: FilterExpr[]); + // (undocumented) + filterable: true; +} + // @public export function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; @@ -271,11 +1542,79 @@ export function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDir // @public export type OrderByDirection = 'desc' | 'asc'; +// @beta +export class Ordering { + constructor(expr: Constant, direction: 'ascending' | 'descending'); + } + +// @beta +export function orExpression(left: FilterExpr, ...right: FilterExpr[]): Or; + // @public export type PartialWithFieldValue = Partial | (T extends Primitive ? T : T extends {} ? { [K in keyof T]?: PartialWithFieldValue | FieldValue; } : never); +// @public +export class Pipeline { + // Warning: (ae-incompatible-release-tags) The symbol "addFields" is marked as @public, but its signature references "Selectable" which is marked as @beta + addFields(...fields: Selectable[]): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "aggregate" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta + aggregate(...accumulators: AccumulatorTarget[]): Pipeline; + aggregate(options: { + accumulators: AccumulatorTarget[]; + groups?: Array; + }): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "distinct" is marked as @public, but its signature references "Selectable" which is marked as @beta + distinct(...groups: Array): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "execute" is marked as @public, but its signature references "PipelineResult" which is marked as @beta + execute(): Promise>>; + // Warning: (ae-incompatible-release-tags) The symbol "findNearest" is marked as @public, but its signature references "FindNearestOptions" which is marked as @beta + // + // (undocumented) + findNearest(options: FindNearestOptions): Pipeline; + genericStage(name: string, params: any[]): Pipeline; + limit(limit: number): Pipeline; + offset(offset: number): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "select" is marked as @public, but its signature references "Selectable" which is marked as @beta + select(...selections: Array): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "sort" is marked as @public, but its signature references "Ordering" which is marked as @beta + sort(...orderings: Ordering[]): Pipeline; + // (undocumented) + sort(options: { + orderings: Ordering[]; + }): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "FilterCondition" which is marked as @beta + // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "Constant" which is marked as @beta + where(condition: FilterCondition & Constant): Pipeline; +} + +// @beta +export class PipelineResult { + /* Excluded from this release type: _ref */ + /* Excluded from this release type: _fields */ + /* Excluded from this release type: __constructor */ + get createTime(): Timestamp | undefined; + data(): AppModelType | undefined; + get executionTime(): Timestamp; + get(fieldPath: string | FieldPath): any; + get id(): string | undefined; + get ref(): DocumentReference | undefined; + get updateTime(): Timestamp | undefined; +} + +// @beta +export class PipelineSource { + // (undocumented) + collection(collectionPath: string): Pipeline; + // (undocumented) + collectionGroup(collectionId: string): Pipeline; + // (undocumented) + database(): Pipeline; + // (undocumented) + documents(docs: DocumentReference[]): Pipeline; + } + // @public export type Primitive = string | number | boolean | undefined | null; @@ -360,9 +1699,102 @@ export class QueryStartAtConstraint extends QueryConstraint { // @public export function refEqual(left: DocumentReference | CollectionReference, right: DocumentReference | CollectionReference): boolean; +// @beta (undocumented) +export class RegexContains extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, pattern: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function regexContains(left: string, pattern: string): RegexContains; + +// @beta +export function regexContains(left: string, pattern: Constant): RegexContains; + +// @beta +export function regexContains(left: Constant, pattern: string): RegexContains; + +// @beta +export function regexContains(left: Constant, pattern: Constant): RegexContains; + +// @beta (undocumented) +export class RegexMatch extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, pattern: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function regexMatch(left: string, pattern: string): RegexMatch; + +// @beta +export function regexMatch(left: string, pattern: Constant): RegexMatch; + +// @beta +export function regexMatch(left: Constant, pattern: string): RegexMatch; + +// @beta +export function regexMatch(left: Constant, pattern: Constant): RegexMatch; + +// @beta (undocumented) +export class ReplaceAll extends FirestoreFunction { + constructor(value: Constant, find: Constant, replace: Constant); + } + +// @beta +export function replaceAll(value: Constant, find: string, replace: string): ReplaceAll; + +// @beta +export function replaceAll(value: Constant, find: Constant, replace: Constant): ReplaceAll; + +// @beta +export function replaceAll(field: string, find: string, replace: string): ReplaceAll; + +// @beta (undocumented) +export class ReplaceFirst extends FirestoreFunction { + constructor(value: Constant, find: Constant, replace: Constant); + } + +// @beta +export function replaceFirst(value: Constant, find: string, replace: string): ReplaceFirst; + +// @beta +export function replaceFirst(value: Constant, find: Constant, replace: Constant): ReplaceFirst; + +// @beta +export function replaceFirst(field: string, find: string, replace: string): ReplaceFirst; + +// @beta (undocumented) +export class Reverse extends FirestoreFunction { + constructor(value: Constant); + } + +// @beta +export function reverse(expr: Constant): Reverse; + +// @beta +export function reverse(field: string): Reverse; + // @public export function runTransaction(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise, options?: TransactionOptions): Promise; +// @beta (undocumented) +export class Select implements Stage { + constructor(projections: Map); + // (undocumented) + name: string; + } + +// @beta +export interface Selectable { + // (undocumented) + selectable: true; +} + +// @beta +export type SelectableExpr = Constant & Selectable; + // @public export function serverTimestamp(): FieldValue; @@ -392,6 +1824,19 @@ export interface Settings { // @public export function snapshotEqual(left: DocumentSnapshot | QuerySnapshot, right: DocumentSnapshot | QuerySnapshot): boolean; +// @beta (undocumented) +export class Sort implements Stage { + constructor(orders: Ordering[]); + // (undocumented) + name: string; + } + +// @beta (undocumented) +export interface Stage { + // (undocumented) + name: string; +} + // @public export function startAfter(snapshot: DocumentSnapshot): QueryStartAtConstraint; @@ -404,9 +1849,88 @@ export function startAt(snapshot // @public export function startAt(...fieldValues: unknown[]): QueryStartAtConstraint; +// @beta (undocumented) +export class StartsWith extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, prefix: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function startsWith(expr: string, prefix: string): StartsWith; + +// @beta +export function startsWith(expr: string, prefix: Constant): StartsWith; + +// @beta +export function startsWith(expr: Constant, prefix: string): StartsWith; + +// @beta +export function startsWith(expr: Constant, prefix: Constant): StartsWith; + +// @beta (undocumented) +export class StrConcat extends FirestoreFunction { + constructor(first: Constant, rest: Constant[]); + } + +// @beta +export function strConcat(first: string, ...elements: Array): StrConcat; + +// @beta +export function strConcat(first: Constant, ...elements: Array): StrConcat; + +// @beta (undocumented) +export class StrContains extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, substring: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function strContains(left: string, substring: string): StrContains; + +// @beta +export function strContains(left: string, substring: Constant): StrContains; + +// @beta +export function strContains(left: Constant, substring: string): StrContains; + +// @beta +export function strContains(left: Constant, substring: Constant): StrContains; + +// @beta (undocumented) +export class Subtract extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function subtract(left: Constant, right: Constant): Subtract; + +// @beta +export function subtract(left: Constant, right: any): Subtract; + +// @beta +export function subtract(left: string, right: Constant): Subtract; + +// @beta +export function subtract(left: string, right: any): Subtract; + +// @beta (undocumented) +export class Sum extends FirestoreFunction implements Accumulator { + constructor(value: Constant, distinct: boolean); + // (undocumented) + accumulator: true; + } + // @public export function sum(field: string | FieldPath): AggregateField; +// @beta +export function sumExpression(value: Constant): Sum; + +// @beta +export function sumExpression(value: string): Sum; + // @public export function terminate(firestore: Firestore): Promise; @@ -431,6 +1955,89 @@ export class Timestamp { valueOf(): string; } +// @beta (undocumented) +export class TimestampAdd extends FirestoreFunction { + constructor(timestamp: Constant, unit: Constant, amount: Constant); + } + +// @beta +export function timestampAdd(timestamp: Constant, unit: Constant, amount: Constant): TimestampAdd; + +// @beta +export function timestampAdd(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + +// @beta +export function timestampAdd(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + +// @beta (undocumented) +export class TimestampSub extends FirestoreFunction { + constructor(timestamp: Constant, unit: Constant, amount: Constant); + } + +// @beta +export function timestampSub(timestamp: Constant, unit: Constant, amount: Constant): TimestampSub; + +// @beta +export function timestampSub(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + +// @beta +export function timestampSub(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + +// @beta (undocumented) +export class TimestampToUnixMicros extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function timestampToUnixMicros(expr: Constant): TimestampToUnixMicros; + +// @beta +export function timestampToUnixMicros(field: string): TimestampToUnixMicros; + +// @beta (undocumented) +export class TimestampToUnixMillis extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function timestampToUnixMillis(expr: Constant): TimestampToUnixMillis; + +// @beta +export function timestampToUnixMillis(field: string): TimestampToUnixMillis; + +// @beta (undocumented) +export class TimestampToUnixSeconds extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function timestampToUnixSeconds(expr: Constant): TimestampToUnixSeconds; + +// @beta +export function timestampToUnixSeconds(field: string): TimestampToUnixSeconds; + +// @beta (undocumented) +export class ToLower extends FirestoreFunction { + constructor(expr: Constant); + } + +// @beta +export function toLower(expr: string): ToLower; + +// @beta +export function toLower(expr: Constant): ToLower; + +// @beta (undocumented) +export class ToUpper extends FirestoreFunction { + constructor(expr: Constant); + } + +// @beta +export function toUpper(expr: string): ToUpper; + +// @beta +export function toUpper(expr: Constant): ToUpper; + // @public export class Transaction { delete(documentRef: DocumentReference): this; @@ -446,9 +2053,53 @@ export interface TransactionOptions { readonly maxAttempts?: number; } +// @beta (undocumented) +export class Trim extends FirestoreFunction { + constructor(expr: Constant); + } + +// @beta +export function trim(expr: string): Trim; + +// @beta +export function trim(expr: Constant): Trim; + // @public export type UnionToIntersection = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never; +// @beta (undocumented) +export class UnixMicrosToTimestamp extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function unixMicrosToTimestamp(expr: Constant): UnixMicrosToTimestamp; + +// @beta +export function unixMicrosToTimestamp(field: string): UnixMicrosToTimestamp; + +// @beta (undocumented) +export class UnixMillisToTimestamp extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function unixMillisToTimestamp(expr: Constant): UnixMillisToTimestamp; + +// @beta +export function unixMillisToTimestamp(field: string): UnixMillisToTimestamp; + +// @beta (undocumented) +export class UnixSecondsToTimestamp extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function unixSecondsToTimestamp(expr: Constant): UnixSecondsToTimestamp; + +// @beta +export function unixSecondsToTimestamp(field: string): UnixSecondsToTimestamp; + // @public export type UpdateData = T extends Primitive ? T : T extends {} ? { [K in keyof T]?: UpdateData | FieldValue; @@ -463,6 +2114,17 @@ export function updateDoc(refere // @public export function vector(values?: number[]): VectorValue; +// @beta (undocumented) +export class VectorLength extends FirestoreFunction { + constructor(value: Constant); + } + +// @beta +export function vectorLength(expr: Constant): VectorLength; + +// @beta +export function vectorLength(field: string): VectorLength; + // @public export class VectorValue { /* Excluded from this release type: __constructor */ @@ -470,6 +2132,13 @@ export class VectorValue { toArray(): number[]; } +// @beta (undocumented) +export class Where implements Stage { + constructor(condition: FilterCondition & Constant); + // (undocumented) + name: string; +} + // @public export function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryFieldFilterConstraint; @@ -494,4 +2163,21 @@ export class WriteBatch { // @public export function writeBatch(firestore: Firestore): WriteBatch; +// @beta (undocumented) +export class Xor extends FirestoreFunction implements FilterCondition { + constructor(conditions: FilterExpr[]); + // (undocumented) + filterable: true; +} + +// @beta +export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; + + +// Warnings were encountered during analysis: +// +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9258:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9259:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9288:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta + ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index 0eba34b259a..f8f76b050c9 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -1813,27 +1813,37 @@ export interface PersistentSingleTabManagerSettings { // @public export type PersistentTabManager = PersistentSingleTabManager | PersistentMultipleTabManager; -// @beta +// @public export class Pipeline { + // Warning: (ae-incompatible-release-tags) The symbol "addFields" is marked as @public, but its signature references "Selectable" which is marked as @beta addFields(...fields: Selectable[]): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "aggregate" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta aggregate(...accumulators: AccumulatorTarget[]): Pipeline; aggregate(options: { accumulators: AccumulatorTarget[]; groups?: Array; }): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "distinct" is marked as @public, but its signature references "Selectable" which is marked as @beta distinct(...groups: Array): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "execute" is marked as @public, but its signature references "PipelineResult" which is marked as @beta execute(): Promise>>; + // Warning: (ae-incompatible-release-tags) The symbol "findNearest" is marked as @public, but its signature references "FindNearestOptions" which is marked as @beta + // // (undocumented) findNearest(options: FindNearestOptions): Pipeline; genericStage(name: string, params: any[]): Pipeline; limit(limit: number): Pipeline; offset(offset: number): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "select" is marked as @public, but its signature references "Selectable" which is marked as @beta select(...selections: Array): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "sort" is marked as @public, but its signature references "Ordering" which is marked as @beta sort(...orderings: Ordering[]): Pipeline; // (undocumented) sort(options: { orderings: Ordering[]; }): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "FilterCondition" which is marked as @beta + // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "Constant" which is marked as @beta where(condition: FilterCondition & Constant): Pipeline; } @@ -2452,4 +2462,10 @@ export class Xor extends FirestoreFunction implements FilterCondition { export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; +// Warnings were encountered during analysis: +// +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10108:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10109:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10138:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta + ``` From 2cd396a85c09ffe4ef50c3d5254ae5fe9ebe7623 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 16 Oct 2024 12:45:08 -0600 Subject: [PATCH 06/59] Adding missing protobufjs-cli --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 7c65287bb20..aaf4eaa8bc8 100644 --- a/package.json +++ b/package.json @@ -142,6 +142,7 @@ "postinstall-postinstall": "2.1.0", "prettier": "2.8.7", "protractor": "5.4.2", + "protobufjs-cli": "^1.1.3", "request": "2.88.2", "semver": "7.5.3", "simple-git": "3.24.0", From 0c76ca0712a0488bf8cf16937439f84b368b849e Mon Sep 17 00:00:00 2001 From: MarkDuckworth Date: Wed, 16 Oct 2024 19:41:55 +0000 Subject: [PATCH 07/59] Update API reports --- common/api-review/firestore-lite.api.md | 6 +++--- common/api-review/firestore.api.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 4117ff2d3ca..97cf9d7189c 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -2176,8 +2176,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9258:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9259:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9288:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9258:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9259:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9288:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index f8f76b050c9..c746620442d 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -2464,8 +2464,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10108:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10109:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10138:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10108:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10109:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10138:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` From 5e9774bd48dfb717df7ed0c1a5714793a17340a8 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 16 Oct 2024 14:11:22 -0600 Subject: [PATCH 08/59] fixes --- packages/firestore/src/lite-api/pipeline.ts | 4 +--- packages/firestore/src/protos/firestore_proto_api.ts | 2 ++ packages/firestore/src/remote/datastore.ts | 2 +- packages/firestore/test/integration/api/pipeline.test.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/firestore/src/lite-api/pipeline.ts b/packages/firestore/src/lite-api/pipeline.ts index d6a6c21bb90..9015182bc5d 100644 --- a/packages/firestore/src/lite-api/pipeline.ts +++ b/packages/firestore/src/lite-api/pipeline.ts @@ -18,7 +18,7 @@ import { DocumentKey } from '../model/document_key'; import { ObjectValue } from '../model/object_value'; import { ExecutePipelineRequest, - firestoreV1ApiClientInterfaces, + StructuredPipeline, Stage as ProtoStage } from '../protos/firestore_proto_api'; import { invokeExecutePipeline } from '../remote/datastore'; @@ -63,8 +63,6 @@ import { } from './user_data_reader'; import { AbstractUserDataWriter } from './user_data_writer'; -import StructuredPipeline = firestoreV1ApiClientInterfaces.StructuredPipeline; - interface ReadableUserData { _readUserData(dataReader: UserDataReader): void; } diff --git a/packages/firestore/src/protos/firestore_proto_api.ts b/packages/firestore/src/protos/firestore_proto_api.ts index 250cfb5ef88..cc1c57259f5 100644 --- a/packages/firestore/src/protos/firestore_proto_api.ts +++ b/packages/firestore/src/protos/firestore_proto_api.ts @@ -572,6 +572,8 @@ export declare type Stage = firestoreV1ApiClientInterfaces.Stage; export declare type Status = firestoreV1ApiClientInterfaces.Status; export declare type StructuredQuery = firestoreV1ApiClientInterfaces.StructuredQuery; +export declare type StructuredPipeline = + firestoreV1ApiClientInterfaces.StructuredPipeline; export declare type Target = firestoreV1ApiClientInterfaces.Target; export declare type TargetChange = firestoreV1ApiClientInterfaces.TargetChange; export declare type TransactionOptions = diff --git a/packages/firestore/src/remote/datastore.ts b/packages/firestore/src/remote/datastore.ts index bca88583d1a..00c1e7fca9e 100644 --- a/packages/firestore/src/remote/datastore.ts +++ b/packages/firestore/src/remote/datastore.ts @@ -252,7 +252,7 @@ export async function invokeExecutePipeline( >( 'ExecutePipeline', datastoreImpl.serializer.databaseId, - toResourcePath(datastoreImpl.serializer.databaseId), + ResourcePath.emptyPath(), executePipelineRequest ); diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index aba38bab427..03950690e77 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -55,7 +55,7 @@ import { apiDescribe, withTestCollection } from '../util/helpers'; use(chaiAsPromised); -apiDescribe('Queries', persistence => { +apiDescribe.only('Pipelines', persistence => { addEqualityMatcher(); let firestore: Firestore; let randomCol: CollectionReference; From 2f3d48a03fec39887067fd0c01cfe8cf9c074924 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 16 Oct 2024 14:31:34 -0600 Subject: [PATCH 09/59] yarn.lock --- yarn.lock | 196 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 188 insertions(+), 8 deletions(-) diff --git a/yarn.lock b/yarn.lock index 92372aa94a3..613906694cd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -430,6 +430,11 @@ resolved "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.24.1.tgz#f99c36d3593db9540705d0739a1f10b5e20c696e" integrity sha512-2ofRCjnnA9y+wk8b9IAREroeUP02KHp431N2mhKniy2yKIDKpbrHv9eXwm8cBeWQYcJmzv5qKCu65P47eCF7CQ== +"@babel/helper-string-parser@^7.25.7": + version "7.25.7" + resolved "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.7.tgz#d50e8d37b1176207b4fe9acedec386c565a44a54" + integrity sha512-CbkjYdsJNHFk8uqpEkpCvRs3YRp9tY6FmFY7wLMSYuGYkrdUi7r2lc4/wqsvlHoMznX3WJ9IP8giGPq68T/Y6g== + "@babel/helper-validator-identifier@^7.14.5", "@babel/helper-validator-identifier@^7.22.20", "@babel/helper-validator-identifier@^7.22.5": version "7.22.20" resolved "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz" @@ -450,6 +455,11 @@ resolved "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.5.tgz#918b1a7fa23056603506370089bd990d8720db62" integrity sha512-3q93SSKX2TWCG30M2G2kwaKeTYgEUp5Snjuj8qm729SObL6nbtUldAi37qbxkD5gg3xnBio+f9nqpSepGZMvxA== +"@babel/helper-validator-identifier@^7.25.7": + version "7.25.7" + resolved "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.7.tgz#77b7f60c40b15c97df735b38a66ba1d7c3e93da5" + integrity sha512-AM6TzwYqGChO45oiuPqwL2t20/HdMC1rTPAesnBCgPCSF1x3oN9MVUwQV2iyz4xqWrctwK5RNC8LV22kaQCNYg== + "@babel/helper-validator-option@^7.14.5": version "7.14.5" resolved "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.14.5.tgz" @@ -525,6 +535,13 @@ resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.15.7.tgz" integrity sha512-rycZXvQ+xS9QyIcJ9HXeDWf1uxqlbVFAUq0Rq0dbc50Zb/+wUe/ehyfzGfm9KZZF0kBejYgxltBXocP+gKdL2g== +"@babel/parser@^7.20.15": + version "7.25.8" + resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.25.8.tgz#f6aaf38e80c36129460c1657c0762db584c9d5e2" + integrity sha512-HcttkxzdPucv3nNFmfOOMfFf64KgdJVqm1KaCm25dPGMLElo9nsLvXeJECQg8UzPuBGLyTSA0ZzqCtDSzKTEoQ== + dependencies: + "@babel/types" "^7.25.8" + "@babel/parser@^7.24.0", "@babel/parser@^7.24.1": version "7.24.1" resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.24.1.tgz#1e416d3627393fab1cb5b0f2f1796a100ae9133a" @@ -1364,6 +1381,15 @@ "@babel/helper-validator-identifier" "^7.22.20" to-fast-properties "^2.0.0" +"@babel/types@^7.25.8": + version "7.25.8" + resolved "https://registry.npmjs.org/@babel/types/-/types-7.25.8.tgz#5cf6037258e8a9bcad533f4979025140cb9993e1" + integrity sha512-JWtuCu8VQsMladxVz/P4HzHUGCAwpuqacmowgXFs5XjxIgKuNjnLokQzuVjlTvIzODaDmpjT3oxcC48vyk9EWg== + dependencies: + "@babel/helper-string-parser" "^7.25.7" + "@babel/helper-validator-identifier" "^7.25.7" + to-fast-properties "^2.0.0" + "@changesets/apply-release-plan@^6.1.4": version "6.1.4" resolved "https://registry.npmjs.org/@changesets/apply-release-plan/-/apply-release-plan-6.1.4.tgz" @@ -1928,6 +1954,13 @@ resolved "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz" integrity sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg== +"@jsdoc/salty@^0.2.1": + version "0.2.8" + resolved "https://registry.npmjs.org/@jsdoc/salty/-/salty-0.2.8.tgz#8d29923a9429694a437a50ab75004b576131d597" + integrity sha512-5e+SFVavj1ORKlKaKr2BmTOekmXbelU7dC0cDkQLqag7xfuTPuGMUFx7KWJuv4bYZrTsoL2Z18VVCOKYxzoHcg== + dependencies: + lodash "^4.17.21" + "@kwsites/file-exists@^1.1.1": version "1.1.1" resolved "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz" @@ -3435,6 +3468,11 @@ dependencies: "@types/node" "*" +"@types/linkify-it@^5": + version "5.0.0" + resolved "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-5.0.0.tgz#21413001973106cda1c3a9b91eedd4ccd5469d76" + integrity sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q== + "@types/listr@0.14.9": version "0.14.9" resolved "https://registry.npmjs.org/@types/listr/-/listr-0.14.9.tgz#736581cfdfcdb821bace0a3e5b05e91182e00c85" @@ -3448,6 +3486,19 @@ resolved "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz" integrity sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA== +"@types/markdown-it@^14.1.1": + version "14.1.2" + resolved "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-14.1.2.tgz#57f2532a0800067d9b934f3521429a2e8bfb4c61" + integrity sha512-promo4eFwuiW+TfGxhi+0x3czqTYJkG8qB17ZUJiVF10Xm7NLVRSLUsfRTU/6h1e24VvRnXCx+hG7li58lkzog== + dependencies: + "@types/linkify-it" "^5" + "@types/mdurl" "^2" + +"@types/mdurl@^2": + version "2.0.0" + resolved "https://registry.npmjs.org/@types/mdurl/-/mdurl-2.0.0.tgz#d43878b5b20222682163ae6f897b20447233bdfd" + integrity sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg== + "@types/mime@*": version "3.0.1" resolved "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz" @@ -5057,9 +5108,9 @@ blocking-proxy@^1.0.0: dependencies: minimist "^1.2.0" -bluebird@3.7.2: +bluebird@3.7.2, bluebird@^3.7.2: version "3.7.2" - resolved "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz" + resolved "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9: @@ -5542,6 +5593,13 @@ caseless@~0.12.0: resolved "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz" integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= +catharsis@^0.9.0: + version "0.9.0" + resolved "https://registry.npmjs.org/catharsis/-/catharsis-0.9.0.tgz#40382a168be0e6da308c277d3a2b3eb40c7d2121" + integrity sha512-prMTQVpcns/tzFgFVkVp6ak6RykZyWb3gu8ckUpd6YkTlacOd3DXGJjIpD4Q6zJirizvaiAjSSHlOsA+6sNh2A== + dependencies: + lodash "^4.17.15" + chai-as-promised@7.1.1: version "7.1.1" resolved "https://registry.npmjs.org/chai-as-promised/-/chai-as-promised-7.1.1.tgz" @@ -7260,6 +7318,11 @@ ent@~2.2.0: resolved "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz" integrity sha1-6WQhkyWiHQX0RGai9obtbOX13R0= +entities@^4.4.0: + version "4.5.0" + resolved "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz#5d268ea5e7113ec74c4d033b79ea5a35a488fb48" + integrity sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw== + env-paths@^2.2.0: version "2.2.1" resolved "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz" @@ -7545,7 +7608,7 @@ escape-string-regexp@^2.0.0: resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz" integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== -escodegen@^1.8.1: +escodegen@^1.13.0, escodegen@^1.8.1: version "1.14.3" resolved "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz" integrity sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw== @@ -7684,7 +7747,7 @@ esniff@^2.0.1: event-emitter "^0.3.5" type "^2.7.2" -espree@^9.6.0, espree@^9.6.1: +espree@^9.0.0, espree@^9.6.0, espree@^9.6.1: version "9.6.1" resolved "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f" integrity sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ== @@ -9056,7 +9119,7 @@ glob@7.2.3, glob@~7.2.0: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^8.0.1: +glob@^8.0.0, glob@^8.0.1: version "8.1.0" resolved "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz" integrity sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ== @@ -9277,7 +9340,7 @@ graceful-fs@^4.1.6, graceful-fs@^4.2.0: resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz" integrity sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ== -graceful-fs@^4.2.10, graceful-fs@^4.2.9: +graceful-fs@^4.1.9, graceful-fs@^4.2.10, graceful-fs@^4.2.9: version "4.2.11" resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz" integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== @@ -11074,11 +11137,39 @@ js-yaml@~3.13.1: argparse "^1.0.7" esprima "^4.0.0" +js2xmlparser@^4.0.2: + version "4.0.2" + resolved "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.2.tgz#2a1fdf01e90585ef2ae872a01bc169c6a8d5e60a" + integrity sha512-6n4D8gLlLf1n5mNLQPRfViYzu9RATblzPEtm1SthMX1Pjao0r9YI9nw7ZIfRxQMERS87mcswrg+r/OYrPRX6jA== + dependencies: + xmlcreate "^2.0.4" + jsbn@~0.1.0: version "0.1.1" resolved "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz" integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM= +jsdoc@^4.0.0: + version "4.0.3" + resolved "https://registry.npmjs.org/jsdoc/-/jsdoc-4.0.3.tgz#bfee86c6a82f6823e12b5e8be698fd99ae46c061" + integrity sha512-Nu7Sf35kXJ1MWDZIMAuATRQTg1iIPdzh7tqJ6jjvaU/GfDf+qi5UV8zJR3Mo+/pYFvm8mzay4+6O5EWigaQBQw== + dependencies: + "@babel/parser" "^7.20.15" + "@jsdoc/salty" "^0.2.1" + "@types/markdown-it" "^14.1.1" + bluebird "^3.7.2" + catharsis "^0.9.0" + escape-string-regexp "^2.0.0" + js2xmlparser "^4.0.2" + klaw "^3.0.0" + markdown-it "^14.1.0" + markdown-it-anchor "^8.6.7" + marked "^4.0.10" + mkdirp "^1.0.4" + requizzle "^0.2.3" + strip-json-comments "^3.1.0" + underscore "~1.13.2" + jsesc@^1.3.0: version "1.3.0" resolved "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz" @@ -11491,6 +11582,13 @@ klaw-sync@^6.0.0: dependencies: graceful-fs "^4.1.11" +klaw@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz#b11bec9cf2492f06756d6e809ab73a2910259146" + integrity sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g== + dependencies: + graceful-fs "^4.1.9" + kleur@^4.1.4: version "4.1.5" resolved "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz" @@ -11649,6 +11747,13 @@ lines-and-columns@^1.1.6: resolved "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz" integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA= +linkify-it@^5.0.0: + version "5.0.0" + resolved "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz#9ef238bfa6dc70bd8e7f9572b52d369af569b421" + integrity sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ== + dependencies: + uc.micro "^2.0.0" + listr-silent-renderer@^1.1.1: version "1.1.1" resolved "https://registry.npmjs.org/listr-silent-renderer/-/listr-silent-renderer-1.1.1.tgz" @@ -12193,6 +12298,23 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" +markdown-it-anchor@^8.6.7: + version "8.6.7" + resolved "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-8.6.7.tgz#ee6926daf3ad1ed5e4e3968b1740eef1c6399634" + integrity sha512-FlCHFwNnutLgVTflOYHPW2pPcl2AACqVzExlkGQNsi4CJgqOHN7YTgDd4LuhgN1BFO3TS0vLAruV1Td6dwWPJA== + +markdown-it@^14.1.0: + version "14.1.0" + resolved "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz#3c3c5992883c633db4714ccb4d7b5935d98b7d45" + integrity sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg== + dependencies: + argparse "^2.0.1" + entities "^4.4.0" + linkify-it "^5.0.0" + mdurl "^2.0.0" + punycode.js "^2.3.1" + uc.micro "^2.1.0" + marked-terminal@^5.1.1: version "5.1.1" resolved "https://registry.npmjs.org/marked-terminal/-/marked-terminal-5.1.1.tgz" @@ -12210,6 +12332,11 @@ marked@^0.8.0: resolved "https://registry.npmjs.org/marked/-/marked-0.8.2.tgz" integrity sha512-EGwzEeCcLniFX51DhTpmTom+dSA/MG/OBUDjnWtHbEnjAH180VzUeAw+oE4+Zv+CoYBWyRlYOTR0N8SO9R1PVw== +marked@^4.0.10: + version "4.3.0" + resolved "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz#796362821b019f734054582038b116481b456cf3" + integrity sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A== + marked@^4.0.14: version "4.0.18" resolved "https://registry.npmjs.org/marked/-/marked-4.0.18.tgz" @@ -12234,6 +12361,11 @@ md5.js@^1.3.4: inherits "^2.0.1" safe-buffer "^5.1.2" +mdurl@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz#80676ec0433025dd3e17ee983d0fe8de5a2237e0" + integrity sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w== + media-typer@0.3.0: version "0.3.0" resolved "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz" @@ -14285,6 +14417,22 @@ proto3-json-serializer@^1.0.0: dependencies: protobufjs "^6.11.3" +protobufjs-cli@^1.1.3: + version "1.1.3" + resolved "https://registry.npmjs.org/protobufjs-cli/-/protobufjs-cli-1.1.3.tgz#c58b8566784f0fa1aff11e8d875a31de999637fe" + integrity sha512-MqD10lqF+FMsOayFiNOdOGNlXc4iKDCf0ZQPkPR+gizYh9gqUeGTWulABUCdI+N67w5RfJ6xhgX4J8pa8qmMXQ== + dependencies: + chalk "^4.0.0" + escodegen "^1.13.0" + espree "^9.0.0" + estraverse "^5.1.0" + glob "^8.0.0" + jsdoc "^4.0.0" + minimist "^1.2.0" + semver "^7.1.2" + tmp "^0.2.1" + uglify-js "^3.7.7" + protobufjs@6.11.3: version "6.11.3" resolved "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.3.tgz#637a527205a35caa4f3e2a9a4a13ddffe0e7af74" @@ -14446,6 +14594,11 @@ pumpify@^1.3.5: inherits "^2.0.3" pump "^2.0.0" +punycode.js@^2.3.1: + version "2.3.1" + resolved "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz#6b53e56ad75588234e79f4affa90972c7dd8cdb7" + integrity sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA== + punycode@1.3.2: version "1.3.2" resolved "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz" @@ -15079,6 +15232,13 @@ requires-port@^1.0.0: resolved "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz" integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8= +requizzle@^0.2.3: + version "0.2.4" + resolved "https://registry.npmjs.org/requizzle/-/requizzle-0.2.4.tgz#319eb658b28c370f0c20f968fa8ceab98c13d27c" + integrity sha512-JRrFk1D4OQ4SqovXOgdav+K8EAhSB/LJZqCz8tbX0KObcdeM15Ss59ozWMBWmmINMagCwmqn4ZNryUGpBsl6Jw== + dependencies: + lodash "^4.17.21" + resolve-alpn@^1.0.0: version "1.2.1" resolved "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz" @@ -15574,7 +15734,7 @@ semver@^7.0.0, semver@^7.1.1, semver@^7.1.3, semver@^7.3.2, semver@^7.3.4, semve dependencies: lru-cache "^6.0.0" -semver@^7.5.4, semver@^7.6.0: +semver@^7.1.2, semver@^7.5.4, semver@^7.6.0: version "7.6.3" resolved "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143" integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A== @@ -16502,7 +16662,7 @@ strip-indent@^3.0.0: dependencies: min-indent "^1.0.0" -strip-json-comments@3.1.1, strip-json-comments@^3.1.1, strip-json-comments@~3.1.1: +strip-json-comments@3.1.1, strip-json-comments@^3.1.0, strip-json-comments@^3.1.1, strip-json-comments@~3.1.1: version "3.1.1" resolved "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== @@ -17324,11 +17484,21 @@ ua-parser-js@^0.7.30: resolved "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.37.tgz#e464e66dac2d33a7a1251d7d7a99d6157ec27832" integrity sha512-xV8kqRKM+jhMvcHWUKthV9fNebIzrNy//2O9ZwWcfiBFR5f25XVZPLlEajk/sf3Ra15V92isyQqnIEXRDaZWEA== +uc.micro@^2.0.0, uc.micro@^2.1.0: + version "2.1.0" + resolved "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz#f8d3f7d0ec4c3dea35a7e3c8efa4cb8b45c9e7ee" + integrity sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A== + uglify-js@^3.1.4, uglify-js@^3.4.9: version "3.14.2" resolved "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.2.tgz" integrity sha512-rtPMlmcO4agTUfz10CbgJ1k6UAoXM2gWb3GoMPPZB/+/Ackf8lNWk11K4rYi2D0apgoFRLtQOZhb+/iGNJq26A== +uglify-js@^3.7.7: + version "3.19.3" + resolved "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz#82315e9bbc6f2b25888858acd1fff8441035b77f" + integrity sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ== + uid-number@0.0.6: version "0.0.6" resolved "https://registry.npmjs.org/uid-number/-/uid-number-0.0.6.tgz" @@ -17369,6 +17539,11 @@ underscore@>=1.8.3, underscore@^1.9.1: resolved "https://registry.npmjs.org/underscore/-/underscore-1.13.1.tgz" integrity sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g== +underscore@~1.13.2: + version "1.13.7" + resolved "https://registry.npmjs.org/underscore/-/underscore-1.13.7.tgz#970e33963af9a7dda228f17ebe8399e5fbe63a10" + integrity sha512-GMXzWtsc57XAtguZgaQViUOzs0KTkk8ojr3/xAxXLITqf/3EMwxC0inyETfDFjH/Krbhuep0HNbbjI9i/q3F3g== + undertaker-registry@^1.0.0: version "1.0.1" resolved "https://registry.npmjs.org/undertaker-registry/-/undertaker-registry-1.0.1.tgz" @@ -18315,6 +18490,11 @@ xmlbuilder@~11.0.0: resolved "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz" integrity sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA== +xmlcreate@^2.0.4: + version "2.0.4" + resolved "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.4.tgz#0c5ab0f99cdd02a81065fa9cd8f8ae87624889be" + integrity sha512-nquOebG4sngPmGPICTS5EnxqhKbCmz5Ox5hsszI2T6U5qdrJizBc+0ilYSEjTSzU0yZcmvppztXe/5Al5fUwdg== + xregexp@2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz" From 076236e2e5df862b8d137b3035df3fb8443eb7ca Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:08:07 -0600 Subject: [PATCH 10/59] Fixes. Passing integration tests. --- common/api-review/firestore-lite.api.md | 6 +- common/api-review/firestore.api.md | 6 +- packages/firestore/src/lite-api/pipeline.ts | 36 ++++---- packages/firestore/src/lite-api/reference.ts | 90 ++++--------------- .../test/integration/api/pipeline.test.ts | 49 ++++++++-- 5 files changed, 82 insertions(+), 105 deletions(-) diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 97cf9d7189c..4117ff2d3ca 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -2176,8 +2176,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9258:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9259:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9288:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9258:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9259:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9288:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index c746620442d..f8f76b050c9 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -2464,8 +2464,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10108:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10109:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10138:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10108:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10109:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10138:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/packages/firestore/src/lite-api/pipeline.ts b/packages/firestore/src/lite-api/pipeline.ts index 9015182bc5d..924eaa9b810 100644 --- a/packages/firestore/src/lite-api/pipeline.ts +++ b/packages/firestore/src/lite-api/pipeline.ts @@ -223,7 +223,9 @@ export class Pipeline { */ select(...selections: Array): Pipeline { const copy = this.stages.map(s => s); - copy.push(new Select(this.selectablesToMap(selections))); + let projections: Map = this.selectablesToMap(selections); + projections = this.readUserData('select', projections); + copy.push(new Select(projections)); return new Pipeline( this.liteDb, this.userDataReader, @@ -781,20 +783,24 @@ export class Pipeline { execute(): Promise>> { const datastore = getDatastore(this.liteDb); return invokeExecutePipeline(datastore, this).then(result => { - const docs = result.map( - element => - new PipelineResult( - this.userDataWriter, - element.key?.path - ? this.documentReferenceFactory(element.key) - : undefined, - element.fields, - element.executionTime?.toTimestamp(), - element.createTime?.toTimestamp(), - element.updateTime?.toTimestamp() - //this.converter - ) - ); + const docs = result + // Currently ignore any response from ExecutePipeline that does + // not contain any document data in the `fields` property. + .filter(element => !!element.fields) + .map( + element => + new PipelineResult( + this.userDataWriter, + element.key?.path + ? this.documentReferenceFactory(element.key) + : undefined, + element.fields, + element.executionTime?.toTimestamp(), + element.createTime?.toTimestamp(), + element.updateTime?.toTimestamp() + //this.converter + ) + ); return docs; }); diff --git a/packages/firestore/src/lite-api/reference.ts b/packages/firestore/src/lite-api/reference.ts index 966a8a4cc23..c51a514015c 100644 --- a/packages/firestore/src/lite-api/reference.ts +++ b/packages/firestore/src/lite-api/reference.ts @@ -184,81 +184,21 @@ export class Query< * @internal */ pipeline(): Pipeline { - throw Error('Not implemented - Query.pipeline()'); - // let pipeline; - // if (this._queryOptions.allDescendants) { - // pipeline = this.firestore - // .pipeline() - // .collectionGroup(this._queryOptions.collectionId); - // } else { - // pipeline = this.firestore - // .pipeline() - // .collection( - // this._queryOptions.parentPath.append(this._queryOptions.collectionId) - // .relativeName - // ); - // } - - // // filters - // for (const f of this._queryOptions.filters) { - // pipeline = pipeline.where(toPipelineFilterCondition(f, this._serializer)); - // } - - // // projections - // const projections = this._queryOptions.projection?.fields || []; - // if (projections.length > 0) { - // pipeline = pipeline.select( - // ...projections.map(p => Field.of(p.fieldPath!)) - // ); - // } - - // // orderbys - // const exists = this.createImplicitOrderBy().map(fieldOrder => { - // return Field.of(fieldOrder.field).exists(); - // }); - // if (exists.length > 1) { - // const [first, ...rest] = exists; - // pipeline = pipeline.where(and(first, ...rest)); - // } else if (exists.length === 1) { - // pipeline = pipeline.where(exists[0]); - // } - - // const orderings = this.createImplicitOrderBy().map(fieldOrder => { - // let dir: 'ascending' | 'descending' | undefined = undefined; - // switch (fieldOrder.direction) { - // case 'ASCENDING': { - // dir = 'ascending'; - // break; - // } - // case 'DESCENDING': { - // dir = 'descending'; - // break; - // } - // } - // return new Ordering(Field.of(fieldOrder.field), dir || 'ascending'); - // }); - // if (orderings.length > 0) { - // pipeline = pipeline.sort({orderings: orderings}); - // } - - // // Cursors, Limit and Offset - // if ( - // !!this._queryOptions.startAt || - // !!this._queryOptions.endAt || - // this._queryOptions.limitType === LimitType.Last - // ) { - // throw new Error( - // 'Query to Pipeline conversion: cursors and limitToLast is not supported yet.' - // ); - // } else { - // if (this._queryOptions.offset) { - // pipeline = pipeline.offset(this._queryOptions.offset); - // } - // if (this._queryOptions.limit) { - // pipeline = pipeline.limit(this._queryOptions.limit); - // } - // } - // return pipeline; + let pipeline; + if (this._query.collectionGroup) { + pipeline = this.firestore + .pipeline() + .collectionGroup(this._query.collectionGroup); + } else { + pipeline = this.firestore + .pipeline() + .collection(this._query.path.canonicalString()); + } + + // TODO(pipeline) convert existing query filters, limits, etc into + // pipeline stages + + return pipeline; } } diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index 03950690e77..48e4e3a4c1b 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -229,6 +229,7 @@ apiDescribe.only('Pipelines', persistence => { beforeEach(async () => { const setupDeferred = new Deferred(); + testDeferred = new Deferred(); withTestCollectionPromise = withTestCollection( persistence, {}, @@ -242,7 +243,7 @@ apiDescribe.only('Pipelines', persistence => { } ); - await setupDeferred; + await setupDeferred.promise; }); afterEach(async () => { @@ -250,13 +251,23 @@ apiDescribe.only('Pipelines', persistence => { await withTestCollectionPromise; }); + // setLogLevel('debug') + it('empty results as expected', async () => { const result = await firestore .pipeline() .collection(randomCol.path) .limit(0) .execute(); - expect(result).to.be.empty; + expect(result.length).to.equal(0); + }); + + it('full results as expected', async () => { + const result = await firestore + .pipeline() + .collection(randomCol.path) + .execute(); + expect(result.length).to.equal(10); }); it('returns aggregate results as expected', async () => { @@ -292,7 +303,8 @@ apiDescribe.only('Pipelines', persistence => { ).to.be.rejected; }); - it('returns distinct values as expected', async () => { + // skip: toLower not supported + it.skip('returns distinct values as expected', async () => { const results = await randomCol .pipeline() .where(lt('published', 1900)) @@ -314,6 +326,7 @@ apiDescribe.only('Pipelines', persistence => { groups: ['genre'] }) .where(gt('avgRating', 4.3)) + .sort(Field.of('avgRating').descending()) .execute(); expectResults( results, @@ -446,7 +459,8 @@ apiDescribe.only('Pipelines', persistence => { expect(results.length).to.equal(10); }); - it('arrayConcat works', async () => { + // skip: arrayConcat not supported + it.skip('arrayConcat works', async () => { const results = await randomCol .pipeline() .select( @@ -510,18 +524,33 @@ apiDescribe.only('Pipelines', persistence => { Field.of('title') ) .where(gt('titleLength', 20)) + .sort(Field.of('title').ascending()) .execute(); + expectResults( results, - { titleLength: 32, title: "The Hitchhiker's Guide to the Galaxy" }, + { - titleLength: 27, + titleLength: 29, title: 'One Hundred Years of Solitude' + }, + { + titleLength: 36, + title: "The Hitchhiker's Guide to the Galaxy" + }, + { + titleLength: 21, + title: 'The Lord of the Rings' + }, + { + titleLength: 21, + title: 'To Kill a Mockingbird' } ); }); - it('testToLowercase', async () => { + // skip: toLower not supported + it.skip('testToLowercase', async () => { const results = await randomCol .pipeline() .select(Field.of('title').toLower().as('lowercaseTitle')) @@ -532,7 +561,8 @@ apiDescribe.only('Pipelines', persistence => { }); }); - it('testToUppercase', async () => { + // skip: toUpper not supported + it.skip('testToUppercase', async () => { const results = await randomCol .pipeline() .select(Field.of('author').toUpper().as('uppercaseAuthor')) @@ -541,7 +571,8 @@ apiDescribe.only('Pipelines', persistence => { expectResults(results, { uppercaseAuthor: 'DOUGLAS ADAMS' }); }); - it('testTrim', async () => { + // skip: trim not supported + it.skip('testTrim', async () => { const results = await randomCol .pipeline() .addFields(strConcat(' ', Field.of('title'), ' ').as('spacedTitle')) From 8af0c57e286faeced06e465dd5b1eb3755034252 Mon Sep 17 00:00:00 2001 From: MarkDuckworth Date: Mon, 28 Oct 2024 20:22:01 +0000 Subject: [PATCH 11/59] Update API reports --- common/api-review/firestore-lite.api.md | 6 +++--- common/api-review/firestore.api.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 4117ff2d3ca..97cf9d7189c 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -2176,8 +2176,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9258:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9259:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9288:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9258:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9259:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9288:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index f8f76b050c9..c746620442d 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -2464,8 +2464,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10108:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10109:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10138:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10108:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10109:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10138:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` From 57d1bf9aad3f5dec391df5c5ca0bff248c3b0084 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Tue, 29 Oct 2024 11:20:22 -0600 Subject: [PATCH 12/59] Move call to readUserData for code readability --- packages/firestore/src/lite-api/pipeline.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/firestore/src/lite-api/pipeline.ts b/packages/firestore/src/lite-api/pipeline.ts index 924eaa9b810..fb7c3b50d53 100644 --- a/packages/firestore/src/lite-api/pipeline.ts +++ b/packages/firestore/src/lite-api/pipeline.ts @@ -316,7 +316,8 @@ export class Pipeline { */ where(condition: FilterCondition & Expr): Pipeline { const copy = this.stages.map(s => s); - copy.push(new Where(this.readUserData('where', condition))); + this.readUserData('where', condition); + copy.push(new Where(condition)); return new Pipeline( this.liteDb, this.userDataReader, From 4f9a5fc469fba413dcd923ed65451a41b8054e5a Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Tue, 29 Oct 2024 13:39:54 -0600 Subject: [PATCH 13/59] Made ProtoSerializable generic and used by Pipeline and Stage --- packages/firestore/src/lite-api/expressions.ts | 2 +- packages/firestore/src/lite-api/pipeline.ts | 4 ++-- packages/firestore/src/lite-api/stage.ts | 10 ++-------- packages/firestore/src/remote/serializer.ts | 8 ++++---- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/packages/firestore/src/lite-api/expressions.ts b/packages/firestore/src/lite-api/expressions.ts index 047df3d8b15..d12c17bdeda 100644 --- a/packages/firestore/src/lite-api/expressions.ts +++ b/packages/firestore/src/lite-api/expressions.ts @@ -122,7 +122,7 @@ export type ExprType = * The `Expr` class provides a fluent API for building expressions. You can chain together * method calls to create complex expressions. */ -export abstract class Expr implements ProtoSerializable, UserData { +export abstract class Expr implements ProtoSerializable, UserData { /** * Creates an expression that adds this expression to another expression. * diff --git a/packages/firestore/src/lite-api/pipeline.ts b/packages/firestore/src/lite-api/pipeline.ts index fb7c3b50d53..4998692f0d0 100644 --- a/packages/firestore/src/lite-api/pipeline.ts +++ b/packages/firestore/src/lite-api/pipeline.ts @@ -24,7 +24,7 @@ import { import { invokeExecutePipeline } from '../remote/datastore'; import { getEncodedDatabaseId, - JsonProtoSerializer + JsonProtoSerializer, ProtoSerializable } from '../remote/serializer'; import { getDatastore } from './components'; @@ -117,7 +117,7 @@ function isReadableUserData(value: any): value is ReadableUserData { /** * Base-class implementation */ -export class Pipeline { +export class Pipeline implements ProtoSerializable{ /** * @internal * @private diff --git a/packages/firestore/src/lite-api/stage.ts b/packages/firestore/src/lite-api/stage.ts index 4cd684fbaac..0a9ce8b7e35 100644 --- a/packages/firestore/src/lite-api/stage.ts +++ b/packages/firestore/src/lite-api/stage.ts @@ -19,7 +19,7 @@ import { } from '../protos/firestore_proto_api'; import { toNumber } from '../remote/number_serializer'; import { - JsonProtoSerializer, + JsonProtoSerializer, ProtoSerializable, toMapValue, toStringValue } from '../remote/serializer'; @@ -37,14 +37,8 @@ import { VectorValue } from './vector_value'; /** * @beta */ -export interface Stage { +export interface Stage extends ProtoSerializable{ name: string; - - /** - * @internal - * @private - */ - _toProto(jsonProtoSerializer: JsonProtoSerializer): ProtoStage; } /** diff --git a/packages/firestore/src/remote/serializer.ts b/packages/firestore/src/remote/serializer.ts index 963116a1ba7..4759571b4a5 100644 --- a/packages/firestore/src/remote/serializer.ts +++ b/packages/firestore/src/remote/serializer.ts @@ -1429,8 +1429,8 @@ export function isValidResourceName(path: ResourcePath): boolean { ); } -export interface ProtoSerializable { - _toProto(serializer: JsonProtoSerializer): ProtoValue; +export interface ProtoSerializable { + _toProto(serializer: JsonProtoSerializer): ProtoType; } export interface UserData { @@ -1439,10 +1439,10 @@ export interface UserData { export function toMapValue( serializer: JsonProtoSerializer, - input: Map + input: Map> ): ProtoValue { const map: ProtoMapValue = { fields: {} }; - input.forEach((exp: ProtoSerializable, key: string) => { + input.forEach((exp: ProtoSerializable, key: string) => { if (typeof key !== 'string') { throw new Error(`Cannot encode map with non-string key: ${key}`); } From 6717ed4d05985d3f48487088a934936020e10ca2 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Thu, 31 Oct 2024 13:45:41 -0600 Subject: [PATCH 14/59] Fixing build and lint issues --- common/api-review/firestore-lite.api.md | 6 +- common/api-review/firestore.api.md | 6 +- .../firestore/src/core/firestore_client.ts | 2 +- packages/firestore/src/lite-api/pipeline.ts | 7 +- packages/firestore/src/lite-api/stage.ts | 5 +- packages/firestore/src/remote/datastore.ts | 2 +- .../test/integration/api/pipeline.test.ts | 115 +++++++++--------- 7 files changed, 73 insertions(+), 70 deletions(-) diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 97cf9d7189c..4117ff2d3ca 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -2176,8 +2176,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9258:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9259:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9288:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9258:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9259:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9288:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index c746620442d..f8f76b050c9 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -2464,8 +2464,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10108:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10109:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10138:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10108:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10109:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10138:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/packages/firestore/src/core/firestore_client.ts b/packages/firestore/src/core/firestore_client.ts index 57aa99869da..508535f8636 100644 --- a/packages/firestore/src/core/firestore_client.ts +++ b/packages/firestore/src/core/firestore_client.ts @@ -556,7 +556,7 @@ export function firestoreClientRunAggregateQuery( export function firestoreClientExecutePipeline( client: FirestoreClient, - pipeline: Pipeline + pipeline: Pipeline ): Promise { const deferred = new Deferred(); diff --git a/packages/firestore/src/lite-api/pipeline.ts b/packages/firestore/src/lite-api/pipeline.ts index 4998692f0d0..e346b5a16ef 100644 --- a/packages/firestore/src/lite-api/pipeline.ts +++ b/packages/firestore/src/lite-api/pipeline.ts @@ -24,7 +24,8 @@ import { import { invokeExecutePipeline } from '../remote/datastore'; import { getEncodedDatabaseId, - JsonProtoSerializer, ProtoSerializable + JsonProtoSerializer, + ProtoSerializable } from '../remote/serializer'; import { getDatastore } from './components'; @@ -117,7 +118,9 @@ function isReadableUserData(value: any): value is ReadableUserData { /** * Base-class implementation */ -export class Pipeline implements ProtoSerializable{ +export class Pipeline + implements ProtoSerializable +{ /** * @internal * @private diff --git a/packages/firestore/src/lite-api/stage.ts b/packages/firestore/src/lite-api/stage.ts index 0a9ce8b7e35..9f4c7735f03 100644 --- a/packages/firestore/src/lite-api/stage.ts +++ b/packages/firestore/src/lite-api/stage.ts @@ -19,7 +19,8 @@ import { } from '../protos/firestore_proto_api'; import { toNumber } from '../remote/number_serializer'; import { - JsonProtoSerializer, ProtoSerializable, + JsonProtoSerializer, + ProtoSerializable, toMapValue, toStringValue } from '../remote/serializer'; @@ -37,7 +38,7 @@ import { VectorValue } from './vector_value'; /** * @beta */ -export interface Stage extends ProtoSerializable{ +export interface Stage extends ProtoSerializable { name: string; } diff --git a/packages/firestore/src/remote/datastore.ts b/packages/firestore/src/remote/datastore.ts index 00c1e7fca9e..5fbff4392ac 100644 --- a/packages/firestore/src/remote/datastore.ts +++ b/packages/firestore/src/remote/datastore.ts @@ -241,7 +241,7 @@ export async function invokeBatchGetDocumentsRpc( export async function invokeExecutePipeline( datastore: Datastore, - pipeline: Pipeline + pipeline: Pipeline ): Promise { const datastoreImpl = debugCast(datastore, DatastoreImpl); const executePipelineRequest = pipeline._toProto(datastoreImpl.serializer); diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index 48e4e3a4c1b..fffa5240b85 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -48,7 +48,6 @@ import { regexMatch, setDoc, startsWith, - strConcat, subtract } from '../util/firebase_export'; import { apiDescribe, withTestCollection } from '../util/helpers'; @@ -304,18 +303,18 @@ apiDescribe.only('Pipelines', persistence => { }); // skip: toLower not supported - it.skip('returns distinct values as expected', async () => { - const results = await randomCol - .pipeline() - .where(lt('published', 1900)) - .distinct(Field.of('genre').toLower().as('lowerGenre')) - .execute(); - expectResults( - results, - { lowerGenre: 'romance' }, - { lowerGenre: 'psychological thriller' } - ); - }); + // it.skip('returns distinct values as expected', async () => { + // const results = await randomCol + // .pipeline() + // .where(lt('published', 1900)) + // .distinct(Field.of('genre').toLower().as('lowerGenre')) + // .execute(); + // expectResults( + // results, + // { lowerGenre: 'romance' }, + // { lowerGenre: 'psychological thriller' } + // ); + // }); it('returns group and accumulate results', async () => { const results = await randomCol @@ -460,18 +459,18 @@ apiDescribe.only('Pipelines', persistence => { }); // skip: arrayConcat not supported - it.skip('arrayConcat works', async () => { - const results = await randomCol - .pipeline() - .select( - Field.of('tags').arrayConcat(['newTag1', 'newTag2']).as('modifiedTags') - ) - .limit(1) - .execute(); - expectResults(results, { - modifiedTags: ['comedy', 'space', 'adventure', 'newTag1', 'newTag2'] - }); - }); + // it.skip('arrayConcat works', async () => { + // const results = await randomCol + // .pipeline() + // .select( + // Field.of('tags').arrayConcat(['newTag1', 'newTag2']).as('modifiedTags') + // ) + // .limit(1) + // .execute(); + // expectResults(results, { + // modifiedTags: ['comedy', 'space', 'adventure', 'newTag1', 'newTag2'] + // }); + // }); it('testStrConcat', async () => { const results = await randomCol @@ -550,43 +549,43 @@ apiDescribe.only('Pipelines', persistence => { }); // skip: toLower not supported - it.skip('testToLowercase', async () => { - const results = await randomCol - .pipeline() - .select(Field.of('title').toLower().as('lowercaseTitle')) - .limit(1) - .execute(); - expectResults(results, { - lowercaseTitle: "the hitchhiker's guide to the galaxy" - }); - }); + // it.skip('testToLowercase', async () => { + // const results = await randomCol + // .pipeline() + // .select(Field.of('title').toLower().as('lowercaseTitle')) + // .limit(1) + // .execute(); + // expectResults(results, { + // lowercaseTitle: "the hitchhiker's guide to the galaxy" + // }); + // }); // skip: toUpper not supported - it.skip('testToUppercase', async () => { - const results = await randomCol - .pipeline() - .select(Field.of('author').toUpper().as('uppercaseAuthor')) - .limit(1) - .execute(); - expectResults(results, { uppercaseAuthor: 'DOUGLAS ADAMS' }); - }); + // it.skip('testToUppercase', async () => { + // const results = await randomCol + // .pipeline() + // .select(Field.of('author').toUpper().as('uppercaseAuthor')) + // .limit(1) + // .execute(); + // expectResults(results, { uppercaseAuthor: 'DOUGLAS ADAMS' }); + // }); // skip: trim not supported - it.skip('testTrim', async () => { - const results = await randomCol - .pipeline() - .addFields(strConcat(' ', Field.of('title'), ' ').as('spacedTitle')) - .select( - Field.of('spacedTitle').trim().as('trimmedTitle'), - Field.of('spacedTitle') - ) - .limit(1) - .execute(); - expectResults(results, { - spacedTitle: " The Hitchhiker's Guide to the Galaxy ", - trimmedTitle: "The Hitchhiker's Guide to the Galaxy" - }); - }); + // it.skip('testTrim', async () => { + // const results = await randomCol + // .pipeline() + // .addFields(strConcat(' ', Field.of('title'), ' ').as('spacedTitle')) + // .select( + // Field.of('spacedTitle').trim().as('trimmedTitle'), + // Field.of('spacedTitle') + // ) + // .limit(1) + // .execute(); + // expectResults(results, { + // spacedTitle: " The Hitchhiker's Guide to the Galaxy ", + // trimmedTitle: "The Hitchhiker's Guide to the Galaxy" + // }); + // }); it('testLike', async () => { const results = await randomCol From 3ab4f5c87d06893eb3d9d3f78b2167e8e6c72aa1 Mon Sep 17 00:00:00 2001 From: MarkDuckworth Date: Thu, 31 Oct 2024 19:58:50 +0000 Subject: [PATCH 15/59] Update API reports --- common/api-review/firestore-lite.api.md | 6 +++--- common/api-review/firestore.api.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 4117ff2d3ca..97cf9d7189c 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -2176,8 +2176,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9258:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9259:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9288:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9258:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9259:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9288:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index f8f76b050c9..c746620442d 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -2464,8 +2464,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10108:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10109:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10138:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10108:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10109:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10138:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` From fd20eff30092a65cab35dae32f73c0057601af11 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Thu, 31 Oct 2024 14:45:05 -0600 Subject: [PATCH 16/59] Adding new bundle size test --- .../bundle-definitions/firestore.json | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/repo-scripts/size-analysis/bundle-definitions/firestore.json b/repo-scripts/size-analysis/bundle-definitions/firestore.json index f5ddafd167c..51416a76cfc 100644 --- a/repo-scripts/size-analysis/bundle-definitions/firestore.json +++ b/repo-scripts/size-analysis/bundle-definitions/firestore.json @@ -128,6 +128,37 @@ } ] }, + { + "name": "Pipeline Query with lt filter", + "dependencies": [ + { + "packageName": "firebase", + "versionOrTag": "latest", + "imports": [ + { + "path": "app", + "imports": [ + "initializeApp" + ] + } + ] + }, + { + "packageName": "firebase", + "versionOrTag": "latest", + "imports": [ + { + "path": "firestore", + "imports": [ + "getFirestore", + "lt", + "Field" + ] + } + ] + } + ] + }, { "name": "Query Cursors", "dependencies": [ From 90a5e3c90f807723d81f4b9de984225f71ec2806 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Mon, 4 Nov 2024 15:51:51 -0700 Subject: [PATCH 17/59] experimentation with augmentation for ppl --- common/api-review/firestore-lite.api.md | 13 +++-- common/api-review/firestore.api.md | 13 +++-- packages/firestore/lite/index.ts | 2 + packages/firestore/src/api.ts | 2 + .../src/api/database-augmentation.ts | 52 ++++++++++++++++++ packages/firestore/src/api/database.ts | 28 ++++------ .../src/lite-api/database-augmentation.ts | 53 +++++++++++++++++++ packages/firestore/src/lite-api/database.ts | 27 ++++------ packages/firestore/src/lite-api/reference.ts | 33 ++++-------- .../test/integration/api/pipeline.test.ts | 4 +- 10 files changed, 155 insertions(+), 72 deletions(-) create mode 100644 packages/firestore/src/api/database-augmentation.ts create mode 100644 packages/firestore/src/lite-api/database-augmentation.ts diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 97cf9d7189c..816dc4c4e66 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -1029,10 +1029,6 @@ export interface FindNearestOptions { // @public export class Firestore { get app(): FirebaseApp; - // Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta - // - // (undocumented) - pipeline(): PipelineSource; toJSON(): object; type: 'firestore-lite' | 'firestore'; } @@ -2111,6 +2107,9 @@ export function updateDoc(refere // @public export function updateDoc(reference: DocumentReference, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise; +// @public (undocumented) +export function useFirestorePipelines(): void; + // @public export function vector(values?: number[]): VectorValue; @@ -2176,8 +2175,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9258:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9259:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9288:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9257:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9258:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9287:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index c746620442d..cdd17494e4c 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -1073,10 +1073,6 @@ export interface FindNearestOptions { // @public export class Firestore { get app(): FirebaseApp; - // Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta - // - // (undocumented) - pipeline: () => PipelineSource; toJSON(): object; type: 'firestore-lite' | 'firestore'; } @@ -2396,6 +2392,9 @@ export function updateDoc(refere // @public export function updateDoc(reference: DocumentReference, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise; +// @public (undocumented) +export function useFirestorePipelines(): void; + // @public export function vector(values?: number[]): VectorValue; @@ -2464,8 +2463,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10108:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10109:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10138:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10107:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10108:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10137:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/packages/firestore/lite/index.ts b/packages/firestore/lite/index.ts index 9969924b5b7..aba1433aa64 100644 --- a/packages/firestore/lite/index.ts +++ b/packages/firestore/lite/index.ts @@ -33,6 +33,8 @@ export { PipelineResult } from '../src/lite-api/pipeline-result'; export { Pipeline } from '../src/lite-api/pipeline'; +export { useFirestorePipelines } from '../src/lite-api/database-augmentation'; + export { Stage, FindNearestOptions, diff --git a/packages/firestore/src/api.ts b/packages/firestore/src/api.ts index 7193bff675a..8b640ca3a62 100644 --- a/packages/firestore/src/api.ts +++ b/packages/firestore/src/api.ts @@ -21,6 +21,8 @@ export { PipelineResult } from './lite-api/pipeline-result'; export { Pipeline } from './lite-api/pipeline'; +export { useFirestorePipelines } from './api/database-augmentation'; + export { Stage, FindNearestOptions, diff --git a/packages/firestore/src/api/database-augmentation.ts b/packages/firestore/src/api/database-augmentation.ts new file mode 100644 index 00000000000..9f272b3a05e --- /dev/null +++ b/packages/firestore/src/api/database-augmentation.ts @@ -0,0 +1,52 @@ +import { Pipeline } from '../lite-api/pipeline'; +import { PipelineSource } from '../lite-api/pipeline-source'; +import { newUserDataReader } from '../lite-api/user_data_reader'; +import { DocumentKey } from '../model/document_key'; + +import { Firestore } from './database'; +import { DocumentReference, Query } from './reference'; +import { ExpUserDataWriter } from './user_data_writer'; + +declare module './database' { + interface Firestore { + pipeline(): PipelineSource; + } +} + +declare module './reference' { + interface Query { + pipeline(): Pipeline; + } +} + +export function useFirestorePipelines(): void { + Firestore.prototype.pipeline = function (): PipelineSource { + const firestore = this; + return new PipelineSource( + this, + newUserDataReader(firestore), + new ExpUserDataWriter(firestore), + (key: DocumentKey) => { + return new DocumentReference(firestore, null, key); + } + ); + }; + + Query.prototype.pipeline = function (): Pipeline { + let pipeline; + if (this._query.collectionGroup) { + pipeline = this.firestore + .pipeline() + .collectionGroup(this._query.collectionGroup); + } else { + pipeline = this.firestore + .pipeline() + .collection(this._query.path.canonicalString()); + } + + // TODO(pipeline) convert existing query filters, limits, etc into + // pipeline stages + + return pipeline; + }; +} diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index 812811f41ed..827f3f1de35 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -46,16 +46,13 @@ import { connectFirestoreEmulator, Firestore as LiteFirestore } from '../lite-api/database'; -import { PipelineSource } from '../lite-api/pipeline-source'; -import { DocumentReference, Query } from '../lite-api/reference'; -import { newUserDataReader } from '../lite-api/user_data_reader'; +import { Query } from '../lite-api/reference'; import { indexedDbClearPersistence, indexedDbStoragePrefix } from '../local/indexeddb_persistence'; import { LRU_COLLECTION_DISABLED } from '../local/lru_garbage_collector'; import { LRU_MINIMUM_CACHE_SIZE_BYTES } from '../local/lru_garbage_collector_impl'; -import { DocumentKey } from '../model/document_key'; import { debugAssert } from '../util/assert'; import { AsyncQueue } from '../util/async_queue'; import { AsyncQueueImpl } from '../util/async_queue_impl'; @@ -67,7 +64,6 @@ import { Deferred } from '../util/promise'; import { LoadBundleTask } from './bundle'; import { CredentialsProvider } from './credentials'; import { FirestoreSettings, PersistenceSettings } from './settings'; -import { ExpUserDataWriter } from './user_data_writer'; export { connectFirestoreEmulator, @@ -108,18 +104,6 @@ export class Firestore extends LiteFirestore { _online: OnlineComponentProviderFactory; }; - pipeline = (): PipelineSource => { - const firestore = this; - return new PipelineSource( - this, - newUserDataReader(firestore), - new ExpUserDataWriter(firestore), - (key: DocumentKey) => { - return new DocumentReference(firestore, null, key); - } - ); - }; - /** @hideconstructor */ constructor( authCredentialsProvider: CredentialsProvider, @@ -146,6 +130,16 @@ export class Firestore extends LiteFirestore { } } +// Undocumented method of Firestore. This is only +// in place to give developers a runtime error suggesting +// how to correctly initialize Firestore for use with Pipelines. +// @ts-ignore +Firestore.prototype.pipeline = function (): unknown { + throw new Error( + 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' + ); +}; + /** * Initializes a new instance of {@link Firestore} with the provided settings. * Can only be called before any other function, including diff --git a/packages/firestore/src/lite-api/database-augmentation.ts b/packages/firestore/src/lite-api/database-augmentation.ts new file mode 100644 index 00000000000..95dab65587d --- /dev/null +++ b/packages/firestore/src/lite-api/database-augmentation.ts @@ -0,0 +1,53 @@ +import { DocumentKey } from '../model/document_key'; + +import { Firestore } from './database'; +import { Pipeline } from './pipeline'; +import { PipelineSource } from './pipeline-source'; +import { DocumentReference, Query } from './reference'; +import { LiteUserDataWriter } from './reference_impl'; +import { newUserDataReader } from './user_data_reader'; + +declare module './database' { + interface Firestore { + pipeline(): PipelineSource; + } +} + +declare module './reference' { + interface Query { + pipeline(): Pipeline; + } +} + +export function useFirestorePipelines(): void { + Firestore.prototype.pipeline = function (): PipelineSource { + const userDataWriter = new LiteUserDataWriter(this); + const userDataReader = newUserDataReader(this); + return new PipelineSource( + this, + userDataReader, + userDataWriter, + (key: DocumentKey) => { + return new DocumentReference(this, null, key); + } + ); + }; + + Query.prototype.pipeline = function (): Pipeline { + let pipeline; + if (this._query.collectionGroup) { + pipeline = this.firestore + .pipeline() + .collectionGroup(this._query.collectionGroup); + } else { + pipeline = this.firestore + .pipeline() + .collection(this._query.path.canonicalString()); + } + + // TODO(pipeline) convert existing query filters, limits, etc into + // pipeline stages + + return pipeline; + }; +} diff --git a/packages/firestore/src/lite-api/database.ts b/packages/firestore/src/lite-api/database.ts index 93fe4eb95d1..172308a02fc 100644 --- a/packages/firestore/src/lite-api/database.ts +++ b/packages/firestore/src/lite-api/database.ts @@ -28,7 +28,6 @@ import { getDefaultEmulatorHostnameAndPort } from '@firebase/util'; -import { PipelineSource, DocumentReference } from '../api'; import { CredentialsProvider, EmulatorAuthCredentialsProvider, @@ -37,20 +36,17 @@ import { } from '../api/credentials'; import { User } from '../auth/user'; import { DatabaseId, DEFAULT_DATABASE_NAME } from '../core/database_info'; -import { DocumentKey } from '../model/document_key'; import { Code, FirestoreError } from '../util/error'; import { cast } from '../util/input_validation'; import { logWarn } from '../util/log'; import { FirestoreService, removeComponents } from './components'; -import { LiteUserDataWriter } from './reference_impl'; import { DEFAULT_HOST, FirestoreSettingsImpl, PrivateSettings, FirestoreSettings } from './settings'; -import { newUserDataReader } from './user_data_reader'; export { EmulatorMockTokenOptions } from '@firebase/util'; @@ -177,21 +173,18 @@ export class Firestore implements FirestoreService { removeComponents(this); return Promise.resolve(); } - - pipeline(): PipelineSource { - const userDataWriter = new LiteUserDataWriter(this); - const userDataReader = newUserDataReader(this); - return new PipelineSource( - this, - userDataReader, - userDataWriter, - (key: DocumentKey) => { - return new DocumentReference(this, null, key); - } - ); - } } +// Undocumented method of Firestore. This is only +// in place to give developers a runtime error suggesting +// how to correctly initialize Firestore for use with Pipelines. +// @ts-ignore +Firestore.prototype.pipeline = function (): unknown { + throw new Error( + 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' + ); +}; + /** * Initializes a new instance of Cloud Firestore with the provided settings. * Can only be called before any other functions, including diff --git a/packages/firestore/src/lite-api/reference.ts b/packages/firestore/src/lite-api/reference.ts index c51a514015c..0a49d177976 100644 --- a/packages/firestore/src/lite-api/reference.ts +++ b/packages/firestore/src/lite-api/reference.ts @@ -37,7 +37,6 @@ import { AutoId } from '../util/misc'; import { Firestore } from './database'; import { FieldPath } from './field_path'; import { FieldValue } from './field_value'; -import { Pipeline } from './pipeline'; import { FirestoreDataConverter } from './snapshot'; import { NestedUpdateFields, Primitive } from './types'; @@ -178,30 +177,18 @@ export class Query< this._query ); } - - /** - * @private - * @internal - */ - pipeline(): Pipeline { - let pipeline; - if (this._query.collectionGroup) { - pipeline = this.firestore - .pipeline() - .collectionGroup(this._query.collectionGroup); - } else { - pipeline = this.firestore - .pipeline() - .collection(this._query.path.canonicalString()); - } - - // TODO(pipeline) convert existing query filters, limits, etc into - // pipeline stages - - return pipeline; - } } +// Undocumented method of Query. This is only +// in place to give developers a runtime error suggesting +// how to correctly initialize Firestore for use with Pipelines. +// @ts-ignore +Query.prototype.pipeline = function () { + throw new Error( + 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' + ); +}; + /** * A `DocumentReference` refers to a document location in a Firestore database * and can be used to write, read, or listen to the location. The document at diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index fffa5240b85..92de61d5644 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -48,11 +48,13 @@ import { regexMatch, setDoc, startsWith, - subtract + subtract, + useFirestorePipelines } from '../util/firebase_export'; import { apiDescribe, withTestCollection } from '../util/helpers'; use(chaiAsPromised); +useFirestorePipelines(); apiDescribe.only('Pipelines', persistence => { addEqualityMatcher(); From 585d52ef63e1ceefbad262ecf8519c660eb6b737 Mon Sep 17 00:00:00 2001 From: MarkDuckworth Date: Mon, 4 Nov 2024 23:04:16 +0000 Subject: [PATCH 18/59] Update API reports --- common/api-review/firestore-lite.api.md | 6 +++--- common/api-review/firestore.api.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 816dc4c4e66..529be17bcee 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -2175,8 +2175,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9257:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9258:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9287:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9257:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9258:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9287:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index cdd17494e4c..b485e3b6530 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -2463,8 +2463,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10107:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10108:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10137:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10107:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10108:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10137:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` From 4b67f8a79645bd673a1d93c5f88e0488a98db235 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Mon, 4 Nov 2024 17:26:40 -0700 Subject: [PATCH 19/59] Documentation and .d.ts improvements --- common/api-review/firestore-lite.api.md | 9 +++++--- common/api-review/firestore.api.md | 9 +++++--- packages/firestore/lite/index.ts | 2 +- packages/firestore/src/api.ts | 2 +- ...gmentation.ts => database_augmentation.ts} | 12 ---------- packages/firestore/src/lite-api/database.ts | 22 ++++++++++--------- ...gmentation.ts => database_augmentation.ts} | 12 ---------- packages/firestore/src/lite-api/reference.ts | 20 ++++++++--------- 8 files changed, 36 insertions(+), 52 deletions(-) rename packages/firestore/src/api/{database-augmentation.ts => database_augmentation.ts} (87%) rename packages/firestore/src/lite-api/{database-augmentation.ts => database_augmentation.ts} (87%) diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 816dc4c4e66..85b9d83998f 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -1029,6 +1029,8 @@ export interface FindNearestOptions { // @public export class Firestore { get app(): FirebaseApp; + // Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta + pipeline(): PipelineSource; toJSON(): object; type: 'firestore-lite' | 'firestore'; } @@ -1619,6 +1621,7 @@ export class Query | null; readonly firestore: Firestore; + pipeline(): Pipeline; readonly type: 'query' | 'collection'; withConverter(converter: null): Query; withConverter(converter: FirestoreDataConverter): Query; @@ -2175,8 +2178,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9257:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9258:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9287:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9261:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9262:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9291:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index cdd17494e4c..5ec345d5f1c 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -1073,6 +1073,8 @@ export interface FindNearestOptions { // @public export class Firestore { get app(): FirebaseApp; + // Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta + pipeline(): PipelineSource; toJSON(): object; type: 'firestore-lite' | 'firestore'; } @@ -1877,6 +1879,7 @@ export class Query | null; readonly firestore: Firestore; + pipeline(): Pipeline; readonly type: 'query' | 'collection'; withConverter(converter: null): Query; withConverter(converter: FirestoreDataConverter): Query; @@ -2463,8 +2466,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10107:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10108:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10137:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10111:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10112:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10141:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/packages/firestore/lite/index.ts b/packages/firestore/lite/index.ts index aba1433aa64..f4a3869a57f 100644 --- a/packages/firestore/lite/index.ts +++ b/packages/firestore/lite/index.ts @@ -33,7 +33,7 @@ export { PipelineResult } from '../src/lite-api/pipeline-result'; export { Pipeline } from '../src/lite-api/pipeline'; -export { useFirestorePipelines } from '../src/lite-api/database-augmentation'; +export { useFirestorePipelines } from '../src/lite-api/database_augmentation'; export { Stage, diff --git a/packages/firestore/src/api.ts b/packages/firestore/src/api.ts index 8b640ca3a62..85ad72a89f2 100644 --- a/packages/firestore/src/api.ts +++ b/packages/firestore/src/api.ts @@ -21,7 +21,7 @@ export { PipelineResult } from './lite-api/pipeline-result'; export { Pipeline } from './lite-api/pipeline'; -export { useFirestorePipelines } from './api/database-augmentation'; +export { useFirestorePipelines } from './api/database_augmentation'; export { Stage, diff --git a/packages/firestore/src/api/database-augmentation.ts b/packages/firestore/src/api/database_augmentation.ts similarity index 87% rename from packages/firestore/src/api/database-augmentation.ts rename to packages/firestore/src/api/database_augmentation.ts index 9f272b3a05e..6015598a29c 100644 --- a/packages/firestore/src/api/database-augmentation.ts +++ b/packages/firestore/src/api/database_augmentation.ts @@ -7,18 +7,6 @@ import { Firestore } from './database'; import { DocumentReference, Query } from './reference'; import { ExpUserDataWriter } from './user_data_writer'; -declare module './database' { - interface Firestore { - pipeline(): PipelineSource; - } -} - -declare module './reference' { - interface Query { - pipeline(): Pipeline; - } -} - export function useFirestorePipelines(): void { Firestore.prototype.pipeline = function (): PipelineSource { const firestore = this; diff --git a/packages/firestore/src/lite-api/database.ts b/packages/firestore/src/lite-api/database.ts index 172308a02fc..f67c5c32767 100644 --- a/packages/firestore/src/lite-api/database.ts +++ b/packages/firestore/src/lite-api/database.ts @@ -41,12 +41,15 @@ import { cast } from '../util/input_validation'; import { logWarn } from '../util/log'; import { FirestoreService, removeComponents } from './components'; +import type { PipelineSource } from './pipeline-source'; import { DEFAULT_HOST, FirestoreSettingsImpl, PrivateSettings, FirestoreSettings } from './settings'; +// `import type` to avoid bundling the source for +// pipelines if `useFirestorePipelines()` is not called export { EmulatorMockTokenOptions } from '@firebase/util'; @@ -173,17 +176,16 @@ export class Firestore implements FirestoreService { removeComponents(this); return Promise.resolve(); } -} -// Undocumented method of Firestore. This is only -// in place to give developers a runtime error suggesting -// how to correctly initialize Firestore for use with Pipelines. -// @ts-ignore -Firestore.prototype.pipeline = function (): unknown { - throw new Error( - 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' - ); -}; + /** + * Pipeline query. + */ + pipeline(): PipelineSource { + throw new Error( + 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' + ); + } +} /** * Initializes a new instance of Cloud Firestore with the provided settings. diff --git a/packages/firestore/src/lite-api/database-augmentation.ts b/packages/firestore/src/lite-api/database_augmentation.ts similarity index 87% rename from packages/firestore/src/lite-api/database-augmentation.ts rename to packages/firestore/src/lite-api/database_augmentation.ts index 95dab65587d..7eb96e658c7 100644 --- a/packages/firestore/src/lite-api/database-augmentation.ts +++ b/packages/firestore/src/lite-api/database_augmentation.ts @@ -7,18 +7,6 @@ import { DocumentReference, Query } from './reference'; import { LiteUserDataWriter } from './reference_impl'; import { newUserDataReader } from './user_data_reader'; -declare module './database' { - interface Firestore { - pipeline(): PipelineSource; - } -} - -declare module './reference' { - interface Query { - pipeline(): Pipeline; - } -} - export function useFirestorePipelines(): void { Firestore.prototype.pipeline = function (): PipelineSource { const userDataWriter = new LiteUserDataWriter(this); diff --git a/packages/firestore/src/lite-api/reference.ts b/packages/firestore/src/lite-api/reference.ts index 0a49d177976..71b789227fc 100644 --- a/packages/firestore/src/lite-api/reference.ts +++ b/packages/firestore/src/lite-api/reference.ts @@ -37,6 +37,7 @@ import { AutoId } from '../util/misc'; import { Firestore } from './database'; import { FieldPath } from './field_path'; import { FieldValue } from './field_value'; +import type { Pipeline } from './pipeline'; import { FirestoreDataConverter } from './snapshot'; import { NestedUpdateFields, Primitive } from './types'; @@ -177,17 +178,16 @@ export class Query< this._query ); } -} -// Undocumented method of Query. This is only -// in place to give developers a runtime error suggesting -// how to correctly initialize Firestore for use with Pipelines. -// @ts-ignore -Query.prototype.pipeline = function () { - throw new Error( - 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' - ); -}; + /** + * Pipeline query. + */ + pipeline(): Pipeline { + throw new Error( + 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' + ); + } +} /** * A `DocumentReference` refers to a document location in a Firestore database From ca0ffd94d68f81d55780007b416d3c650f5f7b8f Mon Sep 17 00:00:00 2001 From: MarkDuckworth Date: Tue, 5 Nov 2024 00:38:52 +0000 Subject: [PATCH 20/59] Update API reports --- common/api-review/firestore-lite.api.md | 9 ++++++--- common/api-review/firestore.api.md | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 529be17bcee..00ed8776beb 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -1029,6 +1029,8 @@ export interface FindNearestOptions { // @public export class Firestore { get app(): FirebaseApp; + // Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta + pipeline(): PipelineSource; toJSON(): object; type: 'firestore-lite' | 'firestore'; } @@ -1619,6 +1621,7 @@ export class Query | null; readonly firestore: Firestore; + pipeline(): Pipeline; readonly type: 'query' | 'collection'; withConverter(converter: null): Query; withConverter(converter: FirestoreDataConverter): Query; @@ -2175,8 +2178,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9257:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9258:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9287:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9261:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9262:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9291:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index b485e3b6530..c50b906e16c 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -1073,6 +1073,8 @@ export interface FindNearestOptions { // @public export class Firestore { get app(): FirebaseApp; + // Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta + pipeline(): PipelineSource; toJSON(): object; type: 'firestore-lite' | 'firestore'; } @@ -1877,6 +1879,7 @@ export class Query | null; readonly firestore: Firestore; + pipeline(): Pipeline; readonly type: 'query' | 'collection'; withConverter(converter: null): Query; withConverter(converter: FirestoreDataConverter): Query; @@ -2463,8 +2466,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10107:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10108:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10137:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10111:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10112:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10141:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` From 2d386c8571587171a2173ff02b850d8ba70b647e Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 6 Nov 2024 13:48:27 -0700 Subject: [PATCH 21/59] Update the bundle definition for the pipeline bundle test --- repo-scripts/size-analysis/bundle-definitions/firestore.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/repo-scripts/size-analysis/bundle-definitions/firestore.json b/repo-scripts/size-analysis/bundle-definitions/firestore.json index 51416a76cfc..e48c8a3fa7c 100644 --- a/repo-scripts/size-analysis/bundle-definitions/firestore.json +++ b/repo-scripts/size-analysis/bundle-definitions/firestore.json @@ -152,7 +152,8 @@ "imports": [ "getFirestore", "lt", - "Field" + "Field", + "useFirestorePipelines" ] } ] From c621b81f3ed740a60d650029ba64d60bb8f75b8a Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 6 Nov 2024 13:53:21 -0700 Subject: [PATCH 22/59] Update the bundle definition adding a pipeline test with and function --- .../bundle-definitions/firestore.json | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/repo-scripts/size-analysis/bundle-definitions/firestore.json b/repo-scripts/size-analysis/bundle-definitions/firestore.json index e48c8a3fa7c..a589732ae5c 100644 --- a/repo-scripts/size-analysis/bundle-definitions/firestore.json +++ b/repo-scripts/size-analysis/bundle-definitions/firestore.json @@ -160,6 +160,39 @@ } ] }, + { + "name": "Pipeline Query with lt plus and filter", + "dependencies": [ + { + "packageName": "firebase", + "versionOrTag": "latest", + "imports": [ + { + "path": "app", + "imports": [ + "initializeApp" + ] + } + ] + }, + { + "packageName": "firebase", + "versionOrTag": "latest", + "imports": [ + { + "path": "firestore", + "imports": [ + "getFirestore", + "lt", + "Field", + "useFirestorePipelines", + "andExpression" + ] + } + ] + } + ] + }, { "name": "Query Cursors", "dependencies": [ From 773ab0259ea485a90bd211aa84b4fdfb9e64c4d5 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 6 Nov 2024 13:53:58 -0700 Subject: [PATCH 23/59] Typo --- repo-scripts/size-analysis/bundle-definitions/firestore.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repo-scripts/size-analysis/bundle-definitions/firestore.json b/repo-scripts/size-analysis/bundle-definitions/firestore.json index a589732ae5c..f7e13a8f401 100644 --- a/repo-scripts/size-analysis/bundle-definitions/firestore.json +++ b/repo-scripts/size-analysis/bundle-definitions/firestore.json @@ -161,7 +161,7 @@ ] }, { - "name": "Pipeline Query with lt plus and filter", + "name": "Pipeline Query with lt plus and function", "dependencies": [ { "packageName": "firebase", From 682997d3e9598195f385688ab596fa355dd4f8dc Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Mon, 11 Nov 2024 09:15:00 -0700 Subject: [PATCH 24/59] And/or overloads. Pipeline serialization for console. --- common/api-review/firestore.api.md | 24 ++++++---- packages/firestore/src/api.ts | 9 ++-- packages/firestore/src/api/database.ts | 20 ++++---- .../src/api/database_augmentation.ts | 10 ++++ .../firestore/src/lite-api/expressions.ts | 38 --------------- packages/firestore/src/lite-api/query.ts | 48 ------------------- .../src/remote/internal_serializer.ts | 26 ++++++++++ .../test/integration/api/pipeline.test.ts | 30 +++++++++--- 8 files changed, 89 insertions(+), 116 deletions(-) diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index c50b906e16c..a8aa8ce6e20 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -100,11 +100,15 @@ export class And extends FirestoreFunction implements FilterCondition { filterable: true; } +// @beta +export function and(left: FilterExpr, ...right: FilterExpr[]): And; + // @public export function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; -// @beta -export function andExpression(left: FilterExpr, ...right: FilterExpr[]): And; +// @public (undocumented) +export namespace and { +} // @beta (undocumented) export class ArrayConcat extends FirestoreFunction { @@ -1738,9 +1742,16 @@ export class Or extends FirestoreFunction implements FilterCondition { filterable: true; } +// @beta +export function or(left: FilterExpr, ...right: FilterExpr[]): Or; + // @public export function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; +// @public (undocumented) +export namespace or { +} + // @public export function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryOrderByConstraint; @@ -1752,9 +1763,6 @@ export class Ordering { constructor(expr: Constant, direction: 'ascending' | 'descending'); } -// @beta -export function orExpression(left: FilterExpr, ...right: FilterExpr[]): Or; - // @public export type PartialWithFieldValue = Partial | (T extends Primitive ? T : T extends {} ? { [K in keyof T]?: PartialWithFieldValue | FieldValue; @@ -2466,8 +2474,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10111:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10112:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10141:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10115:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10116:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10145:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/packages/firestore/src/api.ts b/packages/firestore/src/api.ts index 85ad72a89f2..73b725f184b 100644 --- a/packages/firestore/src/api.ts +++ b/packages/firestore/src/api.ts @@ -61,8 +61,6 @@ export { arrayLength, inAny, notInAny, - and as andExpression, - or as orExpression, xor, ifFunction, not, @@ -183,6 +181,8 @@ export { Accumulator } from './lite-api/expressions'; +export { and, or } from './lite-api/overloads'; + export { aggregateFieldEqual, aggregateQuerySnapshotEqual, @@ -282,12 +282,10 @@ export { } from './api/reference'; export { - and, endAt, endBefore, limit, limitToLast, - or, orderBy, OrderByDirection, query, @@ -392,7 +390,8 @@ export { isBase64Available as _isBase64Available } from './platform/base64'; export { DatabaseId as _DatabaseId } from './core/database_info'; export { _internalQueryToProtoQueryTarget, - _internalAggregationQueryToProtoRunAggregationQueryRequest + _internalAggregationQueryToProtoRunAggregationQueryRequest, + _internalPipelineToExecutePipelineRequestProto } from './remote/internal_serializer'; export { cast as _cast, diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index 827f3f1de35..cc1fab0c86a 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -46,6 +46,7 @@ import { connectFirestoreEmulator, Firestore as LiteFirestore } from '../lite-api/database'; +import type { PipelineSource } from '../lite-api/pipeline-source'; import { Query } from '../lite-api/reference'; import { indexedDbClearPersistence, @@ -128,17 +129,16 @@ export class Firestore extends LiteFirestore { await terminate; } } -} -// Undocumented method of Firestore. This is only -// in place to give developers a runtime error suggesting -// how to correctly initialize Firestore for use with Pipelines. -// @ts-ignore -Firestore.prototype.pipeline = function (): unknown { - throw new Error( - 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' - ); -}; + /** + * Pipeline query. + */ + pipeline(): PipelineSource { + throw new Error( + 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' + ); + } +} /** * Initializes a new instance of {@link Firestore} with the provided settings. diff --git a/packages/firestore/src/api/database_augmentation.ts b/packages/firestore/src/api/database_augmentation.ts index 6015598a29c..dcaff555a04 100644 --- a/packages/firestore/src/api/database_augmentation.ts +++ b/packages/firestore/src/api/database_augmentation.ts @@ -1,3 +1,5 @@ +import { And, FilterExpr, Or } from '../lite-api/expressions'; +import { and, or } from '../lite-api/overloads'; import { Pipeline } from '../lite-api/pipeline'; import { PipelineSource } from '../lite-api/pipeline-source'; import { newUserDataReader } from '../lite-api/user_data_reader'; @@ -37,4 +39,12 @@ export function useFirestorePipelines(): void { return pipeline; }; + + and._andFunction = function (left: FilterExpr, ...right: FilterExpr[]): And { + return new And([left, ...right]); + }; + + or._orFunction = function (left: FilterExpr, ...right: FilterExpr[]): Or { + return new Or([left, ...right]); + }; } diff --git a/packages/firestore/src/lite-api/expressions.ts b/packages/firestore/src/lite-api/expressions.ts index d12c17bdeda..82729147e75 100644 --- a/packages/firestore/src/lite-api/expressions.ts +++ b/packages/firestore/src/lite-api/expressions.ts @@ -4517,44 +4517,6 @@ export function notInAny(element: Expr | string, others: any[]): Not { return new Not(new In(elementExpr, exprOthers)); } -/** - * @beta - * - * Creates an expression that performs a logical 'AND' operation on multiple filter conditions. - * - * ```typescript - * // Check if the 'age' field is greater than 18 AND the 'city' field is "London" AND - * // the 'status' field is "active" - * const condition = and(gt("age", 18), eq("city", "London"), eq("status", "active")); - * ``` - * - * @param left The first filter condition. - * @param right Additional filter conditions to 'AND' together. - * @return A new {@code Expr} representing the logical 'AND' operation. - */ -export function and(left: FilterExpr, ...right: FilterExpr[]): And { - return new And([left, ...right]); -} - -/** - * @beta - * - * Creates an expression that performs a logical 'OR' operation on multiple filter conditions. - * - * ```typescript - * // Check if the 'age' field is greater than 18 OR the 'city' field is "London" OR - * // the 'status' field is "active" - * const condition = or(gt("age", 18), eq("city", "London"), eq("status", "active")); - * ``` - * - * @param left The first filter condition. - * @param right Additional filter conditions to 'OR' together. - * @return A new {@code Expr} representing the logical 'OR' operation. - */ -export function or(left: FilterExpr, ...right: FilterExpr[]): Or { - return new Or([left, ...right]); -} - /** * @beta * diff --git a/packages/firestore/src/lite-api/query.ts b/packages/firestore/src/lite-api/query.ts index f0a357b828c..16ed4f69a31 100644 --- a/packages/firestore/src/lite-api/query.ts +++ b/packages/firestore/src/lite-api/query.ts @@ -367,54 +367,6 @@ export type QueryFilterConstraint = | QueryFieldFilterConstraint | QueryCompositeFilterConstraint; -/** - * Creates a new {@link QueryCompositeFilterConstraint} that is a disjunction of - * the given filter constraints. A disjunction filter includes a document if it - * satisfies any of the given filters. - * - * @param queryConstraints - Optional. The list of - * {@link QueryFilterConstraint}s to perform a disjunction for. These must be - * created with calls to {@link where}, {@link or}, or {@link and}. - * @returns The newly created {@link QueryCompositeFilterConstraint}. - */ -export function or( - ...queryConstraints: QueryFilterConstraint[] -): QueryCompositeFilterConstraint { - // Only support QueryFilterConstraints - queryConstraints.forEach(queryConstraint => - validateQueryFilterConstraint('or', queryConstraint) - ); - - return QueryCompositeFilterConstraint._create( - CompositeOperator.OR, - queryConstraints as QueryFilterConstraint[] - ); -} - -/** - * Creates a new {@link QueryCompositeFilterConstraint} that is a conjunction of - * the given filter constraints. A conjunction filter includes a document if it - * satisfies all of the given filters. - * - * @param queryConstraints - Optional. The list of - * {@link QueryFilterConstraint}s to perform a conjunction for. These must be - * created with calls to {@link where}, {@link or}, or {@link and}. - * @returns The newly created {@link QueryCompositeFilterConstraint}. - */ -export function and( - ...queryConstraints: QueryFilterConstraint[] -): QueryCompositeFilterConstraint { - // Only support QueryFilterConstraints - queryConstraints.forEach(queryConstraint => - validateQueryFilterConstraint('and', queryConstraint) - ); - - return QueryCompositeFilterConstraint._create( - CompositeOperator.AND, - queryConstraints as QueryFilterConstraint[] - ); -} - /** * A `QueryOrderByConstraint` is used to sort the set of documents returned by a * Firestore query. `QueryOrderByConstraint`s are created by invoking diff --git a/packages/firestore/src/remote/internal_serializer.ts b/packages/firestore/src/remote/internal_serializer.ts index 8f278247581..628457ba81c 100644 --- a/packages/firestore/src/remote/internal_serializer.ts +++ b/packages/firestore/src/remote/internal_serializer.ts @@ -19,6 +19,7 @@ import { ensureFirestoreConfigured, Firestore } from '../api/database'; import { AggregateImpl } from '../core/aggregate'; import { queryToAggregateTarget, queryToTarget } from '../core/query'; import { AggregateSpec } from '../lite-api/aggregate_types'; +import { Pipeline } from '../lite-api/pipeline'; import { Query } from '../lite-api/reference'; import { cast } from '../util/input_validation'; import { mapToArray } from '../util/obj'; @@ -87,3 +88,28 @@ export function _internalAggregationQueryToProtoRunAggregationQueryRequest< /* skipAliasing= */ true ).request; } + +/** + * @internal + * @private + * + * This function is for internal use only. + * + * Returns the `ExecutePipelineRequest` representation of the given query. + * Returns `null` if the Firestore client associated with the given query has + * not been initialized or has been terminated. + * + * @param pipeline - The Pipeline to convert to proto representation. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export function _internalPipelineToExecutePipelineRequestProto( + pipeline: Pipeline +): any { + const firestore = cast(pipeline._db, Firestore); + const client = ensureFirestoreConfigured(firestore); + const serializer = client._onlineComponents?.datastore.serializer; + if (serializer === undefined) { + return null; + } + return pipeline._toProto(serializer); +} diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index 92de61d5644..1c210067785 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -18,8 +18,9 @@ import chaiAsPromised from 'chai-as-promised'; import { addEqualityMatcher } from '../../util/equality_matcher'; import { Deferred } from '../../util/promise'; import { + _internalPipelineToExecutePipelineRequestProto, add, - andExpression, + and, arrayContains, arrayContainsAny, avg, @@ -42,7 +43,7 @@ import { mapGet, neq, not, - orExpression, + or, PipelineResult, regexContains, regexMatch, @@ -384,7 +385,7 @@ apiDescribe.only('Pipelines', persistence => { it('where with and', async () => { const results = await randomCol .pipeline() - .where(andExpression(gt('rating', 4.5), eq('genre', 'Science Fiction'))) + .where(and(gt('rating', 4.5), eq('genre', 'Science Fiction'))) .execute(); expectResults(results, 'book10'); }); @@ -392,7 +393,7 @@ apiDescribe.only('Pipelines', persistence => { it('where with or', async () => { const results = await randomCol .pipeline() - .where(orExpression(eq('genre', 'Romance'), eq('genre', 'Dystopian'))) + .where(or(eq('genre', 'Romance'), eq('genre', 'Dystopian'))) .select('title') .execute(); expectResults( @@ -637,7 +638,7 @@ apiDescribe.only('Pipelines', persistence => { const results = await randomCol .pipeline() .where( - andExpression( + and( gt('rating', 4.2), lte(Field.of('rating'), 4.5), neq('genre', 'Science Fiction') @@ -661,8 +662,8 @@ apiDescribe.only('Pipelines', persistence => { const results = await randomCol .pipeline() .where( - orExpression( - andExpression(gt('rating', 4.5), eq('genre', 'Science Fiction')), + or( + and(gt('rating', 4.5), eq('genre', 'Science Fiction')), lt('published', 1900) ) ) @@ -793,6 +794,21 @@ apiDescribe.only('Pipelines', persistence => { ); }); + it('supports internal serialization to proto', async () => { + const pipeline = firestore + .pipeline() + .collection('books') + .where(eq('awards.hugo', true)) + .select( + 'title', + Field.of('nestedField.level.1'), + mapGet('nestedField', 'level.1').mapGet('level.2').as('nested') + ); + + const proto = _internalPipelineToExecutePipelineRequestProto(pipeline); + expect(proto).not.to.be.null; + }); + // TODO(pipeline) support converter // it('pipeline converter works', async () => { // interface AppModel {myTitle: string; myAuthor: string; myPublished: number} From 8eb90826e4d63452db8d7565737ac2b0ec414282 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Mon, 11 Nov 2024 09:15:55 -0700 Subject: [PATCH 25/59] Cast Firestore --- packages/firestore/src/api/pipeline.ts | 6 +++-- packages/firestore/src/lite-api/pipeline.ts | 30 ++++++++++++--------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/packages/firestore/src/api/pipeline.ts b/packages/firestore/src/api/pipeline.ts index 047731b40e5..9aeccae9ad0 100644 --- a/packages/firestore/src/api/pipeline.ts +++ b/packages/firestore/src/api/pipeline.ts @@ -6,6 +6,7 @@ import { Stage } from '../lite-api/stage'; import { UserDataReader } from '../lite-api/user_data_reader'; import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; import { DocumentKey } from '../model/document_key'; +import { cast } from '../util/input_validation'; import { ensureFirestoreConfigured, Firestore } from './database'; @@ -23,7 +24,7 @@ export class Pipeline< * @param converter */ constructor( - private db: Firestore, + db: Firestore, userDataReader: UserDataReader, userDataWriter: AbstractUserDataWriter, documentReferenceFactory: (id: DocumentKey) => DocumentReference, @@ -74,7 +75,8 @@ export class Pipeline< * @return A Promise representing the asynchronous pipeline execution. */ execute(): Promise>> { - const client = ensureFirestoreConfigured(this.db); + const firestore = cast(this._db, Firestore); + const client = ensureFirestoreConfigured(firestore); return firestoreClientExecutePipeline(client, this).then(result => { const docs = result.map( element => diff --git a/packages/firestore/src/lite-api/pipeline.ts b/packages/firestore/src/lite-api/pipeline.ts index e346b5a16ef..41a3b4590d8 100644 --- a/packages/firestore/src/lite-api/pipeline.ts +++ b/packages/firestore/src/lite-api/pipeline.ts @@ -124,7 +124,7 @@ export class Pipeline /** * @internal * @private - * @param liteDb + * @param _db * @param userDataReader * @param userDataWriter * @param documentReferenceFactory @@ -132,7 +132,11 @@ export class Pipeline * @param converter */ constructor( - private liteDb: Firestore, + /** + * @internal + * @private + */ + public _db: Firestore, private userDataReader: UserDataReader, /** * @internal @@ -184,7 +188,7 @@ export class Pipeline ) ); return new Pipeline( - this.liteDb, + this._db, this.userDataReader, this.userDataWriter, this.documentReferenceFactory, @@ -230,7 +234,7 @@ export class Pipeline projections = this.readUserData('select', projections); copy.push(new Select(projections)); return new Pipeline( - this.liteDb, + this._db, this.userDataReader, this.userDataWriter, this.documentReferenceFactory, @@ -322,7 +326,7 @@ export class Pipeline this.readUserData('where', condition); copy.push(new Where(condition)); return new Pipeline( - this.liteDb, + this._db, this.userDataReader, this.userDataWriter, this.documentReferenceFactory, @@ -355,7 +359,7 @@ export class Pipeline const copy = this.stages.map(s => s); copy.push(new Offset(offset)); return new Pipeline( - this.liteDb, + this._db, this.userDataReader, this.userDataWriter, this.documentReferenceFactory, @@ -393,7 +397,7 @@ export class Pipeline const copy = this.stages.map(s => s); copy.push(new Limit(limit)); return new Pipeline( - this.liteDb, + this._db, this.userDataReader, this.userDataWriter, this.documentReferenceFactory, @@ -438,7 +442,7 @@ export class Pipeline ) ); return new Pipeline( - this.liteDb, + this._db, this.userDataReader, this.userDataWriter, this.documentReferenceFactory, @@ -551,7 +555,7 @@ export class Pipeline ); } return new Pipeline( - this.liteDb, + this._db, this.userDataReader, this.userDataWriter, this.documentReferenceFactory, @@ -579,7 +583,7 @@ export class Pipeline ) ); return new Pipeline( - this.liteDb, + this._db, this.userDataReader, this.userDataWriter, this.documentReferenceFactory, @@ -640,7 +644,7 @@ export class Pipeline } return new Pipeline( - this.liteDb, + this._db, this.userDataReader, this.userDataWriter, this.documentReferenceFactory, @@ -678,7 +682,7 @@ export class Pipeline }); copy.push(new GenericStage(name, params)); return new Pipeline( - this.liteDb, + this._db, this.userDataReader, this.userDataWriter, this.documentReferenceFactory, @@ -785,7 +789,7 @@ export class Pipeline * @return A Promise representing the asynchronous pipeline execution. */ execute(): Promise>> { - const datastore = getDatastore(this.liteDb); + const datastore = getDatastore(this._db); return invokeExecutePipeline(datastore, this).then(result => { const docs = result // Currently ignore any response from ExecutePipeline that does From 6a2abf337bb09d5d98261782b614aea141a72391 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Mon, 11 Nov 2024 14:21:39 -0700 Subject: [PATCH 26/59] And/or overloads --- common/api-review/firestore-lite.api.md | 65 ++++--- common/api-review/firestore.api.md | 31 +++- packages/firestore/lite/index.ts | 14 +- packages/firestore/src/api/filter.ts | 2 - packages/firestore/src/core/pipeline-util.ts | 6 +- packages/firestore/src/lite-api/overloads.ts | 167 ++++++++++++++++++ .../src/remote/internal_serializer.ts | 4 +- .../test/integration/api/pipeline.test.ts | 3 +- 8 files changed, 256 insertions(+), 36 deletions(-) create mode 100644 packages/firestore/src/lite-api/overloads.ts diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 00ed8776beb..6a75658c0d0 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -100,11 +100,15 @@ export class And extends FirestoreFunction implements FilterCondition { filterable: true; } +// @beta +export function and(left: FilterExpr, ...right: FilterExpr[]): And; + // @public export function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; -// @beta -export function andExpression(left: FilterExpr, ...right: FilterExpr[]): And; +// @public (undocumented) +export namespace and { +} // @beta (undocumented) export class ArrayConcat extends FirestoreFunction { @@ -218,10 +222,10 @@ export class Avg extends FirestoreFunction implements Accumulator { } // @beta -export function avg(value: Constant): Avg; +export function avgFunction(value: Constant): Avg; // @beta -export function avg(value: string): Avg; +export function avgFunction(value: string): Avg; // @beta (undocumented) export class ByteLength extends FirestoreFunction { @@ -450,14 +454,6 @@ export function count(): AggregateField; // @beta export function countAll(): Count; -// @beta -export function countExpression(value: Constant): Count; - -// Warning: (ae-incompatible-release-tags) The symbol "countExpression" is marked as @public, but its signature references "Count" which is marked as @beta -// -// @public -export function countExpression(value: string): Count; - // @beta (undocumented) export class DatabaseSource implements Stage { // (undocumented) @@ -1531,9 +1527,16 @@ export class Or extends FirestoreFunction implements FilterCondition { filterable: true; } +// @beta +export function or(left: FilterExpr, ...right: FilterExpr[]): Or; + // @public export function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; +// @public (undocumented) +export namespace or { +} + // @public export function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryOrderByConstraint; @@ -1545,9 +1548,6 @@ export class Ordering { constructor(expr: Constant, direction: 'ascending' | 'descending'); } -// @beta -export function orExpression(left: FilterExpr, ...right: FilterExpr[]): Or; - // @public export type PartialWithFieldValue = Partial | (T extends Primitive ? T : T extends {} ? { [K in keyof T]?: PartialWithFieldValue | FieldValue; @@ -1555,33 +1555,58 @@ export type PartialWithFieldValue = Partial | (T extends Primitive ? T : T // @public export class Pipeline { + /* Excluded from this release type: _db */ // Warning: (ae-incompatible-release-tags) The symbol "addFields" is marked as @public, but its signature references "Selectable" which is marked as @beta addFields(...fields: Selectable[]): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "aggregate" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta aggregate(...accumulators: AccumulatorTarget[]): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ aggregate(options: { accumulators: AccumulatorTarget[]; groups?: Array; }): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "distinct" is marked as @public, but its signature references "Selectable" which is marked as @beta distinct(...groups: Array): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "execute" is marked as @public, but its signature references "PipelineResult" which is marked as @beta execute(): Promise>>; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "findNearest" is marked as @public, but its signature references "FindNearestOptions" which is marked as @beta // // (undocumented) findNearest(options: FindNearestOptions): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ genericStage(name: string, params: any[]): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ limit(limit: number): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ offset(offset: number): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "select" is marked as @public, but its signature references "Selectable" which is marked as @beta select(...selections: Array): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "sort" is marked as @public, but its signature references "Ordering" which is marked as @beta sort(...orderings: Ordering[]): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ // (undocumented) sort(options: { orderings: Ordering[]; }): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "FilterCondition" which is marked as @beta // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "Constant" which is marked as @beta where(condition: FilterCondition & Constant): Pipeline; @@ -1925,10 +1950,10 @@ export class Sum extends FirestoreFunction implements Accumulator { export function sum(field: string | FieldPath): AggregateField; // @beta -export function sumExpression(value: Constant): Sum; +export function sumFunction(value: Constant): Sum; // @beta -export function sumExpression(value: string): Sum; +export function sumFunction(value: string): Sum; // @public export function terminate(firestore: Firestore): Promise; @@ -2178,8 +2203,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9261:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9262:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9291:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9237:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9238:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9267:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index a8aa8ce6e20..70b8664fa94 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -1821,33 +1821,58 @@ export type PersistentTabManager = PersistentSingleTabManager | PersistentMultip // @public export class Pipeline { + /* Excluded from this release type: _db */ // Warning: (ae-incompatible-release-tags) The symbol "addFields" is marked as @public, but its signature references "Selectable" which is marked as @beta addFields(...fields: Selectable[]): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "aggregate" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta aggregate(...accumulators: AccumulatorTarget[]): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ aggregate(options: { accumulators: AccumulatorTarget[]; groups?: Array; }): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "distinct" is marked as @public, but its signature references "Selectable" which is marked as @beta distinct(...groups: Array): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "execute" is marked as @public, but its signature references "PipelineResult" which is marked as @beta execute(): Promise>>; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "findNearest" is marked as @public, but its signature references "FindNearestOptions" which is marked as @beta // // (undocumented) findNearest(options: FindNearestOptions): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ genericStage(name: string, params: any[]): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ limit(limit: number): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ offset(offset: number): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "select" is marked as @public, but its signature references "Selectable" which is marked as @beta select(...selections: Array): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "sort" is marked as @public, but its signature references "Ordering" which is marked as @beta sort(...orderings: Ordering[]): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ // (undocumented) sort(options: { orderings: Ordering[]; }): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "FilterCondition" which is marked as @beta // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "Constant" which is marked as @beta where(condition: FilterCondition & Constant): Pipeline; @@ -2474,8 +2499,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10115:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10116:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10145:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10116:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10117:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10146:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/packages/firestore/lite/index.ts b/packages/firestore/lite/index.ts index f4a3869a57f..6e30bdd4e0c 100644 --- a/packages/firestore/lite/index.ts +++ b/packages/firestore/lite/index.ts @@ -73,8 +73,6 @@ export { arrayLength, inAny, notInAny, - and as andExpression, - or as orExpression, xor, ifFunction, not, @@ -99,9 +97,6 @@ export { strConcat, mapGet, countAll, - count as countExpression, - sum as sumExpression, - avg, min, max, cosineDistance, @@ -192,7 +187,9 @@ export { SelectableExpr, Selectable, FilterCondition, - Accumulator + Accumulator, + sum as sumFunction, + avg as avgFunction } from '../src/lite-api/expressions'; export { @@ -243,6 +240,10 @@ export { export { and, + or, +} from '../src/lite-api/overloads'; + +export { endAt, endBefore, startAt, @@ -250,7 +251,6 @@ export { limit, limitToLast, where, - or, orderBy, query, QueryConstraint, diff --git a/packages/firestore/src/api/filter.ts b/packages/firestore/src/api/filter.ts index 035aca66aba..99906e31db8 100644 --- a/packages/firestore/src/api/filter.ts +++ b/packages/firestore/src/api/filter.ts @@ -16,14 +16,12 @@ */ export { - and, endAt, endBefore, startAfter, startAt, limitToLast, limit, - or, orderBy, OrderByDirection, where, diff --git a/packages/firestore/src/core/pipeline-util.ts b/packages/firestore/src/core/pipeline-util.ts index 228aee304c4..8a6ef9e17a7 100644 --- a/packages/firestore/src/core/pipeline-util.ts +++ b/packages/firestore/src/core/pipeline-util.ts @@ -13,14 +13,16 @@ // limitations under the License. import { - and, Constant, Expr, Field, FilterCondition, not, - or } from '../lite-api/expressions'; +import { + and, + or +} from '../lite-api/overloads'; import { isNanValue, isNullValue } from '../model/values'; import { ArrayValue as ProtoArrayValue, diff --git a/packages/firestore/src/lite-api/overloads.ts b/packages/firestore/src/lite-api/overloads.ts new file mode 100644 index 00000000000..53413007c60 --- /dev/null +++ b/packages/firestore/src/lite-api/overloads.ts @@ -0,0 +1,167 @@ +import { CompositeOperator } from '../core/filter'; + +import { + And as AndFunction, + FilterExpr, + Or as OrFunction +} from './expressions'; +import { + QueryCompositeFilterConstraint, + QueryConstraint, + QueryFilterConstraint, + validateQueryFilterConstraint +} from './query'; + +/** + * @beta + * + * Creates an expression that performs a logical 'OR' operation on multiple filter conditions. + * + * ```typescript + * // Check if the 'age' field is greater than 18 OR the 'city' field is "London" OR + * // the 'status' field is "active" + * const condition = or(gt("age", 18), eq("city", "London"), eq("status", "active")); + * ``` + * + * @param left The first filter condition. + * @param right Additional filter conditions to 'OR' together. + * @return A new {@code Expr} representing the logical 'OR' operation. + */ +export function or(left: FilterExpr, ...right: FilterExpr[]): OrFunction; + +/** + * Creates a new {@link QueryCompositeFilterConstraint} that is a disjunction of + * the given filter constraints. A disjunction filter includes a document if it + * satisfies any of the given filters. + * + * @param queryConstraints - Optional. The list of + * {@link QueryFilterConstraint}s to perform a disjunction for. These must be + * created with calls to {@link where}, {@link or}, or {@link and}. + * @returns The newly created {@link QueryCompositeFilterConstraint}. + */ +export function or( + ...queryConstraints: QueryFilterConstraint[] +): QueryCompositeFilterConstraint; + +export function or( + leftFilterExprOrQueryConstraint?: FilterExpr | QueryFilterConstraint, + ...right: FilterExpr[] | QueryFilterConstraint[] +): OrFunction | QueryCompositeFilterConstraint { + if (leftFilterExprOrQueryConstraint === undefined) { + return or._orFilters(); + } + if ( + leftFilterExprOrQueryConstraint instanceof QueryConstraint || + leftFilterExprOrQueryConstraint === undefined + ) { + return or._orFilters( + leftFilterExprOrQueryConstraint, + ...(right as QueryFilterConstraint[]) + ); + } else { + return or._orFunction( + leftFilterExprOrQueryConstraint as FilterExpr, + ...(right as FilterExpr[]) + ); + } +} + +or._orFilters = function ( + ...queryConstraints: QueryFilterConstraint[] +): QueryCompositeFilterConstraint { + // Only support QueryFilterConstraints + queryConstraints.forEach(queryConstraint => + validateQueryFilterConstraint('or', queryConstraint) + ); + + return QueryCompositeFilterConstraint._create( + CompositeOperator.OR, + queryConstraints as QueryFilterConstraint[] + ); +}; + +or._orFunction = function ( + left: FilterExpr, + ...right: FilterExpr[] +): OrFunction { + throw new Error( + 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' + ); +}; + +/** + * @beta + * + * Creates an expression that performs a logical 'AND' operation on multiple filter conditions. + * + * ```typescript + * // Check if the 'age' field is greater than 18 AND the 'city' field is "London" AND + * // the 'status' field is "active" + * const condition = and(gt("age", 18), eq("city", "London"), eq("status", "active")); + * ``` + * + * @param left The first filter condition. + * @param right Additional filter conditions to 'AND' together. + * @return A new {@code Expr} representing the logical 'AND' operation. + */ +export function and(left: FilterExpr, ...right: FilterExpr[]): AndFunction; + +/** + * Creates a new {@link QueryCompositeFilterConstraint} that is a conjunction of + * the given filter constraints. A conjunction filter includes a document if it + * satisfies all of the given filters. + * + * @param queryConstraints - Optional. The list of + * {@link QueryFilterConstraint}s to perform a conjunction for. These must be + * created with calls to {@link where}, {@link or}, or {@link and}. + * @returns The newly created {@link QueryCompositeFilterConstraint}. + */ +export function and( + ...queryConstraints: QueryFilterConstraint[] +): QueryCompositeFilterConstraint; + +export function and( + leftFilterExprOrQueryConstraint?: FilterExpr | QueryFilterConstraint, + ...right: FilterExpr[] | QueryFilterConstraint[] +): AndFunction | QueryCompositeFilterConstraint { + if (leftFilterExprOrQueryConstraint === undefined) { + return and._andFilters(); + } + if ( + leftFilterExprOrQueryConstraint instanceof QueryConstraint || + leftFilterExprOrQueryConstraint === undefined + ) { + return and._andFilters( + leftFilterExprOrQueryConstraint, + ...(right as QueryFilterConstraint[]) + ); + } else { + return and._andFunction( + leftFilterExprOrQueryConstraint as FilterExpr, + ...(right as FilterExpr[]) + ); + } +} + +and._andFilters = function ( + ...queryConstraints: QueryFilterConstraint[] +): QueryCompositeFilterConstraint { + // Only support QueryFilterConstraints + queryConstraints.forEach(queryConstraint => + validateQueryFilterConstraint('and', queryConstraint) + ); + + return QueryCompositeFilterConstraint._create( + CompositeOperator.AND, + queryConstraints as QueryFilterConstraint[] + ); +}; + +and._andFunction = function ( + left: FilterExpr, + ...right: FilterExpr[] +): AndFunction { + throw new Error( + 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' + ); +}; diff --git a/packages/firestore/src/remote/internal_serializer.ts b/packages/firestore/src/remote/internal_serializer.ts index 628457ba81c..c0e688585ef 100644 --- a/packages/firestore/src/remote/internal_serializer.ts +++ b/packages/firestore/src/remote/internal_serializer.ts @@ -25,6 +25,7 @@ import { cast } from '../util/input_validation'; import { mapToArray } from '../util/obj'; import { toQueryTarget, toRunAggregationQueryRequest } from './serializer'; +import {getDatastore} from "../lite-api/components"; /** * @internal @@ -107,7 +108,8 @@ export function _internalPipelineToExecutePipelineRequestProto( ): any { const firestore = cast(pipeline._db, Firestore); const client = ensureFirestoreConfigured(firestore); - const serializer = client._onlineComponents?.datastore.serializer; + const datastore = getDatastore(firestore); + const serializer = datastore.serializer; if (serializer === undefined) { return null; } diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index 1c210067785..0fb1d1fa49c 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -794,7 +794,7 @@ apiDescribe.only('Pipelines', persistence => { ); }); - it('supports internal serialization to proto', async () => { + it.only('supports internal serialization to proto', async () => { const pipeline = firestore .pipeline() .collection('books') @@ -807,6 +807,7 @@ apiDescribe.only('Pipelines', persistence => { const proto = _internalPipelineToExecutePipelineRequestProto(pipeline); expect(proto).not.to.be.null; + console.log(JSON.stringify(proto, null, 2)) }); // TODO(pipeline) support converter From 422cbd6d2fb46ecec88b515dd855a03da6f00a13 Mon Sep 17 00:00:00 2001 From: MarkDuckworth Date: Mon, 11 Nov 2024 21:33:12 +0000 Subject: [PATCH 27/59] Update API reports --- common/api-review/firestore-lite.api.md | 6 +++--- common/api-review/firestore.api.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 6a75658c0d0..4d8f428ad06 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -2203,8 +2203,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9237:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9238:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9267:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9237:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9238:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9267:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index 70b8664fa94..720dd83d983 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -2499,8 +2499,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10116:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10117:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10146:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10116:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10117:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10146:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` From c78bae9e2ee506c9e7e309d2f7914e0d03e30d31 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 13 Nov 2024 08:30:40 -0700 Subject: [PATCH 28/59] Fix and/or overloads --- .../src/lite-api/database_augmentation.ts | 10 +++++++ packages/firestore/src/lite-api/overloads.ts | 29 ++++++++++--------- .../test/integration/api/pipeline.test.ts | 2 +- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/packages/firestore/src/lite-api/database_augmentation.ts b/packages/firestore/src/lite-api/database_augmentation.ts index 7eb96e658c7..d1140260b20 100644 --- a/packages/firestore/src/lite-api/database_augmentation.ts +++ b/packages/firestore/src/lite-api/database_augmentation.ts @@ -6,6 +6,8 @@ import { PipelineSource } from './pipeline-source'; import { DocumentReference, Query } from './reference'; import { LiteUserDataWriter } from './reference_impl'; import { newUserDataReader } from './user_data_reader'; +import {or, and} from "./overloads"; +import {And, Avg, Expr, Field, FilterExpr, Or, Sum} from "./expressions"; export function useFirestorePipelines(): void { Firestore.prototype.pipeline = function (): PipelineSource { @@ -38,4 +40,12 @@ export function useFirestorePipelines(): void { return pipeline; }; + + and._andFunction = function(left: FilterExpr, ...right: FilterExpr[]): And { + return new And([left, ...right]); + } + + or._orFunction = function(left: FilterExpr, ...right: FilterExpr[]): Or { + return new Or([left, ...right]); + } } diff --git a/packages/firestore/src/lite-api/overloads.ts b/packages/firestore/src/lite-api/overloads.ts index 53413007c60..c17ea7ee46a 100644 --- a/packages/firestore/src/lite-api/overloads.ts +++ b/packages/firestore/src/lite-api/overloads.ts @@ -1,16 +1,20 @@ import { CompositeOperator } from '../core/filter'; import { - And as AndFunction, + And, Avg, Expr, Field, FilterExpr, - Or as OrFunction + Or, Sum } from './expressions'; + import { QueryCompositeFilterConstraint, QueryConstraint, QueryFilterConstraint, validateQueryFilterConstraint } from './query'; +import {FieldPath} from "./field_path"; +import {AggregateField} from "./aggregate_types"; +import {fieldPathFromArgument} from "./user_data_reader"; /** * @beta @@ -27,7 +31,7 @@ import { * @param right Additional filter conditions to 'OR' together. * @return A new {@code Expr} representing the logical 'OR' operation. */ -export function or(left: FilterExpr, ...right: FilterExpr[]): OrFunction; +export function or(left: FilterExpr, ...right: FilterExpr[]): Or; /** * Creates a new {@link QueryCompositeFilterConstraint} that is a disjunction of @@ -46,12 +50,13 @@ export function or( export function or( leftFilterExprOrQueryConstraint?: FilterExpr | QueryFilterConstraint, ...right: FilterExpr[] | QueryFilterConstraint[] -): OrFunction | QueryCompositeFilterConstraint { +): Or | QueryCompositeFilterConstraint { if (leftFilterExprOrQueryConstraint === undefined) { return or._orFilters(); } - if ( + else if ( leftFilterExprOrQueryConstraint instanceof QueryConstraint || + leftFilterExprOrQueryConstraint instanceof QueryCompositeFilterConstraint || leftFilterExprOrQueryConstraint === undefined ) { return or._orFilters( @@ -59,10 +64,8 @@ export function or( ...(right as QueryFilterConstraint[]) ); } else { - return or._orFunction( - leftFilterExprOrQueryConstraint as FilterExpr, - ...(right as FilterExpr[]) - ); + // @ts-ignore + return or._orFunction(leftFilterExprOrQueryConstraint, ...(right)); } } @@ -83,7 +86,7 @@ or._orFilters = function ( or._orFunction = function ( left: FilterExpr, ...right: FilterExpr[] -): OrFunction { +): Or { throw new Error( 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' ); @@ -104,7 +107,7 @@ or._orFunction = function ( * @param right Additional filter conditions to 'AND' together. * @return A new {@code Expr} representing the logical 'AND' operation. */ -export function and(left: FilterExpr, ...right: FilterExpr[]): AndFunction; +export function and(left: FilterExpr, ...right: FilterExpr[]): And; /** * Creates a new {@link QueryCompositeFilterConstraint} that is a conjunction of @@ -123,7 +126,7 @@ export function and( export function and( leftFilterExprOrQueryConstraint?: FilterExpr | QueryFilterConstraint, ...right: FilterExpr[] | QueryFilterConstraint[] -): AndFunction | QueryCompositeFilterConstraint { +): And | QueryCompositeFilterConstraint { if (leftFilterExprOrQueryConstraint === undefined) { return and._andFilters(); } @@ -160,7 +163,7 @@ and._andFilters = function ( and._andFunction = function ( left: FilterExpr, ...right: FilterExpr[] -): AndFunction { +): And { throw new Error( 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' ); diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index 0fb1d1fa49c..57a5121ed37 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -794,7 +794,7 @@ apiDescribe.only('Pipelines', persistence => { ); }); - it.only('supports internal serialization to proto', async () => { + it('supports internal serialization to proto', async () => { const pipeline = firestore .pipeline() .collection('books') From bcfaf2a16857071da6639d04781de4d75be92bc8 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 13 Nov 2024 13:24:51 -0700 Subject: [PATCH 29/59] Modular-style pipeline and execute methods for experimentation. Plus cleanup. --- common/api-review/firestore-lite.api.md | 17 ++++- common/api-review/firestore.api.md | 65 ++++++++----------- packages/firestore/lite/index.ts | 9 ++- packages/firestore/src/api.ts | 4 +- packages/firestore/src/api/pipeline.ts | 21 +++++- packages/firestore/src/core/pipeline-util.ts | 7 +- .../src/lite-api/database_augmentation.ts | 12 ++-- packages/firestore/src/lite-api/overloads.ts | 25 ++----- packages/firestore/src/lite-api/pipeline.ts | 21 +++++- .../firestore/src/lite-api/pipeline_impl.ts | 13 ++++ .../src/remote/internal_serializer.ts | 4 +- .../test/integration/api/pipeline.test.ts | 47 +++++++++++++- 12 files changed, 162 insertions(+), 83 deletions(-) create mode 100644 packages/firestore/src/lite-api/pipeline_impl.ts diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 4d8f428ad06..3acb768aa40 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -639,6 +639,9 @@ export function euclideanDistance(expr: Constant, other: VectorValue): Euclidean // @beta export function euclideanDistance(expr: Constant, other: Constant): EuclideanDistance; +// @beta +export function execute(pipeline: Pipeline): Promise>>; + // @beta (undocumented) export class Exists extends FirestoreFunction implements FilterCondition { constructor(expr: Constant); @@ -1612,6 +1615,14 @@ export class Pipeline { where(condition: FilterCondition & Constant): Pipeline; } +// Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta +// +// @public +export function pipeline(firestore: Firestore): PipelineSource; + +// @public +export function pipeline(query: Query): Pipeline; + // @beta export class PipelineResult { /* Excluded from this release type: _ref */ @@ -2203,8 +2214,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9237:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9238:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9267:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9243:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9244:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9273:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index 720dd83d983..5f17b27219f 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -686,6 +686,9 @@ export function euclideanDistance(expr: Constant, other: VectorValue): Euclidean // @beta export function euclideanDistance(expr: Constant, other: Constant): EuclideanDistance; +// @beta +export function execute(pipeline: Pipeline): Promise>>; + // @beta (undocumented) export class Exists extends FirestoreFunction implements FilterCondition { constructor(expr: Constant); @@ -1819,65 +1822,53 @@ export interface PersistentSingleTabManagerSettings { // @public export type PersistentTabManager = PersistentSingleTabManager | PersistentMultipleTabManager; -// @public +// @public (undocumented) export class Pipeline { - /* Excluded from this release type: _db */ + /* Excluded from this release type: __constructor */ // Warning: (ae-incompatible-release-tags) The symbol "addFields" is marked as @public, but its signature references "Selectable" which is marked as @beta addFields(...fields: Selectable[]): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "aggregate" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta aggregate(...accumulators: AccumulatorTarget[]): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ - aggregate(options: { - accumulators: AccumulatorTarget[]; - groups?: Array; - }): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ + aggregate(options: { accumulators: AccumulatorTarget[]; groups?: Array; }): Pipeline; + // (undocumented) + converter: any; // Warning: (ae-incompatible-release-tags) The symbol "distinct" is marked as @public, but its signature references "Selectable" which is marked as @beta distinct(...groups: Array): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "execute" is marked as @public, but its signature references "PipelineResult" which is marked as @beta execute(): Promise>>; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "findNearest" is marked as @public, but its signature references "FindNearestOptions" which is marked as @beta // // (undocumented) findNearest(options: FindNearestOptions): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ genericStage(name: string, params: any[]): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ limit(limit: number): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ offset(offset: number): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ + readUserData: any; // Warning: (ae-incompatible-release-tags) The symbol "select" is marked as @public, but its signature references "Selectable" which is marked as @beta select(...selections: Array): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ + // (undocumented) + selectablesToMap: any; // Warning: (ae-incompatible-release-tags) The symbol "sort" is marked as @public, but its signature references "Ordering" which is marked as @beta sort(...orderings: Ordering[]): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ - // (undocumented) - sort(options: { - orderings: Ordering[]; - }): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ + // (undocumented) + sort(options: { orderings: Ordering[]; }): Pipeline; + // (undocumented) + stages: any; + // (undocumented) + userDataReader: any; // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "FilterCondition" which is marked as @beta // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "Constant" which is marked as @beta where(condition: FilterCondition & Constant): Pipeline; } +// Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta +// +// @public +export function pipeline(firestore: Firestore): PipelineSource; + +// @public +export function pipeline(query: Query): Pipeline; + // @beta export class PipelineResult { /* Excluded from this release type: _ref */ @@ -2499,8 +2490,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10116:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10117:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10146:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10106:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10106:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10133:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/packages/firestore/lite/index.ts b/packages/firestore/lite/index.ts index 6e30bdd4e0c..7bd1b2ce3db 100644 --- a/packages/firestore/lite/index.ts +++ b/packages/firestore/lite/index.ts @@ -31,10 +31,12 @@ export { PipelineSource } from '../src/lite-api/pipeline-source'; export { PipelineResult } from '../src/lite-api/pipeline-result'; -export { Pipeline } from '../src/lite-api/pipeline'; +export { Pipeline, pipeline } from '../src/lite-api/pipeline'; export { useFirestorePipelines } from '../src/lite-api/database_augmentation'; +export { execute } from '../src/lite-api/pipeline_impl'; + export { Stage, FindNearestOptions, @@ -238,10 +240,7 @@ export { queryEqual } from '../src/lite-api/reference'; -export { - and, - or, -} from '../src/lite-api/overloads'; +export { and, or } from '../src/lite-api/overloads'; export { endAt, diff --git a/packages/firestore/src/api.ts b/packages/firestore/src/api.ts index 73b725f184b..9b77311666b 100644 --- a/packages/firestore/src/api.ts +++ b/packages/firestore/src/api.ts @@ -19,10 +19,12 @@ export { PipelineSource } from './lite-api/pipeline-source'; export { PipelineResult } from './lite-api/pipeline-result'; -export { Pipeline } from './lite-api/pipeline'; +export { Pipeline, pipeline } from './api/pipeline'; export { useFirestorePipelines } from './api/database_augmentation'; +export { execute } from './lite-api/pipeline_impl'; + export { Stage, FindNearestOptions, diff --git a/packages/firestore/src/api/pipeline.ts b/packages/firestore/src/api/pipeline.ts index 9aeccae9ad0..3122fc36412 100644 --- a/packages/firestore/src/api/pipeline.ts +++ b/packages/firestore/src/api/pipeline.ts @@ -1,7 +1,8 @@ import { firestoreClientExecutePipeline } from '../core/firestore_client'; import { Pipeline as LitePipeline } from '../lite-api/pipeline'; import { PipelineResult } from '../lite-api/pipeline-result'; -import { DocumentData, DocumentReference } from '../lite-api/reference'; +import { PipelineSource } from '../lite-api/pipeline-source'; +import { DocumentData, DocumentReference, Query } from '../lite-api/reference'; import { Stage } from '../lite-api/stage'; import { UserDataReader } from '../lite-api/user_data_reader'; import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; @@ -97,3 +98,21 @@ export class Pipeline< }); } } + +/** + * Experimental Modular API for console testing. + * @param firestore + */ +export function pipeline(firestore: Firestore): PipelineSource; + +/** + * Experimental Modular API for console testing. + * @param query + */ +export function pipeline(query: Query): Pipeline; + +export function pipeline( + firestoreOrQuery: Firestore | Query +): PipelineSource | Pipeline { + return firestoreOrQuery.pipeline(); +} diff --git a/packages/firestore/src/core/pipeline-util.ts b/packages/firestore/src/core/pipeline-util.ts index 8a6ef9e17a7..49704e06381 100644 --- a/packages/firestore/src/core/pipeline-util.ts +++ b/packages/firestore/src/core/pipeline-util.ts @@ -17,12 +17,9 @@ import { Expr, Field, FilterCondition, - not, + not } from '../lite-api/expressions'; -import { - and, - or -} from '../lite-api/overloads'; +import { and, or } from '../lite-api/overloads'; import { isNanValue, isNullValue } from '../model/values'; import { ArrayValue as ProtoArrayValue, diff --git a/packages/firestore/src/lite-api/database_augmentation.ts b/packages/firestore/src/lite-api/database_augmentation.ts index d1140260b20..cce1214138a 100644 --- a/packages/firestore/src/lite-api/database_augmentation.ts +++ b/packages/firestore/src/lite-api/database_augmentation.ts @@ -1,13 +1,13 @@ import { DocumentKey } from '../model/document_key'; import { Firestore } from './database'; +import { And, FilterExpr, Or } from './expressions'; +import { or, and } from './overloads'; import { Pipeline } from './pipeline'; import { PipelineSource } from './pipeline-source'; import { DocumentReference, Query } from './reference'; import { LiteUserDataWriter } from './reference_impl'; import { newUserDataReader } from './user_data_reader'; -import {or, and} from "./overloads"; -import {And, Avg, Expr, Field, FilterExpr, Or, Sum} from "./expressions"; export function useFirestorePipelines(): void { Firestore.prototype.pipeline = function (): PipelineSource { @@ -41,11 +41,11 @@ export function useFirestorePipelines(): void { return pipeline; }; - and._andFunction = function(left: FilterExpr, ...right: FilterExpr[]): And { + and._andFunction = function (left: FilterExpr, ...right: FilterExpr[]): And { return new And([left, ...right]); - } + }; - or._orFunction = function(left: FilterExpr, ...right: FilterExpr[]): Or { + or._orFunction = function (left: FilterExpr, ...right: FilterExpr[]): Or { return new Or([left, ...right]); - } + }; } diff --git a/packages/firestore/src/lite-api/overloads.ts b/packages/firestore/src/lite-api/overloads.ts index c17ea7ee46a..2b3675db521 100644 --- a/packages/firestore/src/lite-api/overloads.ts +++ b/packages/firestore/src/lite-api/overloads.ts @@ -1,20 +1,12 @@ import { CompositeOperator } from '../core/filter'; -import { - And, Avg, Expr, Field, - FilterExpr, - Or, Sum -} from './expressions'; - +import { And, FilterExpr, Or } from './expressions'; import { QueryCompositeFilterConstraint, QueryConstraint, QueryFilterConstraint, validateQueryFilterConstraint } from './query'; -import {FieldPath} from "./field_path"; -import {AggregateField} from "./aggregate_types"; -import {fieldPathFromArgument} from "./user_data_reader"; /** * @beta @@ -53,8 +45,7 @@ export function or( ): Or | QueryCompositeFilterConstraint { if (leftFilterExprOrQueryConstraint === undefined) { return or._orFilters(); - } - else if ( + } else if ( leftFilterExprOrQueryConstraint instanceof QueryConstraint || leftFilterExprOrQueryConstraint instanceof QueryCompositeFilterConstraint || leftFilterExprOrQueryConstraint === undefined @@ -65,7 +56,7 @@ export function or( ); } else { // @ts-ignore - return or._orFunction(leftFilterExprOrQueryConstraint, ...(right)); + return or._orFunction(leftFilterExprOrQueryConstraint, ...right); } } @@ -83,10 +74,7 @@ or._orFilters = function ( ); }; -or._orFunction = function ( - left: FilterExpr, - ...right: FilterExpr[] -): Or { +or._orFunction = function (left: FilterExpr, ...right: FilterExpr[]): Or { throw new Error( 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' ); @@ -160,10 +148,7 @@ and._andFilters = function ( ); }; -and._andFunction = function ( - left: FilterExpr, - ...right: FilterExpr[] -): And { +and._andFunction = function (left: FilterExpr, ...right: FilterExpr[]): And { throw new Error( 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' ); diff --git a/packages/firestore/src/lite-api/pipeline.ts b/packages/firestore/src/lite-api/pipeline.ts index 41a3b4590d8..5b9c061c1b9 100644 --- a/packages/firestore/src/lite-api/pipeline.ts +++ b/packages/firestore/src/lite-api/pipeline.ts @@ -42,7 +42,8 @@ import { Selectable } from './expressions'; import { PipelineResult } from './pipeline-result'; -import { DocumentData, DocumentReference } from './reference'; +import { PipelineSource } from './pipeline-source'; +import { DocumentData, DocumentReference, Query } from './reference'; import { AddFields, Aggregate, @@ -829,3 +830,21 @@ export class Pipeline }; } } + +/** + * Experimental Modular API for console testing. + * @param firestore + */ +export function pipeline(firestore: Firestore): PipelineSource; + +/** + * Experimental Modular API for console testing. + * @param query + */ +export function pipeline(query: Query): Pipeline; + +export function pipeline( + firestoreOrQuery: Firestore | Query +): PipelineSource | Pipeline { + return firestoreOrQuery.pipeline(); +} diff --git a/packages/firestore/src/lite-api/pipeline_impl.ts b/packages/firestore/src/lite-api/pipeline_impl.ts new file mode 100644 index 00000000000..30ccc04cbd4 --- /dev/null +++ b/packages/firestore/src/lite-api/pipeline_impl.ts @@ -0,0 +1,13 @@ +import { Pipeline } from './pipeline'; +import { PipelineResult } from './pipeline-result'; + +/** + * Modular API for console experimentation. + * @param pipeline Execute this pipeline. + * @beta + */ +export function execute( + pipeline: Pipeline +): Promise>> { + return pipeline.execute(); +} diff --git a/packages/firestore/src/remote/internal_serializer.ts b/packages/firestore/src/remote/internal_serializer.ts index c0e688585ef..dafdea85efc 100644 --- a/packages/firestore/src/remote/internal_serializer.ts +++ b/packages/firestore/src/remote/internal_serializer.ts @@ -19,13 +19,13 @@ import { ensureFirestoreConfigured, Firestore } from '../api/database'; import { AggregateImpl } from '../core/aggregate'; import { queryToAggregateTarget, queryToTarget } from '../core/query'; import { AggregateSpec } from '../lite-api/aggregate_types'; +import { getDatastore } from '../lite-api/components'; import { Pipeline } from '../lite-api/pipeline'; import { Query } from '../lite-api/reference'; import { cast } from '../util/input_validation'; import { mapToArray } from '../util/obj'; import { toQueryTarget, toRunAggregationQueryRequest } from './serializer'; -import {getDatastore} from "../lite-api/components"; /** * @internal @@ -105,9 +105,9 @@ export function _internalAggregationQueryToProtoRunAggregationQueryRequest< // eslint-disable-next-line @typescript-eslint/no-explicit-any export function _internalPipelineToExecutePipelineRequestProto( pipeline: Pipeline + // eslint-disable-next-line @typescript-eslint/no-explicit-any ): any { const firestore = cast(pipeline._db, Firestore); - const client = ensureFirestoreConfigured(firestore); const datastore = getDatastore(firestore); const serializer = datastore.serializer; if (serializer === undefined) { diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index 57a5121ed37..aa68528d124 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -15,6 +15,8 @@ import { expect, use } from 'chai'; import chaiAsPromised from 'chai-as-promised'; +import { pipeline } from '../../../src/api/pipeline'; +import { execute } from '../../../src/lite-api/pipeline_impl'; import { addEqualityMatcher } from '../../util/equality_matcher'; import { Deferred } from '../../util/promise'; import { @@ -57,7 +59,7 @@ import { apiDescribe, withTestCollection } from '../util/helpers'; use(chaiAsPromised); useFirestorePipelines(); -apiDescribe.only('Pipelines', persistence => { +apiDescribe('Pipelines', persistence => { addEqualityMatcher(); let firestore: Firestore; let randomCol: CollectionReference; @@ -807,7 +809,6 @@ apiDescribe.only('Pipelines', persistence => { const proto = _internalPipelineToExecutePipelineRequestProto(pipeline); expect(proto).not.to.be.null; - console.log(JSON.stringify(proto, null, 2)) }); // TODO(pipeline) support converter @@ -843,4 +844,46 @@ apiDescribe.only('Pipelines', persistence => { // myTitle: 'Crime and Punishment', // }); // }); + describe('modular API', () => { + it('works when creating a pipeline from a Firestore instance', async () => { + const myPipeline = pipeline(firestore) + .collection(randomCol.path) + .where(lt(Field.of('published'), 1984)) + .aggregate({ + accumulators: [avg('rating').as('avgRating')], + groups: ['genre'] + }) + .where(gt('avgRating', 4.3)) + .sort(Field.of('avgRating').descending()); + + const results = await execute(myPipeline); + + expectResults( + results, + { avgRating: 4.7, genre: 'Fantasy' }, + { avgRating: 4.5, genre: 'Romance' }, + { avgRating: 4.4, genre: 'Science Fiction' } + ); + }); + + it('works when creating a pipeline from a collection', async () => { + const myPipeline = pipeline(randomCol) + .where(lt(Field.of('published'), 1984)) + .aggregate({ + accumulators: [avg('rating').as('avgRating')], + groups: ['genre'] + }) + .where(gt('avgRating', 4.3)) + .sort(Field.of('avgRating').descending()); + + const results = await execute(myPipeline); + + expectResults( + results, + { avgRating: 4.7, genre: 'Fantasy' }, + { avgRating: 4.5, genre: 'Romance' }, + { avgRating: 4.4, genre: 'Science Fiction' } + ); + }); + }); }); From 5425705e3af8e0eee8ecf1b982e6a2f7a59b59cc Mon Sep 17 00:00:00 2001 From: MarkDuckworth Date: Wed, 13 Nov 2024 20:40:35 +0000 Subject: [PATCH 30/59] Update API reports --- common/api-review/firestore-lite.api.md | 6 +++--- common/api-review/firestore.api.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 3acb768aa40..1d32a0b466a 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -2214,8 +2214,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9243:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9244:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9273:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9243:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9244:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9273:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index 5f17b27219f..bafcf704778 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -2490,8 +2490,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10106:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10106:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10133:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10106:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10106:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10133:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` From edc1ea5276575279dea4967818538d5a4e67939e Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 13 Nov 2024 14:08:07 -0700 Subject: [PATCH 31/59] Docgen --- docs-devsite/_toc.yaml | 483 +- docs-devsite/firestore_.accumulator.md | 39 + docs-devsite/firestore_.add.md | 49 + docs-devsite/firestore_.addfields.md | 64 + docs-devsite/firestore_.aggregate.md | 65 + docs-devsite/firestore_.and.md | 17 + docs-devsite/firestore_.arrayconcat.md | 49 + docs-devsite/firestore_.arraycontains.md | 67 + docs-devsite/firestore_.arraycontainsall.md | 67 + docs-devsite/firestore_.arraycontainsany.md | 67 + docs-devsite/firestore_.arrayelement.md | 41 + docs-devsite/firestore_.arraylength.md | 48 + docs-devsite/firestore_.arrayreverse.md | 48 + docs-devsite/firestore_.avg.md | 67 + docs-devsite/firestore_.bytelength.md | 48 + docs-devsite/firestore_.charlength.md | 48 + .../firestore_.collectiongroupsource.md | 64 + docs-devsite/firestore_.collectionsource.md | 64 + docs-devsite/firestore_.constant.md | 3504 +++++++ docs-devsite/firestore_.cosinedistance.md | 49 + docs-devsite/firestore_.count.md | 67 + docs-devsite/firestore_.databasesource.md | 39 + docs-devsite/firestore_.distinct.md | 64 + docs-devsite/firestore_.divide.md | 49 + docs-devsite/firestore_.documentssource.md | 92 + docs-devsite/firestore_.dotproduct.md | 49 + docs-devsite/firestore_.endswith.md | 67 + docs-devsite/firestore_.eq.md | 67 + docs-devsite/firestore_.euclideandistance.md | 49 + docs-devsite/firestore_.exists.md | 66 + docs-devsite/firestore_.exprwithalias.md | 3207 ++++++ docs-devsite/firestore_.field.md | 3275 ++++++ docs-devsite/firestore_.fields.md | 3210 ++++++ docs-devsite/firestore_.filtercondition.md | 39 + docs-devsite/firestore_.findnearest.md | 39 + docs-devsite/firestore_.findnearestoptions.md | 86 + docs-devsite/firestore_.firestore.md | 14 + docs-devsite/firestore_.firestorefunction.md | 3173 ++++++ docs-devsite/firestore_.genericstage.md | 65 + docs-devsite/firestore_.gt.md | 67 + docs-devsite/firestore_.gte.md | 67 + docs-devsite/firestore_.if.md | 68 + docs-devsite/firestore_.in.md | 67 + docs-devsite/firestore_.isnan.md | 66 + docs-devsite/firestore_.like.md | 67 + docs-devsite/firestore_.limit.md | 64 + docs-devsite/firestore_.logicalmax.md | 49 + docs-devsite/firestore_.logicalmin.md | 49 + docs-devsite/firestore_.lt.md | 67 + docs-devsite/firestore_.lte.md | 67 + docs-devsite/firestore_.mapget.md | 49 + docs-devsite/firestore_.max.md | 67 + docs-devsite/firestore_.md | 8966 +++++++++++++++-- docs-devsite/firestore_.min.md | 67 + docs-devsite/firestore_.mod.md | 49 + docs-devsite/firestore_.multiply.md | 49 + docs-devsite/firestore_.neq.md | 67 + docs-devsite/firestore_.not.md | 66 + docs-devsite/firestore_.offset.md | 64 + docs-devsite/firestore_.or.md | 17 + docs-devsite/firestore_.ordering.md | 51 + docs-devsite/firestore_.pipeline.md | 609 ++ docs-devsite/firestore_.pipelineresult.md | 184 + docs-devsite/firestore_.pipelinesource.md | 109 + docs-devsite/firestore_.query.md | 14 + ...restore_.querycompositefilterconstraint.md | 2 +- docs-devsite/firestore_.regexcontains.md | 67 + docs-devsite/firestore_.regexmatch.md | 67 + docs-devsite/firestore_.replaceall.md | 50 + docs-devsite/firestore_.replacefirst.md | 50 + docs-devsite/firestore_.reverse.md | 48 + docs-devsite/firestore_.select.md | 64 + docs-devsite/firestore_.selectable.md | 39 + docs-devsite/firestore_.sort.md | 64 + docs-devsite/firestore_.stage.md | 38 + docs-devsite/firestore_.startswith.md | 67 + docs-devsite/firestore_.strconcat.md | 49 + docs-devsite/firestore_.strcontains.md | 67 + docs-devsite/firestore_.subtract.md | 49 + docs-devsite/firestore_.sum.md | 67 + docs-devsite/firestore_.timestampadd.md | 50 + docs-devsite/firestore_.timestampsub.md | 50 + .../firestore_.timestamptounixmicros.md | 48 + .../firestore_.timestamptounixmillis.md | 48 + .../firestore_.timestamptounixseconds.md | 48 + docs-devsite/firestore_.tolower.md | 48 + docs-devsite/firestore_.toupper.md | 48 + docs-devsite/firestore_.trim.md | 48 + .../firestore_.unixmicrostotimestamp.md | 48 + .../firestore_.unixmillistotimestamp.md | 48 + .../firestore_.unixsecondstotimestamp.md | 48 + docs-devsite/firestore_.vectorlength.md | 48 + docs-devsite/firestore_.where.md | 64 + docs-devsite/firestore_.xor.md | 66 + docs-devsite/firestore_lite.accumulator.md | 39 + docs-devsite/firestore_lite.add.md | 49 + docs-devsite/firestore_lite.addfields.md | 64 + docs-devsite/firestore_lite.aggregate.md | 65 + docs-devsite/firestore_lite.and.md | 17 + docs-devsite/firestore_lite.arrayconcat.md | 49 + docs-devsite/firestore_lite.arraycontains.md | 67 + .../firestore_lite.arraycontainsall.md | 67 + .../firestore_lite.arraycontainsany.md | 67 + docs-devsite/firestore_lite.arrayelement.md | 41 + docs-devsite/firestore_lite.arraylength.md | 48 + docs-devsite/firestore_lite.arrayreverse.md | 48 + docs-devsite/firestore_lite.avg.md | 67 + docs-devsite/firestore_lite.bytelength.md | 48 + docs-devsite/firestore_lite.charlength.md | 48 + .../firestore_lite.collectiongroupsource.md | 64 + .../firestore_lite.collectionsource.md | 64 + docs-devsite/firestore_lite.constant.md | 3504 +++++++ docs-devsite/firestore_lite.cosinedistance.md | 49 + docs-devsite/firestore_lite.count.md | 67 + docs-devsite/firestore_lite.databasesource.md | 39 + docs-devsite/firestore_lite.distinct.md | 64 + docs-devsite/firestore_lite.divide.md | 49 + .../firestore_lite.documentssource.md | 92 + docs-devsite/firestore_lite.dotproduct.md | 49 + docs-devsite/firestore_lite.endswith.md | 67 + docs-devsite/firestore_lite.eq.md | 67 + .../firestore_lite.euclideandistance.md | 49 + docs-devsite/firestore_lite.exists.md | 66 + docs-devsite/firestore_lite.exprwithalias.md | 3207 ++++++ docs-devsite/firestore_lite.field.md | 3275 ++++++ docs-devsite/firestore_lite.fields.md | 3210 ++++++ .../firestore_lite.filtercondition.md | 39 + docs-devsite/firestore_lite.findnearest.md | 39 + .../firestore_lite.findnearestoptions.md | 86 + docs-devsite/firestore_lite.firestore.md | 14 + .../firestore_lite.firestorefunction.md | 3173 ++++++ docs-devsite/firestore_lite.genericstage.md | 65 + docs-devsite/firestore_lite.gt.md | 67 + docs-devsite/firestore_lite.gte.md | 67 + docs-devsite/firestore_lite.if.md | 68 + docs-devsite/firestore_lite.in.md | 67 + docs-devsite/firestore_lite.isnan.md | 66 + docs-devsite/firestore_lite.like.md | 67 + docs-devsite/firestore_lite.limit.md | 64 + docs-devsite/firestore_lite.logicalmax.md | 49 + docs-devsite/firestore_lite.logicalmin.md | 49 + docs-devsite/firestore_lite.lt.md | 67 + docs-devsite/firestore_lite.lte.md | 67 + docs-devsite/firestore_lite.mapget.md | 49 + docs-devsite/firestore_lite.max.md | 67 + docs-devsite/firestore_lite.md | 8123 ++++++++++++++- docs-devsite/firestore_lite.min.md | 67 + docs-devsite/firestore_lite.mod.md | 49 + docs-devsite/firestore_lite.multiply.md | 49 + docs-devsite/firestore_lite.neq.md | 67 + docs-devsite/firestore_lite.not.md | 66 + docs-devsite/firestore_lite.offset.md | 64 + docs-devsite/firestore_lite.or.md | 17 + docs-devsite/firestore_lite.ordering.md | 51 + docs-devsite/firestore_lite.pipeline.md | 564 ++ docs-devsite/firestore_lite.pipelineresult.md | 184 + docs-devsite/firestore_lite.pipelinesource.md | 109 + docs-devsite/firestore_lite.query.md | 14 + ...ore_lite.querycompositefilterconstraint.md | 2 +- docs-devsite/firestore_lite.regexcontains.md | 67 + docs-devsite/firestore_lite.regexmatch.md | 67 + docs-devsite/firestore_lite.replaceall.md | 50 + docs-devsite/firestore_lite.replacefirst.md | 50 + docs-devsite/firestore_lite.reverse.md | 48 + docs-devsite/firestore_lite.select.md | 64 + docs-devsite/firestore_lite.selectable.md | 39 + docs-devsite/firestore_lite.sort.md | 64 + docs-devsite/firestore_lite.stage.md | 38 + docs-devsite/firestore_lite.startswith.md | 67 + docs-devsite/firestore_lite.strconcat.md | 49 + docs-devsite/firestore_lite.strcontains.md | 67 + docs-devsite/firestore_lite.subtract.md | 49 + docs-devsite/firestore_lite.sum.md | 67 + docs-devsite/firestore_lite.timestampadd.md | 50 + docs-devsite/firestore_lite.timestampsub.md | 50 + .../firestore_lite.timestamptounixmicros.md | 48 + .../firestore_lite.timestamptounixmillis.md | 48 + .../firestore_lite.timestamptounixseconds.md | 48 + docs-devsite/firestore_lite.tolower.md | 48 + docs-devsite/firestore_lite.toupper.md | 48 + docs-devsite/firestore_lite.trim.md | 48 + .../firestore_lite.unixmicrostotimestamp.md | 48 + .../firestore_lite.unixmillistotimestamp.md | 48 + .../firestore_lite.unixsecondstotimestamp.md | 48 + docs-devsite/firestore_lite.vectorlength.md | 48 + docs-devsite/firestore_lite.where.md | 64 + docs-devsite/firestore_lite.xor.md | 66 + docs-devsite/index.md | 2 +- ...rams.md => vertexai-preview.baseparams.md} | 4 +- docs-devsite/vertexai-preview.chatsession.md | 138 + ...tation.md => vertexai-preview.citation.md} | 12 +- ...d => vertexai-preview.citationmetadata.md} | 4 +- ...content.md => vertexai-preview.content.md} | 4 +- ...=> vertexai-preview.counttokensrequest.md} | 4 +- ...> vertexai-preview.counttokensresponse.md} | 6 +- ...md => vertexai-preview.customerrordata.md} | 10 +- ...i.date_2.md => vertexai-preview.date_2.md} | 6 +- ...review.enhancedgeneratecontentresponse.md} | 6 +- ...ls.md => vertexai-preview.errordetails.md} | 8 +- ...ledata.md => vertexai-preview.filedata.md} | 4 +- ...rt.md => vertexai-preview.filedatapart.md} | 12 +- ...ll.md => vertexai-preview.functioncall.md} | 6 +- ...vertexai-preview.functioncallingconfig.md} | 4 +- ...d => vertexai-preview.functioncallpart.md} | 10 +- ...> vertexai-preview.functiondeclaration.md} | 12 +- ...texai-preview.functiondeclarationschema.md | 70 + ...eview.functiondeclarationschemaproperty.md | 125 + ...rtexai-preview.functiondeclarationstool.md | 35 + ...d => vertexai-preview.functionresponse.md} | 6 +- ... vertexai-preview.functionresponsepart.md} | 10 +- ...rtexai-preview.generatecontentcandidate.md | 87 + ...ertexai-preview.generatecontentrequest.md} | 12 +- ...rtexai-preview.generatecontentresponse.md} | 8 +- ...vertexai-preview.generatecontentresult.md} | 4 +- ...ai-preview.generatecontentstreamresult.md} | 6 +- .../vertexai-preview.generationconfig.md | 107 + ...vertexai-preview.generativecontentblob.md} | 4 +- .../vertexai-preview.generativemodel.md | 201 + ... vertexai-preview.groundingattribution.md} | 8 +- ... => vertexai-preview.groundingmetadata.md} | 6 +- ....md => vertexai-preview.inlinedatapart.md} | 10 +- docs-devsite/vertexai-preview.md | 397 + ...ams.md => vertexai-preview.modelparams.md} | 12 +- ....md => vertexai-preview.promptfeedback.md} | 8 +- ....md => vertexai-preview.requestoptions.md} | 10 +- ...ai-preview.retrievedcontextattribution.md} | 4 +- ...ng.md => vertexai-preview.safetyrating.md} | 14 +- ...g.md => vertexai-preview.safetysetting.md} | 8 +- ...segment.md => vertexai-preview.segment.md} | 6 +- ...md => vertexai-preview.startchatparams.md} | 12 +- ...xtpart.md => vertexai-preview.textpart.md} | 8 +- ...nfig.md => vertexai-preview.toolconfig.md} | 4 +- ...a.md => vertexai-preview.usagemetadata.md} | 8 +- ...rtexai.md => vertexai-preview.vertexai.md} | 8 +- ...r.md => vertexai-preview.vertexaierror.md} | 21 +- ...md => vertexai-preview.vertexaioptions.md} | 4 +- ...a.md => vertexai-preview.videometadata.md} | 4 +- ....md => vertexai-preview.webattribution.md} | 4 +- docs-devsite/vertexai.arrayschema.md | 57 - docs-devsite/vertexai.booleanschema.md | 43 - docs-devsite/vertexai.chatsession.md | 138 - .../vertexai.functiondeclarationstool.md | 35 - .../vertexai.generatecontentcandidate.md | 87 - docs-devsite/vertexai.generationconfig.md | 118 - docs-devsite/vertexai.generativemodel.md | 201 - docs-devsite/vertexai.integerschema.md | 43 - docs-devsite/vertexai.md | 412 - docs-devsite/vertexai.numberschema.md | 43 - docs-devsite/vertexai.objectschema.md | 71 - .../vertexai.objectschemainterface.md | 43 - docs-devsite/vertexai.schema.md | 250 - docs-devsite/vertexai.schemainterface.md | 36 - docs-devsite/vertexai.schemaparams.md | 21 - docs-devsite/vertexai.schemarequest.md | 47 - docs-devsite/vertexai.schemashared.md | 103 - docs-devsite/vertexai.stringschema.md | 57 - 256 files changed, 60953 insertions(+), 3542 deletions(-) create mode 100644 docs-devsite/firestore_.accumulator.md create mode 100644 docs-devsite/firestore_.add.md create mode 100644 docs-devsite/firestore_.addfields.md create mode 100644 docs-devsite/firestore_.aggregate.md create mode 100644 docs-devsite/firestore_.and.md create mode 100644 docs-devsite/firestore_.arrayconcat.md create mode 100644 docs-devsite/firestore_.arraycontains.md create mode 100644 docs-devsite/firestore_.arraycontainsall.md create mode 100644 docs-devsite/firestore_.arraycontainsany.md create mode 100644 docs-devsite/firestore_.arrayelement.md create mode 100644 docs-devsite/firestore_.arraylength.md create mode 100644 docs-devsite/firestore_.arrayreverse.md create mode 100644 docs-devsite/firestore_.avg.md create mode 100644 docs-devsite/firestore_.bytelength.md create mode 100644 docs-devsite/firestore_.charlength.md create mode 100644 docs-devsite/firestore_.collectiongroupsource.md create mode 100644 docs-devsite/firestore_.collectionsource.md create mode 100644 docs-devsite/firestore_.constant.md create mode 100644 docs-devsite/firestore_.cosinedistance.md create mode 100644 docs-devsite/firestore_.count.md create mode 100644 docs-devsite/firestore_.databasesource.md create mode 100644 docs-devsite/firestore_.distinct.md create mode 100644 docs-devsite/firestore_.divide.md create mode 100644 docs-devsite/firestore_.documentssource.md create mode 100644 docs-devsite/firestore_.dotproduct.md create mode 100644 docs-devsite/firestore_.endswith.md create mode 100644 docs-devsite/firestore_.eq.md create mode 100644 docs-devsite/firestore_.euclideandistance.md create mode 100644 docs-devsite/firestore_.exists.md create mode 100644 docs-devsite/firestore_.exprwithalias.md create mode 100644 docs-devsite/firestore_.field.md create mode 100644 docs-devsite/firestore_.fields.md create mode 100644 docs-devsite/firestore_.filtercondition.md create mode 100644 docs-devsite/firestore_.findnearest.md create mode 100644 docs-devsite/firestore_.findnearestoptions.md create mode 100644 docs-devsite/firestore_.firestorefunction.md create mode 100644 docs-devsite/firestore_.genericstage.md create mode 100644 docs-devsite/firestore_.gt.md create mode 100644 docs-devsite/firestore_.gte.md create mode 100644 docs-devsite/firestore_.if.md create mode 100644 docs-devsite/firestore_.in.md create mode 100644 docs-devsite/firestore_.isnan.md create mode 100644 docs-devsite/firestore_.like.md create mode 100644 docs-devsite/firestore_.limit.md create mode 100644 docs-devsite/firestore_.logicalmax.md create mode 100644 docs-devsite/firestore_.logicalmin.md create mode 100644 docs-devsite/firestore_.lt.md create mode 100644 docs-devsite/firestore_.lte.md create mode 100644 docs-devsite/firestore_.mapget.md create mode 100644 docs-devsite/firestore_.max.md create mode 100644 docs-devsite/firestore_.min.md create mode 100644 docs-devsite/firestore_.mod.md create mode 100644 docs-devsite/firestore_.multiply.md create mode 100644 docs-devsite/firestore_.neq.md create mode 100644 docs-devsite/firestore_.not.md create mode 100644 docs-devsite/firestore_.offset.md create mode 100644 docs-devsite/firestore_.or.md create mode 100644 docs-devsite/firestore_.ordering.md create mode 100644 docs-devsite/firestore_.pipeline.md create mode 100644 docs-devsite/firestore_.pipelineresult.md create mode 100644 docs-devsite/firestore_.pipelinesource.md create mode 100644 docs-devsite/firestore_.regexcontains.md create mode 100644 docs-devsite/firestore_.regexmatch.md create mode 100644 docs-devsite/firestore_.replaceall.md create mode 100644 docs-devsite/firestore_.replacefirst.md create mode 100644 docs-devsite/firestore_.reverse.md create mode 100644 docs-devsite/firestore_.select.md create mode 100644 docs-devsite/firestore_.selectable.md create mode 100644 docs-devsite/firestore_.sort.md create mode 100644 docs-devsite/firestore_.stage.md create mode 100644 docs-devsite/firestore_.startswith.md create mode 100644 docs-devsite/firestore_.strconcat.md create mode 100644 docs-devsite/firestore_.strcontains.md create mode 100644 docs-devsite/firestore_.subtract.md create mode 100644 docs-devsite/firestore_.sum.md create mode 100644 docs-devsite/firestore_.timestampadd.md create mode 100644 docs-devsite/firestore_.timestampsub.md create mode 100644 docs-devsite/firestore_.timestamptounixmicros.md create mode 100644 docs-devsite/firestore_.timestamptounixmillis.md create mode 100644 docs-devsite/firestore_.timestamptounixseconds.md create mode 100644 docs-devsite/firestore_.tolower.md create mode 100644 docs-devsite/firestore_.toupper.md create mode 100644 docs-devsite/firestore_.trim.md create mode 100644 docs-devsite/firestore_.unixmicrostotimestamp.md create mode 100644 docs-devsite/firestore_.unixmillistotimestamp.md create mode 100644 docs-devsite/firestore_.unixsecondstotimestamp.md create mode 100644 docs-devsite/firestore_.vectorlength.md create mode 100644 docs-devsite/firestore_.where.md create mode 100644 docs-devsite/firestore_.xor.md create mode 100644 docs-devsite/firestore_lite.accumulator.md create mode 100644 docs-devsite/firestore_lite.add.md create mode 100644 docs-devsite/firestore_lite.addfields.md create mode 100644 docs-devsite/firestore_lite.aggregate.md create mode 100644 docs-devsite/firestore_lite.and.md create mode 100644 docs-devsite/firestore_lite.arrayconcat.md create mode 100644 docs-devsite/firestore_lite.arraycontains.md create mode 100644 docs-devsite/firestore_lite.arraycontainsall.md create mode 100644 docs-devsite/firestore_lite.arraycontainsany.md create mode 100644 docs-devsite/firestore_lite.arrayelement.md create mode 100644 docs-devsite/firestore_lite.arraylength.md create mode 100644 docs-devsite/firestore_lite.arrayreverse.md create mode 100644 docs-devsite/firestore_lite.avg.md create mode 100644 docs-devsite/firestore_lite.bytelength.md create mode 100644 docs-devsite/firestore_lite.charlength.md create mode 100644 docs-devsite/firestore_lite.collectiongroupsource.md create mode 100644 docs-devsite/firestore_lite.collectionsource.md create mode 100644 docs-devsite/firestore_lite.constant.md create mode 100644 docs-devsite/firestore_lite.cosinedistance.md create mode 100644 docs-devsite/firestore_lite.count.md create mode 100644 docs-devsite/firestore_lite.databasesource.md create mode 100644 docs-devsite/firestore_lite.distinct.md create mode 100644 docs-devsite/firestore_lite.divide.md create mode 100644 docs-devsite/firestore_lite.documentssource.md create mode 100644 docs-devsite/firestore_lite.dotproduct.md create mode 100644 docs-devsite/firestore_lite.endswith.md create mode 100644 docs-devsite/firestore_lite.eq.md create mode 100644 docs-devsite/firestore_lite.euclideandistance.md create mode 100644 docs-devsite/firestore_lite.exists.md create mode 100644 docs-devsite/firestore_lite.exprwithalias.md create mode 100644 docs-devsite/firestore_lite.field.md create mode 100644 docs-devsite/firestore_lite.fields.md create mode 100644 docs-devsite/firestore_lite.filtercondition.md create mode 100644 docs-devsite/firestore_lite.findnearest.md create mode 100644 docs-devsite/firestore_lite.findnearestoptions.md create mode 100644 docs-devsite/firestore_lite.firestorefunction.md create mode 100644 docs-devsite/firestore_lite.genericstage.md create mode 100644 docs-devsite/firestore_lite.gt.md create mode 100644 docs-devsite/firestore_lite.gte.md create mode 100644 docs-devsite/firestore_lite.if.md create mode 100644 docs-devsite/firestore_lite.in.md create mode 100644 docs-devsite/firestore_lite.isnan.md create mode 100644 docs-devsite/firestore_lite.like.md create mode 100644 docs-devsite/firestore_lite.limit.md create mode 100644 docs-devsite/firestore_lite.logicalmax.md create mode 100644 docs-devsite/firestore_lite.logicalmin.md create mode 100644 docs-devsite/firestore_lite.lt.md create mode 100644 docs-devsite/firestore_lite.lte.md create mode 100644 docs-devsite/firestore_lite.mapget.md create mode 100644 docs-devsite/firestore_lite.max.md create mode 100644 docs-devsite/firestore_lite.min.md create mode 100644 docs-devsite/firestore_lite.mod.md create mode 100644 docs-devsite/firestore_lite.multiply.md create mode 100644 docs-devsite/firestore_lite.neq.md create mode 100644 docs-devsite/firestore_lite.not.md create mode 100644 docs-devsite/firestore_lite.offset.md create mode 100644 docs-devsite/firestore_lite.or.md create mode 100644 docs-devsite/firestore_lite.ordering.md create mode 100644 docs-devsite/firestore_lite.pipeline.md create mode 100644 docs-devsite/firestore_lite.pipelineresult.md create mode 100644 docs-devsite/firestore_lite.pipelinesource.md create mode 100644 docs-devsite/firestore_lite.regexcontains.md create mode 100644 docs-devsite/firestore_lite.regexmatch.md create mode 100644 docs-devsite/firestore_lite.replaceall.md create mode 100644 docs-devsite/firestore_lite.replacefirst.md create mode 100644 docs-devsite/firestore_lite.reverse.md create mode 100644 docs-devsite/firestore_lite.select.md create mode 100644 docs-devsite/firestore_lite.selectable.md create mode 100644 docs-devsite/firestore_lite.sort.md create mode 100644 docs-devsite/firestore_lite.stage.md create mode 100644 docs-devsite/firestore_lite.startswith.md create mode 100644 docs-devsite/firestore_lite.strconcat.md create mode 100644 docs-devsite/firestore_lite.strcontains.md create mode 100644 docs-devsite/firestore_lite.subtract.md create mode 100644 docs-devsite/firestore_lite.sum.md create mode 100644 docs-devsite/firestore_lite.timestampadd.md create mode 100644 docs-devsite/firestore_lite.timestampsub.md create mode 100644 docs-devsite/firestore_lite.timestamptounixmicros.md create mode 100644 docs-devsite/firestore_lite.timestamptounixmillis.md create mode 100644 docs-devsite/firestore_lite.timestamptounixseconds.md create mode 100644 docs-devsite/firestore_lite.tolower.md create mode 100644 docs-devsite/firestore_lite.toupper.md create mode 100644 docs-devsite/firestore_lite.trim.md create mode 100644 docs-devsite/firestore_lite.unixmicrostotimestamp.md create mode 100644 docs-devsite/firestore_lite.unixmillistotimestamp.md create mode 100644 docs-devsite/firestore_lite.unixsecondstotimestamp.md create mode 100644 docs-devsite/firestore_lite.vectorlength.md create mode 100644 docs-devsite/firestore_lite.where.md create mode 100644 docs-devsite/firestore_lite.xor.md rename docs-devsite/{vertexai.baseparams.md => vertexai-preview.baseparams.md} (67%) create mode 100644 docs-devsite/vertexai-preview.chatsession.md rename docs-devsite/{vertexai.citation.md => vertexai-preview.citation.md} (68%) rename docs-devsite/{vertexai.citationmetadata.md => vertexai-preview.citationmetadata.md} (64%) rename docs-devsite/{vertexai.content.md => vertexai-preview.content.md} (76%) rename docs-devsite/{vertexai.counttokensrequest.md => vertexai-preview.counttokensrequest.md} (68%) rename docs-devsite/{vertexai.counttokensresponse.md => vertexai-preview.counttokensresponse.md} (67%) rename docs-devsite/{vertexai.customerrordata.md => vertexai-preview.customerrordata.md} (54%) rename docs-devsite/{vertexai.date_2.md => vertexai-preview.date_2.md} (78%) rename docs-devsite/{vertexai.enhancedgeneratecontentresponse.md => vertexai-preview.enhancedgeneratecontentresponse.md} (61%) rename docs-devsite/{vertexai.errordetails.md => vertexai-preview.errordetails.md} (68%) rename docs-devsite/{vertexai.filedata.md => vertexai-preview.filedata.md} (81%) rename docs-devsite/{vertexai.filedatapart.md => vertexai-preview.filedatapart.md} (60%) rename docs-devsite/{vertexai.functioncall.md => vertexai-preview.functioncall.md} (57%) rename docs-devsite/{vertexai.functioncallingconfig.md => vertexai-preview.functioncallingconfig.md} (71%) rename docs-devsite/{vertexai.functioncallpart.md => vertexai-preview.functioncallpart.md} (59%) rename docs-devsite/{vertexai.functiondeclaration.md => vertexai-preview.functiondeclaration.md} (57%) create mode 100644 docs-devsite/vertexai-preview.functiondeclarationschema.md create mode 100644 docs-devsite/vertexai-preview.functiondeclarationschemaproperty.md create mode 100644 docs-devsite/vertexai-preview.functiondeclarationstool.md rename docs-devsite/{vertexai.functionresponse.md => vertexai-preview.functionresponse.md} (50%) rename docs-devsite/{vertexai.functionresponsepart.md => vertexai-preview.functionresponsepart.md} (58%) create mode 100644 docs-devsite/vertexai-preview.generatecontentcandidate.md rename docs-devsite/{vertexai.generatecontentrequest.md => vertexai-preview.generatecontentrequest.md} (54%) rename docs-devsite/{vertexai.generatecontentresponse.md => vertexai-preview.generatecontentresponse.md} (50%) rename docs-devsite/{vertexai.generatecontentresult.md => vertexai-preview.generatecontentresult.md} (69%) rename docs-devsite/{vertexai.generatecontentstreamresult.md => vertexai-preview.generatecontentstreamresult.md} (52%) create mode 100644 docs-devsite/vertexai-preview.generationconfig.md rename docs-devsite/{vertexai.generativecontentblob.md => vertexai-preview.generativecontentblob.md} (76%) create mode 100644 docs-devsite/vertexai-preview.generativemodel.md rename docs-devsite/{vertexai.groundingattribution.md => vertexai-preview.groundingattribution.md} (58%) rename docs-devsite/{vertexai.groundingmetadata.md => vertexai-preview.groundingmetadata.md} (66%) rename docs-devsite/{vertexai.inlinedatapart.md => vertexai-preview.inlinedatapart.md} (60%) create mode 100644 docs-devsite/vertexai-preview.md rename docs-devsite/{vertexai.modelparams.md => vertexai-preview.modelparams.md} (54%) rename docs-devsite/{vertexai.promptfeedback.md => vertexai-preview.promptfeedback.md} (66%) rename docs-devsite/{vertexai.requestoptions.md => vertexai-preview.requestoptions.md} (55%) rename docs-devsite/{vertexai.retrievedcontextattribution.md => vertexai-preview.retrievedcontextattribution.md} (76%) rename docs-devsite/{vertexai.safetyrating.md => vertexai-preview.safetyrating.md} (55%) rename docs-devsite/{vertexai.safetysetting.md => vertexai-preview.safetysetting.md} (64%) rename docs-devsite/{vertexai.segment.md => vertexai-preview.segment.md} (75%) rename docs-devsite/{vertexai.startchatparams.md => vertexai-preview.startchatparams.md} (51%) rename docs-devsite/{vertexai.textpart.md => vertexai-preview.textpart.md} (72%) rename docs-devsite/{vertexai.toolconfig.md => vertexai-preview.toolconfig.md} (71%) rename docs-devsite/{vertexai.usagemetadata.md => vertexai-preview.usagemetadata.md} (63%) rename docs-devsite/{vertexai.vertexai.md => vertexai-preview.vertexai.md} (58%) rename docs-devsite/{vertexai.vertexaierror.md => vertexai-preview.vertexaierror.md} (55%) rename docs-devsite/{vertexai.vertexaioptions.md => vertexai-preview.vertexaioptions.md} (79%) rename docs-devsite/{vertexai.videometadata.md => vertexai-preview.videometadata.md} (66%) rename docs-devsite/{vertexai.webattribution.md => vertexai-preview.webattribution.md} (79%) delete mode 100644 docs-devsite/vertexai.arrayschema.md delete mode 100644 docs-devsite/vertexai.booleanschema.md delete mode 100644 docs-devsite/vertexai.chatsession.md delete mode 100644 docs-devsite/vertexai.functiondeclarationstool.md delete mode 100644 docs-devsite/vertexai.generatecontentcandidate.md delete mode 100644 docs-devsite/vertexai.generationconfig.md delete mode 100644 docs-devsite/vertexai.generativemodel.md delete mode 100644 docs-devsite/vertexai.integerschema.md delete mode 100644 docs-devsite/vertexai.md delete mode 100644 docs-devsite/vertexai.numberschema.md delete mode 100644 docs-devsite/vertexai.objectschema.md delete mode 100644 docs-devsite/vertexai.objectschemainterface.md delete mode 100644 docs-devsite/vertexai.schema.md delete mode 100644 docs-devsite/vertexai.schemainterface.md delete mode 100644 docs-devsite/vertexai.schemaparams.md delete mode 100644 docs-devsite/vertexai.schemarequest.md delete mode 100644 docs-devsite/vertexai.schemashared.md delete mode 100644 docs-devsite/vertexai.stringschema.md diff --git a/docs-devsite/_toc.yaml b/docs-devsite/_toc.yaml index a27f2832eb7..569c436a053 100644 --- a/docs-devsite/_toc.yaml +++ b/docs-devsite/_toc.yaml @@ -201,16 +201,62 @@ toc: - title: firestore path: /docs/reference/js/firestore_.md section: + - title: Accumulator + path: /docs/reference/js/firestore_.accumulator.md + - title: Add + path: /docs/reference/js/firestore_.add.md + - title: AddFields + path: /docs/reference/js/firestore_.addfields.md + - title: Aggregate + path: /docs/reference/js/firestore_.aggregate.md - title: AggregateField path: /docs/reference/js/firestore_.aggregatefield.md - title: AggregateQuerySnapshot path: /docs/reference/js/firestore_.aggregatequerysnapshot.md - title: AggregateSpec path: /docs/reference/js/firestore_.aggregatespec.md + - title: And + path: /docs/reference/js/firestore_.and.md + - title: ArrayConcat + path: /docs/reference/js/firestore_.arrayconcat.md + - title: ArrayContains + path: /docs/reference/js/firestore_.arraycontains.md + - title: ArrayContainsAll + path: /docs/reference/js/firestore_.arraycontainsall.md + - title: ArrayContainsAny + path: /docs/reference/js/firestore_.arraycontainsany.md + - title: ArrayElement + path: /docs/reference/js/firestore_.arrayelement.md + - title: ArrayLength + path: /docs/reference/js/firestore_.arraylength.md + - title: ArrayReverse + path: /docs/reference/js/firestore_.arrayreverse.md + - title: Avg + path: /docs/reference/js/firestore_.avg.md + - title: ByteLength + path: /docs/reference/js/firestore_.bytelength.md - title: Bytes path: /docs/reference/js/firestore_.bytes.md + - title: CharLength + path: /docs/reference/js/firestore_.charlength.md + - title: CollectionGroupSource + path: /docs/reference/js/firestore_.collectiongroupsource.md - title: CollectionReference path: /docs/reference/js/firestore_.collectionreference.md + - title: CollectionSource + path: /docs/reference/js/firestore_.collectionsource.md + - title: Constant + path: /docs/reference/js/firestore_.constant.md + - title: CosineDistance + path: /docs/reference/js/firestore_.cosinedistance.md + - title: Count + path: /docs/reference/js/firestore_.count.md + - title: DatabaseSource + path: /docs/reference/js/firestore_.databasesource.md + - title: Distinct + path: /docs/reference/js/firestore_.distinct.md + - title: Divide + path: /docs/reference/js/firestore_.divide.md - title: DocumentChange path: /docs/reference/js/firestore_.documentchange.md - title: DocumentData @@ -219,32 +265,86 @@ toc: path: /docs/reference/js/firestore_.documentreference.md - title: DocumentSnapshot path: /docs/reference/js/firestore_.documentsnapshot.md + - title: DocumentsSource + path: /docs/reference/js/firestore_.documentssource.md + - title: DotProduct + path: /docs/reference/js/firestore_.dotproduct.md + - title: EndsWith + path: /docs/reference/js/firestore_.endswith.md + - title: Eq + path: /docs/reference/js/firestore_.eq.md + - title: EuclideanDistance + path: /docs/reference/js/firestore_.euclideandistance.md + - title: Exists + path: /docs/reference/js/firestore_.exists.md - title: ExperimentalLongPollingOptions path: /docs/reference/js/firestore_.experimentallongpollingoptions.md + - title: ExprWithAlias + path: /docs/reference/js/firestore_.exprwithalias.md + - title: Field + path: /docs/reference/js/firestore_.field.md - title: FieldPath path: /docs/reference/js/firestore_.fieldpath.md + - title: Fields + path: /docs/reference/js/firestore_.fields.md - title: FieldValue path: /docs/reference/js/firestore_.fieldvalue.md + - title: FilterCondition + path: /docs/reference/js/firestore_.filtercondition.md + - title: FindNearest + path: /docs/reference/js/firestore_.findnearest.md + - title: FindNearestOptions + path: /docs/reference/js/firestore_.findnearestoptions.md - title: Firestore path: /docs/reference/js/firestore_.firestore.md - title: FirestoreDataConverter path: /docs/reference/js/firestore_.firestoredataconverter.md - title: FirestoreError path: /docs/reference/js/firestore_.firestoreerror.md + - title: FirestoreFunction + path: /docs/reference/js/firestore_.firestorefunction.md - title: FirestoreSettings path: /docs/reference/js/firestore_.firestoresettings.md + - title: GenericStage + path: /docs/reference/js/firestore_.genericstage.md - title: GeoPoint path: /docs/reference/js/firestore_.geopoint.md + - title: Gt + path: /docs/reference/js/firestore_.gt.md + - title: Gte + path: /docs/reference/js/firestore_.gte.md + - title: If + path: /docs/reference/js/firestore_.if.md + - title: In + path: /docs/reference/js/firestore_.in.md - title: Index path: /docs/reference/js/firestore_.index.md - title: IndexConfiguration path: /docs/reference/js/firestore_.indexconfiguration.md - title: IndexField path: /docs/reference/js/firestore_.indexfield.md + - title: IsNan + path: /docs/reference/js/firestore_.isnan.md + - title: Like + path: /docs/reference/js/firestore_.like.md + - title: Limit + path: /docs/reference/js/firestore_.limit.md - title: LoadBundleTask path: /docs/reference/js/firestore_.loadbundletask.md - title: LoadBundleTaskProgress path: /docs/reference/js/firestore_.loadbundletaskprogress.md + - title: LogicalMax + path: /docs/reference/js/firestore_.logicalmax.md + - title: LogicalMin + path: /docs/reference/js/firestore_.logicalmin.md + - title: Lt + path: /docs/reference/js/firestore_.lt.md + - title: Lte + path: /docs/reference/js/firestore_.lte.md + - title: MapGet + path: /docs/reference/js/firestore_.mapget.md + - title: Max + path: /docs/reference/js/firestore_.max.md - title: MemoryCacheSettings path: /docs/reference/js/firestore_.memorycachesettings.md - title: MemoryEagerGarbageCollector @@ -253,6 +353,22 @@ toc: path: /docs/reference/js/firestore_.memorylocalcache.md - title: MemoryLruGarbageCollector path: /docs/reference/js/firestore_.memorylrugarbagecollector.md + - title: Min + path: /docs/reference/js/firestore_.min.md + - title: Mod + path: /docs/reference/js/firestore_.mod.md + - title: Multiply + path: /docs/reference/js/firestore_.multiply.md + - title: Neq + path: /docs/reference/js/firestore_.neq.md + - title: Not + path: /docs/reference/js/firestore_.not.md + - title: Offset + path: /docs/reference/js/firestore_.offset.md + - title: Or + path: /docs/reference/js/firestore_.or.md + - title: Ordering + path: /docs/reference/js/firestore_.ordering.md - title: PersistenceSettings path: /docs/reference/js/firestore_.persistencesettings.md - title: PersistentCacheIndexManager @@ -267,6 +383,12 @@ toc: path: /docs/reference/js/firestore_.persistentsingletabmanager.md - title: PersistentSingleTabManagerSettings path: /docs/reference/js/firestore_.persistentsingletabmanagersettings.md + - title: Pipeline + path: /docs/reference/js/firestore_.pipeline.md + - title: PipelineResult + path: /docs/reference/js/firestore_.pipelineresult.md + - title: PipelineSource + path: /docs/reference/js/firestore_.pipelinesource.md - title: Query path: /docs/reference/js/firestore_.query.md - title: QueryCompositeFilterConstraint @@ -287,55 +409,233 @@ toc: path: /docs/reference/js/firestore_.querysnapshot.md - title: QueryStartAtConstraint path: /docs/reference/js/firestore_.querystartatconstraint.md + - title: RegexContains + path: /docs/reference/js/firestore_.regexcontains.md + - title: RegexMatch + path: /docs/reference/js/firestore_.regexmatch.md + - title: ReplaceAll + path: /docs/reference/js/firestore_.replaceall.md + - title: ReplaceFirst + path: /docs/reference/js/firestore_.replacefirst.md + - title: Reverse + path: /docs/reference/js/firestore_.reverse.md + - title: Select + path: /docs/reference/js/firestore_.select.md + - title: Selectable + path: /docs/reference/js/firestore_.selectable.md - title: SnapshotListenOptions path: /docs/reference/js/firestore_.snapshotlistenoptions.md - title: SnapshotMetadata path: /docs/reference/js/firestore_.snapshotmetadata.md - title: SnapshotOptions path: /docs/reference/js/firestore_.snapshotoptions.md + - title: Sort + path: /docs/reference/js/firestore_.sort.md + - title: Stage + path: /docs/reference/js/firestore_.stage.md + - title: StartsWith + path: /docs/reference/js/firestore_.startswith.md + - title: StrConcat + path: /docs/reference/js/firestore_.strconcat.md + - title: StrContains + path: /docs/reference/js/firestore_.strcontains.md + - title: Subtract + path: /docs/reference/js/firestore_.subtract.md + - title: Sum + path: /docs/reference/js/firestore_.sum.md - title: Timestamp path: /docs/reference/js/firestore_.timestamp.md + - title: TimestampAdd + path: /docs/reference/js/firestore_.timestampadd.md + - title: TimestampSub + path: /docs/reference/js/firestore_.timestampsub.md + - title: TimestampToUnixMicros + path: /docs/reference/js/firestore_.timestamptounixmicros.md + - title: TimestampToUnixMillis + path: /docs/reference/js/firestore_.timestamptounixmillis.md + - title: TimestampToUnixSeconds + path: /docs/reference/js/firestore_.timestamptounixseconds.md + - title: ToLower + path: /docs/reference/js/firestore_.tolower.md + - title: ToUpper + path: /docs/reference/js/firestore_.toupper.md - title: Transaction path: /docs/reference/js/firestore_.transaction.md - title: TransactionOptions path: /docs/reference/js/firestore_.transactionoptions.md + - title: Trim + path: /docs/reference/js/firestore_.trim.md + - title: UnixMicrosToTimestamp + path: /docs/reference/js/firestore_.unixmicrostotimestamp.md + - title: UnixMillisToTimestamp + path: /docs/reference/js/firestore_.unixmillistotimestamp.md + - title: UnixSecondsToTimestamp + path: /docs/reference/js/firestore_.unixsecondstotimestamp.md - title: Unsubscribe path: /docs/reference/js/firestore_.unsubscribe.md + - title: VectorLength + path: /docs/reference/js/firestore_.vectorlength.md - title: VectorValue path: /docs/reference/js/firestore_.vectorvalue.md + - title: Where + path: /docs/reference/js/firestore_.where.md - title: WriteBatch path: /docs/reference/js/firestore_.writebatch.md + - title: Xor + path: /docs/reference/js/firestore_.xor.md - title: firestore/lite path: /docs/reference/js/firestore_lite.md section: + - title: Accumulator + path: /docs/reference/js/firestore_lite.accumulator.md + - title: Add + path: /docs/reference/js/firestore_lite.add.md + - title: AddFields + path: /docs/reference/js/firestore_lite.addfields.md + - title: Aggregate + path: /docs/reference/js/firestore_lite.aggregate.md - title: AggregateField path: /docs/reference/js/firestore_lite.aggregatefield.md - title: AggregateQuerySnapshot path: /docs/reference/js/firestore_lite.aggregatequerysnapshot.md - title: AggregateSpec path: /docs/reference/js/firestore_lite.aggregatespec.md + - title: And + path: /docs/reference/js/firestore_lite.and.md + - title: ArrayConcat + path: /docs/reference/js/firestore_lite.arrayconcat.md + - title: ArrayContains + path: /docs/reference/js/firestore_lite.arraycontains.md + - title: ArrayContainsAll + path: /docs/reference/js/firestore_lite.arraycontainsall.md + - title: ArrayContainsAny + path: /docs/reference/js/firestore_lite.arraycontainsany.md + - title: ArrayElement + path: /docs/reference/js/firestore_lite.arrayelement.md + - title: ArrayLength + path: /docs/reference/js/firestore_lite.arraylength.md + - title: ArrayReverse + path: /docs/reference/js/firestore_lite.arrayreverse.md + - title: Avg + path: /docs/reference/js/firestore_lite.avg.md + - title: ByteLength + path: /docs/reference/js/firestore_lite.bytelength.md - title: Bytes path: /docs/reference/js/firestore_lite.bytes.md + - title: CharLength + path: /docs/reference/js/firestore_lite.charlength.md + - title: CollectionGroupSource + path: /docs/reference/js/firestore_lite.collectiongroupsource.md - title: CollectionReference path: /docs/reference/js/firestore_lite.collectionreference.md + - title: CollectionSource + path: /docs/reference/js/firestore_lite.collectionsource.md + - title: Constant + path: /docs/reference/js/firestore_lite.constant.md + - title: CosineDistance + path: /docs/reference/js/firestore_lite.cosinedistance.md + - title: Count + path: /docs/reference/js/firestore_lite.count.md + - title: DatabaseSource + path: /docs/reference/js/firestore_lite.databasesource.md + - title: Distinct + path: /docs/reference/js/firestore_lite.distinct.md + - title: Divide + path: /docs/reference/js/firestore_lite.divide.md - title: DocumentData path: /docs/reference/js/firestore_lite.documentdata.md - title: DocumentReference path: /docs/reference/js/firestore_lite.documentreference.md - title: DocumentSnapshot path: /docs/reference/js/firestore_lite.documentsnapshot.md + - title: DocumentsSource + path: /docs/reference/js/firestore_lite.documentssource.md + - title: DotProduct + path: /docs/reference/js/firestore_lite.dotproduct.md + - title: EndsWith + path: /docs/reference/js/firestore_lite.endswith.md + - title: Eq + path: /docs/reference/js/firestore_lite.eq.md + - title: EuclideanDistance + path: /docs/reference/js/firestore_lite.euclideandistance.md + - title: Exists + path: /docs/reference/js/firestore_lite.exists.md + - title: ExprWithAlias + path: /docs/reference/js/firestore_lite.exprwithalias.md + - title: Field + path: /docs/reference/js/firestore_lite.field.md - title: FieldPath path: /docs/reference/js/firestore_lite.fieldpath.md + - title: Fields + path: /docs/reference/js/firestore_lite.fields.md - title: FieldValue path: /docs/reference/js/firestore_lite.fieldvalue.md + - title: FilterCondition + path: /docs/reference/js/firestore_lite.filtercondition.md + - title: FindNearest + path: /docs/reference/js/firestore_lite.findnearest.md + - title: FindNearestOptions + path: /docs/reference/js/firestore_lite.findnearestoptions.md - title: Firestore path: /docs/reference/js/firestore_lite.firestore.md - title: FirestoreDataConverter path: /docs/reference/js/firestore_lite.firestoredataconverter.md - title: FirestoreError path: /docs/reference/js/firestore_lite.firestoreerror.md + - title: FirestoreFunction + path: /docs/reference/js/firestore_lite.firestorefunction.md + - title: GenericStage + path: /docs/reference/js/firestore_lite.genericstage.md - title: GeoPoint path: /docs/reference/js/firestore_lite.geopoint.md + - title: Gt + path: /docs/reference/js/firestore_lite.gt.md + - title: Gte + path: /docs/reference/js/firestore_lite.gte.md + - title: If + path: /docs/reference/js/firestore_lite.if.md + - title: In + path: /docs/reference/js/firestore_lite.in.md + - title: IsNan + path: /docs/reference/js/firestore_lite.isnan.md + - title: Like + path: /docs/reference/js/firestore_lite.like.md + - title: Limit + path: /docs/reference/js/firestore_lite.limit.md + - title: LogicalMax + path: /docs/reference/js/firestore_lite.logicalmax.md + - title: LogicalMin + path: /docs/reference/js/firestore_lite.logicalmin.md + - title: Lt + path: /docs/reference/js/firestore_lite.lt.md + - title: Lte + path: /docs/reference/js/firestore_lite.lte.md + - title: MapGet + path: /docs/reference/js/firestore_lite.mapget.md + - title: Max + path: /docs/reference/js/firestore_lite.max.md + - title: Min + path: /docs/reference/js/firestore_lite.min.md + - title: Mod + path: /docs/reference/js/firestore_lite.mod.md + - title: Multiply + path: /docs/reference/js/firestore_lite.multiply.md + - title: Neq + path: /docs/reference/js/firestore_lite.neq.md + - title: Not + path: /docs/reference/js/firestore_lite.not.md + - title: Offset + path: /docs/reference/js/firestore_lite.offset.md + - title: Or + path: /docs/reference/js/firestore_lite.or.md + - title: Ordering + path: /docs/reference/js/firestore_lite.ordering.md + - title: Pipeline + path: /docs/reference/js/firestore_lite.pipeline.md + - title: PipelineResult + path: /docs/reference/js/firestore_lite.pipelineresult.md + - title: PipelineSource + path: /docs/reference/js/firestore_lite.pipelinesource.md - title: Query path: /docs/reference/js/firestore_lite.query.md - title: QueryCompositeFilterConstraint @@ -356,18 +656,74 @@ toc: path: /docs/reference/js/firestore_lite.querysnapshot.md - title: QueryStartAtConstraint path: /docs/reference/js/firestore_lite.querystartatconstraint.md + - title: RegexContains + path: /docs/reference/js/firestore_lite.regexcontains.md + - title: RegexMatch + path: /docs/reference/js/firestore_lite.regexmatch.md + - title: ReplaceAll + path: /docs/reference/js/firestore_lite.replaceall.md + - title: ReplaceFirst + path: /docs/reference/js/firestore_lite.replacefirst.md + - title: Reverse + path: /docs/reference/js/firestore_lite.reverse.md + - title: Select + path: /docs/reference/js/firestore_lite.select.md + - title: Selectable + path: /docs/reference/js/firestore_lite.selectable.md - title: Settings path: /docs/reference/js/firestore_lite.settings.md + - title: Sort + path: /docs/reference/js/firestore_lite.sort.md + - title: Stage + path: /docs/reference/js/firestore_lite.stage.md + - title: StartsWith + path: /docs/reference/js/firestore_lite.startswith.md + - title: StrConcat + path: /docs/reference/js/firestore_lite.strconcat.md + - title: StrContains + path: /docs/reference/js/firestore_lite.strcontains.md + - title: Subtract + path: /docs/reference/js/firestore_lite.subtract.md + - title: Sum + path: /docs/reference/js/firestore_lite.sum.md - title: Timestamp path: /docs/reference/js/firestore_lite.timestamp.md + - title: TimestampAdd + path: /docs/reference/js/firestore_lite.timestampadd.md + - title: TimestampSub + path: /docs/reference/js/firestore_lite.timestampsub.md + - title: TimestampToUnixMicros + path: /docs/reference/js/firestore_lite.timestamptounixmicros.md + - title: TimestampToUnixMillis + path: /docs/reference/js/firestore_lite.timestamptounixmillis.md + - title: TimestampToUnixSeconds + path: /docs/reference/js/firestore_lite.timestamptounixseconds.md + - title: ToLower + path: /docs/reference/js/firestore_lite.tolower.md + - title: ToUpper + path: /docs/reference/js/firestore_lite.toupper.md - title: Transaction path: /docs/reference/js/firestore_lite.transaction.md - title: TransactionOptions path: /docs/reference/js/firestore_lite.transactionoptions.md + - title: Trim + path: /docs/reference/js/firestore_lite.trim.md + - title: UnixMicrosToTimestamp + path: /docs/reference/js/firestore_lite.unixmicrostotimestamp.md + - title: UnixMillisToTimestamp + path: /docs/reference/js/firestore_lite.unixmillistotimestamp.md + - title: UnixSecondsToTimestamp + path: /docs/reference/js/firestore_lite.unixsecondstotimestamp.md + - title: VectorLength + path: /docs/reference/js/firestore_lite.vectorlength.md - title: VectorValue path: /docs/reference/js/firestore_lite.vectorvalue.md + - title: Where + path: /docs/reference/js/firestore_lite.where.md - title: WriteBatch path: /docs/reference/js/firestore_lite.writebatch.md + - title: Xor + path: /docs/reference/js/firestore_lite.xor.md - title: functions path: /docs/reference/js/functions.md section: @@ -455,124 +811,105 @@ toc: path: /docs/reference/js/storage.uploadtask.md - title: UploadTaskSnapshot path: /docs/reference/js/storage.uploadtasksnapshot.md - - title: vertexai - path: /docs/reference/js/vertexai.md + - title: vertexai-preview + path: /docs/reference/js/vertexai-preview.md section: - - title: ArraySchema - path: /docs/reference/js/vertexai.arrayschema.md - title: BaseParams - path: /docs/reference/js/vertexai.baseparams.md - - title: BooleanSchema - path: /docs/reference/js/vertexai.booleanschema.md + path: /docs/reference/js/vertexai-preview.baseparams.md - title: ChatSession - path: /docs/reference/js/vertexai.chatsession.md + path: /docs/reference/js/vertexai-preview.chatsession.md - title: Citation - path: /docs/reference/js/vertexai.citation.md + path: /docs/reference/js/vertexai-preview.citation.md - title: CitationMetadata - path: /docs/reference/js/vertexai.citationmetadata.md + path: /docs/reference/js/vertexai-preview.citationmetadata.md - title: Content - path: /docs/reference/js/vertexai.content.md + path: /docs/reference/js/vertexai-preview.content.md - title: CountTokensRequest - path: /docs/reference/js/vertexai.counttokensrequest.md + path: /docs/reference/js/vertexai-preview.counttokensrequest.md - title: CountTokensResponse - path: /docs/reference/js/vertexai.counttokensresponse.md + path: /docs/reference/js/vertexai-preview.counttokensresponse.md - title: CustomErrorData - path: /docs/reference/js/vertexai.customerrordata.md + path: /docs/reference/js/vertexai-preview.customerrordata.md - title: Date_2 - path: /docs/reference/js/vertexai.date_2.md + path: /docs/reference/js/vertexai-preview.date_2.md - title: EnhancedGenerateContentResponse - path: /docs/reference/js/vertexai.enhancedgeneratecontentresponse.md + path: /docs/reference/js/vertexai-preview.enhancedgeneratecontentresponse.md - title: ErrorDetails - path: /docs/reference/js/vertexai.errordetails.md + path: /docs/reference/js/vertexai-preview.errordetails.md - title: FileData - path: /docs/reference/js/vertexai.filedata.md + path: /docs/reference/js/vertexai-preview.filedata.md - title: FileDataPart - path: /docs/reference/js/vertexai.filedatapart.md + path: /docs/reference/js/vertexai-preview.filedatapart.md - title: FunctionCall - path: /docs/reference/js/vertexai.functioncall.md + path: /docs/reference/js/vertexai-preview.functioncall.md - title: FunctionCallingConfig - path: /docs/reference/js/vertexai.functioncallingconfig.md + path: /docs/reference/js/vertexai-preview.functioncallingconfig.md - title: FunctionCallPart - path: /docs/reference/js/vertexai.functioncallpart.md + path: /docs/reference/js/vertexai-preview.functioncallpart.md - title: FunctionDeclaration - path: /docs/reference/js/vertexai.functiondeclaration.md + path: /docs/reference/js/vertexai-preview.functiondeclaration.md + - title: FunctionDeclarationSchema + path: /docs/reference/js/vertexai-preview.functiondeclarationschema.md + - title: FunctionDeclarationSchemaProperty + path: >- + /docs/reference/js/vertexai-preview.functiondeclarationschemaproperty.md - title: FunctionDeclarationsTool - path: /docs/reference/js/vertexai.functiondeclarationstool.md + path: /docs/reference/js/vertexai-preview.functiondeclarationstool.md - title: FunctionResponse - path: /docs/reference/js/vertexai.functionresponse.md + path: /docs/reference/js/vertexai-preview.functionresponse.md - title: FunctionResponsePart - path: /docs/reference/js/vertexai.functionresponsepart.md + path: /docs/reference/js/vertexai-preview.functionresponsepart.md - title: GenerateContentCandidate - path: /docs/reference/js/vertexai.generatecontentcandidate.md + path: /docs/reference/js/vertexai-preview.generatecontentcandidate.md - title: GenerateContentRequest - path: /docs/reference/js/vertexai.generatecontentrequest.md + path: /docs/reference/js/vertexai-preview.generatecontentrequest.md - title: GenerateContentResponse - path: /docs/reference/js/vertexai.generatecontentresponse.md + path: /docs/reference/js/vertexai-preview.generatecontentresponse.md - title: GenerateContentResult - path: /docs/reference/js/vertexai.generatecontentresult.md + path: /docs/reference/js/vertexai-preview.generatecontentresult.md - title: GenerateContentStreamResult - path: /docs/reference/js/vertexai.generatecontentstreamresult.md + path: /docs/reference/js/vertexai-preview.generatecontentstreamresult.md - title: GenerationConfig - path: /docs/reference/js/vertexai.generationconfig.md + path: /docs/reference/js/vertexai-preview.generationconfig.md - title: GenerativeContentBlob - path: /docs/reference/js/vertexai.generativecontentblob.md + path: /docs/reference/js/vertexai-preview.generativecontentblob.md - title: GenerativeModel - path: /docs/reference/js/vertexai.generativemodel.md + path: /docs/reference/js/vertexai-preview.generativemodel.md - title: GroundingAttribution - path: /docs/reference/js/vertexai.groundingattribution.md + path: /docs/reference/js/vertexai-preview.groundingattribution.md - title: GroundingMetadata - path: /docs/reference/js/vertexai.groundingmetadata.md + path: /docs/reference/js/vertexai-preview.groundingmetadata.md - title: InlineDataPart - path: /docs/reference/js/vertexai.inlinedatapart.md - - title: IntegerSchema - path: /docs/reference/js/vertexai.integerschema.md + path: /docs/reference/js/vertexai-preview.inlinedatapart.md - title: ModelParams - path: /docs/reference/js/vertexai.modelparams.md - - title: NumberSchema - path: /docs/reference/js/vertexai.numberschema.md - - title: ObjectSchema - path: /docs/reference/js/vertexai.objectschema.md - - title: ObjectSchemaInterface - path: /docs/reference/js/vertexai.objectschemainterface.md + path: /docs/reference/js/vertexai-preview.modelparams.md - title: PromptFeedback - path: /docs/reference/js/vertexai.promptfeedback.md + path: /docs/reference/js/vertexai-preview.promptfeedback.md - title: RequestOptions - path: /docs/reference/js/vertexai.requestoptions.md + path: /docs/reference/js/vertexai-preview.requestoptions.md - title: RetrievedContextAttribution - path: /docs/reference/js/vertexai.retrievedcontextattribution.md + path: /docs/reference/js/vertexai-preview.retrievedcontextattribution.md - title: SafetyRating - path: /docs/reference/js/vertexai.safetyrating.md + path: /docs/reference/js/vertexai-preview.safetyrating.md - title: SafetySetting - path: /docs/reference/js/vertexai.safetysetting.md - - title: Schema - path: /docs/reference/js/vertexai.schema.md - - title: SchemaInterface - path: /docs/reference/js/vertexai.schemainterface.md - - title: SchemaParams - path: /docs/reference/js/vertexai.schemaparams.md - - title: SchemaRequest - path: /docs/reference/js/vertexai.schemarequest.md - - title: SchemaShared - path: /docs/reference/js/vertexai.schemashared.md + path: /docs/reference/js/vertexai-preview.safetysetting.md - title: Segment - path: /docs/reference/js/vertexai.segment.md + path: /docs/reference/js/vertexai-preview.segment.md - title: StartChatParams - path: /docs/reference/js/vertexai.startchatparams.md - - title: StringSchema - path: /docs/reference/js/vertexai.stringschema.md + path: /docs/reference/js/vertexai-preview.startchatparams.md - title: TextPart - path: /docs/reference/js/vertexai.textpart.md + path: /docs/reference/js/vertexai-preview.textpart.md - title: ToolConfig - path: /docs/reference/js/vertexai.toolconfig.md + path: /docs/reference/js/vertexai-preview.toolconfig.md - title: UsageMetadata - path: /docs/reference/js/vertexai.usagemetadata.md + path: /docs/reference/js/vertexai-preview.usagemetadata.md - title: VertexAI - path: /docs/reference/js/vertexai.vertexai.md + path: /docs/reference/js/vertexai-preview.vertexai.md - title: VertexAIError - path: /docs/reference/js/vertexai.vertexaierror.md + path: /docs/reference/js/vertexai-preview.vertexaierror.md - title: VertexAIOptions - path: /docs/reference/js/vertexai.vertexaioptions.md + path: /docs/reference/js/vertexai-preview.vertexaioptions.md - title: VideoMetadata - path: /docs/reference/js/vertexai.videometadata.md + path: /docs/reference/js/vertexai-preview.videometadata.md - title: WebAttribution - path: /docs/reference/js/vertexai.webattribution.md + path: /docs/reference/js/vertexai-preview.webattribution.md diff --git a/docs-devsite/firestore_.accumulator.md b/docs-devsite/firestore_.accumulator.md new file mode 100644 index 00000000000..540bb3da217 --- /dev/null +++ b/docs-devsite/firestore_.accumulator.md @@ -0,0 +1,39 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Accumulator interface +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +An interface that represents an accumulator. + +Signature: + +```typescript +export declare interface Accumulator +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [accumulator](./firestore_.accumulator.md#accumulatoraccumulator) | true | (BETA) | + +## Accumulator.accumulator + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +accumulator: true; +``` diff --git a/docs-devsite/firestore_.add.md b/docs-devsite/firestore_.add.md new file mode 100644 index 00000000000..5fa68c68d84 --- /dev/null +++ b/docs-devsite/firestore_.add.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Add class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Add extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_.add.md#addconstructor) | | (BETA) Constructs a new instance of the Add class | + +## Add.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Add` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | | +| right | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.addfields.md b/docs-devsite/firestore_.addfields.md new file mode 100644 index 00000000000..23cf88da2d0 --- /dev/null +++ b/docs-devsite/firestore_.addfields.md @@ -0,0 +1,64 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# AddFields class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class AddFields implements Stage +``` +Implements: [Stage](./firestore_.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(fields)](./firestore_.addfields.md#addfieldsconstructor) | | (BETA) Constructs a new instance of the AddFields class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_.addfields.md#addfieldsname) | | string | (BETA) | + +## AddFields.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `AddFields` class + +Signature: + +```typescript +constructor(fields: Map); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| fields | Map<string, [Constant](./firestore_.constant.md#constant_class)> | | + +## AddFields.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_.aggregate.md b/docs-devsite/firestore_.aggregate.md new file mode 100644 index 00000000000..0868c5edc95 --- /dev/null +++ b/docs-devsite/firestore_.aggregate.md @@ -0,0 +1,65 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Aggregate class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Aggregate implements Stage +``` +Implements: [Stage](./firestore_.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(accumulators, groups)](./firestore_.aggregate.md#aggregateconstructor) | | (BETA) Constructs a new instance of the Aggregate class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_.aggregate.md#aggregatename) | | string | (BETA) | + +## Aggregate.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Aggregate` class + +Signature: + +```typescript +constructor(accumulators: Map, groups: Map); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| accumulators | Map<string, [Accumulator](./firestore_.accumulator.md#accumulator_interface)> | | +| groups | Map<string, [Constant](./firestore_.constant.md#constant_class)> | | + +## Aggregate.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_.and.md b/docs-devsite/firestore_.and.md new file mode 100644 index 00000000000..59b0a32b25d --- /dev/null +++ b/docs-devsite/firestore_.and.md @@ -0,0 +1,17 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# and namespace +Signature: + +```typescript +export declare namespace and +``` diff --git a/docs-devsite/firestore_.arrayconcat.md b/docs-devsite/firestore_.arrayconcat.md new file mode 100644 index 00000000000..d7f104b6954 --- /dev/null +++ b/docs-devsite/firestore_.arrayconcat.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ArrayConcat class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ArrayConcat extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(array, elements)](./firestore_.arrayconcat.md#arrayconcatconstructor) | | (BETA) Constructs a new instance of the ArrayConcat class | + +## ArrayConcat.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ArrayConcat` class + +Signature: + +```typescript +constructor(array: Constant, elements: Constant[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_.constant.md#constant_class) | | +| elements | [Constant](./firestore_.constant.md#constant_class)\[\] | | + diff --git a/docs-devsite/firestore_.arraycontains.md b/docs-devsite/firestore_.arraycontains.md new file mode 100644 index 00000000000..c56ae8b281d --- /dev/null +++ b/docs-devsite/firestore_.arraycontains.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ArrayContains class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ArrayContains extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(array, element)](./firestore_.arraycontains.md#arraycontainsconstructor) | | (BETA) Constructs a new instance of the ArrayContains class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_.arraycontains.md#arraycontainsfilterable) | | true | (BETA) | + +## ArrayContains.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ArrayContains` class + +Signature: + +```typescript +constructor(array: Constant, element: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_.constant.md#constant_class) | | +| element | [Constant](./firestore_.constant.md#constant_class) | | + +## ArrayContains.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_.arraycontainsall.md b/docs-devsite/firestore_.arraycontainsall.md new file mode 100644 index 00000000000..0509d2ee79d --- /dev/null +++ b/docs-devsite/firestore_.arraycontainsall.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ArrayContainsAll class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ArrayContainsAll extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(array, values)](./firestore_.arraycontainsall.md#arraycontainsallconstructor) | | (BETA) Constructs a new instance of the ArrayContainsAll class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_.arraycontainsall.md#arraycontainsallfilterable) | | true | (BETA) | + +## ArrayContainsAll.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ArrayContainsAll` class + +Signature: + +```typescript +constructor(array: Constant, values: Constant[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_.constant.md#constant_class) | | +| values | [Constant](./firestore_.constant.md#constant_class)\[\] | | + +## ArrayContainsAll.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_.arraycontainsany.md b/docs-devsite/firestore_.arraycontainsany.md new file mode 100644 index 00000000000..0736b7b198b --- /dev/null +++ b/docs-devsite/firestore_.arraycontainsany.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ArrayContainsAny class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ArrayContainsAny extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(array, values)](./firestore_.arraycontainsany.md#arraycontainsanyconstructor) | | (BETA) Constructs a new instance of the ArrayContainsAny class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_.arraycontainsany.md#arraycontainsanyfilterable) | | true | (BETA) | + +## ArrayContainsAny.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ArrayContainsAny` class + +Signature: + +```typescript +constructor(array: Constant, values: Constant[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_.constant.md#constant_class) | | +| values | [Constant](./firestore_.constant.md#constant_class)\[\] | | + +## ArrayContainsAny.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_.arrayelement.md b/docs-devsite/firestore_.arrayelement.md new file mode 100644 index 00000000000..e8dcd7e04b7 --- /dev/null +++ b/docs-devsite/firestore_.arrayelement.md @@ -0,0 +1,41 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ArrayElement class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ArrayElement extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)()](./firestore_.arrayelement.md#arrayelementconstructor) | | (BETA) Constructs a new instance of the ArrayElement class | + +## ArrayElement.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ArrayElement` class + +Signature: + +```typescript +constructor(); +``` diff --git a/docs-devsite/firestore_.arraylength.md b/docs-devsite/firestore_.arraylength.md new file mode 100644 index 00000000000..88b3b3fa624 --- /dev/null +++ b/docs-devsite/firestore_.arraylength.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ArrayLength class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ArrayLength extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(array)](./firestore_.arraylength.md#arraylengthconstructor) | | (BETA) Constructs a new instance of the ArrayLength class | + +## ArrayLength.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ArrayLength` class + +Signature: + +```typescript +constructor(array: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.arrayreverse.md b/docs-devsite/firestore_.arrayreverse.md new file mode 100644 index 00000000000..bc7e06c72a7 --- /dev/null +++ b/docs-devsite/firestore_.arrayreverse.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ArrayReverse class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ArrayReverse extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(array)](./firestore_.arrayreverse.md#arrayreverseconstructor) | | (BETA) Constructs a new instance of the ArrayReverse class | + +## ArrayReverse.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ArrayReverse` class + +Signature: + +```typescript +constructor(array: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.avg.md b/docs-devsite/firestore_.avg.md new file mode 100644 index 00000000000..e93ade31d62 --- /dev/null +++ b/docs-devsite/firestore_.avg.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Avg class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Avg extends FirestoreFunction implements Accumulator +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [Accumulator](./firestore_.accumulator.md#accumulator_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value, distinct)](./firestore_.avg.md#avgconstructor) | | (BETA) Constructs a new instance of the Avg class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [accumulator](./firestore_.avg.md#avgaccumulator) | | true | (BETA) | + +## Avg.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Avg` class + +Signature: + +```typescript +constructor(value: Constant, distinct: boolean); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_.constant.md#constant_class) | | +| distinct | boolean | | + +## Avg.accumulator + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +accumulator: true; +``` diff --git a/docs-devsite/firestore_.bytelength.md b/docs-devsite/firestore_.bytelength.md new file mode 100644 index 00000000000..7b7055b2951 --- /dev/null +++ b/docs-devsite/firestore_.bytelength.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ByteLength class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ByteLength extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value)](./firestore_.bytelength.md#bytelengthconstructor) | | (BETA) Constructs a new instance of the ByteLength class | + +## ByteLength.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ByteLength` class + +Signature: + +```typescript +constructor(value: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.charlength.md b/docs-devsite/firestore_.charlength.md new file mode 100644 index 00000000000..cb978a4675f --- /dev/null +++ b/docs-devsite/firestore_.charlength.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# CharLength class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class CharLength extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value)](./firestore_.charlength.md#charlengthconstructor) | | (BETA) Constructs a new instance of the CharLength class | + +## CharLength.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `CharLength` class + +Signature: + +```typescript +constructor(value: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.collectiongroupsource.md b/docs-devsite/firestore_.collectiongroupsource.md new file mode 100644 index 00000000000..58d0d7e9b25 --- /dev/null +++ b/docs-devsite/firestore_.collectiongroupsource.md @@ -0,0 +1,64 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# CollectionGroupSource class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class CollectionGroupSource implements Stage +``` +Implements: [Stage](./firestore_.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(collectionId)](./firestore_.collectiongroupsource.md#collectiongroupsourceconstructor) | | (BETA) Constructs a new instance of the CollectionGroupSource class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_.collectiongroupsource.md#collectiongroupsourcename) | | string | (BETA) | + +## CollectionGroupSource.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `CollectionGroupSource` class + +Signature: + +```typescript +constructor(collectionId: string); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| collectionId | string | | + +## CollectionGroupSource.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_.collectionsource.md b/docs-devsite/firestore_.collectionsource.md new file mode 100644 index 00000000000..d5b485ea610 --- /dev/null +++ b/docs-devsite/firestore_.collectionsource.md @@ -0,0 +1,64 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# CollectionSource class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class CollectionSource implements Stage +``` +Implements: [Stage](./firestore_.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(collectionPath)](./firestore_.collectionsource.md#collectionsourceconstructor) | | (BETA) Constructs a new instance of the CollectionSource class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_.collectionsource.md#collectionsourcename) | | string | (BETA) | + +## CollectionSource.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `CollectionSource` class + +Signature: + +```typescript +constructor(collectionPath: string); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| collectionPath | string | | + +## CollectionSource.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_.constant.md b/docs-devsite/firestore_.constant.md new file mode 100644 index 00000000000..42463dbc01d --- /dev/null +++ b/docs-devsite/firestore_.constant.md @@ -0,0 +1,3504 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Constant class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Represents a constant value that can be used in a Firestore pipeline expression. + +You can create a `Constant` instance using the static method: + +```typescript +// Create a Constant instance for the number 10 +const ten = Constant.of(10); + +// Create a Constant instance for the string "hello" +const hello = Constant.of("hello"); + +``` + +Signature: + +```typescript +export declare class Constant +``` + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [exprType](./firestore_.constant.md#constantexprtype) | | [ExprType](./firestore_.md#exprtype) | (BETA) | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [add(other)](./firestore_.constant.md#constantadd) | | (BETA) Creates an expression that adds this expression to another expression. +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +Field.of("quantity").add(Field.of("reserve")); + +``` + | +| [add(other)](./firestore_.constant.md#constantadd) | | (BETA) Creates an expression that adds this expression to a constant value. +```typescript +// Add 5 to the value of the 'age' field +Field.of("age").add(5); + +``` + | +| [arrayConcat(arrays)](./firestore_.constant.md#constantarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. +```typescript +// Combine the 'items' array with another array field. +Field.of("items").arrayConcat(Field.of("otherItems")); + +``` + | +| [arrayConcat(arrays)](./firestore_.constant.md#constantarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. +```typescript +// Combine the 'tags' array with a new array and an array field +Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + +``` + | +| [arrayContains(element)](./firestore_.constant.md#constantarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific element. +```typescript +// Check if the 'sizes' array contains the value from the 'selectedSize' field +Field.of("sizes").arrayContains(Field.of("selectedSize")); + +``` + | +| [arrayContains(element)](./firestore_.constant.md#constantarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific value. +```typescript +// Check if the 'colors' array contains "red" +Field.of("colors").arrayContains("red"); + +``` + | +| [arrayContainsAll(values)](./firestore_.constant.md#constantarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. +```typescript +// Check if the 'tags' array contains both "news" and "sports" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + | +| [arrayContainsAll(values)](./firestore_.constant.md#constantarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + | +| [arrayContainsAny(values)](./firestore_.constant.md#constantarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "cate2" +Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + +``` + | +| [arrayContainsAny(values)](./firestore_.constant.md#constantarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + +``` + | +| [arrayLength()](./firestore_.constant.md#constantarraylength) | | (BETA) Creates an expression that calculates the length of an array. +```typescript +// Get the number of items in the 'cart' array +Field.of("cart").arrayLength(); + +``` + A new Expr representing the length of the array. | +| [as(name)](./firestore_.constant.md#constantas) | | (BETA) Assigns an alias to this expression.Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. +```typescript +// Calculate the total price and assign it the alias "totalPrice" and add it to the output. +firestore.pipeline().collection("items") +.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + +``` + | +| [ascending()](./firestore_.constant.md#constantascending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. +```typescript +// Sort documents by the 'name' field in ascending order +pipeline().collection("users") +.sort(Field.of("name").ascending()); + +``` + A new Ordering for ascending sorting. | +| [avg()](./firestore_.constant.md#constantavg) | | (BETA) Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. +```typescript +// Calculate the average age of users +Field.of("age").avg().as("averageAge"); + +``` + A new Accumulator representing the 'avg' aggregation. | +| [byteLength()](./firestore_.constant.md#constantbytelength) | | (BETA) Creates an expression that calculates the length of this string expression in bytes. +```typescript +// Calculate the length of the 'myString' field in bytes. +Field.of("myString").byteLength(); + +``` + A new representing the length of the string in bytes. | +| [charLength()](./firestore_.constant.md#constantcharlength) | | (BETA) Creates an expression that calculates the character length of a string in UTF-8. +```typescript +// Get the character length of the 'name' field in its UTF-8 form. +Field.of("name").charLength(); + +``` + A new Expr representing the length of the string. | +| [cosineDistance(other)](./firestore_.constant.md#constantcosinedistance) | | (BETA) Calculates the cosine distance between two vectors. +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +Field.of("userVector").cosineDistance(Field.of("itemVector")); + +``` + | +| [cosineDistance(other)](./firestore_.constant.md#constantcosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + +``` + | +| [cosineDistance(other)](./firestore_.constant.md#constantcosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance([37.7749, -122.4194]); + +``` + | +| [count()](./firestore_.constant.md#constantcount) | | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. +```typescript +// Count the total number of products +Field.of("productId").count().as("totalProducts"); + +``` + A new Accumulator representing the 'count' aggregation. | +| [descending()](./firestore_.constant.md#constantdescending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") +.sort(Field.of("createdAt").descending()); + +``` + A new Ordering for descending sorting. | +| [divide(other)](./firestore_.constant.md#constantdivide) | | (BETA) Creates an expression that divides this expression by another expression. +```typescript +// Divide the 'total' field by the 'count' field +Field.of("total").divide(Field.of("count")); + +``` + | +| [divide(other)](./firestore_.constant.md#constantdivide) | | (BETA) Creates an expression that divides this expression by a constant value. +```typescript +// Divide the 'value' field by 10 +Field.of("value").divide(10); + +``` + | +| [dotProduct(other)](./firestore_.constant.md#constantdotproduct) | | (BETA) Calculates the dot product between two vectors. +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct([0.5, 0.8, 0.2]); + +``` + | +| [dotProduct(other)](./firestore_.constant.md#constantdotproduct) | | (BETA) Calculates the dot product between two vectors. +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + +``` + | +| [dotProduct(other)](./firestore_.constant.md#constantdotproduct) | | (BETA) | +| [endsWith(suffix)](./firestore_.constant.md#constantendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix. +```typescript +// Check if the 'filename' field ends with ".txt" +Field.of("filename").endsWith(".txt"); + +``` + | +| [endsWith(suffix)](./firestore_.constant.md#constantendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix (represented as an expression). +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +Field.of("url").endsWith(Field.of("extension")); + +``` + | +| [eq(other)](./firestore_.constant.md#constanteq) | | (BETA) Creates an expression that checks if this expression is equal to another expression. +```typescript +// Check if the 'age' field is equal to 21 +Field.of("age").eq(21); + +``` + | +| [eq(other)](./firestore_.constant.md#constanteq) | | (BETA) Creates an expression that checks if this expression is equal to a constant value. +```typescript +// Check if the 'city' field is equal to "London" +Field.of("city").eq("London"); + +``` + | +| [euclideanDistance(other)](./firestore_.constant.md#constanteuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance([37.7749, -122.4194]); + +``` + | +| [euclideanDistance(other)](./firestore_.constant.md#constanteuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + +``` + | +| [euclideanDistance(other)](./firestore_.constant.md#constanteuclideandistance) | | (BETA) | +| [exists()](./firestore_.constant.md#constantexists) | | (BETA) Creates an expression that checks if a field exists in the document. +```typescript +// Check if the document has a field named "phoneNumber" +Field.of("phoneNumber").exists(); + +``` + A new Expr representing the 'exists' check. | +| [gt(other)](./firestore_.constant.md#constantgt) | | (BETA) Creates an expression that checks if this expression is greater than another expression. +```typescript +// Check if the 'age' field is greater than the 'limit' field +Field.of("age").gt(Field.of("limit")); + +``` + | +| [gt(other)](./firestore_.constant.md#constantgt) | | (BETA) Creates an expression that checks if this expression is greater than a constant value. +```typescript +// Check if the 'price' field is greater than 100 +Field.of("price").gt(100); + +``` + | +| [gte(other)](./firestore_.constant.md#constantgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to another expression. +```typescript +// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 +Field.of("quantity").gte(Field.of('requirement').add(1)); + +``` + | +| [gte(other)](./firestore_.constant.md#constantgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to a constant value. +```typescript +// Check if the 'score' field is greater than or equal to 80 +Field.of("score").gte(80); + +``` + | +| [in(others)](./firestore_.constant.md#constantin) | | (BETA) Creates an expression that checks if this expression is equal to any of the provided values or expressions. +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +Field.of("category").in("Electronics", Field.of("primaryType")); + +``` + | +| [in(others)](./firestore_.constant.md#constantin) | | (BETA) | +| [isNaN()](./firestore_.constant.md#constantisnan) | | (BETA) Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). +```typescript +// Check if the result of a calculation is NaN +Field.of("value").divide(0).isNaN(); + +``` + A new Expr representing the 'isNaN' check. | +| [like(pattern)](./firestore_.constant.md#constantlike) | | (BETA) Creates an expression that performs a case-sensitive string comparison. +```typescript +// Check if the 'title' field contains the word "guide" (case-sensitive) +Field.of("title").like("%guide%"); + +``` + | +| [like(pattern)](./firestore_.constant.md#constantlike) | | (BETA) | +| [logicalMax(other)](./firestore_.constant.md#constantlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMax(Function.currentTimestamp()); + +``` + | +| [logicalMax(other)](./firestore_.constant.md#constantlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'value' field and 10. +Field.of("value").logicalMax(10); + +``` + | +| [logicalMin(other)](./firestore_.constant.md#constantlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMin(Function.currentTimestamp()); + +``` + | +| [logicalMin(other)](./firestore_.constant.md#constantlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'value' field and 10. +Field.of("value").logicalMin(10); + +``` + | +| [lt(other)](./firestore_.constant.md#constantlt) | | (BETA) Creates an expression that checks if this expression is less than another expression. +```typescript +// Check if the 'age' field is less than 'limit' +Field.of("age").lt(Field.of('limit')); + +``` + | +| [lt(other)](./firestore_.constant.md#constantlt) | | (BETA) Creates an expression that checks if this expression is less than a constant value. +```typescript +// Check if the 'price' field is less than 50 +Field.of("price").lt(50); + +``` + | +| [lte(other)](./firestore_.constant.md#constantlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to another expression. +```typescript +// Check if the 'quantity' field is less than or equal to 20 +Field.of("quantity").lte(Constant.of(20)); + +``` + | +| [lte(other)](./firestore_.constant.md#constantlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to a constant value. +```typescript +// Check if the 'score' field is less than or equal to 70 +Field.of("score").lte(70); + +``` + | +| [mapGet(subfield)](./firestore_.constant.md#constantmapget) | | (BETA) Accesses a value from a map (object) field using the provided key. +```typescript +// Get the 'city' value from the 'address' map field +Field.of("address").mapGet("city"); + +``` + | +| [max()](./firestore_.constant.md#constantmax) | | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. +```typescript +// Find the highest score in a leaderboard +Field.of("score").max().as("highestScore"); + +``` + A new Accumulator representing the 'max' aggregation. | +| [min()](./firestore_.constant.md#constantmin) | | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. +```typescript +// Find the lowest price of all products +Field.of("price").min().as("lowestPrice"); + +``` + A new Accumulator representing the 'min' aggregation. | +| [mod(other)](./firestore_.constant.md#constantmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. +```typescript +// Calculate the remainder of dividing the 'value' field by the 'divisor' field +Field.of("value").mod(Field.of("divisor")); + +``` + | +| [mod(other)](./firestore_.constant.md#constantmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. +```typescript +// Calculate the remainder of dividing the 'value' field by 10 +Field.of("value").mod(10); + +``` + | +| [multiply(other)](./firestore_.constant.md#constantmultiply) | | (BETA) Creates an expression that multiplies this expression by another expression. +```typescript +// Multiply the 'quantity' field by the 'price' field +Field.of("quantity").multiply(Field.of("price")); + +``` + | +| [multiply(other)](./firestore_.constant.md#constantmultiply) | | (BETA) Creates an expression that multiplies this expression by a constant value. +```typescript +// Multiply the 'value' field by 2 +Field.of("value").multiply(2); + +``` + | +| [neq(other)](./firestore_.constant.md#constantneq) | | (BETA) Creates an expression that checks if this expression is not equal to another expression. +```typescript +// Check if the 'status' field is not equal to "completed" +Field.of("status").neq("completed"); + +``` + | +| [neq(other)](./firestore_.constant.md#constantneq) | | (BETA) Creates an expression that checks if this expression is not equal to a constant value. +```typescript +// Check if the 'country' field is not equal to "USA" +Field.of("country").neq("USA"); + +``` + | +| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a number value. | +| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a DocumentReference value. | +| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for an array value. | +| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a map value. | +| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a VectorValue value. | +| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a string value. | +| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a boolean value. | +| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a null value. | +| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for an undefined value. | +| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a GeoPoint value. | +| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a Timestamp value. | +| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a Date value. | +| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a Uint8Array value. | +| [regexContains(pattern)](./firestore_.constant.md#constantregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +Field.of("description").regexContains("(?i)example"); + +``` + | +| [regexContains(pattern)](./firestore_.constant.md#constantregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains the regular expression stored in field 'regex' +Field.of("description").regexContains(Field.of("regex")); + +``` + | +| [regexMatch(pattern)](./firestore_.constant.md#constantregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. +```typescript +// Check if the 'email' field matches a valid email pattern +Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + | +| [regexMatch(pattern)](./firestore_.constant.md#constantregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. +```typescript +// Check if the 'email' field matches a regular expression stored in field 'regex' +Field.of("email").regexMatch(Field.of("regex")); + +``` + | +| [replaceAll(find, replace)](./firestore_.constant.md#constantreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring. +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field +Field.of("message").replaceAll("hello", "hi"); + +``` + | +| [replaceAll(find, replace)](./firestore_.constant.md#constantreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + +``` + | +| [replaceFirst(find, replace)](./firestore_.constant.md#constantreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field +Field.of("message").replaceFirst("hello", "hi"); + +``` + | +| [replaceFirst(find, replace)](./firestore_.constant.md#constantreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + +``` + | +| [reverse()](./firestore_.constant.md#constantreverse) | | (BETA) Creates an expression that reverses this string expression. +```typescript +// Reverse the value of the 'myString' field. +Field.of("myString").reverse(); + +``` + A new representing the reversed string. | +| [startsWith(prefix)](./firestore_.constant.md#constantstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix. +```typescript +// Check if the 'name' field starts with "Mr." +Field.of("name").startsWith("Mr."); + +``` + | +| [startsWith(prefix)](./firestore_.constant.md#constantstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix (represented as an expression). +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +Field.of("fullName").startsWith(Field.of("firstName")); + +``` + | +| [strConcat(elements)](./firestore_.constant.md#constantstrconcat) | | (BETA) Creates an expression that concatenates string expressions together. +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + +``` + | +| [strContains(substring)](./firestore_.constant.md#constantstrcontains) | | (BETA) Creates an expression that checks if a string contains a specified substring. +```typescript +// Check if the 'description' field contains "example". +Field.of("description").strContains("example"); + +``` + | +| [strContains(expr)](./firestore_.constant.md#constantstrcontains) | | (BETA) Creates an expression that checks if a string contains the string represented by another expression. +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +Field.of("description").strContains(Field.of("keyword")); + +``` + | +| [subtract(other)](./firestore_.constant.md#constantsubtract) | | (BETA) Creates an expression that subtracts another expression from this expression. +```typescript +// Subtract the 'discount' field from the 'price' field +Field.of("price").subtract(Field.of("discount")); + +``` + | +| [subtract(other)](./firestore_.constant.md#constantsubtract) | | (BETA) Creates an expression that subtracts a constant value from this expression. +```typescript +// Subtract 20 from the value of the 'total' field +Field.of("total").subtract(20); + +``` + | +| [sum()](./firestore_.constant.md#constantsum) | | (BETA) Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. +```typescript +// Calculate the total revenue from a set of orders +Field.of("orderAmount").sum().as("totalRevenue"); + +``` + A new Accumulator representing the 'sum' aggregation. | +| [timestampAdd(unit, amount)](./firestore_.constant.md#constanttimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampAdd(unit, amount)](./firestore_.constant.md#constanttimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. +```typescript +// Add 1 day to the 'timestamp' field. +Field.of("timestamp").timestampAdd("day", 1); + +``` + | +| [timestampSub(unit, amount)](./firestore_.constant.md#constanttimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampSub(unit, amount)](./firestore_.constant.md#constanttimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. +```typescript +// Subtract 1 day from the 'timestamp' field. +Field.of("timestamp").timestampSub("day", 1); + +``` + | +| [timestampToUnixMicros()](./firestore_.constant.md#constanttimestamptounixmicros) | | (BETA) Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +Field.of("timestamp").timestampToUnixMicros(); + +``` + A new representing the number of microseconds since epoch. | +| [timestampToUnixMillis()](./firestore_.constant.md#constanttimestamptounixmillis) | | (BETA) Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +Field.of("timestamp").timestampToUnixMillis(); + +``` + A new representing the number of milliseconds since epoch. | +| [timestampToUnixSeconds()](./firestore_.constant.md#constanttimestamptounixseconds) | | (BETA) Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to seconds since epoch. +Field.of("timestamp").timestampToUnixSeconds(); + +``` + A new representing the number of seconds since epoch. | +| [toLower()](./firestore_.constant.md#constanttolower) | | (BETA) Creates an expression that converts a string to lowercase. +```typescript +// Convert the 'name' field to lowercase +Field.of("name").toLower(); + +``` + A new Expr representing the lowercase string. | +| [toUpper()](./firestore_.constant.md#constanttoupper) | | (BETA) Creates an expression that converts a string to uppercase. +```typescript +// Convert the 'title' field to uppercase +Field.of("title").toUpper(); + +``` + A new Expr representing the uppercase string. | +| [trim()](./firestore_.constant.md#constanttrim) | | (BETA) Creates an expression that removes leading and trailing whitespace from a string. +```typescript +// Trim whitespace from the 'userInput' field +Field.of("userInput").trim(); + +``` + A new Expr representing the trimmed string. | +| [unixMicrosToTimestamp()](./firestore_.constant.md#constantunixmicrostotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +Field.of("microseconds").unixMicrosToTimestamp(); + +``` + A new representing the timestamp. | +| [unixMillisToTimestamp()](./firestore_.constant.md#constantunixmillistotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +Field.of("milliseconds").unixMillisToTimestamp(); + +``` + A new representing the timestamp. | +| [unixSecondsToTimestamp()](./firestore_.constant.md#constantunixsecondstotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'seconds' field as seconds since epoch. +Field.of("seconds").unixSecondsToTimestamp(); + +``` + A new representing the timestamp. | +| [vector(value)](./firestore_.constant.md#constantvector) | static | (BETA) Creates a Constant instance for a VectorValue value. +```typescript +// Create a Constant instance for a vector value +const vectorConstant = Constant.ofVector([1, 2, 3]); + +``` + | +| [vectorLength()](./firestore_.constant.md#constantvectorlength) | | (BETA) Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. +```typescript +// Get the vector length (dimension) of the field 'embedding'. +Field.of("embedding").vectorLength(); + +``` + A new representing the length of the vector. | + +## Constant.exprType + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +exprType: ExprType; +``` + +## Constant.add() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds this expression to another expression. + +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +Field.of("quantity").add(Field.of("reserve")); + +``` + +Signature: + +```typescript +add(other: Constant): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to add to this expression. A new Expr representing the addition operation. | + +Returns: + +[Add](./firestore_.add.md#add_class) + +## Constant.add() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds this expression to a constant value. + +```typescript +// Add 5 to the value of the 'age' field +Field.of("age").add(5); + +``` + +Signature: + +```typescript +add(other: any): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to add. A new Expr representing the addition operation. | + +Returns: + +[Add](./firestore_.add.md#add_class) + +## Constant.arrayConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with one or more other arrays. + +```typescript +// Combine the 'items' array with another array field. +Field.of("items").arrayConcat(Field.of("otherItems")); + +``` + +Signature: + +```typescript +arrayConcat(arrays: Constant[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrays | [Constant](./firestore_.constant.md#constant_class)\[\] | The array expressions to concatenate. A new Expr representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) + +## Constant.arrayConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with one or more other arrays. + +```typescript +// Combine the 'tags' array with a new array and an array field +Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + +``` + +Signature: + +```typescript +arrayConcat(arrays: any[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrays | any\[\] | The array expressions or values to concatenate. A new Expr representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) + +## Constant.arrayContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains a specific element. + +```typescript +// Check if the 'sizes' array contains the value from the 'selectedSize' field +Field.of("sizes").arrayContains(Field.of("selectedSize")); + +``` + +Signature: + +```typescript +arrayContains(element: Constant): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | [Constant](./firestore_.constant.md#constant_class) | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) + +## Constant.arrayContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains a specific value. + +```typescript +// Check if the 'colors' array contains "red" +Field.of("colors").arrayContains("red"); + +``` + +Signature: + +```typescript +arrayContains(element: any): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | any | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) + +## Constant.arrayContainsAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both "news" and "sports" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + +Signature: + +```typescript +arrayContainsAll(...values: Constant[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) + +## Constant.arrayContainsAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + +Signature: + +```typescript +arrayContainsAll(...values: any[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) + +## Constant.arrayContainsAny() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains any of the specified elements. + +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "cate2" +Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + +``` + +Signature: + +```typescript +arrayContainsAny(...values: Constant[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) + +## Constant.arrayContainsAny() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains any of the specified elements. + +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + +``` + +Signature: + +```typescript +arrayContainsAny(...values: any[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) + +## Constant.arrayLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of an array. + +```typescript +// Get the number of items in the 'cart' array +Field.of("cart").arrayLength(); + +``` + A new `Expr` representing the length of the array. + +Signature: + +```typescript +arrayLength(): ArrayLength; +``` +Returns: + +[ArrayLength](./firestore_.arraylength.md#arraylength_class) + +## Constant.as() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Assigns an alias to this expression. + +Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. + +```typescript +// Calculate the total price and assign it the alias "totalPrice" and add it to the output. +firestore.pipeline().collection("items") +.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + +``` + +Signature: + +```typescript +as(name: string): ExprWithAlias; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | The alias to assign to this expression. A new [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) that wraps this expression and associates it with the provided alias. | + +Returns: + +[ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class)<this> + +## Constant.ascending() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. + +```typescript +// Sort documents by the 'name' field in ascending order +pipeline().collection("users") +.sort(Field.of("name").ascending()); + +``` + A new `Ordering` for ascending sorting. + +Signature: + +```typescript +ascending(): Ordering; +``` +Returns: + +[Ordering](./firestore_.ordering.md#ordering_class) + +## Constant.avg() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. + +```typescript +// Calculate the average age of users +Field.of("age").avg().as("averageAge"); + +``` + A new `Accumulator` representing the 'avg' aggregation. + +Signature: + +```typescript +avg(): Avg; +``` +Returns: + +[Avg](./firestore_.avg.md#avg_class) + +## Constant.byteLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of this string expression in bytes. + +```typescript +// Calculate the length of the 'myString' field in bytes. +Field.of("myString").byteLength(); + +``` + A new representing the length of the string in bytes. + +Signature: + +```typescript +byteLength(): ByteLength; +``` +Returns: + +[ByteLength](./firestore_.bytelength.md#bytelength_class) + +## Constant.charLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the character length of a string in UTF-8. + +```typescript +// Get the character length of the 'name' field in its UTF-8 form. +Field.of("name").charLength(); + +``` + A new `Expr` representing the length of the string. + +Signature: + +```typescript +charLength(): CharLength; +``` +Returns: + +[CharLength](./firestore_.charlength.md#charlength_class) + +## Constant.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the cosine distance between two vectors. + +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +Field.of("userVector").cosineDistance(Field.of("itemVector")); + +``` + +Signature: + +```typescript +cosineDistance(other: Constant): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new Expr representing the cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) + +## Constant.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vectors. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +cosineDistance(other: VectorValue): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) + +## Constant.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vectors. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance([37.7749, -122.4194]); + +``` + +Signature: + +```typescript +cosineDistance(other: number[]): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | The other vector (as an array of numbers) to compare against. A new Expr representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) + +## Constant.count() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. + +```typescript +// Count the total number of products +Field.of("productId").count().as("totalProducts"); + +``` + A new `Accumulator` representing the 'count' aggregation. + +Signature: + +```typescript +count(): Count; +``` +Returns: + +[Count](./firestore_.count.md#count_class) + +## Constant.descending() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. + +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") +.sort(Field.of("createdAt").descending()); + +``` + A new `Ordering` for descending sorting. + +Signature: + +```typescript +descending(): Ordering; +``` +Returns: + +[Ordering](./firestore_.ordering.md#ordering_class) + +## Constant.divide() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides this expression by another expression. + +```typescript +// Divide the 'total' field by the 'count' field +Field.of("total").divide(Field.of("count")); + +``` + +Signature: + +```typescript +divide(other: Constant): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new Expr representing the division operation. | + +Returns: + +[Divide](./firestore_.divide.md#divide_class) + +## Constant.divide() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides this expression by a constant value. + +```typescript +// Divide the 'value' field by 10 +Field.of("value").divide(10); + +``` + +Signature: + +```typescript +divide(other: any): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to divide by. A new Expr representing the division operation. | + +Returns: + +[Divide](./firestore_.divide.md#divide_class) + +## Constant.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vectors. + +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct([0.5, 0.8, 0.2]); + +``` + +Signature: + +```typescript +dotProduct(other: Constant): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_.dotproduct.md#dotproduct_class) + +## Constant.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vectors. + +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + +``` + +Signature: + +```typescript +dotProduct(other: VectorValue): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_.dotproduct.md#dotproduct_class) + +## Constant.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +dotProduct(other: number[]): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | | + +Returns: + +[DotProduct](./firestore_.dotproduct.md#dotproduct_class) + +## Constant.endsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string ends with a given postfix. + +```typescript +// Check if the 'filename' field ends with ".txt" +Field.of("filename").endsWith(".txt"); + +``` + +Signature: + +```typescript +endsWith(suffix: string): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| suffix | string | The postfix to check for. A new Expr representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_.endswith.md#endswith_class) + +## Constant.endsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string ends with a given postfix (represented as an expression). + +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +Field.of("url").endsWith(Field.of("extension")); + +``` + +Signature: + +```typescript +endsWith(suffix: Constant): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| suffix | [Constant](./firestore_.constant.md#constant_class) | The postfix expression to check for. A new Expr representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_.endswith.md#endswith_class) + +## Constant.eq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to another expression. + +```typescript +// Check if the 'age' field is equal to 21 +Field.of("age").eq(21); + +``` + +Signature: + +```typescript +eq(other: Constant): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for equality. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_.eq.md#eq_class) + +## Constant.eq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to a constant value. + +```typescript +// Check if the 'city' field is equal to "London" +Field.of("city").eq("London"); + +``` + +Signature: + +```typescript +eq(other: any): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for equality. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_.eq.md#eq_class) + +## Constant.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vectors. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance([37.7749, -122.4194]); + +``` + +Signature: + +```typescript +euclideanDistance(other: Constant): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) + +## Constant.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vectors. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +euclideanDistance(other: VectorValue): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) + +## Constant.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +euclideanDistance(other: number[]): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | | + +Returns: + +[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) + +## Constant.exists() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field exists in the document. + +```typescript +// Check if the document has a field named "phoneNumber" +Field.of("phoneNumber").exists(); + +``` + A new `Expr` representing the 'exists' check. + +Signature: + +```typescript +exists(): Exists; +``` +Returns: + +[Exists](./firestore_.exists.md#exists_class) + +## Constant.gt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than another expression. + +```typescript +// Check if the 'age' field is greater than the 'limit' field +Field.of("age").gt(Field.of("limit")); + +``` + +Signature: + +```typescript +gt(other: Constant): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for greater than. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_.gt.md#gt_class) + +## Constant.gt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than a constant value. + +```typescript +// Check if the 'price' field is greater than 100 +Field.of("price").gt(100); + +``` + +Signature: + +```typescript +gt(other: any): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for greater than. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_.gt.md#gt_class) + +## Constant.gte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than or equal to another expression. + +```typescript +// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 +Field.of("quantity").gte(Field.of('requirement').add(1)); + +``` + +Signature: + +```typescript +gte(other: Constant): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_.gte.md#gte_class) + +## Constant.gte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than or equal to a constant value. + +```typescript +// Check if the 'score' field is greater than or equal to 80 +Field.of("score").gte(80); + +``` + +Signature: + +```typescript +gte(other: any): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_.gte.md#gte_class) + +## Constant.in() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to any of the provided values or expressions. + +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +Field.of("category").in("Electronics", Field.of("primaryType")); + +``` + +Signature: + +```typescript +in(...others: Constant[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| others | [Constant](./firestore_.constant.md#constant_class)\[\] | The values or expressions to check against. A new Expr representing the 'IN' comparison. | + +Returns: + +[In](./firestore_.in.md#in_class) + +## Constant.in() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +in(...others: any[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| others | any\[\] | | + +Returns: + +[In](./firestore_.in.md#in_class) + +## Constant.isNaN() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). + +```typescript +// Check if the result of a calculation is NaN +Field.of("value").divide(0).isNaN(); + +``` + A new `Expr` representing the 'isNaN' check. + +Signature: + +```typescript +isNaN(): IsNan; +``` +Returns: + +[IsNan](./firestore_.isnan.md#isnan_class) + +## Constant.like() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that performs a case-sensitive string comparison. + +```typescript +// Check if the 'title' field contains the word "guide" (case-sensitive) +Field.of("title").like("%guide%"); + +``` + +Signature: + +```typescript +like(pattern: string): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new Expr representing the 'like' comparison. | + +Returns: + +[Like](./firestore_.like.md#like_class) + +## Constant.like() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +like(pattern: Constant): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_.constant.md#constant_class) | | + +Returns: + +[Like](./firestore_.like.md#like_class) + +## Constant.logicalMax() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMax(Function.currentTimestamp()); + +``` + +Signature: + +```typescript +logicalMax(other: Constant): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare with. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) + +## Constant.logicalMax() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'value' field and 10. +Field.of("value").logicalMax(10); + +``` + +Signature: + +```typescript +logicalMax(other: any): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare with. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) + +## Constant.logicalMin() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMin(Function.currentTimestamp()); + +``` + +Signature: + +```typescript +logicalMin(other: Constant): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare with. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) + +## Constant.logicalMin() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'value' field and 10. +Field.of("value").logicalMin(10); + +``` + +Signature: + +```typescript +logicalMin(other: any): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare with. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) + +## Constant.lt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than another expression. + +```typescript +// Check if the 'age' field is less than 'limit' +Field.of("age").lt(Field.of('limit')); + +``` + +Signature: + +```typescript +lt(other: Constant): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for less than. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_.lt.md#lt_class) + +## Constant.lt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than a constant value. + +```typescript +// Check if the 'price' field is less than 50 +Field.of("price").lt(50); + +``` + +Signature: + +```typescript +lt(other: any): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for less than. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_.lt.md#lt_class) + +## Constant.lte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than or equal to another expression. + +```typescript +// Check if the 'quantity' field is less than or equal to 20 +Field.of("quantity").lte(Constant.of(20)); + +``` + +Signature: + +```typescript +lte(other: Constant): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_.lte.md#lte_class) + +## Constant.lte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than or equal to a constant value. + +```typescript +// Check if the 'score' field is less than or equal to 70 +Field.of("score").lte(70); + +``` + +Signature: + +```typescript +lte(other: any): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_.lte.md#lte_class) + +## Constant.mapGet() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Accesses a value from a map (object) field using the provided key. + +```typescript +// Get the 'city' value from the 'address' map field +Field.of("address").mapGet("city"); + +``` + +Signature: + +```typescript +mapGet(subfield: string): MapGet; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| subfield | string | The key to access in the map. A new Expr representing the value associated with the given key in the map. | + +Returns: + +[MapGet](./firestore_.mapget.md#mapget_class) + +## Constant.max() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that finds the maximum value of a field across multiple stage inputs. + +```typescript +// Find the highest score in a leaderboard +Field.of("score").max().as("highestScore"); + +``` + A new `Accumulator` representing the 'max' aggregation. + +Signature: + +```typescript +max(): Max; +``` +Returns: + +[Max](./firestore_.max.md#max_class) + +## Constant.min() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that finds the minimum value of a field across multiple stage inputs. + +```typescript +// Find the lowest price of all products +Field.of("price").min().as("lowestPrice"); + +``` + A new `Accumulator` representing the 'min' aggregation. + +Signature: + +```typescript +min(): Min; +``` +Returns: + +[Min](./firestore_.min.md#min_class) + +## Constant.mod() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. + +```typescript +// Calculate the remainder of dividing the 'value' field by the 'divisor' field +Field.of("value").mod(Field.of("divisor")); + +``` + +Signature: + +```typescript +mod(other: Constant): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new Expr representing the modulo operation. | + +Returns: + +[Mod](./firestore_.mod.md#mod_class) + +## Constant.mod() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. + +```typescript +// Calculate the remainder of dividing the 'value' field by 10 +Field.of("value").mod(10); + +``` + +Signature: + +```typescript +mod(other: any): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to divide by. A new Expr representing the modulo operation. | + +Returns: + +[Mod](./firestore_.mod.md#mod_class) + +## Constant.multiply() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies this expression by another expression. + +```typescript +// Multiply the 'quantity' field by the 'price' field +Field.of("quantity").multiply(Field.of("price")); + +``` + +Signature: + +```typescript +multiply(other: Constant): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to multiply by. A new Expr representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_.multiply.md#multiply_class) + +## Constant.multiply() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies this expression by a constant value. + +```typescript +// Multiply the 'value' field by 2 +Field.of("value").multiply(2); + +``` + +Signature: + +```typescript +multiply(other: any): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to multiply by. A new Expr representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_.multiply.md#multiply_class) + +## Constant.neq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is not equal to another expression. + +```typescript +// Check if the 'status' field is not equal to "completed" +Field.of("status").neq("completed"); + +``` + +Signature: + +```typescript +neq(other: Constant): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for inequality. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_.neq.md#neq_class) + +## Constant.neq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is not equal to a constant value. + +```typescript +// Check if the 'country' field is not equal to "USA" +Field.of("country").neq("USA"); + +``` + +Signature: + +```typescript +neq(other: any): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for inequality. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_.neq.md#neq_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a number value. + +Signature: + +```typescript +static of(value: number): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | number | The number value. A new Constant instance. | + +Returns: + +[Constant](./firestore_.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a DocumentReference value. + +Signature: + +```typescript +static of(value: DocumentReference): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [DocumentReference](./firestore_.documentreference.md#documentreference_class) | The DocumentReference value. A new Constant instance. | + +Returns: + +[Constant](./firestore_.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for an array value. + +Signature: + +```typescript +static of(value: any[]): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | any\[\] | The array value. A new Constant instance. | + +Returns: + +[Constant](./firestore_.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a map value. + +Signature: + +```typescript +static of(value: Map): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | Map<string, any> | The map value. A new Constant instance. | + +Returns: + +[Constant](./firestore_.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a VectorValue value. + +Signature: + +```typescript +static of(value: VectorValue): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The VectorValue value. A new Constant instance. | + +Returns: + +[Constant](./firestore_.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a string value. + +Signature: + +```typescript +static of(value: string): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | string | The string value. A new Constant instance. | + +Returns: + +[Constant](./firestore_.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a boolean value. + +Signature: + +```typescript +static of(value: boolean): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | boolean | The boolean value. A new Constant instance. | + +Returns: + +[Constant](./firestore_.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a null value. + +Signature: + +```typescript +static of(value: null): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | null | The null value. A new Constant instance. | + +Returns: + +[Constant](./firestore_.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for an undefined value. + +Signature: + +```typescript +static of(value: undefined): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | undefined | The undefined value. A new Constant instance. | + +Returns: + +[Constant](./firestore_.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a GeoPoint value. + +Signature: + +```typescript +static of(value: GeoPoint): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [GeoPoint](./firestore_.geopoint.md#geopoint_class) | The GeoPoint value. A new Constant instance. | + +Returns: + +[Constant](./firestore_.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a Timestamp value. + +Signature: + +```typescript +static of(value: Timestamp): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Timestamp](./firestore_.timestamp.md#timestamp_class) | The Timestamp value. A new Constant instance. | + +Returns: + +[Constant](./firestore_.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a Date value. + +Signature: + +```typescript +static of(value: Date): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | Date | The Date value. A new Constant instance. | + +Returns: + +[Constant](./firestore_.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a Uint8Array value. + +Signature: + +```typescript +static of(value: Uint8Array): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | Uint8Array | The Uint8Array value. A new Constant instance. | + +Returns: + +[Constant](./firestore_.constant.md#constant_class) + +## Constant.regexContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +Field.of("description").regexContains("(?i)example"); + +``` + +Signature: + +```typescript +regexContains(pattern: string): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_.regexcontains.md#regexcontains_class) + +## Constant.regexContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains the regular expression stored in field 'regex' +Field.of("description").regexContains(Field.of("regex")); + +``` + +Signature: + +```typescript +regexContains(pattern: Constant): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_.regexcontains.md#regexcontains_class) + +## Constant.regexMatch() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a valid email pattern +Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + +Signature: + +```typescript +regexMatch(pattern: string): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The regular expression to use for the match. A new Expr representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) + +## Constant.regexMatch() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a regular expression stored in field 'regex' +Field.of("email").regexMatch(Field.of("regex")); + +``` + +Signature: + +```typescript +regexMatch(pattern: Constant): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the match. A new Expr representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) + +## Constant.replaceAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within this string expression with another substring. + +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field +Field.of("message").replaceAll("hello", "hi"); + +``` + +Signature: + +```typescript +replaceAll(find: string, replace: string): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | string | The substring to search for. | +| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_.replaceall.md#replaceall_class) + +## Constant.replaceAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + +``` + +Signature: + +```typescript +replaceAll(find: Constant, replace: Constant): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_.replaceall.md#replaceall_class) + +## Constant.replaceFirst() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. + +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field +Field.of("message").replaceFirst("hello", "hi"); + +``` + +Signature: + +```typescript +replaceFirst(find: string, replace: string): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | string | The substring to search for. | +| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) + +## Constant.replaceFirst() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + +``` + +Signature: + +```typescript +replaceFirst(find: Constant, replace: Constant): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) + +## Constant.reverse() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that reverses this string expression. + +```typescript +// Reverse the value of the 'myString' field. +Field.of("myString").reverse(); + +``` + A new representing the reversed string. + +Signature: + +```typescript +reverse(): Reverse; +``` +Returns: + +[Reverse](./firestore_.reverse.md#reverse_class) + +## Constant.startsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string starts with a given prefix. + +```typescript +// Check if the 'name' field starts with "Mr." +Field.of("name").startsWith("Mr."); + +``` + +Signature: + +```typescript +startsWith(prefix: string): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| prefix | string | The prefix to check for. A new Expr representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_.startswith.md#startswith_class) + +## Constant.startsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string starts with a given prefix (represented as an expression). + +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +Field.of("fullName").startsWith(Field.of("firstName")); + +``` + +Signature: + +```typescript +startsWith(prefix: Constant): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| prefix | [Constant](./firestore_.constant.md#constant_class) | The prefix expression to check for. A new Expr representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_.startswith.md#startswith_class) + +## Constant.strConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates string expressions together. + +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + +``` + +Signature: + +```typescript +strConcat(...elements: Array): StrConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| elements | Array<string \| [Constant](./firestore_.constant.md#constant_class)> | The expressions (typically strings) to concatenate. A new Expr representing the concatenated string. | + +Returns: + +[StrConcat](./firestore_.strconcat.md#strconcat_class) + +## Constant.strContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified substring. + +```typescript +// Check if the 'description' field contains "example". +Field.of("description").strContains("example"); + +``` + +Signature: + +```typescript +strContains(substring: string): StrContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| substring | string | The substring to search for. A new Expr representing the 'contains' comparison. | + +Returns: + +[StrContains](./firestore_.strcontains.md#strcontains_class) + +## Constant.strContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains the string represented by another expression. + +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +Field.of("description").strContains(Field.of("keyword")); + +``` + +Signature: + +```typescript +strContains(expr: Constant): StrContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. A new Expr representing the 'contains' comparison. | + +Returns: + +[StrContains](./firestore_.strcontains.md#strcontains_class) + +## Constant.subtract() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts another expression from this expression. + +```typescript +// Subtract the 'discount' field from the 'price' field +Field.of("price").subtract(Field.of("discount")); + +``` + +Signature: + +```typescript +subtract(other: Constant): Subtract; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to subtract from this expression. A new Expr representing the subtraction operation. | + +Returns: + +[Subtract](./firestore_.subtract.md#subtract_class) + +## Constant.subtract() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a constant value from this expression. + +```typescript +// Subtract 20 from the value of the 'total' field +Field.of("total").subtract(20); + +``` + +Signature: + +```typescript +subtract(other: any): Subtract; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to subtract. A new Expr representing the subtraction operation. | + +Returns: + +[Subtract](./firestore_.subtract.md#subtract_class) + +## Constant.sum() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. + +```typescript +// Calculate the total revenue from a set of orders +Field.of("orderAmount").sum().as("totalRevenue"); + +``` + A new `Accumulator` representing the 'sum' aggregation. + +Signature: + +```typescript +sum(): Sum; +``` +Returns: + +[Sum](./firestore_.sum.md#sum_class) + +## Constant.timestampAdd() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to this timestamp expression. + +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + +``` + +Signature: + +```typescript +timestampAdd(unit: Constant, amount: Constant): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) + +## Constant.timestampAdd() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to this timestamp expression. + +```typescript +// Add 1 day to the 'timestamp' field. +Field.of("timestamp").timestampAdd("day", 1); + +``` + +Signature: + +```typescript +timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | +| amount | number | The amount of time to add. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) + +## Constant.timestampSub() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from this timestamp expression. + +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + +``` + +Signature: + +```typescript +timestampSub(unit: Constant, amount: Constant): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) + +## Constant.timestampSub() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from this timestamp expression. + +```typescript +// Subtract 1 day from the 'timestamp' field. +Field.of("timestamp").timestampSub("day", 1); + +``` + +Signature: + +```typescript +timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | +| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) + +## Constant.timestampToUnixMicros() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +Field.of("timestamp").timestampToUnixMicros(); + +``` + A new representing the number of microseconds since epoch. + +Signature: + +```typescript +timestampToUnixMicros(): TimestampToUnixMicros; +``` +Returns: + +[TimestampToUnixMicros](./firestore_.timestamptounixmicros.md#timestamptounixmicros_class) + +## Constant.timestampToUnixMillis() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +Field.of("timestamp").timestampToUnixMillis(); + +``` + A new representing the number of milliseconds since epoch. + +Signature: + +```typescript +timestampToUnixMillis(): TimestampToUnixMillis; +``` +Returns: + +[TimestampToUnixMillis](./firestore_.timestamptounixmillis.md#timestamptounixmillis_class) + +## Constant.timestampToUnixSeconds() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to seconds since epoch. +Field.of("timestamp").timestampToUnixSeconds(); + +``` + A new representing the number of seconds since epoch. + +Signature: + +```typescript +timestampToUnixSeconds(): TimestampToUnixSeconds; +``` +Returns: + +[TimestampToUnixSeconds](./firestore_.timestamptounixseconds.md#timestamptounixseconds_class) + +## Constant.toLower() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string to lowercase. + +```typescript +// Convert the 'name' field to lowercase +Field.of("name").toLower(); + +``` + A new `Expr` representing the lowercase string. + +Signature: + +```typescript +toLower(): ToLower; +``` +Returns: + +[ToLower](./firestore_.tolower.md#tolower_class) + +## Constant.toUpper() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string to uppercase. + +```typescript +// Convert the 'title' field to uppercase +Field.of("title").toUpper(); + +``` + A new `Expr` representing the uppercase string. + +Signature: + +```typescript +toUpper(): ToUpper; +``` +Returns: + +[ToUpper](./firestore_.toupper.md#toupper_class) + +## Constant.trim() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that removes leading and trailing whitespace from a string. + +```typescript +// Trim whitespace from the 'userInput' field +Field.of("userInput").trim(); + +``` + A new `Expr` representing the trimmed string. + +Signature: + +```typescript +trim(): Trim; +``` +Returns: + +[Trim](./firestore_.trim.md#trim_class) + +## Constant.unixMicrosToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +Field.of("microseconds").unixMicrosToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixMicrosToTimestamp(): UnixMicrosToTimestamp; +``` +Returns: + +[UnixMicrosToTimestamp](./firestore_.unixmicrostotimestamp.md#unixmicrostotimestamp_class) + +## Constant.unixMillisToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +Field.of("milliseconds").unixMillisToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixMillisToTimestamp(): UnixMillisToTimestamp; +``` +Returns: + +[UnixMillisToTimestamp](./firestore_.unixmillistotimestamp.md#unixmillistotimestamp_class) + +## Constant.unixSecondsToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'seconds' field as seconds since epoch. +Field.of("seconds").unixSecondsToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixSecondsToTimestamp(): UnixSecondsToTimestamp; +``` +Returns: + +[UnixSecondsToTimestamp](./firestore_.unixsecondstotimestamp.md#unixsecondstotimestamp_class) + +## Constant.vector() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a VectorValue value. + +```typescript +// Create a Constant instance for a vector value +const vectorConstant = Constant.ofVector([1, 2, 3]); + +``` + +Signature: + +```typescript +static vector(value: number[] | VectorValue): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | number\[\] \| [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The VectorValue value. A new Constant instance. | + +Returns: + +[Constant](./firestore_.constant.md#constant_class) + +## Constant.vectorLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. + +```typescript +// Get the vector length (dimension) of the field 'embedding'. +Field.of("embedding").vectorLength(); + +``` + A new representing the length of the vector. + +Signature: + +```typescript +vectorLength(): VectorLength; +``` +Returns: + +[VectorLength](./firestore_.vectorlength.md#vectorlength_class) + diff --git a/docs-devsite/firestore_.cosinedistance.md b/docs-devsite/firestore_.cosinedistance.md new file mode 100644 index 00000000000..794d99c6d34 --- /dev/null +++ b/docs-devsite/firestore_.cosinedistance.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# CosineDistance class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class CosineDistance extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(vector1, vector2)](./firestore_.cosinedistance.md#cosinedistanceconstructor) | | (BETA) Constructs a new instance of the CosineDistance class | + +## CosineDistance.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `CosineDistance` class + +Signature: + +```typescript +constructor(vector1: Constant, vector2: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| vector1 | [Constant](./firestore_.constant.md#constant_class) | | +| vector2 | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.count.md b/docs-devsite/firestore_.count.md new file mode 100644 index 00000000000..be4c3a37c57 --- /dev/null +++ b/docs-devsite/firestore_.count.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Count class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Count extends FirestoreFunction implements Accumulator +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [Accumulator](./firestore_.accumulator.md#accumulator_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value, distinct)](./firestore_.count.md#countconstructor) | | (BETA) Constructs a new instance of the Count class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [accumulator](./firestore_.count.md#countaccumulator) | | true | (BETA) | + +## Count.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Count` class + +Signature: + +```typescript +constructor(value: Constant | undefined, distinct: boolean); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_.constant.md#constant_class) \| undefined | | +| distinct | boolean | | + +## Count.accumulator + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +accumulator: true; +``` diff --git a/docs-devsite/firestore_.databasesource.md b/docs-devsite/firestore_.databasesource.md new file mode 100644 index 00000000000..0989b69042c --- /dev/null +++ b/docs-devsite/firestore_.databasesource.md @@ -0,0 +1,39 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# DatabaseSource class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class DatabaseSource implements Stage +``` +Implements: [Stage](./firestore_.stage.md#stage_interface) + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_.databasesource.md#databasesourcename) | | string | (BETA) | + +## DatabaseSource.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_.distinct.md b/docs-devsite/firestore_.distinct.md new file mode 100644 index 00000000000..a893d3f7e47 --- /dev/null +++ b/docs-devsite/firestore_.distinct.md @@ -0,0 +1,64 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Distinct class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Distinct implements Stage +``` +Implements: [Stage](./firestore_.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(groups)](./firestore_.distinct.md#distinctconstructor) | | (BETA) Constructs a new instance of the Distinct class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_.distinct.md#distinctname) | | string | (BETA) | + +## Distinct.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Distinct` class + +Signature: + +```typescript +constructor(groups: Map); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| groups | Map<string, [Constant](./firestore_.constant.md#constant_class)> | | + +## Distinct.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_.divide.md b/docs-devsite/firestore_.divide.md new file mode 100644 index 00000000000..ac77d7916d8 --- /dev/null +++ b/docs-devsite/firestore_.divide.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Divide class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Divide extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_.divide.md#divideconstructor) | | (BETA) Constructs a new instance of the Divide class | + +## Divide.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Divide` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | | +| right | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.documentssource.md b/docs-devsite/firestore_.documentssource.md new file mode 100644 index 00000000000..18ea01c0517 --- /dev/null +++ b/docs-devsite/firestore_.documentssource.md @@ -0,0 +1,92 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# DocumentsSource class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class DocumentsSource implements Stage +``` +Implements: [Stage](./firestore_.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(docPaths)](./firestore_.documentssource.md#documentssourceconstructor) | | (BETA) Constructs a new instance of the DocumentsSource class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_.documentssource.md#documentssourcename) | | string | (BETA) | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [of(refs)](./firestore_.documentssource.md#documentssourceof) | static | (BETA) | + +## DocumentsSource.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `DocumentsSource` class + +Signature: + +```typescript +constructor(docPaths: string[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| docPaths | string\[\] | | + +## DocumentsSource.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` + +## DocumentsSource.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +static of(refs: DocumentReference[]): DocumentsSource; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| refs | [DocumentReference](./firestore_.documentreference.md#documentreference_class)\[\] | | + +Returns: + +[DocumentsSource](./firestore_.documentssource.md#documentssource_class) + diff --git a/docs-devsite/firestore_.dotproduct.md b/docs-devsite/firestore_.dotproduct.md new file mode 100644 index 00000000000..2e1a21700ad --- /dev/null +++ b/docs-devsite/firestore_.dotproduct.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# DotProduct class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class DotProduct extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(vector1, vector2)](./firestore_.dotproduct.md#dotproductconstructor) | | (BETA) Constructs a new instance of the DotProduct class | + +## DotProduct.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `DotProduct` class + +Signature: + +```typescript +constructor(vector1: Constant, vector2: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| vector1 | [Constant](./firestore_.constant.md#constant_class) | | +| vector2 | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.endswith.md b/docs-devsite/firestore_.endswith.md new file mode 100644 index 00000000000..85f67657c50 --- /dev/null +++ b/docs-devsite/firestore_.endswith.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# EndsWith class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class EndsWith extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr, suffix)](./firestore_.endswith.md#endswithconstructor) | | (BETA) Constructs a new instance of the EndsWith class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_.endswith.md#endswithfilterable) | | true | (BETA) | + +## EndsWith.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `EndsWith` class + +Signature: + +```typescript +constructor(expr: Constant, suffix: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | | +| suffix | [Constant](./firestore_.constant.md#constant_class) | | + +## EndsWith.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_.eq.md b/docs-devsite/firestore_.eq.md new file mode 100644 index 00000000000..15cc19e3c2b --- /dev/null +++ b/docs-devsite/firestore_.eq.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Eq class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Eq extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_.eq.md#eqconstructor) | | (BETA) Constructs a new instance of the Eq class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_.eq.md#eqfilterable) | | true | (BETA) | + +## Eq.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Eq` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | | +| right | [Constant](./firestore_.constant.md#constant_class) | | + +## Eq.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_.euclideandistance.md b/docs-devsite/firestore_.euclideandistance.md new file mode 100644 index 00000000000..240f048f42e --- /dev/null +++ b/docs-devsite/firestore_.euclideandistance.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# EuclideanDistance class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class EuclideanDistance extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(vector1, vector2)](./firestore_.euclideandistance.md#euclideandistanceconstructor) | | (BETA) Constructs a new instance of the EuclideanDistance class | + +## EuclideanDistance.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `EuclideanDistance` class + +Signature: + +```typescript +constructor(vector1: Constant, vector2: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| vector1 | [Constant](./firestore_.constant.md#constant_class) | | +| vector2 | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.exists.md b/docs-devsite/firestore_.exists.md new file mode 100644 index 00000000000..459196066d4 --- /dev/null +++ b/docs-devsite/firestore_.exists.md @@ -0,0 +1,66 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Exists class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Exists extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr)](./firestore_.exists.md#existsconstructor) | | (BETA) Constructs a new instance of the Exists class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_.exists.md#existsfilterable) | | true | (BETA) | + +## Exists.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Exists` class + +Signature: + +```typescript +constructor(expr: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | | + +## Exists.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_.exprwithalias.md b/docs-devsite/firestore_.exprwithalias.md new file mode 100644 index 00000000000..7d92f0e46fa --- /dev/null +++ b/docs-devsite/firestore_.exprwithalias.md @@ -0,0 +1,3207 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ExprWithAlias class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ExprWithAlias implements Selectable +``` +Implements: [Selectable](./firestore_.selectable.md#selectable_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr, alias)](./firestore_.exprwithalias.md#exprwithaliasconstructor) | | (BETA) Constructs a new instance of the ExprWithAlias class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [alias](./firestore_.exprwithalias.md#exprwithaliasalias) | | string | (BETA) | +| [expr](./firestore_.exprwithalias.md#exprwithaliasexpr) | | T | (BETA) | +| [exprType](./firestore_.exprwithalias.md#exprwithaliasexprtype) | | [ExprType](./firestore_.md#exprtype) | (BETA) | +| [selectable](./firestore_.exprwithalias.md#exprwithaliasselectable) | | true | (BETA) | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [add(other)](./firestore_.exprwithalias.md#exprwithaliasadd) | | (BETA) Creates an expression that adds this expression to another expression. +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +Field.of("quantity").add(Field.of("reserve")); + +``` + | +| [add(other)](./firestore_.exprwithalias.md#exprwithaliasadd) | | (BETA) Creates an expression that adds this expression to a constant value. +```typescript +// Add 5 to the value of the 'age' field +Field.of("age").add(5); + +``` + | +| [arrayConcat(arrays)](./firestore_.exprwithalias.md#exprwithaliasarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. +```typescript +// Combine the 'items' array with another array field. +Field.of("items").arrayConcat(Field.of("otherItems")); + +``` + | +| [arrayConcat(arrays)](./firestore_.exprwithalias.md#exprwithaliasarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. +```typescript +// Combine the 'tags' array with a new array and an array field +Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + +``` + | +| [arrayContains(element)](./firestore_.exprwithalias.md#exprwithaliasarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific element. +```typescript +// Check if the 'sizes' array contains the value from the 'selectedSize' field +Field.of("sizes").arrayContains(Field.of("selectedSize")); + +``` + | +| [arrayContains(element)](./firestore_.exprwithalias.md#exprwithaliasarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific value. +```typescript +// Check if the 'colors' array contains "red" +Field.of("colors").arrayContains("red"); + +``` + | +| [arrayContainsAll(values)](./firestore_.exprwithalias.md#exprwithaliasarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. +```typescript +// Check if the 'tags' array contains both "news" and "sports" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + | +| [arrayContainsAll(values)](./firestore_.exprwithalias.md#exprwithaliasarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + | +| [arrayContainsAny(values)](./firestore_.exprwithalias.md#exprwithaliasarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "cate2" +Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + +``` + | +| [arrayContainsAny(values)](./firestore_.exprwithalias.md#exprwithaliasarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + +``` + | +| [arrayLength()](./firestore_.exprwithalias.md#exprwithaliasarraylength) | | (BETA) Creates an expression that calculates the length of an array. +```typescript +// Get the number of items in the 'cart' array +Field.of("cart").arrayLength(); + +``` + A new Expr representing the length of the array. | +| [as(name)](./firestore_.exprwithalias.md#exprwithaliasas) | | (BETA) Assigns an alias to this expression.Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. +```typescript +// Calculate the total price and assign it the alias "totalPrice" and add it to the output. +firestore.pipeline().collection("items") +.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + +``` + | +| [ascending()](./firestore_.exprwithalias.md#exprwithaliasascending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. +```typescript +// Sort documents by the 'name' field in ascending order +pipeline().collection("users") +.sort(Field.of("name").ascending()); + +``` + A new Ordering for ascending sorting. | +| [avg()](./firestore_.exprwithalias.md#exprwithaliasavg) | | (BETA) Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. +```typescript +// Calculate the average age of users +Field.of("age").avg().as("averageAge"); + +``` + A new Accumulator representing the 'avg' aggregation. | +| [byteLength()](./firestore_.exprwithalias.md#exprwithaliasbytelength) | | (BETA) Creates an expression that calculates the length of this string expression in bytes. +```typescript +// Calculate the length of the 'myString' field in bytes. +Field.of("myString").byteLength(); + +``` + A new representing the length of the string in bytes. | +| [charLength()](./firestore_.exprwithalias.md#exprwithaliascharlength) | | (BETA) Creates an expression that calculates the character length of a string in UTF-8. +```typescript +// Get the character length of the 'name' field in its UTF-8 form. +Field.of("name").charLength(); + +``` + A new Expr representing the length of the string. | +| [cosineDistance(other)](./firestore_.exprwithalias.md#exprwithaliascosinedistance) | | (BETA) Calculates the cosine distance between two vectors. +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +Field.of("userVector").cosineDistance(Field.of("itemVector")); + +``` + | +| [cosineDistance(other)](./firestore_.exprwithalias.md#exprwithaliascosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + +``` + | +| [cosineDistance(other)](./firestore_.exprwithalias.md#exprwithaliascosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance([37.7749, -122.4194]); + +``` + | +| [count()](./firestore_.exprwithalias.md#exprwithaliascount) | | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. +```typescript +// Count the total number of products +Field.of("productId").count().as("totalProducts"); + +``` + A new Accumulator representing the 'count' aggregation. | +| [descending()](./firestore_.exprwithalias.md#exprwithaliasdescending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") +.sort(Field.of("createdAt").descending()); + +``` + A new Ordering for descending sorting. | +| [divide(other)](./firestore_.exprwithalias.md#exprwithaliasdivide) | | (BETA) Creates an expression that divides this expression by another expression. +```typescript +// Divide the 'total' field by the 'count' field +Field.of("total").divide(Field.of("count")); + +``` + | +| [divide(other)](./firestore_.exprwithalias.md#exprwithaliasdivide) | | (BETA) Creates an expression that divides this expression by a constant value. +```typescript +// Divide the 'value' field by 10 +Field.of("value").divide(10); + +``` + | +| [dotProduct(other)](./firestore_.exprwithalias.md#exprwithaliasdotproduct) | | (BETA) Calculates the dot product between two vectors. +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct([0.5, 0.8, 0.2]); + +``` + | +| [dotProduct(other)](./firestore_.exprwithalias.md#exprwithaliasdotproduct) | | (BETA) Calculates the dot product between two vectors. +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + +``` + | +| [dotProduct(other)](./firestore_.exprwithalias.md#exprwithaliasdotproduct) | | (BETA) | +| [endsWith(suffix)](./firestore_.exprwithalias.md#exprwithaliasendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix. +```typescript +// Check if the 'filename' field ends with ".txt" +Field.of("filename").endsWith(".txt"); + +``` + | +| [endsWith(suffix)](./firestore_.exprwithalias.md#exprwithaliasendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix (represented as an expression). +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +Field.of("url").endsWith(Field.of("extension")); + +``` + | +| [eq(other)](./firestore_.exprwithalias.md#exprwithaliaseq) | | (BETA) Creates an expression that checks if this expression is equal to another expression. +```typescript +// Check if the 'age' field is equal to 21 +Field.of("age").eq(21); + +``` + | +| [eq(other)](./firestore_.exprwithalias.md#exprwithaliaseq) | | (BETA) Creates an expression that checks if this expression is equal to a constant value. +```typescript +// Check if the 'city' field is equal to "London" +Field.of("city").eq("London"); + +``` + | +| [euclideanDistance(other)](./firestore_.exprwithalias.md#exprwithaliaseuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance([37.7749, -122.4194]); + +``` + | +| [euclideanDistance(other)](./firestore_.exprwithalias.md#exprwithaliaseuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + +``` + | +| [euclideanDistance(other)](./firestore_.exprwithalias.md#exprwithaliaseuclideandistance) | | (BETA) | +| [exists()](./firestore_.exprwithalias.md#exprwithaliasexists) | | (BETA) Creates an expression that checks if a field exists in the document. +```typescript +// Check if the document has a field named "phoneNumber" +Field.of("phoneNumber").exists(); + +``` + A new Expr representing the 'exists' check. | +| [gt(other)](./firestore_.exprwithalias.md#exprwithaliasgt) | | (BETA) Creates an expression that checks if this expression is greater than another expression. +```typescript +// Check if the 'age' field is greater than the 'limit' field +Field.of("age").gt(Field.of("limit")); + +``` + | +| [gt(other)](./firestore_.exprwithalias.md#exprwithaliasgt) | | (BETA) Creates an expression that checks if this expression is greater than a constant value. +```typescript +// Check if the 'price' field is greater than 100 +Field.of("price").gt(100); + +``` + | +| [gte(other)](./firestore_.exprwithalias.md#exprwithaliasgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to another expression. +```typescript +// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 +Field.of("quantity").gte(Field.of('requirement').add(1)); + +``` + | +| [gte(other)](./firestore_.exprwithalias.md#exprwithaliasgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to a constant value. +```typescript +// Check if the 'score' field is greater than or equal to 80 +Field.of("score").gte(80); + +``` + | +| [in(others)](./firestore_.exprwithalias.md#exprwithaliasin) | | (BETA) Creates an expression that checks if this expression is equal to any of the provided values or expressions. +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +Field.of("category").in("Electronics", Field.of("primaryType")); + +``` + | +| [in(others)](./firestore_.exprwithalias.md#exprwithaliasin) | | (BETA) | +| [isNaN()](./firestore_.exprwithalias.md#exprwithaliasisnan) | | (BETA) Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). +```typescript +// Check if the result of a calculation is NaN +Field.of("value").divide(0).isNaN(); + +``` + A new Expr representing the 'isNaN' check. | +| [like(pattern)](./firestore_.exprwithalias.md#exprwithaliaslike) | | (BETA) Creates an expression that performs a case-sensitive string comparison. +```typescript +// Check if the 'title' field contains the word "guide" (case-sensitive) +Field.of("title").like("%guide%"); + +``` + | +| [like(pattern)](./firestore_.exprwithalias.md#exprwithaliaslike) | | (BETA) | +| [logicalMax(other)](./firestore_.exprwithalias.md#exprwithaliaslogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMax(Function.currentTimestamp()); + +``` + | +| [logicalMax(other)](./firestore_.exprwithalias.md#exprwithaliaslogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'value' field and 10. +Field.of("value").logicalMax(10); + +``` + | +| [logicalMin(other)](./firestore_.exprwithalias.md#exprwithaliaslogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMin(Function.currentTimestamp()); + +``` + | +| [logicalMin(other)](./firestore_.exprwithalias.md#exprwithaliaslogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'value' field and 10. +Field.of("value").logicalMin(10); + +``` + | +| [lt(other)](./firestore_.exprwithalias.md#exprwithaliaslt) | | (BETA) Creates an expression that checks if this expression is less than another expression. +```typescript +// Check if the 'age' field is less than 'limit' +Field.of("age").lt(Field.of('limit')); + +``` + | +| [lt(other)](./firestore_.exprwithalias.md#exprwithaliaslt) | | (BETA) Creates an expression that checks if this expression is less than a constant value. +```typescript +// Check if the 'price' field is less than 50 +Field.of("price").lt(50); + +``` + | +| [lte(other)](./firestore_.exprwithalias.md#exprwithaliaslte) | | (BETA) Creates an expression that checks if this expression is less than or equal to another expression. +```typescript +// Check if the 'quantity' field is less than or equal to 20 +Field.of("quantity").lte(Constant.of(20)); + +``` + | +| [lte(other)](./firestore_.exprwithalias.md#exprwithaliaslte) | | (BETA) Creates an expression that checks if this expression is less than or equal to a constant value. +```typescript +// Check if the 'score' field is less than or equal to 70 +Field.of("score").lte(70); + +``` + | +| [mapGet(subfield)](./firestore_.exprwithalias.md#exprwithaliasmapget) | | (BETA) Accesses a value from a map (object) field using the provided key. +```typescript +// Get the 'city' value from the 'address' map field +Field.of("address").mapGet("city"); + +``` + | +| [max()](./firestore_.exprwithalias.md#exprwithaliasmax) | | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. +```typescript +// Find the highest score in a leaderboard +Field.of("score").max().as("highestScore"); + +``` + A new Accumulator representing the 'max' aggregation. | +| [min()](./firestore_.exprwithalias.md#exprwithaliasmin) | | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. +```typescript +// Find the lowest price of all products +Field.of("price").min().as("lowestPrice"); + +``` + A new Accumulator representing the 'min' aggregation. | +| [mod(other)](./firestore_.exprwithalias.md#exprwithaliasmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. +```typescript +// Calculate the remainder of dividing the 'value' field by the 'divisor' field +Field.of("value").mod(Field.of("divisor")); + +``` + | +| [mod(other)](./firestore_.exprwithalias.md#exprwithaliasmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. +```typescript +// Calculate the remainder of dividing the 'value' field by 10 +Field.of("value").mod(10); + +``` + | +| [multiply(other)](./firestore_.exprwithalias.md#exprwithaliasmultiply) | | (BETA) Creates an expression that multiplies this expression by another expression. +```typescript +// Multiply the 'quantity' field by the 'price' field +Field.of("quantity").multiply(Field.of("price")); + +``` + | +| [multiply(other)](./firestore_.exprwithalias.md#exprwithaliasmultiply) | | (BETA) Creates an expression that multiplies this expression by a constant value. +```typescript +// Multiply the 'value' field by 2 +Field.of("value").multiply(2); + +``` + | +| [neq(other)](./firestore_.exprwithalias.md#exprwithaliasneq) | | (BETA) Creates an expression that checks if this expression is not equal to another expression. +```typescript +// Check if the 'status' field is not equal to "completed" +Field.of("status").neq("completed"); + +``` + | +| [neq(other)](./firestore_.exprwithalias.md#exprwithaliasneq) | | (BETA) Creates an expression that checks if this expression is not equal to a constant value. +```typescript +// Check if the 'country' field is not equal to "USA" +Field.of("country").neq("USA"); + +``` + | +| [regexContains(pattern)](./firestore_.exprwithalias.md#exprwithaliasregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +Field.of("description").regexContains("(?i)example"); + +``` + | +| [regexContains(pattern)](./firestore_.exprwithalias.md#exprwithaliasregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains the regular expression stored in field 'regex' +Field.of("description").regexContains(Field.of("regex")); + +``` + | +| [regexMatch(pattern)](./firestore_.exprwithalias.md#exprwithaliasregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. +```typescript +// Check if the 'email' field matches a valid email pattern +Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + | +| [regexMatch(pattern)](./firestore_.exprwithalias.md#exprwithaliasregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. +```typescript +// Check if the 'email' field matches a regular expression stored in field 'regex' +Field.of("email").regexMatch(Field.of("regex")); + +``` + | +| [replaceAll(find, replace)](./firestore_.exprwithalias.md#exprwithaliasreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring. +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field +Field.of("message").replaceAll("hello", "hi"); + +``` + | +| [replaceAll(find, replace)](./firestore_.exprwithalias.md#exprwithaliasreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + +``` + | +| [replaceFirst(find, replace)](./firestore_.exprwithalias.md#exprwithaliasreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field +Field.of("message").replaceFirst("hello", "hi"); + +``` + | +| [replaceFirst(find, replace)](./firestore_.exprwithalias.md#exprwithaliasreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + +``` + | +| [reverse()](./firestore_.exprwithalias.md#exprwithaliasreverse) | | (BETA) Creates an expression that reverses this string expression. +```typescript +// Reverse the value of the 'myString' field. +Field.of("myString").reverse(); + +``` + A new representing the reversed string. | +| [startsWith(prefix)](./firestore_.exprwithalias.md#exprwithaliasstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix. +```typescript +// Check if the 'name' field starts with "Mr." +Field.of("name").startsWith("Mr."); + +``` + | +| [startsWith(prefix)](./firestore_.exprwithalias.md#exprwithaliasstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix (represented as an expression). +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +Field.of("fullName").startsWith(Field.of("firstName")); + +``` + | +| [strConcat(elements)](./firestore_.exprwithalias.md#exprwithaliasstrconcat) | | (BETA) Creates an expression that concatenates string expressions together. +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + +``` + | +| [strContains(substring)](./firestore_.exprwithalias.md#exprwithaliasstrcontains) | | (BETA) Creates an expression that checks if a string contains a specified substring. +```typescript +// Check if the 'description' field contains "example". +Field.of("description").strContains("example"); + +``` + | +| [strContains(expr)](./firestore_.exprwithalias.md#exprwithaliasstrcontains) | | (BETA) Creates an expression that checks if a string contains the string represented by another expression. +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +Field.of("description").strContains(Field.of("keyword")); + +``` + | +| [subtract(other)](./firestore_.exprwithalias.md#exprwithaliassubtract) | | (BETA) Creates an expression that subtracts another expression from this expression. +```typescript +// Subtract the 'discount' field from the 'price' field +Field.of("price").subtract(Field.of("discount")); + +``` + | +| [subtract(other)](./firestore_.exprwithalias.md#exprwithaliassubtract) | | (BETA) Creates an expression that subtracts a constant value from this expression. +```typescript +// Subtract 20 from the value of the 'total' field +Field.of("total").subtract(20); + +``` + | +| [sum()](./firestore_.exprwithalias.md#exprwithaliassum) | | (BETA) Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. +```typescript +// Calculate the total revenue from a set of orders +Field.of("orderAmount").sum().as("totalRevenue"); + +``` + A new Accumulator representing the 'sum' aggregation. | +| [timestampAdd(unit, amount)](./firestore_.exprwithalias.md#exprwithaliastimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampAdd(unit, amount)](./firestore_.exprwithalias.md#exprwithaliastimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. +```typescript +// Add 1 day to the 'timestamp' field. +Field.of("timestamp").timestampAdd("day", 1); + +``` + | +| [timestampSub(unit, amount)](./firestore_.exprwithalias.md#exprwithaliastimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampSub(unit, amount)](./firestore_.exprwithalias.md#exprwithaliastimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. +```typescript +// Subtract 1 day from the 'timestamp' field. +Field.of("timestamp").timestampSub("day", 1); + +``` + | +| [timestampToUnixMicros()](./firestore_.exprwithalias.md#exprwithaliastimestamptounixmicros) | | (BETA) Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +Field.of("timestamp").timestampToUnixMicros(); + +``` + A new representing the number of microseconds since epoch. | +| [timestampToUnixMillis()](./firestore_.exprwithalias.md#exprwithaliastimestamptounixmillis) | | (BETA) Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +Field.of("timestamp").timestampToUnixMillis(); + +``` + A new representing the number of milliseconds since epoch. | +| [timestampToUnixSeconds()](./firestore_.exprwithalias.md#exprwithaliastimestamptounixseconds) | | (BETA) Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to seconds since epoch. +Field.of("timestamp").timestampToUnixSeconds(); + +``` + A new representing the number of seconds since epoch. | +| [toLower()](./firestore_.exprwithalias.md#exprwithaliastolower) | | (BETA) Creates an expression that converts a string to lowercase. +```typescript +// Convert the 'name' field to lowercase +Field.of("name").toLower(); + +``` + A new Expr representing the lowercase string. | +| [toUpper()](./firestore_.exprwithalias.md#exprwithaliastoupper) | | (BETA) Creates an expression that converts a string to uppercase. +```typescript +// Convert the 'title' field to uppercase +Field.of("title").toUpper(); + +``` + A new Expr representing the uppercase string. | +| [trim()](./firestore_.exprwithalias.md#exprwithaliastrim) | | (BETA) Creates an expression that removes leading and trailing whitespace from a string. +```typescript +// Trim whitespace from the 'userInput' field +Field.of("userInput").trim(); + +``` + A new Expr representing the trimmed string. | +| [unixMicrosToTimestamp()](./firestore_.exprwithalias.md#exprwithaliasunixmicrostotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +Field.of("microseconds").unixMicrosToTimestamp(); + +``` + A new representing the timestamp. | +| [unixMillisToTimestamp()](./firestore_.exprwithalias.md#exprwithaliasunixmillistotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +Field.of("milliseconds").unixMillisToTimestamp(); + +``` + A new representing the timestamp. | +| [unixSecondsToTimestamp()](./firestore_.exprwithalias.md#exprwithaliasunixsecondstotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'seconds' field as seconds since epoch. +Field.of("seconds").unixSecondsToTimestamp(); + +``` + A new representing the timestamp. | +| [vectorLength()](./firestore_.exprwithalias.md#exprwithaliasvectorlength) | | (BETA) Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. +```typescript +// Get the vector length (dimension) of the field 'embedding'. +Field.of("embedding").vectorLength(); + +``` + A new representing the length of the vector. | + +## ExprWithAlias.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ExprWithAlias` class + +Signature: + +```typescript +constructor(expr: T, alias: string); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | T | | +| alias | string | | + +## ExprWithAlias.alias + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +alias: string; +``` + +## ExprWithAlias.expr + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +expr: T; +``` + +## ExprWithAlias.exprType + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +exprType: ExprType; +``` + +## ExprWithAlias.selectable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +selectable: true; +``` + +## ExprWithAlias.add() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds this expression to another expression. + +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +Field.of("quantity").add(Field.of("reserve")); + +``` + +Signature: + +```typescript +add(other: Constant): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to add to this expression. A new Expr representing the addition operation. | + +Returns: + +[Add](./firestore_.add.md#add_class) + +## ExprWithAlias.add() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds this expression to a constant value. + +```typescript +// Add 5 to the value of the 'age' field +Field.of("age").add(5); + +``` + +Signature: + +```typescript +add(other: any): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to add. A new Expr representing the addition operation. | + +Returns: + +[Add](./firestore_.add.md#add_class) + +## ExprWithAlias.arrayConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with one or more other arrays. + +```typescript +// Combine the 'items' array with another array field. +Field.of("items").arrayConcat(Field.of("otherItems")); + +``` + +Signature: + +```typescript +arrayConcat(arrays: Constant[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrays | [Constant](./firestore_.constant.md#constant_class)\[\] | The array expressions to concatenate. A new Expr representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) + +## ExprWithAlias.arrayConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with one or more other arrays. + +```typescript +// Combine the 'tags' array with a new array and an array field +Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + +``` + +Signature: + +```typescript +arrayConcat(arrays: any[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrays | any\[\] | The array expressions or values to concatenate. A new Expr representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) + +## ExprWithAlias.arrayContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains a specific element. + +```typescript +// Check if the 'sizes' array contains the value from the 'selectedSize' field +Field.of("sizes").arrayContains(Field.of("selectedSize")); + +``` + +Signature: + +```typescript +arrayContains(element: Constant): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | [Constant](./firestore_.constant.md#constant_class) | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) + +## ExprWithAlias.arrayContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains a specific value. + +```typescript +// Check if the 'colors' array contains "red" +Field.of("colors").arrayContains("red"); + +``` + +Signature: + +```typescript +arrayContains(element: any): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | any | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) + +## ExprWithAlias.arrayContainsAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both "news" and "sports" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + +Signature: + +```typescript +arrayContainsAll(...values: Constant[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) + +## ExprWithAlias.arrayContainsAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + +Signature: + +```typescript +arrayContainsAll(...values: any[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) + +## ExprWithAlias.arrayContainsAny() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains any of the specified elements. + +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "cate2" +Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + +``` + +Signature: + +```typescript +arrayContainsAny(...values: Constant[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) + +## ExprWithAlias.arrayContainsAny() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains any of the specified elements. + +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + +``` + +Signature: + +```typescript +arrayContainsAny(...values: any[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) + +## ExprWithAlias.arrayLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of an array. + +```typescript +// Get the number of items in the 'cart' array +Field.of("cart").arrayLength(); + +``` + A new `Expr` representing the length of the array. + +Signature: + +```typescript +arrayLength(): ArrayLength; +``` +Returns: + +[ArrayLength](./firestore_.arraylength.md#arraylength_class) + +## ExprWithAlias.as() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Assigns an alias to this expression. + +Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. + +```typescript +// Calculate the total price and assign it the alias "totalPrice" and add it to the output. +firestore.pipeline().collection("items") +.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + +``` + +Signature: + +```typescript +as(name: string): ExprWithAlias; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | The alias to assign to this expression. A new [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) that wraps this expression and associates it with the provided alias. | + +Returns: + +[ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class)<this> + +## ExprWithAlias.ascending() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. + +```typescript +// Sort documents by the 'name' field in ascending order +pipeline().collection("users") +.sort(Field.of("name").ascending()); + +``` + A new `Ordering` for ascending sorting. + +Signature: + +```typescript +ascending(): Ordering; +``` +Returns: + +[Ordering](./firestore_.ordering.md#ordering_class) + +## ExprWithAlias.avg() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. + +```typescript +// Calculate the average age of users +Field.of("age").avg().as("averageAge"); + +``` + A new `Accumulator` representing the 'avg' aggregation. + +Signature: + +```typescript +avg(): Avg; +``` +Returns: + +[Avg](./firestore_.avg.md#avg_class) + +## ExprWithAlias.byteLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of this string expression in bytes. + +```typescript +// Calculate the length of the 'myString' field in bytes. +Field.of("myString").byteLength(); + +``` + A new representing the length of the string in bytes. + +Signature: + +```typescript +byteLength(): ByteLength; +``` +Returns: + +[ByteLength](./firestore_.bytelength.md#bytelength_class) + +## ExprWithAlias.charLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the character length of a string in UTF-8. + +```typescript +// Get the character length of the 'name' field in its UTF-8 form. +Field.of("name").charLength(); + +``` + A new `Expr` representing the length of the string. + +Signature: + +```typescript +charLength(): CharLength; +``` +Returns: + +[CharLength](./firestore_.charlength.md#charlength_class) + +## ExprWithAlias.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the cosine distance between two vectors. + +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +Field.of("userVector").cosineDistance(Field.of("itemVector")); + +``` + +Signature: + +```typescript +cosineDistance(other: Constant): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new Expr representing the cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) + +## ExprWithAlias.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vectors. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +cosineDistance(other: VectorValue): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) + +## ExprWithAlias.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vectors. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance([37.7749, -122.4194]); + +``` + +Signature: + +```typescript +cosineDistance(other: number[]): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | The other vector (as an array of numbers) to compare against. A new Expr representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) + +## ExprWithAlias.count() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. + +```typescript +// Count the total number of products +Field.of("productId").count().as("totalProducts"); + +``` + A new `Accumulator` representing the 'count' aggregation. + +Signature: + +```typescript +count(): Count; +``` +Returns: + +[Count](./firestore_.count.md#count_class) + +## ExprWithAlias.descending() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. + +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") +.sort(Field.of("createdAt").descending()); + +``` + A new `Ordering` for descending sorting. + +Signature: + +```typescript +descending(): Ordering; +``` +Returns: + +[Ordering](./firestore_.ordering.md#ordering_class) + +## ExprWithAlias.divide() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides this expression by another expression. + +```typescript +// Divide the 'total' field by the 'count' field +Field.of("total").divide(Field.of("count")); + +``` + +Signature: + +```typescript +divide(other: Constant): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new Expr representing the division operation. | + +Returns: + +[Divide](./firestore_.divide.md#divide_class) + +## ExprWithAlias.divide() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides this expression by a constant value. + +```typescript +// Divide the 'value' field by 10 +Field.of("value").divide(10); + +``` + +Signature: + +```typescript +divide(other: any): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to divide by. A new Expr representing the division operation. | + +Returns: + +[Divide](./firestore_.divide.md#divide_class) + +## ExprWithAlias.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vectors. + +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct([0.5, 0.8, 0.2]); + +``` + +Signature: + +```typescript +dotProduct(other: Constant): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_.dotproduct.md#dotproduct_class) + +## ExprWithAlias.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vectors. + +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + +``` + +Signature: + +```typescript +dotProduct(other: VectorValue): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_.dotproduct.md#dotproduct_class) + +## ExprWithAlias.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +dotProduct(other: number[]): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | | + +Returns: + +[DotProduct](./firestore_.dotproduct.md#dotproduct_class) + +## ExprWithAlias.endsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string ends with a given postfix. + +```typescript +// Check if the 'filename' field ends with ".txt" +Field.of("filename").endsWith(".txt"); + +``` + +Signature: + +```typescript +endsWith(suffix: string): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| suffix | string | The postfix to check for. A new Expr representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_.endswith.md#endswith_class) + +## ExprWithAlias.endsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string ends with a given postfix (represented as an expression). + +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +Field.of("url").endsWith(Field.of("extension")); + +``` + +Signature: + +```typescript +endsWith(suffix: Constant): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| suffix | [Constant](./firestore_.constant.md#constant_class) | The postfix expression to check for. A new Expr representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_.endswith.md#endswith_class) + +## ExprWithAlias.eq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to another expression. + +```typescript +// Check if the 'age' field is equal to 21 +Field.of("age").eq(21); + +``` + +Signature: + +```typescript +eq(other: Constant): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for equality. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_.eq.md#eq_class) + +## ExprWithAlias.eq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to a constant value. + +```typescript +// Check if the 'city' field is equal to "London" +Field.of("city").eq("London"); + +``` + +Signature: + +```typescript +eq(other: any): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for equality. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_.eq.md#eq_class) + +## ExprWithAlias.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vectors. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance([37.7749, -122.4194]); + +``` + +Signature: + +```typescript +euclideanDistance(other: Constant): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) + +## ExprWithAlias.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vectors. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +euclideanDistance(other: VectorValue): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) + +## ExprWithAlias.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +euclideanDistance(other: number[]): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | | + +Returns: + +[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) + +## ExprWithAlias.exists() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field exists in the document. + +```typescript +// Check if the document has a field named "phoneNumber" +Field.of("phoneNumber").exists(); + +``` + A new `Expr` representing the 'exists' check. + +Signature: + +```typescript +exists(): Exists; +``` +Returns: + +[Exists](./firestore_.exists.md#exists_class) + +## ExprWithAlias.gt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than another expression. + +```typescript +// Check if the 'age' field is greater than the 'limit' field +Field.of("age").gt(Field.of("limit")); + +``` + +Signature: + +```typescript +gt(other: Constant): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for greater than. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_.gt.md#gt_class) + +## ExprWithAlias.gt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than a constant value. + +```typescript +// Check if the 'price' field is greater than 100 +Field.of("price").gt(100); + +``` + +Signature: + +```typescript +gt(other: any): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for greater than. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_.gt.md#gt_class) + +## ExprWithAlias.gte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than or equal to another expression. + +```typescript +// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 +Field.of("quantity").gte(Field.of('requirement').add(1)); + +``` + +Signature: + +```typescript +gte(other: Constant): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_.gte.md#gte_class) + +## ExprWithAlias.gte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than or equal to a constant value. + +```typescript +// Check if the 'score' field is greater than or equal to 80 +Field.of("score").gte(80); + +``` + +Signature: + +```typescript +gte(other: any): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_.gte.md#gte_class) + +## ExprWithAlias.in() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to any of the provided values or expressions. + +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +Field.of("category").in("Electronics", Field.of("primaryType")); + +``` + +Signature: + +```typescript +in(...others: Constant[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| others | [Constant](./firestore_.constant.md#constant_class)\[\] | The values or expressions to check against. A new Expr representing the 'IN' comparison. | + +Returns: + +[In](./firestore_.in.md#in_class) + +## ExprWithAlias.in() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +in(...others: any[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| others | any\[\] | | + +Returns: + +[In](./firestore_.in.md#in_class) + +## ExprWithAlias.isNaN() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). + +```typescript +// Check if the result of a calculation is NaN +Field.of("value").divide(0).isNaN(); + +``` + A new `Expr` representing the 'isNaN' check. + +Signature: + +```typescript +isNaN(): IsNan; +``` +Returns: + +[IsNan](./firestore_.isnan.md#isnan_class) + +## ExprWithAlias.like() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that performs a case-sensitive string comparison. + +```typescript +// Check if the 'title' field contains the word "guide" (case-sensitive) +Field.of("title").like("%guide%"); + +``` + +Signature: + +```typescript +like(pattern: string): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new Expr representing the 'like' comparison. | + +Returns: + +[Like](./firestore_.like.md#like_class) + +## ExprWithAlias.like() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +like(pattern: Constant): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_.constant.md#constant_class) | | + +Returns: + +[Like](./firestore_.like.md#like_class) + +## ExprWithAlias.logicalMax() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMax(Function.currentTimestamp()); + +``` + +Signature: + +```typescript +logicalMax(other: Constant): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare with. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) + +## ExprWithAlias.logicalMax() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'value' field and 10. +Field.of("value").logicalMax(10); + +``` + +Signature: + +```typescript +logicalMax(other: any): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare with. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) + +## ExprWithAlias.logicalMin() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMin(Function.currentTimestamp()); + +``` + +Signature: + +```typescript +logicalMin(other: Constant): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare with. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) + +## ExprWithAlias.logicalMin() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'value' field and 10. +Field.of("value").logicalMin(10); + +``` + +Signature: + +```typescript +logicalMin(other: any): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare with. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) + +## ExprWithAlias.lt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than another expression. + +```typescript +// Check if the 'age' field is less than 'limit' +Field.of("age").lt(Field.of('limit')); + +``` + +Signature: + +```typescript +lt(other: Constant): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for less than. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_.lt.md#lt_class) + +## ExprWithAlias.lt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than a constant value. + +```typescript +// Check if the 'price' field is less than 50 +Field.of("price").lt(50); + +``` + +Signature: + +```typescript +lt(other: any): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for less than. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_.lt.md#lt_class) + +## ExprWithAlias.lte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than or equal to another expression. + +```typescript +// Check if the 'quantity' field is less than or equal to 20 +Field.of("quantity").lte(Constant.of(20)); + +``` + +Signature: + +```typescript +lte(other: Constant): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_.lte.md#lte_class) + +## ExprWithAlias.lte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than or equal to a constant value. + +```typescript +// Check if the 'score' field is less than or equal to 70 +Field.of("score").lte(70); + +``` + +Signature: + +```typescript +lte(other: any): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_.lte.md#lte_class) + +## ExprWithAlias.mapGet() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Accesses a value from a map (object) field using the provided key. + +```typescript +// Get the 'city' value from the 'address' map field +Field.of("address").mapGet("city"); + +``` + +Signature: + +```typescript +mapGet(subfield: string): MapGet; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| subfield | string | The key to access in the map. A new Expr representing the value associated with the given key in the map. | + +Returns: + +[MapGet](./firestore_.mapget.md#mapget_class) + +## ExprWithAlias.max() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that finds the maximum value of a field across multiple stage inputs. + +```typescript +// Find the highest score in a leaderboard +Field.of("score").max().as("highestScore"); + +``` + A new `Accumulator` representing the 'max' aggregation. + +Signature: + +```typescript +max(): Max; +``` +Returns: + +[Max](./firestore_.max.md#max_class) + +## ExprWithAlias.min() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that finds the minimum value of a field across multiple stage inputs. + +```typescript +// Find the lowest price of all products +Field.of("price").min().as("lowestPrice"); + +``` + A new `Accumulator` representing the 'min' aggregation. + +Signature: + +```typescript +min(): Min; +``` +Returns: + +[Min](./firestore_.min.md#min_class) + +## ExprWithAlias.mod() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. + +```typescript +// Calculate the remainder of dividing the 'value' field by the 'divisor' field +Field.of("value").mod(Field.of("divisor")); + +``` + +Signature: + +```typescript +mod(other: Constant): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new Expr representing the modulo operation. | + +Returns: + +[Mod](./firestore_.mod.md#mod_class) + +## ExprWithAlias.mod() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. + +```typescript +// Calculate the remainder of dividing the 'value' field by 10 +Field.of("value").mod(10); + +``` + +Signature: + +```typescript +mod(other: any): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to divide by. A new Expr representing the modulo operation. | + +Returns: + +[Mod](./firestore_.mod.md#mod_class) + +## ExprWithAlias.multiply() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies this expression by another expression. + +```typescript +// Multiply the 'quantity' field by the 'price' field +Field.of("quantity").multiply(Field.of("price")); + +``` + +Signature: + +```typescript +multiply(other: Constant): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to multiply by. A new Expr representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_.multiply.md#multiply_class) + +## ExprWithAlias.multiply() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies this expression by a constant value. + +```typescript +// Multiply the 'value' field by 2 +Field.of("value").multiply(2); + +``` + +Signature: + +```typescript +multiply(other: any): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to multiply by. A new Expr representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_.multiply.md#multiply_class) + +## ExprWithAlias.neq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is not equal to another expression. + +```typescript +// Check if the 'status' field is not equal to "completed" +Field.of("status").neq("completed"); + +``` + +Signature: + +```typescript +neq(other: Constant): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for inequality. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_.neq.md#neq_class) + +## ExprWithAlias.neq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is not equal to a constant value. + +```typescript +// Check if the 'country' field is not equal to "USA" +Field.of("country").neq("USA"); + +``` + +Signature: + +```typescript +neq(other: any): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for inequality. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_.neq.md#neq_class) + +## ExprWithAlias.regexContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +Field.of("description").regexContains("(?i)example"); + +``` + +Signature: + +```typescript +regexContains(pattern: string): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_.regexcontains.md#regexcontains_class) + +## ExprWithAlias.regexContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains the regular expression stored in field 'regex' +Field.of("description").regexContains(Field.of("regex")); + +``` + +Signature: + +```typescript +regexContains(pattern: Constant): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_.regexcontains.md#regexcontains_class) + +## ExprWithAlias.regexMatch() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a valid email pattern +Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + +Signature: + +```typescript +regexMatch(pattern: string): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The regular expression to use for the match. A new Expr representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) + +## ExprWithAlias.regexMatch() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a regular expression stored in field 'regex' +Field.of("email").regexMatch(Field.of("regex")); + +``` + +Signature: + +```typescript +regexMatch(pattern: Constant): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the match. A new Expr representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) + +## ExprWithAlias.replaceAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within this string expression with another substring. + +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field +Field.of("message").replaceAll("hello", "hi"); + +``` + +Signature: + +```typescript +replaceAll(find: string, replace: string): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | string | The substring to search for. | +| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_.replaceall.md#replaceall_class) + +## ExprWithAlias.replaceAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + +``` + +Signature: + +```typescript +replaceAll(find: Constant, replace: Constant): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_.replaceall.md#replaceall_class) + +## ExprWithAlias.replaceFirst() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. + +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field +Field.of("message").replaceFirst("hello", "hi"); + +``` + +Signature: + +```typescript +replaceFirst(find: string, replace: string): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | string | The substring to search for. | +| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) + +## ExprWithAlias.replaceFirst() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + +``` + +Signature: + +```typescript +replaceFirst(find: Constant, replace: Constant): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) + +## ExprWithAlias.reverse() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that reverses this string expression. + +```typescript +// Reverse the value of the 'myString' field. +Field.of("myString").reverse(); + +``` + A new representing the reversed string. + +Signature: + +```typescript +reverse(): Reverse; +``` +Returns: + +[Reverse](./firestore_.reverse.md#reverse_class) + +## ExprWithAlias.startsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string starts with a given prefix. + +```typescript +// Check if the 'name' field starts with "Mr." +Field.of("name").startsWith("Mr."); + +``` + +Signature: + +```typescript +startsWith(prefix: string): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| prefix | string | The prefix to check for. A new Expr representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_.startswith.md#startswith_class) + +## ExprWithAlias.startsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string starts with a given prefix (represented as an expression). + +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +Field.of("fullName").startsWith(Field.of("firstName")); + +``` + +Signature: + +```typescript +startsWith(prefix: Constant): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| prefix | [Constant](./firestore_.constant.md#constant_class) | The prefix expression to check for. A new Expr representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_.startswith.md#startswith_class) + +## ExprWithAlias.strConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates string expressions together. + +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + +``` + +Signature: + +```typescript +strConcat(...elements: Array): StrConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| elements | Array<string \| [Constant](./firestore_.constant.md#constant_class)> | The expressions (typically strings) to concatenate. A new Expr representing the concatenated string. | + +Returns: + +[StrConcat](./firestore_.strconcat.md#strconcat_class) + +## ExprWithAlias.strContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified substring. + +```typescript +// Check if the 'description' field contains "example". +Field.of("description").strContains("example"); + +``` + +Signature: + +```typescript +strContains(substring: string): StrContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| substring | string | The substring to search for. A new Expr representing the 'contains' comparison. | + +Returns: + +[StrContains](./firestore_.strcontains.md#strcontains_class) + +## ExprWithAlias.strContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains the string represented by another expression. + +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +Field.of("description").strContains(Field.of("keyword")); + +``` + +Signature: + +```typescript +strContains(expr: Constant): StrContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. A new Expr representing the 'contains' comparison. | + +Returns: + +[StrContains](./firestore_.strcontains.md#strcontains_class) + +## ExprWithAlias.subtract() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts another expression from this expression. + +```typescript +// Subtract the 'discount' field from the 'price' field +Field.of("price").subtract(Field.of("discount")); + +``` + +Signature: + +```typescript +subtract(other: Constant): Subtract; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to subtract from this expression. A new Expr representing the subtraction operation. | + +Returns: + +[Subtract](./firestore_.subtract.md#subtract_class) + +## ExprWithAlias.subtract() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a constant value from this expression. + +```typescript +// Subtract 20 from the value of the 'total' field +Field.of("total").subtract(20); + +``` + +Signature: + +```typescript +subtract(other: any): Subtract; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to subtract. A new Expr representing the subtraction operation. | + +Returns: + +[Subtract](./firestore_.subtract.md#subtract_class) + +## ExprWithAlias.sum() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. + +```typescript +// Calculate the total revenue from a set of orders +Field.of("orderAmount").sum().as("totalRevenue"); + +``` + A new `Accumulator` representing the 'sum' aggregation. + +Signature: + +```typescript +sum(): Sum; +``` +Returns: + +[Sum](./firestore_.sum.md#sum_class) + +## ExprWithAlias.timestampAdd() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to this timestamp expression. + +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + +``` + +Signature: + +```typescript +timestampAdd(unit: Constant, amount: Constant): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) + +## ExprWithAlias.timestampAdd() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to this timestamp expression. + +```typescript +// Add 1 day to the 'timestamp' field. +Field.of("timestamp").timestampAdd("day", 1); + +``` + +Signature: + +```typescript +timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | +| amount | number | The amount of time to add. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) + +## ExprWithAlias.timestampSub() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from this timestamp expression. + +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + +``` + +Signature: + +```typescript +timestampSub(unit: Constant, amount: Constant): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) + +## ExprWithAlias.timestampSub() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from this timestamp expression. + +```typescript +// Subtract 1 day from the 'timestamp' field. +Field.of("timestamp").timestampSub("day", 1); + +``` + +Signature: + +```typescript +timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | +| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) + +## ExprWithAlias.timestampToUnixMicros() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +Field.of("timestamp").timestampToUnixMicros(); + +``` + A new representing the number of microseconds since epoch. + +Signature: + +```typescript +timestampToUnixMicros(): TimestampToUnixMicros; +``` +Returns: + +[TimestampToUnixMicros](./firestore_.timestamptounixmicros.md#timestamptounixmicros_class) + +## ExprWithAlias.timestampToUnixMillis() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +Field.of("timestamp").timestampToUnixMillis(); + +``` + A new representing the number of milliseconds since epoch. + +Signature: + +```typescript +timestampToUnixMillis(): TimestampToUnixMillis; +``` +Returns: + +[TimestampToUnixMillis](./firestore_.timestamptounixmillis.md#timestamptounixmillis_class) + +## ExprWithAlias.timestampToUnixSeconds() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to seconds since epoch. +Field.of("timestamp").timestampToUnixSeconds(); + +``` + A new representing the number of seconds since epoch. + +Signature: + +```typescript +timestampToUnixSeconds(): TimestampToUnixSeconds; +``` +Returns: + +[TimestampToUnixSeconds](./firestore_.timestamptounixseconds.md#timestamptounixseconds_class) + +## ExprWithAlias.toLower() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string to lowercase. + +```typescript +// Convert the 'name' field to lowercase +Field.of("name").toLower(); + +``` + A new `Expr` representing the lowercase string. + +Signature: + +```typescript +toLower(): ToLower; +``` +Returns: + +[ToLower](./firestore_.tolower.md#tolower_class) + +## ExprWithAlias.toUpper() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string to uppercase. + +```typescript +// Convert the 'title' field to uppercase +Field.of("title").toUpper(); + +``` + A new `Expr` representing the uppercase string. + +Signature: + +```typescript +toUpper(): ToUpper; +``` +Returns: + +[ToUpper](./firestore_.toupper.md#toupper_class) + +## ExprWithAlias.trim() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that removes leading and trailing whitespace from a string. + +```typescript +// Trim whitespace from the 'userInput' field +Field.of("userInput").trim(); + +``` + A new `Expr` representing the trimmed string. + +Signature: + +```typescript +trim(): Trim; +``` +Returns: + +[Trim](./firestore_.trim.md#trim_class) + +## ExprWithAlias.unixMicrosToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +Field.of("microseconds").unixMicrosToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixMicrosToTimestamp(): UnixMicrosToTimestamp; +``` +Returns: + +[UnixMicrosToTimestamp](./firestore_.unixmicrostotimestamp.md#unixmicrostotimestamp_class) + +## ExprWithAlias.unixMillisToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +Field.of("milliseconds").unixMillisToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixMillisToTimestamp(): UnixMillisToTimestamp; +``` +Returns: + +[UnixMillisToTimestamp](./firestore_.unixmillistotimestamp.md#unixmillistotimestamp_class) + +## ExprWithAlias.unixSecondsToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'seconds' field as seconds since epoch. +Field.of("seconds").unixSecondsToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixSecondsToTimestamp(): UnixSecondsToTimestamp; +``` +Returns: + +[UnixSecondsToTimestamp](./firestore_.unixsecondstotimestamp.md#unixsecondstotimestamp_class) + +## ExprWithAlias.vectorLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. + +```typescript +// Get the vector length (dimension) of the field 'embedding'. +Field.of("embedding").vectorLength(); + +``` + A new representing the length of the vector. + +Signature: + +```typescript +vectorLength(): VectorLength; +``` +Returns: + +[VectorLength](./firestore_.vectorlength.md#vectorlength_class) + diff --git a/docs-devsite/firestore_.field.md b/docs-devsite/firestore_.field.md new file mode 100644 index 00000000000..d2406157dab --- /dev/null +++ b/docs-devsite/firestore_.field.md @@ -0,0 +1,3275 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Field class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Represents a reference to a field in a Firestore document, or outputs of a [Pipeline](./firestore_.pipeline.md#pipeline_class) stage. + +

Field references are used to access document field values in expressions and to specify fields for sorting, filtering, and projecting data in Firestore pipelines. + +

You can create a `Field` instance using the static method: + +```typescript +// Create a Field instance for the 'name' field +const nameField = Field.of("name"); + +// Create a Field instance for a nested field 'address.city' +const cityField = Field.of("address.city"); + +``` + +Signature: + +```typescript +export declare class Field implements Selectable +``` +Implements: [Selectable](./firestore_.selectable.md#selectable_interface) + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [exprType](./firestore_.field.md#fieldexprtype) | | [ExprType](./firestore_.md#exprtype) | (BETA) | +| [selectable](./firestore_.field.md#fieldselectable) | | true | (BETA) | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [add(other)](./firestore_.field.md#fieldadd) | | (BETA) Creates an expression that adds this expression to another expression. +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +Field.of("quantity").add(Field.of("reserve")); + +``` + | +| [add(other)](./firestore_.field.md#fieldadd) | | (BETA) Creates an expression that adds this expression to a constant value. +```typescript +// Add 5 to the value of the 'age' field +Field.of("age").add(5); + +``` + | +| [arrayConcat(arrays)](./firestore_.field.md#fieldarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. +```typescript +// Combine the 'items' array with another array field. +Field.of("items").arrayConcat(Field.of("otherItems")); + +``` + | +| [arrayConcat(arrays)](./firestore_.field.md#fieldarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. +```typescript +// Combine the 'tags' array with a new array and an array field +Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + +``` + | +| [arrayContains(element)](./firestore_.field.md#fieldarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific element. +```typescript +// Check if the 'sizes' array contains the value from the 'selectedSize' field +Field.of("sizes").arrayContains(Field.of("selectedSize")); + +``` + | +| [arrayContains(element)](./firestore_.field.md#fieldarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific value. +```typescript +// Check if the 'colors' array contains "red" +Field.of("colors").arrayContains("red"); + +``` + | +| [arrayContainsAll(values)](./firestore_.field.md#fieldarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. +```typescript +// Check if the 'tags' array contains both "news" and "sports" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + | +| [arrayContainsAll(values)](./firestore_.field.md#fieldarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + | +| [arrayContainsAny(values)](./firestore_.field.md#fieldarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "cate2" +Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + +``` + | +| [arrayContainsAny(values)](./firestore_.field.md#fieldarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + +``` + | +| [arrayLength()](./firestore_.field.md#fieldarraylength) | | (BETA) Creates an expression that calculates the length of an array. +```typescript +// Get the number of items in the 'cart' array +Field.of("cart").arrayLength(); + +``` + A new Expr representing the length of the array. | +| [as(name)](./firestore_.field.md#fieldas) | | (BETA) Assigns an alias to this expression.Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. +```typescript +// Calculate the total price and assign it the alias "totalPrice" and add it to the output. +firestore.pipeline().collection("items") +.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + +``` + | +| [ascending()](./firestore_.field.md#fieldascending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. +```typescript +// Sort documents by the 'name' field in ascending order +pipeline().collection("users") +.sort(Field.of("name").ascending()); + +``` + A new Ordering for ascending sorting. | +| [avg()](./firestore_.field.md#fieldavg) | | (BETA) Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. +```typescript +// Calculate the average age of users +Field.of("age").avg().as("averageAge"); + +``` + A new Accumulator representing the 'avg' aggregation. | +| [byteLength()](./firestore_.field.md#fieldbytelength) | | (BETA) Creates an expression that calculates the length of this string expression in bytes. +```typescript +// Calculate the length of the 'myString' field in bytes. +Field.of("myString").byteLength(); + +``` + A new representing the length of the string in bytes. | +| [charLength()](./firestore_.field.md#fieldcharlength) | | (BETA) Creates an expression that calculates the character length of a string in UTF-8. +```typescript +// Get the character length of the 'name' field in its UTF-8 form. +Field.of("name").charLength(); + +``` + A new Expr representing the length of the string. | +| [cosineDistance(other)](./firestore_.field.md#fieldcosinedistance) | | (BETA) Calculates the cosine distance between two vectors. +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +Field.of("userVector").cosineDistance(Field.of("itemVector")); + +``` + | +| [cosineDistance(other)](./firestore_.field.md#fieldcosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + +``` + | +| [cosineDistance(other)](./firestore_.field.md#fieldcosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance([37.7749, -122.4194]); + +``` + | +| [count()](./firestore_.field.md#fieldcount) | | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. +```typescript +// Count the total number of products +Field.of("productId").count().as("totalProducts"); + +``` + A new Accumulator representing the 'count' aggregation. | +| [descending()](./firestore_.field.md#fielddescending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") +.sort(Field.of("createdAt").descending()); + +``` + A new Ordering for descending sorting. | +| [divide(other)](./firestore_.field.md#fielddivide) | | (BETA) Creates an expression that divides this expression by another expression. +```typescript +// Divide the 'total' field by the 'count' field +Field.of("total").divide(Field.of("count")); + +``` + | +| [divide(other)](./firestore_.field.md#fielddivide) | | (BETA) Creates an expression that divides this expression by a constant value. +```typescript +// Divide the 'value' field by 10 +Field.of("value").divide(10); + +``` + | +| [dotProduct(other)](./firestore_.field.md#fielddotproduct) | | (BETA) Calculates the dot product between two vectors. +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct([0.5, 0.8, 0.2]); + +``` + | +| [dotProduct(other)](./firestore_.field.md#fielddotproduct) | | (BETA) Calculates the dot product between two vectors. +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + +``` + | +| [dotProduct(other)](./firestore_.field.md#fielddotproduct) | | (BETA) | +| [endsWith(suffix)](./firestore_.field.md#fieldendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix. +```typescript +// Check if the 'filename' field ends with ".txt" +Field.of("filename").endsWith(".txt"); + +``` + | +| [endsWith(suffix)](./firestore_.field.md#fieldendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix (represented as an expression). +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +Field.of("url").endsWith(Field.of("extension")); + +``` + | +| [eq(other)](./firestore_.field.md#fieldeq) | | (BETA) Creates an expression that checks if this expression is equal to another expression. +```typescript +// Check if the 'age' field is equal to 21 +Field.of("age").eq(21); + +``` + | +| [eq(other)](./firestore_.field.md#fieldeq) | | (BETA) Creates an expression that checks if this expression is equal to a constant value. +```typescript +// Check if the 'city' field is equal to "London" +Field.of("city").eq("London"); + +``` + | +| [euclideanDistance(other)](./firestore_.field.md#fieldeuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance([37.7749, -122.4194]); + +``` + | +| [euclideanDistance(other)](./firestore_.field.md#fieldeuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + +``` + | +| [euclideanDistance(other)](./firestore_.field.md#fieldeuclideandistance) | | (BETA) | +| [exists()](./firestore_.field.md#fieldexists) | | (BETA) Creates an expression that checks if a field exists in the document. +```typescript +// Check if the document has a field named "phoneNumber" +Field.of("phoneNumber").exists(); + +``` + A new Expr representing the 'exists' check. | +| [fieldName()](./firestore_.field.md#fieldfieldname) | | (BETA) | +| [gt(other)](./firestore_.field.md#fieldgt) | | (BETA) Creates an expression that checks if this expression is greater than another expression. +```typescript +// Check if the 'age' field is greater than the 'limit' field +Field.of("age").gt(Field.of("limit")); + +``` + | +| [gt(other)](./firestore_.field.md#fieldgt) | | (BETA) Creates an expression that checks if this expression is greater than a constant value. +```typescript +// Check if the 'price' field is greater than 100 +Field.of("price").gt(100); + +``` + | +| [gte(other)](./firestore_.field.md#fieldgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to another expression. +```typescript +// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 +Field.of("quantity").gte(Field.of('requirement').add(1)); + +``` + | +| [gte(other)](./firestore_.field.md#fieldgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to a constant value. +```typescript +// Check if the 'score' field is greater than or equal to 80 +Field.of("score").gte(80); + +``` + | +| [in(others)](./firestore_.field.md#fieldin) | | (BETA) Creates an expression that checks if this expression is equal to any of the provided values or expressions. +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +Field.of("category").in("Electronics", Field.of("primaryType")); + +``` + | +| [in(others)](./firestore_.field.md#fieldin) | | (BETA) | +| [isNaN()](./firestore_.field.md#fieldisnan) | | (BETA) Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). +```typescript +// Check if the result of a calculation is NaN +Field.of("value").divide(0).isNaN(); + +``` + A new Expr representing the 'isNaN' check. | +| [like(pattern)](./firestore_.field.md#fieldlike) | | (BETA) Creates an expression that performs a case-sensitive string comparison. +```typescript +// Check if the 'title' field contains the word "guide" (case-sensitive) +Field.of("title").like("%guide%"); + +``` + | +| [like(pattern)](./firestore_.field.md#fieldlike) | | (BETA) | +| [logicalMax(other)](./firestore_.field.md#fieldlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMax(Function.currentTimestamp()); + +``` + | +| [logicalMax(other)](./firestore_.field.md#fieldlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'value' field and 10. +Field.of("value").logicalMax(10); + +``` + | +| [logicalMin(other)](./firestore_.field.md#fieldlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMin(Function.currentTimestamp()); + +``` + | +| [logicalMin(other)](./firestore_.field.md#fieldlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'value' field and 10. +Field.of("value").logicalMin(10); + +``` + | +| [lt(other)](./firestore_.field.md#fieldlt) | | (BETA) Creates an expression that checks if this expression is less than another expression. +```typescript +// Check if the 'age' field is less than 'limit' +Field.of("age").lt(Field.of('limit')); + +``` + | +| [lt(other)](./firestore_.field.md#fieldlt) | | (BETA) Creates an expression that checks if this expression is less than a constant value. +```typescript +// Check if the 'price' field is less than 50 +Field.of("price").lt(50); + +``` + | +| [lte(other)](./firestore_.field.md#fieldlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to another expression. +```typescript +// Check if the 'quantity' field is less than or equal to 20 +Field.of("quantity").lte(Constant.of(20)); + +``` + | +| [lte(other)](./firestore_.field.md#fieldlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to a constant value. +```typescript +// Check if the 'score' field is less than or equal to 70 +Field.of("score").lte(70); + +``` + | +| [mapGet(subfield)](./firestore_.field.md#fieldmapget) | | (BETA) Accesses a value from a map (object) field using the provided key. +```typescript +// Get the 'city' value from the 'address' map field +Field.of("address").mapGet("city"); + +``` + | +| [max()](./firestore_.field.md#fieldmax) | | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. +```typescript +// Find the highest score in a leaderboard +Field.of("score").max().as("highestScore"); + +``` + A new Accumulator representing the 'max' aggregation. | +| [min()](./firestore_.field.md#fieldmin) | | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. +```typescript +// Find the lowest price of all products +Field.of("price").min().as("lowestPrice"); + +``` + A new Accumulator representing the 'min' aggregation. | +| [mod(other)](./firestore_.field.md#fieldmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. +```typescript +// Calculate the remainder of dividing the 'value' field by the 'divisor' field +Field.of("value").mod(Field.of("divisor")); + +``` + | +| [mod(other)](./firestore_.field.md#fieldmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. +```typescript +// Calculate the remainder of dividing the 'value' field by 10 +Field.of("value").mod(10); + +``` + | +| [multiply(other)](./firestore_.field.md#fieldmultiply) | | (BETA) Creates an expression that multiplies this expression by another expression. +```typescript +// Multiply the 'quantity' field by the 'price' field +Field.of("quantity").multiply(Field.of("price")); + +``` + | +| [multiply(other)](./firestore_.field.md#fieldmultiply) | | (BETA) Creates an expression that multiplies this expression by a constant value. +```typescript +// Multiply the 'value' field by 2 +Field.of("value").multiply(2); + +``` + | +| [neq(other)](./firestore_.field.md#fieldneq) | | (BETA) Creates an expression that checks if this expression is not equal to another expression. +```typescript +// Check if the 'status' field is not equal to "completed" +Field.of("status").neq("completed"); + +``` + | +| [neq(other)](./firestore_.field.md#fieldneq) | | (BETA) Creates an expression that checks if this expression is not equal to a constant value. +```typescript +// Check if the 'country' field is not equal to "USA" +Field.of("country").neq("USA"); + +``` + | +| [of(name)](./firestore_.field.md#fieldof) | static | (BETA) Creates a instance representing the field at the given path.The path can be a simple field name (e.g., "name") or a dot-separated path to a nested field (e.g., "address.city"). +```typescript +// Create a Field instance for the 'title' field +const titleField = Field.of("title"); + +// Create a Field instance for a nested field 'author.firstName' +const authorFirstNameField = Field.of("author.firstName"); + +``` + | +| [of(path)](./firestore_.field.md#fieldof) | static | (BETA) | +| [of(pipeline, name)](./firestore_.field.md#fieldof) | static | (BETA) | +| [regexContains(pattern)](./firestore_.field.md#fieldregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +Field.of("description").regexContains("(?i)example"); + +``` + | +| [regexContains(pattern)](./firestore_.field.md#fieldregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains the regular expression stored in field 'regex' +Field.of("description").regexContains(Field.of("regex")); + +``` + | +| [regexMatch(pattern)](./firestore_.field.md#fieldregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. +```typescript +// Check if the 'email' field matches a valid email pattern +Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + | +| [regexMatch(pattern)](./firestore_.field.md#fieldregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. +```typescript +// Check if the 'email' field matches a regular expression stored in field 'regex' +Field.of("email").regexMatch(Field.of("regex")); + +``` + | +| [replaceAll(find, replace)](./firestore_.field.md#fieldreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring. +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field +Field.of("message").replaceAll("hello", "hi"); + +``` + | +| [replaceAll(find, replace)](./firestore_.field.md#fieldreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + +``` + | +| [replaceFirst(find, replace)](./firestore_.field.md#fieldreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field +Field.of("message").replaceFirst("hello", "hi"); + +``` + | +| [replaceFirst(find, replace)](./firestore_.field.md#fieldreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + +``` + | +| [reverse()](./firestore_.field.md#fieldreverse) | | (BETA) Creates an expression that reverses this string expression. +```typescript +// Reverse the value of the 'myString' field. +Field.of("myString").reverse(); + +``` + A new representing the reversed string. | +| [startsWith(prefix)](./firestore_.field.md#fieldstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix. +```typescript +// Check if the 'name' field starts with "Mr." +Field.of("name").startsWith("Mr."); + +``` + | +| [startsWith(prefix)](./firestore_.field.md#fieldstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix (represented as an expression). +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +Field.of("fullName").startsWith(Field.of("firstName")); + +``` + | +| [strConcat(elements)](./firestore_.field.md#fieldstrconcat) | | (BETA) Creates an expression that concatenates string expressions together. +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + +``` + | +| [strContains(substring)](./firestore_.field.md#fieldstrcontains) | | (BETA) Creates an expression that checks if a string contains a specified substring. +```typescript +// Check if the 'description' field contains "example". +Field.of("description").strContains("example"); + +``` + | +| [strContains(expr)](./firestore_.field.md#fieldstrcontains) | | (BETA) Creates an expression that checks if a string contains the string represented by another expression. +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +Field.of("description").strContains(Field.of("keyword")); + +``` + | +| [subtract(other)](./firestore_.field.md#fieldsubtract) | | (BETA) Creates an expression that subtracts another expression from this expression. +```typescript +// Subtract the 'discount' field from the 'price' field +Field.of("price").subtract(Field.of("discount")); + +``` + | +| [subtract(other)](./firestore_.field.md#fieldsubtract) | | (BETA) Creates an expression that subtracts a constant value from this expression. +```typescript +// Subtract 20 from the value of the 'total' field +Field.of("total").subtract(20); + +``` + | +| [sum()](./firestore_.field.md#fieldsum) | | (BETA) Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. +```typescript +// Calculate the total revenue from a set of orders +Field.of("orderAmount").sum().as("totalRevenue"); + +``` + A new Accumulator representing the 'sum' aggregation. | +| [timestampAdd(unit, amount)](./firestore_.field.md#fieldtimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampAdd(unit, amount)](./firestore_.field.md#fieldtimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. +```typescript +// Add 1 day to the 'timestamp' field. +Field.of("timestamp").timestampAdd("day", 1); + +``` + | +| [timestampSub(unit, amount)](./firestore_.field.md#fieldtimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampSub(unit, amount)](./firestore_.field.md#fieldtimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. +```typescript +// Subtract 1 day from the 'timestamp' field. +Field.of("timestamp").timestampSub("day", 1); + +``` + | +| [timestampToUnixMicros()](./firestore_.field.md#fieldtimestamptounixmicros) | | (BETA) Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +Field.of("timestamp").timestampToUnixMicros(); + +``` + A new representing the number of microseconds since epoch. | +| [timestampToUnixMillis()](./firestore_.field.md#fieldtimestamptounixmillis) | | (BETA) Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +Field.of("timestamp").timestampToUnixMillis(); + +``` + A new representing the number of milliseconds since epoch. | +| [timestampToUnixSeconds()](./firestore_.field.md#fieldtimestamptounixseconds) | | (BETA) Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to seconds since epoch. +Field.of("timestamp").timestampToUnixSeconds(); + +``` + A new representing the number of seconds since epoch. | +| [toLower()](./firestore_.field.md#fieldtolower) | | (BETA) Creates an expression that converts a string to lowercase. +```typescript +// Convert the 'name' field to lowercase +Field.of("name").toLower(); + +``` + A new Expr representing the lowercase string. | +| [toUpper()](./firestore_.field.md#fieldtoupper) | | (BETA) Creates an expression that converts a string to uppercase. +```typescript +// Convert the 'title' field to uppercase +Field.of("title").toUpper(); + +``` + A new Expr representing the uppercase string. | +| [trim()](./firestore_.field.md#fieldtrim) | | (BETA) Creates an expression that removes leading and trailing whitespace from a string. +```typescript +// Trim whitespace from the 'userInput' field +Field.of("userInput").trim(); + +``` + A new Expr representing the trimmed string. | +| [unixMicrosToTimestamp()](./firestore_.field.md#fieldunixmicrostotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +Field.of("microseconds").unixMicrosToTimestamp(); + +``` + A new representing the timestamp. | +| [unixMillisToTimestamp()](./firestore_.field.md#fieldunixmillistotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +Field.of("milliseconds").unixMillisToTimestamp(); + +``` + A new representing the timestamp. | +| [unixSecondsToTimestamp()](./firestore_.field.md#fieldunixsecondstotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'seconds' field as seconds since epoch. +Field.of("seconds").unixSecondsToTimestamp(); + +``` + A new representing the timestamp. | +| [vectorLength()](./firestore_.field.md#fieldvectorlength) | | (BETA) Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. +```typescript +// Get the vector length (dimension) of the field 'embedding'. +Field.of("embedding").vectorLength(); + +``` + A new representing the length of the vector. | + +## Field.exprType + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +exprType: ExprType; +``` + +## Field.selectable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +selectable: true; +``` + +## Field.add() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds this expression to another expression. + +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +Field.of("quantity").add(Field.of("reserve")); + +``` + +Signature: + +```typescript +add(other: Constant): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to add to this expression. A new Expr representing the addition operation. | + +Returns: + +[Add](./firestore_.add.md#add_class) + +## Field.add() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds this expression to a constant value. + +```typescript +// Add 5 to the value of the 'age' field +Field.of("age").add(5); + +``` + +Signature: + +```typescript +add(other: any): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to add. A new Expr representing the addition operation. | + +Returns: + +[Add](./firestore_.add.md#add_class) + +## Field.arrayConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with one or more other arrays. + +```typescript +// Combine the 'items' array with another array field. +Field.of("items").arrayConcat(Field.of("otherItems")); + +``` + +Signature: + +```typescript +arrayConcat(arrays: Constant[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrays | [Constant](./firestore_.constant.md#constant_class)\[\] | The array expressions to concatenate. A new Expr representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) + +## Field.arrayConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with one or more other arrays. + +```typescript +// Combine the 'tags' array with a new array and an array field +Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + +``` + +Signature: + +```typescript +arrayConcat(arrays: any[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrays | any\[\] | The array expressions or values to concatenate. A new Expr representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) + +## Field.arrayContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains a specific element. + +```typescript +// Check if the 'sizes' array contains the value from the 'selectedSize' field +Field.of("sizes").arrayContains(Field.of("selectedSize")); + +``` + +Signature: + +```typescript +arrayContains(element: Constant): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | [Constant](./firestore_.constant.md#constant_class) | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) + +## Field.arrayContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains a specific value. + +```typescript +// Check if the 'colors' array contains "red" +Field.of("colors").arrayContains("red"); + +``` + +Signature: + +```typescript +arrayContains(element: any): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | any | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) + +## Field.arrayContainsAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both "news" and "sports" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + +Signature: + +```typescript +arrayContainsAll(...values: Constant[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) + +## Field.arrayContainsAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + +Signature: + +```typescript +arrayContainsAll(...values: any[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) + +## Field.arrayContainsAny() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains any of the specified elements. + +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "cate2" +Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + +``` + +Signature: + +```typescript +arrayContainsAny(...values: Constant[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) + +## Field.arrayContainsAny() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains any of the specified elements. + +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + +``` + +Signature: + +```typescript +arrayContainsAny(...values: any[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) + +## Field.arrayLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of an array. + +```typescript +// Get the number of items in the 'cart' array +Field.of("cart").arrayLength(); + +``` + A new `Expr` representing the length of the array. + +Signature: + +```typescript +arrayLength(): ArrayLength; +``` +Returns: + +[ArrayLength](./firestore_.arraylength.md#arraylength_class) + +## Field.as() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Assigns an alias to this expression. + +Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. + +```typescript +// Calculate the total price and assign it the alias "totalPrice" and add it to the output. +firestore.pipeline().collection("items") +.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + +``` + +Signature: + +```typescript +as(name: string): ExprWithAlias; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | The alias to assign to this expression. A new [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) that wraps this expression and associates it with the provided alias. | + +Returns: + +[ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class)<this> + +## Field.ascending() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. + +```typescript +// Sort documents by the 'name' field in ascending order +pipeline().collection("users") +.sort(Field.of("name").ascending()); + +``` + A new `Ordering` for ascending sorting. + +Signature: + +```typescript +ascending(): Ordering; +``` +Returns: + +[Ordering](./firestore_.ordering.md#ordering_class) + +## Field.avg() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. + +```typescript +// Calculate the average age of users +Field.of("age").avg().as("averageAge"); + +``` + A new `Accumulator` representing the 'avg' aggregation. + +Signature: + +```typescript +avg(): Avg; +``` +Returns: + +[Avg](./firestore_.avg.md#avg_class) + +## Field.byteLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of this string expression in bytes. + +```typescript +// Calculate the length of the 'myString' field in bytes. +Field.of("myString").byteLength(); + +``` + A new representing the length of the string in bytes. + +Signature: + +```typescript +byteLength(): ByteLength; +``` +Returns: + +[ByteLength](./firestore_.bytelength.md#bytelength_class) + +## Field.charLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the character length of a string in UTF-8. + +```typescript +// Get the character length of the 'name' field in its UTF-8 form. +Field.of("name").charLength(); + +``` + A new `Expr` representing the length of the string. + +Signature: + +```typescript +charLength(): CharLength; +``` +Returns: + +[CharLength](./firestore_.charlength.md#charlength_class) + +## Field.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the cosine distance between two vectors. + +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +Field.of("userVector").cosineDistance(Field.of("itemVector")); + +``` + +Signature: + +```typescript +cosineDistance(other: Constant): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new Expr representing the cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) + +## Field.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vectors. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +cosineDistance(other: VectorValue): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) + +## Field.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vectors. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance([37.7749, -122.4194]); + +``` + +Signature: + +```typescript +cosineDistance(other: number[]): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | The other vector (as an array of numbers) to compare against. A new Expr representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) + +## Field.count() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. + +```typescript +// Count the total number of products +Field.of("productId").count().as("totalProducts"); + +``` + A new `Accumulator` representing the 'count' aggregation. + +Signature: + +```typescript +count(): Count; +``` +Returns: + +[Count](./firestore_.count.md#count_class) + +## Field.descending() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. + +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") +.sort(Field.of("createdAt").descending()); + +``` + A new `Ordering` for descending sorting. + +Signature: + +```typescript +descending(): Ordering; +``` +Returns: + +[Ordering](./firestore_.ordering.md#ordering_class) + +## Field.divide() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides this expression by another expression. + +```typescript +// Divide the 'total' field by the 'count' field +Field.of("total").divide(Field.of("count")); + +``` + +Signature: + +```typescript +divide(other: Constant): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new Expr representing the division operation. | + +Returns: + +[Divide](./firestore_.divide.md#divide_class) + +## Field.divide() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides this expression by a constant value. + +```typescript +// Divide the 'value' field by 10 +Field.of("value").divide(10); + +``` + +Signature: + +```typescript +divide(other: any): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to divide by. A new Expr representing the division operation. | + +Returns: + +[Divide](./firestore_.divide.md#divide_class) + +## Field.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vectors. + +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct([0.5, 0.8, 0.2]); + +``` + +Signature: + +```typescript +dotProduct(other: Constant): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_.dotproduct.md#dotproduct_class) + +## Field.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vectors. + +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + +``` + +Signature: + +```typescript +dotProduct(other: VectorValue): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_.dotproduct.md#dotproduct_class) + +## Field.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +dotProduct(other: number[]): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | | + +Returns: + +[DotProduct](./firestore_.dotproduct.md#dotproduct_class) + +## Field.endsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string ends with a given postfix. + +```typescript +// Check if the 'filename' field ends with ".txt" +Field.of("filename").endsWith(".txt"); + +``` + +Signature: + +```typescript +endsWith(suffix: string): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| suffix | string | The postfix to check for. A new Expr representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_.endswith.md#endswith_class) + +## Field.endsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string ends with a given postfix (represented as an expression). + +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +Field.of("url").endsWith(Field.of("extension")); + +``` + +Signature: + +```typescript +endsWith(suffix: Constant): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| suffix | [Constant](./firestore_.constant.md#constant_class) | The postfix expression to check for. A new Expr representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_.endswith.md#endswith_class) + +## Field.eq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to another expression. + +```typescript +// Check if the 'age' field is equal to 21 +Field.of("age").eq(21); + +``` + +Signature: + +```typescript +eq(other: Constant): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for equality. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_.eq.md#eq_class) + +## Field.eq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to a constant value. + +```typescript +// Check if the 'city' field is equal to "London" +Field.of("city").eq("London"); + +``` + +Signature: + +```typescript +eq(other: any): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for equality. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_.eq.md#eq_class) + +## Field.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vectors. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance([37.7749, -122.4194]); + +``` + +Signature: + +```typescript +euclideanDistance(other: Constant): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) + +## Field.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vectors. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +euclideanDistance(other: VectorValue): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) + +## Field.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +euclideanDistance(other: number[]): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | | + +Returns: + +[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) + +## Field.exists() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field exists in the document. + +```typescript +// Check if the document has a field named "phoneNumber" +Field.of("phoneNumber").exists(); + +``` + A new `Expr` representing the 'exists' check. + +Signature: + +```typescript +exists(): Exists; +``` +Returns: + +[Exists](./firestore_.exists.md#exists_class) + +## Field.fieldName() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +fieldName(): string; +``` +Returns: + +string + +## Field.gt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than another expression. + +```typescript +// Check if the 'age' field is greater than the 'limit' field +Field.of("age").gt(Field.of("limit")); + +``` + +Signature: + +```typescript +gt(other: Constant): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for greater than. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_.gt.md#gt_class) + +## Field.gt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than a constant value. + +```typescript +// Check if the 'price' field is greater than 100 +Field.of("price").gt(100); + +``` + +Signature: + +```typescript +gt(other: any): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for greater than. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_.gt.md#gt_class) + +## Field.gte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than or equal to another expression. + +```typescript +// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 +Field.of("quantity").gte(Field.of('requirement').add(1)); + +``` + +Signature: + +```typescript +gte(other: Constant): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_.gte.md#gte_class) + +## Field.gte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than or equal to a constant value. + +```typescript +// Check if the 'score' field is greater than or equal to 80 +Field.of("score").gte(80); + +``` + +Signature: + +```typescript +gte(other: any): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_.gte.md#gte_class) + +## Field.in() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to any of the provided values or expressions. + +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +Field.of("category").in("Electronics", Field.of("primaryType")); + +``` + +Signature: + +```typescript +in(...others: Constant[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| others | [Constant](./firestore_.constant.md#constant_class)\[\] | The values or expressions to check against. A new Expr representing the 'IN' comparison. | + +Returns: + +[In](./firestore_.in.md#in_class) + +## Field.in() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +in(...others: any[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| others | any\[\] | | + +Returns: + +[In](./firestore_.in.md#in_class) + +## Field.isNaN() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). + +```typescript +// Check if the result of a calculation is NaN +Field.of("value").divide(0).isNaN(); + +``` + A new `Expr` representing the 'isNaN' check. + +Signature: + +```typescript +isNaN(): IsNan; +``` +Returns: + +[IsNan](./firestore_.isnan.md#isnan_class) + +## Field.like() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that performs a case-sensitive string comparison. + +```typescript +// Check if the 'title' field contains the word "guide" (case-sensitive) +Field.of("title").like("%guide%"); + +``` + +Signature: + +```typescript +like(pattern: string): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new Expr representing the 'like' comparison. | + +Returns: + +[Like](./firestore_.like.md#like_class) + +## Field.like() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +like(pattern: Constant): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_.constant.md#constant_class) | | + +Returns: + +[Like](./firestore_.like.md#like_class) + +## Field.logicalMax() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMax(Function.currentTimestamp()); + +``` + +Signature: + +```typescript +logicalMax(other: Constant): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare with. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) + +## Field.logicalMax() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'value' field and 10. +Field.of("value").logicalMax(10); + +``` + +Signature: + +```typescript +logicalMax(other: any): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare with. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) + +## Field.logicalMin() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMin(Function.currentTimestamp()); + +``` + +Signature: + +```typescript +logicalMin(other: Constant): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare with. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) + +## Field.logicalMin() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'value' field and 10. +Field.of("value").logicalMin(10); + +``` + +Signature: + +```typescript +logicalMin(other: any): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare with. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) + +## Field.lt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than another expression. + +```typescript +// Check if the 'age' field is less than 'limit' +Field.of("age").lt(Field.of('limit')); + +``` + +Signature: + +```typescript +lt(other: Constant): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for less than. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_.lt.md#lt_class) + +## Field.lt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than a constant value. + +```typescript +// Check if the 'price' field is less than 50 +Field.of("price").lt(50); + +``` + +Signature: + +```typescript +lt(other: any): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for less than. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_.lt.md#lt_class) + +## Field.lte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than or equal to another expression. + +```typescript +// Check if the 'quantity' field is less than or equal to 20 +Field.of("quantity").lte(Constant.of(20)); + +``` + +Signature: + +```typescript +lte(other: Constant): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_.lte.md#lte_class) + +## Field.lte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than or equal to a constant value. + +```typescript +// Check if the 'score' field is less than or equal to 70 +Field.of("score").lte(70); + +``` + +Signature: + +```typescript +lte(other: any): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_.lte.md#lte_class) + +## Field.mapGet() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Accesses a value from a map (object) field using the provided key. + +```typescript +// Get the 'city' value from the 'address' map field +Field.of("address").mapGet("city"); + +``` + +Signature: + +```typescript +mapGet(subfield: string): MapGet; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| subfield | string | The key to access in the map. A new Expr representing the value associated with the given key in the map. | + +Returns: + +[MapGet](./firestore_.mapget.md#mapget_class) + +## Field.max() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that finds the maximum value of a field across multiple stage inputs. + +```typescript +// Find the highest score in a leaderboard +Field.of("score").max().as("highestScore"); + +``` + A new `Accumulator` representing the 'max' aggregation. + +Signature: + +```typescript +max(): Max; +``` +Returns: + +[Max](./firestore_.max.md#max_class) + +## Field.min() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that finds the minimum value of a field across multiple stage inputs. + +```typescript +// Find the lowest price of all products +Field.of("price").min().as("lowestPrice"); + +``` + A new `Accumulator` representing the 'min' aggregation. + +Signature: + +```typescript +min(): Min; +``` +Returns: + +[Min](./firestore_.min.md#min_class) + +## Field.mod() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. + +```typescript +// Calculate the remainder of dividing the 'value' field by the 'divisor' field +Field.of("value").mod(Field.of("divisor")); + +``` + +Signature: + +```typescript +mod(other: Constant): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new Expr representing the modulo operation. | + +Returns: + +[Mod](./firestore_.mod.md#mod_class) + +## Field.mod() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. + +```typescript +// Calculate the remainder of dividing the 'value' field by 10 +Field.of("value").mod(10); + +``` + +Signature: + +```typescript +mod(other: any): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to divide by. A new Expr representing the modulo operation. | + +Returns: + +[Mod](./firestore_.mod.md#mod_class) + +## Field.multiply() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies this expression by another expression. + +```typescript +// Multiply the 'quantity' field by the 'price' field +Field.of("quantity").multiply(Field.of("price")); + +``` + +Signature: + +```typescript +multiply(other: Constant): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to multiply by. A new Expr representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_.multiply.md#multiply_class) + +## Field.multiply() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies this expression by a constant value. + +```typescript +// Multiply the 'value' field by 2 +Field.of("value").multiply(2); + +``` + +Signature: + +```typescript +multiply(other: any): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to multiply by. A new Expr representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_.multiply.md#multiply_class) + +## Field.neq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is not equal to another expression. + +```typescript +// Check if the 'status' field is not equal to "completed" +Field.of("status").neq("completed"); + +``` + +Signature: + +```typescript +neq(other: Constant): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for inequality. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_.neq.md#neq_class) + +## Field.neq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is not equal to a constant value. + +```typescript +// Check if the 'country' field is not equal to "USA" +Field.of("country").neq("USA"); + +``` + +Signature: + +```typescript +neq(other: any): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for inequality. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_.neq.md#neq_class) + +## Field.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a instance representing the field at the given path. + +The path can be a simple field name (e.g., "name") or a dot-separated path to a nested field (e.g., "address.city"). + +```typescript +// Create a Field instance for the 'title' field +const titleField = Field.of("title"); + +// Create a Field instance for a nested field 'author.firstName' +const authorFirstNameField = Field.of("author.firstName"); + +``` + +Signature: + +```typescript +static of(name: string): Field; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | The path to the field. A new instance representing the specified field. | + +Returns: + +[Field](./firestore_.field.md#field_class) + +## Field.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +static of(path: FieldPath): Field; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| path | [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | | + +Returns: + +[Field](./firestore_.field.md#field_class) + +## Field.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +static of(pipeline: Pipeline, name: string): Field; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pipeline | [Pipeline](./firestore_.pipeline.md#pipeline_class) | | +| name | string | | + +Returns: + +[Field](./firestore_.field.md#field_class) + +## Field.regexContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +Field.of("description").regexContains("(?i)example"); + +``` + +Signature: + +```typescript +regexContains(pattern: string): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_.regexcontains.md#regexcontains_class) + +## Field.regexContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains the regular expression stored in field 'regex' +Field.of("description").regexContains(Field.of("regex")); + +``` + +Signature: + +```typescript +regexContains(pattern: Constant): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_.regexcontains.md#regexcontains_class) + +## Field.regexMatch() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a valid email pattern +Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + +Signature: + +```typescript +regexMatch(pattern: string): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The regular expression to use for the match. A new Expr representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) + +## Field.regexMatch() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a regular expression stored in field 'regex' +Field.of("email").regexMatch(Field.of("regex")); + +``` + +Signature: + +```typescript +regexMatch(pattern: Constant): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the match. A new Expr representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) + +## Field.replaceAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within this string expression with another substring. + +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field +Field.of("message").replaceAll("hello", "hi"); + +``` + +Signature: + +```typescript +replaceAll(find: string, replace: string): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | string | The substring to search for. | +| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_.replaceall.md#replaceall_class) + +## Field.replaceAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + +``` + +Signature: + +```typescript +replaceAll(find: Constant, replace: Constant): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_.replaceall.md#replaceall_class) + +## Field.replaceFirst() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. + +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field +Field.of("message").replaceFirst("hello", "hi"); + +``` + +Signature: + +```typescript +replaceFirst(find: string, replace: string): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | string | The substring to search for. | +| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) + +## Field.replaceFirst() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + +``` + +Signature: + +```typescript +replaceFirst(find: Constant, replace: Constant): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) + +## Field.reverse() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that reverses this string expression. + +```typescript +// Reverse the value of the 'myString' field. +Field.of("myString").reverse(); + +``` + A new representing the reversed string. + +Signature: + +```typescript +reverse(): Reverse; +``` +Returns: + +[Reverse](./firestore_.reverse.md#reverse_class) + +## Field.startsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string starts with a given prefix. + +```typescript +// Check if the 'name' field starts with "Mr." +Field.of("name").startsWith("Mr."); + +``` + +Signature: + +```typescript +startsWith(prefix: string): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| prefix | string | The prefix to check for. A new Expr representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_.startswith.md#startswith_class) + +## Field.startsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string starts with a given prefix (represented as an expression). + +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +Field.of("fullName").startsWith(Field.of("firstName")); + +``` + +Signature: + +```typescript +startsWith(prefix: Constant): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| prefix | [Constant](./firestore_.constant.md#constant_class) | The prefix expression to check for. A new Expr representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_.startswith.md#startswith_class) + +## Field.strConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates string expressions together. + +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + +``` + +Signature: + +```typescript +strConcat(...elements: Array): StrConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| elements | Array<string \| [Constant](./firestore_.constant.md#constant_class)> | The expressions (typically strings) to concatenate. A new Expr representing the concatenated string. | + +Returns: + +[StrConcat](./firestore_.strconcat.md#strconcat_class) + +## Field.strContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified substring. + +```typescript +// Check if the 'description' field contains "example". +Field.of("description").strContains("example"); + +``` + +Signature: + +```typescript +strContains(substring: string): StrContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| substring | string | The substring to search for. A new Expr representing the 'contains' comparison. | + +Returns: + +[StrContains](./firestore_.strcontains.md#strcontains_class) + +## Field.strContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains the string represented by another expression. + +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +Field.of("description").strContains(Field.of("keyword")); + +``` + +Signature: + +```typescript +strContains(expr: Constant): StrContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. A new Expr representing the 'contains' comparison. | + +Returns: + +[StrContains](./firestore_.strcontains.md#strcontains_class) + +## Field.subtract() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts another expression from this expression. + +```typescript +// Subtract the 'discount' field from the 'price' field +Field.of("price").subtract(Field.of("discount")); + +``` + +Signature: + +```typescript +subtract(other: Constant): Subtract; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to subtract from this expression. A new Expr representing the subtraction operation. | + +Returns: + +[Subtract](./firestore_.subtract.md#subtract_class) + +## Field.subtract() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a constant value from this expression. + +```typescript +// Subtract 20 from the value of the 'total' field +Field.of("total").subtract(20); + +``` + +Signature: + +```typescript +subtract(other: any): Subtract; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to subtract. A new Expr representing the subtraction operation. | + +Returns: + +[Subtract](./firestore_.subtract.md#subtract_class) + +## Field.sum() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. + +```typescript +// Calculate the total revenue from a set of orders +Field.of("orderAmount").sum().as("totalRevenue"); + +``` + A new `Accumulator` representing the 'sum' aggregation. + +Signature: + +```typescript +sum(): Sum; +``` +Returns: + +[Sum](./firestore_.sum.md#sum_class) + +## Field.timestampAdd() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to this timestamp expression. + +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + +``` + +Signature: + +```typescript +timestampAdd(unit: Constant, amount: Constant): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) + +## Field.timestampAdd() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to this timestamp expression. + +```typescript +// Add 1 day to the 'timestamp' field. +Field.of("timestamp").timestampAdd("day", 1); + +``` + +Signature: + +```typescript +timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | +| amount | number | The amount of time to add. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) + +## Field.timestampSub() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from this timestamp expression. + +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + +``` + +Signature: + +```typescript +timestampSub(unit: Constant, amount: Constant): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) + +## Field.timestampSub() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from this timestamp expression. + +```typescript +// Subtract 1 day from the 'timestamp' field. +Field.of("timestamp").timestampSub("day", 1); + +``` + +Signature: + +```typescript +timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | +| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) + +## Field.timestampToUnixMicros() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +Field.of("timestamp").timestampToUnixMicros(); + +``` + A new representing the number of microseconds since epoch. + +Signature: + +```typescript +timestampToUnixMicros(): TimestampToUnixMicros; +``` +Returns: + +[TimestampToUnixMicros](./firestore_.timestamptounixmicros.md#timestamptounixmicros_class) + +## Field.timestampToUnixMillis() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +Field.of("timestamp").timestampToUnixMillis(); + +``` + A new representing the number of milliseconds since epoch. + +Signature: + +```typescript +timestampToUnixMillis(): TimestampToUnixMillis; +``` +Returns: + +[TimestampToUnixMillis](./firestore_.timestamptounixmillis.md#timestamptounixmillis_class) + +## Field.timestampToUnixSeconds() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to seconds since epoch. +Field.of("timestamp").timestampToUnixSeconds(); + +``` + A new representing the number of seconds since epoch. + +Signature: + +```typescript +timestampToUnixSeconds(): TimestampToUnixSeconds; +``` +Returns: + +[TimestampToUnixSeconds](./firestore_.timestamptounixseconds.md#timestamptounixseconds_class) + +## Field.toLower() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string to lowercase. + +```typescript +// Convert the 'name' field to lowercase +Field.of("name").toLower(); + +``` + A new `Expr` representing the lowercase string. + +Signature: + +```typescript +toLower(): ToLower; +``` +Returns: + +[ToLower](./firestore_.tolower.md#tolower_class) + +## Field.toUpper() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string to uppercase. + +```typescript +// Convert the 'title' field to uppercase +Field.of("title").toUpper(); + +``` + A new `Expr` representing the uppercase string. + +Signature: + +```typescript +toUpper(): ToUpper; +``` +Returns: + +[ToUpper](./firestore_.toupper.md#toupper_class) + +## Field.trim() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that removes leading and trailing whitespace from a string. + +```typescript +// Trim whitespace from the 'userInput' field +Field.of("userInput").trim(); + +``` + A new `Expr` representing the trimmed string. + +Signature: + +```typescript +trim(): Trim; +``` +Returns: + +[Trim](./firestore_.trim.md#trim_class) + +## Field.unixMicrosToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +Field.of("microseconds").unixMicrosToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixMicrosToTimestamp(): UnixMicrosToTimestamp; +``` +Returns: + +[UnixMicrosToTimestamp](./firestore_.unixmicrostotimestamp.md#unixmicrostotimestamp_class) + +## Field.unixMillisToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +Field.of("milliseconds").unixMillisToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixMillisToTimestamp(): UnixMillisToTimestamp; +``` +Returns: + +[UnixMillisToTimestamp](./firestore_.unixmillistotimestamp.md#unixmillistotimestamp_class) + +## Field.unixSecondsToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'seconds' field as seconds since epoch. +Field.of("seconds").unixSecondsToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixSecondsToTimestamp(): UnixSecondsToTimestamp; +``` +Returns: + +[UnixSecondsToTimestamp](./firestore_.unixsecondstotimestamp.md#unixsecondstotimestamp_class) + +## Field.vectorLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. + +```typescript +// Get the vector length (dimension) of the field 'embedding'. +Field.of("embedding").vectorLength(); + +``` + A new representing the length of the vector. + +Signature: + +```typescript +vectorLength(): VectorLength; +``` +Returns: + +[VectorLength](./firestore_.vectorlength.md#vectorlength_class) + diff --git a/docs-devsite/firestore_.fields.md b/docs-devsite/firestore_.fields.md new file mode 100644 index 00000000000..8baec029555 --- /dev/null +++ b/docs-devsite/firestore_.fields.md @@ -0,0 +1,3210 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Fields class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Fields implements Selectable +``` +Implements: [Selectable](./firestore_.selectable.md#selectable_interface) + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [exprType](./firestore_.fields.md#fieldsexprtype) | | [ExprType](./firestore_.md#exprtype) | (BETA) | +| [selectable](./firestore_.fields.md#fieldsselectable) | | true | (BETA) | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [add(other)](./firestore_.fields.md#fieldsadd) | | (BETA) Creates an expression that adds this expression to another expression. +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +Field.of("quantity").add(Field.of("reserve")); + +``` + | +| [add(other)](./firestore_.fields.md#fieldsadd) | | (BETA) Creates an expression that adds this expression to a constant value. +```typescript +// Add 5 to the value of the 'age' field +Field.of("age").add(5); + +``` + | +| [arrayConcat(arrays)](./firestore_.fields.md#fieldsarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. +```typescript +// Combine the 'items' array with another array field. +Field.of("items").arrayConcat(Field.of("otherItems")); + +``` + | +| [arrayConcat(arrays)](./firestore_.fields.md#fieldsarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. +```typescript +// Combine the 'tags' array with a new array and an array field +Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + +``` + | +| [arrayContains(element)](./firestore_.fields.md#fieldsarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific element. +```typescript +// Check if the 'sizes' array contains the value from the 'selectedSize' field +Field.of("sizes").arrayContains(Field.of("selectedSize")); + +``` + | +| [arrayContains(element)](./firestore_.fields.md#fieldsarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific value. +```typescript +// Check if the 'colors' array contains "red" +Field.of("colors").arrayContains("red"); + +``` + | +| [arrayContainsAll(values)](./firestore_.fields.md#fieldsarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. +```typescript +// Check if the 'tags' array contains both "news" and "sports" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + | +| [arrayContainsAll(values)](./firestore_.fields.md#fieldsarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + | +| [arrayContainsAny(values)](./firestore_.fields.md#fieldsarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "cate2" +Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + +``` + | +| [arrayContainsAny(values)](./firestore_.fields.md#fieldsarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + +``` + | +| [arrayLength()](./firestore_.fields.md#fieldsarraylength) | | (BETA) Creates an expression that calculates the length of an array. +```typescript +// Get the number of items in the 'cart' array +Field.of("cart").arrayLength(); + +``` + A new Expr representing the length of the array. | +| [as(name)](./firestore_.fields.md#fieldsas) | | (BETA) Assigns an alias to this expression.Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. +```typescript +// Calculate the total price and assign it the alias "totalPrice" and add it to the output. +firestore.pipeline().collection("items") +.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + +``` + | +| [ascending()](./firestore_.fields.md#fieldsascending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. +```typescript +// Sort documents by the 'name' field in ascending order +pipeline().collection("users") +.sort(Field.of("name").ascending()); + +``` + A new Ordering for ascending sorting. | +| [avg()](./firestore_.fields.md#fieldsavg) | | (BETA) Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. +```typescript +// Calculate the average age of users +Field.of("age").avg().as("averageAge"); + +``` + A new Accumulator representing the 'avg' aggregation. | +| [byteLength()](./firestore_.fields.md#fieldsbytelength) | | (BETA) Creates an expression that calculates the length of this string expression in bytes. +```typescript +// Calculate the length of the 'myString' field in bytes. +Field.of("myString").byteLength(); + +``` + A new representing the length of the string in bytes. | +| [charLength()](./firestore_.fields.md#fieldscharlength) | | (BETA) Creates an expression that calculates the character length of a string in UTF-8. +```typescript +// Get the character length of the 'name' field in its UTF-8 form. +Field.of("name").charLength(); + +``` + A new Expr representing the length of the string. | +| [cosineDistance(other)](./firestore_.fields.md#fieldscosinedistance) | | (BETA) Calculates the cosine distance between two vectors. +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +Field.of("userVector").cosineDistance(Field.of("itemVector")); + +``` + | +| [cosineDistance(other)](./firestore_.fields.md#fieldscosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + +``` + | +| [cosineDistance(other)](./firestore_.fields.md#fieldscosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance([37.7749, -122.4194]); + +``` + | +| [count()](./firestore_.fields.md#fieldscount) | | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. +```typescript +// Count the total number of products +Field.of("productId").count().as("totalProducts"); + +``` + A new Accumulator representing the 'count' aggregation. | +| [descending()](./firestore_.fields.md#fieldsdescending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") +.sort(Field.of("createdAt").descending()); + +``` + A new Ordering for descending sorting. | +| [divide(other)](./firestore_.fields.md#fieldsdivide) | | (BETA) Creates an expression that divides this expression by another expression. +```typescript +// Divide the 'total' field by the 'count' field +Field.of("total").divide(Field.of("count")); + +``` + | +| [divide(other)](./firestore_.fields.md#fieldsdivide) | | (BETA) Creates an expression that divides this expression by a constant value. +```typescript +// Divide the 'value' field by 10 +Field.of("value").divide(10); + +``` + | +| [dotProduct(other)](./firestore_.fields.md#fieldsdotproduct) | | (BETA) Calculates the dot product between two vectors. +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct([0.5, 0.8, 0.2]); + +``` + | +| [dotProduct(other)](./firestore_.fields.md#fieldsdotproduct) | | (BETA) Calculates the dot product between two vectors. +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + +``` + | +| [dotProduct(other)](./firestore_.fields.md#fieldsdotproduct) | | (BETA) | +| [endsWith(suffix)](./firestore_.fields.md#fieldsendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix. +```typescript +// Check if the 'filename' field ends with ".txt" +Field.of("filename").endsWith(".txt"); + +``` + | +| [endsWith(suffix)](./firestore_.fields.md#fieldsendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix (represented as an expression). +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +Field.of("url").endsWith(Field.of("extension")); + +``` + | +| [eq(other)](./firestore_.fields.md#fieldseq) | | (BETA) Creates an expression that checks if this expression is equal to another expression. +```typescript +// Check if the 'age' field is equal to 21 +Field.of("age").eq(21); + +``` + | +| [eq(other)](./firestore_.fields.md#fieldseq) | | (BETA) Creates an expression that checks if this expression is equal to a constant value. +```typescript +// Check if the 'city' field is equal to "London" +Field.of("city").eq("London"); + +``` + | +| [euclideanDistance(other)](./firestore_.fields.md#fieldseuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance([37.7749, -122.4194]); + +``` + | +| [euclideanDistance(other)](./firestore_.fields.md#fieldseuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + +``` + | +| [euclideanDistance(other)](./firestore_.fields.md#fieldseuclideandistance) | | (BETA) | +| [exists()](./firestore_.fields.md#fieldsexists) | | (BETA) Creates an expression that checks if a field exists in the document. +```typescript +// Check if the document has a field named "phoneNumber" +Field.of("phoneNumber").exists(); + +``` + A new Expr representing the 'exists' check. | +| [fieldList()](./firestore_.fields.md#fieldsfieldlist) | | (BETA) | +| [gt(other)](./firestore_.fields.md#fieldsgt) | | (BETA) Creates an expression that checks if this expression is greater than another expression. +```typescript +// Check if the 'age' field is greater than the 'limit' field +Field.of("age").gt(Field.of("limit")); + +``` + | +| [gt(other)](./firestore_.fields.md#fieldsgt) | | (BETA) Creates an expression that checks if this expression is greater than a constant value. +```typescript +// Check if the 'price' field is greater than 100 +Field.of("price").gt(100); + +``` + | +| [gte(other)](./firestore_.fields.md#fieldsgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to another expression. +```typescript +// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 +Field.of("quantity").gte(Field.of('requirement').add(1)); + +``` + | +| [gte(other)](./firestore_.fields.md#fieldsgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to a constant value. +```typescript +// Check if the 'score' field is greater than or equal to 80 +Field.of("score").gte(80); + +``` + | +| [in(others)](./firestore_.fields.md#fieldsin) | | (BETA) Creates an expression that checks if this expression is equal to any of the provided values or expressions. +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +Field.of("category").in("Electronics", Field.of("primaryType")); + +``` + | +| [in(others)](./firestore_.fields.md#fieldsin) | | (BETA) | +| [isNaN()](./firestore_.fields.md#fieldsisnan) | | (BETA) Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). +```typescript +// Check if the result of a calculation is NaN +Field.of("value").divide(0).isNaN(); + +``` + A new Expr representing the 'isNaN' check. | +| [like(pattern)](./firestore_.fields.md#fieldslike) | | (BETA) Creates an expression that performs a case-sensitive string comparison. +```typescript +// Check if the 'title' field contains the word "guide" (case-sensitive) +Field.of("title").like("%guide%"); + +``` + | +| [like(pattern)](./firestore_.fields.md#fieldslike) | | (BETA) | +| [logicalMax(other)](./firestore_.fields.md#fieldslogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMax(Function.currentTimestamp()); + +``` + | +| [logicalMax(other)](./firestore_.fields.md#fieldslogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'value' field and 10. +Field.of("value").logicalMax(10); + +``` + | +| [logicalMin(other)](./firestore_.fields.md#fieldslogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMin(Function.currentTimestamp()); + +``` + | +| [logicalMin(other)](./firestore_.fields.md#fieldslogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'value' field and 10. +Field.of("value").logicalMin(10); + +``` + | +| [lt(other)](./firestore_.fields.md#fieldslt) | | (BETA) Creates an expression that checks if this expression is less than another expression. +```typescript +// Check if the 'age' field is less than 'limit' +Field.of("age").lt(Field.of('limit')); + +``` + | +| [lt(other)](./firestore_.fields.md#fieldslt) | | (BETA) Creates an expression that checks if this expression is less than a constant value. +```typescript +// Check if the 'price' field is less than 50 +Field.of("price").lt(50); + +``` + | +| [lte(other)](./firestore_.fields.md#fieldslte) | | (BETA) Creates an expression that checks if this expression is less than or equal to another expression. +```typescript +// Check if the 'quantity' field is less than or equal to 20 +Field.of("quantity").lte(Constant.of(20)); + +``` + | +| [lte(other)](./firestore_.fields.md#fieldslte) | | (BETA) Creates an expression that checks if this expression is less than or equal to a constant value. +```typescript +// Check if the 'score' field is less than or equal to 70 +Field.of("score").lte(70); + +``` + | +| [mapGet(subfield)](./firestore_.fields.md#fieldsmapget) | | (BETA) Accesses a value from a map (object) field using the provided key. +```typescript +// Get the 'city' value from the 'address' map field +Field.of("address").mapGet("city"); + +``` + | +| [max()](./firestore_.fields.md#fieldsmax) | | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. +```typescript +// Find the highest score in a leaderboard +Field.of("score").max().as("highestScore"); + +``` + A new Accumulator representing the 'max' aggregation. | +| [min()](./firestore_.fields.md#fieldsmin) | | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. +```typescript +// Find the lowest price of all products +Field.of("price").min().as("lowestPrice"); + +``` + A new Accumulator representing the 'min' aggregation. | +| [mod(other)](./firestore_.fields.md#fieldsmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. +```typescript +// Calculate the remainder of dividing the 'value' field by the 'divisor' field +Field.of("value").mod(Field.of("divisor")); + +``` + | +| [mod(other)](./firestore_.fields.md#fieldsmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. +```typescript +// Calculate the remainder of dividing the 'value' field by 10 +Field.of("value").mod(10); + +``` + | +| [multiply(other)](./firestore_.fields.md#fieldsmultiply) | | (BETA) Creates an expression that multiplies this expression by another expression. +```typescript +// Multiply the 'quantity' field by the 'price' field +Field.of("quantity").multiply(Field.of("price")); + +``` + | +| [multiply(other)](./firestore_.fields.md#fieldsmultiply) | | (BETA) Creates an expression that multiplies this expression by a constant value. +```typescript +// Multiply the 'value' field by 2 +Field.of("value").multiply(2); + +``` + | +| [neq(other)](./firestore_.fields.md#fieldsneq) | | (BETA) Creates an expression that checks if this expression is not equal to another expression. +```typescript +// Check if the 'status' field is not equal to "completed" +Field.of("status").neq("completed"); + +``` + | +| [neq(other)](./firestore_.fields.md#fieldsneq) | | (BETA) Creates an expression that checks if this expression is not equal to a constant value. +```typescript +// Check if the 'country' field is not equal to "USA" +Field.of("country").neq("USA"); + +``` + | +| [of(name, others)](./firestore_.fields.md#fieldsof) | static | (BETA) | +| [ofAll()](./firestore_.fields.md#fieldsofall) | static | (BETA) | +| [regexContains(pattern)](./firestore_.fields.md#fieldsregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +Field.of("description").regexContains("(?i)example"); + +``` + | +| [regexContains(pattern)](./firestore_.fields.md#fieldsregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains the regular expression stored in field 'regex' +Field.of("description").regexContains(Field.of("regex")); + +``` + | +| [regexMatch(pattern)](./firestore_.fields.md#fieldsregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. +```typescript +// Check if the 'email' field matches a valid email pattern +Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + | +| [regexMatch(pattern)](./firestore_.fields.md#fieldsregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. +```typescript +// Check if the 'email' field matches a regular expression stored in field 'regex' +Field.of("email").regexMatch(Field.of("regex")); + +``` + | +| [replaceAll(find, replace)](./firestore_.fields.md#fieldsreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring. +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field +Field.of("message").replaceAll("hello", "hi"); + +``` + | +| [replaceAll(find, replace)](./firestore_.fields.md#fieldsreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + +``` + | +| [replaceFirst(find, replace)](./firestore_.fields.md#fieldsreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field +Field.of("message").replaceFirst("hello", "hi"); + +``` + | +| [replaceFirst(find, replace)](./firestore_.fields.md#fieldsreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + +``` + | +| [reverse()](./firestore_.fields.md#fieldsreverse) | | (BETA) Creates an expression that reverses this string expression. +```typescript +// Reverse the value of the 'myString' field. +Field.of("myString").reverse(); + +``` + A new representing the reversed string. | +| [startsWith(prefix)](./firestore_.fields.md#fieldsstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix. +```typescript +// Check if the 'name' field starts with "Mr." +Field.of("name").startsWith("Mr."); + +``` + | +| [startsWith(prefix)](./firestore_.fields.md#fieldsstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix (represented as an expression). +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +Field.of("fullName").startsWith(Field.of("firstName")); + +``` + | +| [strConcat(elements)](./firestore_.fields.md#fieldsstrconcat) | | (BETA) Creates an expression that concatenates string expressions together. +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + +``` + | +| [strContains(substring)](./firestore_.fields.md#fieldsstrcontains) | | (BETA) Creates an expression that checks if a string contains a specified substring. +```typescript +// Check if the 'description' field contains "example". +Field.of("description").strContains("example"); + +``` + | +| [strContains(expr)](./firestore_.fields.md#fieldsstrcontains) | | (BETA) Creates an expression that checks if a string contains the string represented by another expression. +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +Field.of("description").strContains(Field.of("keyword")); + +``` + | +| [subtract(other)](./firestore_.fields.md#fieldssubtract) | | (BETA) Creates an expression that subtracts another expression from this expression. +```typescript +// Subtract the 'discount' field from the 'price' field +Field.of("price").subtract(Field.of("discount")); + +``` + | +| [subtract(other)](./firestore_.fields.md#fieldssubtract) | | (BETA) Creates an expression that subtracts a constant value from this expression. +```typescript +// Subtract 20 from the value of the 'total' field +Field.of("total").subtract(20); + +``` + | +| [sum()](./firestore_.fields.md#fieldssum) | | (BETA) Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. +```typescript +// Calculate the total revenue from a set of orders +Field.of("orderAmount").sum().as("totalRevenue"); + +``` + A new Accumulator representing the 'sum' aggregation. | +| [timestampAdd(unit, amount)](./firestore_.fields.md#fieldstimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampAdd(unit, amount)](./firestore_.fields.md#fieldstimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. +```typescript +// Add 1 day to the 'timestamp' field. +Field.of("timestamp").timestampAdd("day", 1); + +``` + | +| [timestampSub(unit, amount)](./firestore_.fields.md#fieldstimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampSub(unit, amount)](./firestore_.fields.md#fieldstimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. +```typescript +// Subtract 1 day from the 'timestamp' field. +Field.of("timestamp").timestampSub("day", 1); + +``` + | +| [timestampToUnixMicros()](./firestore_.fields.md#fieldstimestamptounixmicros) | | (BETA) Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +Field.of("timestamp").timestampToUnixMicros(); + +``` + A new representing the number of microseconds since epoch. | +| [timestampToUnixMillis()](./firestore_.fields.md#fieldstimestamptounixmillis) | | (BETA) Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +Field.of("timestamp").timestampToUnixMillis(); + +``` + A new representing the number of milliseconds since epoch. | +| [timestampToUnixSeconds()](./firestore_.fields.md#fieldstimestamptounixseconds) | | (BETA) Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to seconds since epoch. +Field.of("timestamp").timestampToUnixSeconds(); + +``` + A new representing the number of seconds since epoch. | +| [toLower()](./firestore_.fields.md#fieldstolower) | | (BETA) Creates an expression that converts a string to lowercase. +```typescript +// Convert the 'name' field to lowercase +Field.of("name").toLower(); + +``` + A new Expr representing the lowercase string. | +| [toUpper()](./firestore_.fields.md#fieldstoupper) | | (BETA) Creates an expression that converts a string to uppercase. +```typescript +// Convert the 'title' field to uppercase +Field.of("title").toUpper(); + +``` + A new Expr representing the uppercase string. | +| [trim()](./firestore_.fields.md#fieldstrim) | | (BETA) Creates an expression that removes leading and trailing whitespace from a string. +```typescript +// Trim whitespace from the 'userInput' field +Field.of("userInput").trim(); + +``` + A new Expr representing the trimmed string. | +| [unixMicrosToTimestamp()](./firestore_.fields.md#fieldsunixmicrostotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +Field.of("microseconds").unixMicrosToTimestamp(); + +``` + A new representing the timestamp. | +| [unixMillisToTimestamp()](./firestore_.fields.md#fieldsunixmillistotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +Field.of("milliseconds").unixMillisToTimestamp(); + +``` + A new representing the timestamp. | +| [unixSecondsToTimestamp()](./firestore_.fields.md#fieldsunixsecondstotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'seconds' field as seconds since epoch. +Field.of("seconds").unixSecondsToTimestamp(); + +``` + A new representing the timestamp. | +| [vectorLength()](./firestore_.fields.md#fieldsvectorlength) | | (BETA) Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. +```typescript +// Get the vector length (dimension) of the field 'embedding'. +Field.of("embedding").vectorLength(); + +``` + A new representing the length of the vector. | + +## Fields.exprType + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +exprType: ExprType; +``` + +## Fields.selectable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +selectable: true; +``` + +## Fields.add() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds this expression to another expression. + +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +Field.of("quantity").add(Field.of("reserve")); + +``` + +Signature: + +```typescript +add(other: Constant): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to add to this expression. A new Expr representing the addition operation. | + +Returns: + +[Add](./firestore_.add.md#add_class) + +## Fields.add() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds this expression to a constant value. + +```typescript +// Add 5 to the value of the 'age' field +Field.of("age").add(5); + +``` + +Signature: + +```typescript +add(other: any): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to add. A new Expr representing the addition operation. | + +Returns: + +[Add](./firestore_.add.md#add_class) + +## Fields.arrayConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with one or more other arrays. + +```typescript +// Combine the 'items' array with another array field. +Field.of("items").arrayConcat(Field.of("otherItems")); + +``` + +Signature: + +```typescript +arrayConcat(arrays: Constant[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrays | [Constant](./firestore_.constant.md#constant_class)\[\] | The array expressions to concatenate. A new Expr representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) + +## Fields.arrayConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with one or more other arrays. + +```typescript +// Combine the 'tags' array with a new array and an array field +Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + +``` + +Signature: + +```typescript +arrayConcat(arrays: any[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrays | any\[\] | The array expressions or values to concatenate. A new Expr representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) + +## Fields.arrayContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains a specific element. + +```typescript +// Check if the 'sizes' array contains the value from the 'selectedSize' field +Field.of("sizes").arrayContains(Field.of("selectedSize")); + +``` + +Signature: + +```typescript +arrayContains(element: Constant): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | [Constant](./firestore_.constant.md#constant_class) | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) + +## Fields.arrayContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains a specific value. + +```typescript +// Check if the 'colors' array contains "red" +Field.of("colors").arrayContains("red"); + +``` + +Signature: + +```typescript +arrayContains(element: any): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | any | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) + +## Fields.arrayContainsAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both "news" and "sports" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + +Signature: + +```typescript +arrayContainsAll(...values: Constant[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) + +## Fields.arrayContainsAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + +Signature: + +```typescript +arrayContainsAll(...values: any[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) + +## Fields.arrayContainsAny() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains any of the specified elements. + +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "cate2" +Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + +``` + +Signature: + +```typescript +arrayContainsAny(...values: Constant[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) + +## Fields.arrayContainsAny() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains any of the specified elements. + +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + +``` + +Signature: + +```typescript +arrayContainsAny(...values: any[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) + +## Fields.arrayLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of an array. + +```typescript +// Get the number of items in the 'cart' array +Field.of("cart").arrayLength(); + +``` + A new `Expr` representing the length of the array. + +Signature: + +```typescript +arrayLength(): ArrayLength; +``` +Returns: + +[ArrayLength](./firestore_.arraylength.md#arraylength_class) + +## Fields.as() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Assigns an alias to this expression. + +Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. + +```typescript +// Calculate the total price and assign it the alias "totalPrice" and add it to the output. +firestore.pipeline().collection("items") +.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + +``` + +Signature: + +```typescript +as(name: string): ExprWithAlias; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | The alias to assign to this expression. A new [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) that wraps this expression and associates it with the provided alias. | + +Returns: + +[ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class)<this> + +## Fields.ascending() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. + +```typescript +// Sort documents by the 'name' field in ascending order +pipeline().collection("users") +.sort(Field.of("name").ascending()); + +``` + A new `Ordering` for ascending sorting. + +Signature: + +```typescript +ascending(): Ordering; +``` +Returns: + +[Ordering](./firestore_.ordering.md#ordering_class) + +## Fields.avg() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. + +```typescript +// Calculate the average age of users +Field.of("age").avg().as("averageAge"); + +``` + A new `Accumulator` representing the 'avg' aggregation. + +Signature: + +```typescript +avg(): Avg; +``` +Returns: + +[Avg](./firestore_.avg.md#avg_class) + +## Fields.byteLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of this string expression in bytes. + +```typescript +// Calculate the length of the 'myString' field in bytes. +Field.of("myString").byteLength(); + +``` + A new representing the length of the string in bytes. + +Signature: + +```typescript +byteLength(): ByteLength; +``` +Returns: + +[ByteLength](./firestore_.bytelength.md#bytelength_class) + +## Fields.charLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the character length of a string in UTF-8. + +```typescript +// Get the character length of the 'name' field in its UTF-8 form. +Field.of("name").charLength(); + +``` + A new `Expr` representing the length of the string. + +Signature: + +```typescript +charLength(): CharLength; +``` +Returns: + +[CharLength](./firestore_.charlength.md#charlength_class) + +## Fields.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the cosine distance between two vectors. + +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +Field.of("userVector").cosineDistance(Field.of("itemVector")); + +``` + +Signature: + +```typescript +cosineDistance(other: Constant): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new Expr representing the cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) + +## Fields.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vectors. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +cosineDistance(other: VectorValue): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) + +## Fields.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vectors. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance([37.7749, -122.4194]); + +``` + +Signature: + +```typescript +cosineDistance(other: number[]): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | The other vector (as an array of numbers) to compare against. A new Expr representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) + +## Fields.count() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. + +```typescript +// Count the total number of products +Field.of("productId").count().as("totalProducts"); + +``` + A new `Accumulator` representing the 'count' aggregation. + +Signature: + +```typescript +count(): Count; +``` +Returns: + +[Count](./firestore_.count.md#count_class) + +## Fields.descending() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. + +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") +.sort(Field.of("createdAt").descending()); + +``` + A new `Ordering` for descending sorting. + +Signature: + +```typescript +descending(): Ordering; +``` +Returns: + +[Ordering](./firestore_.ordering.md#ordering_class) + +## Fields.divide() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides this expression by another expression. + +```typescript +// Divide the 'total' field by the 'count' field +Field.of("total").divide(Field.of("count")); + +``` + +Signature: + +```typescript +divide(other: Constant): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new Expr representing the division operation. | + +Returns: + +[Divide](./firestore_.divide.md#divide_class) + +## Fields.divide() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides this expression by a constant value. + +```typescript +// Divide the 'value' field by 10 +Field.of("value").divide(10); + +``` + +Signature: + +```typescript +divide(other: any): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to divide by. A new Expr representing the division operation. | + +Returns: + +[Divide](./firestore_.divide.md#divide_class) + +## Fields.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vectors. + +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct([0.5, 0.8, 0.2]); + +``` + +Signature: + +```typescript +dotProduct(other: Constant): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_.dotproduct.md#dotproduct_class) + +## Fields.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vectors. + +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + +``` + +Signature: + +```typescript +dotProduct(other: VectorValue): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_.dotproduct.md#dotproduct_class) + +## Fields.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +dotProduct(other: number[]): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | | + +Returns: + +[DotProduct](./firestore_.dotproduct.md#dotproduct_class) + +## Fields.endsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string ends with a given postfix. + +```typescript +// Check if the 'filename' field ends with ".txt" +Field.of("filename").endsWith(".txt"); + +``` + +Signature: + +```typescript +endsWith(suffix: string): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| suffix | string | The postfix to check for. A new Expr representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_.endswith.md#endswith_class) + +## Fields.endsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string ends with a given postfix (represented as an expression). + +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +Field.of("url").endsWith(Field.of("extension")); + +``` + +Signature: + +```typescript +endsWith(suffix: Constant): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| suffix | [Constant](./firestore_.constant.md#constant_class) | The postfix expression to check for. A new Expr representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_.endswith.md#endswith_class) + +## Fields.eq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to another expression. + +```typescript +// Check if the 'age' field is equal to 21 +Field.of("age").eq(21); + +``` + +Signature: + +```typescript +eq(other: Constant): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for equality. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_.eq.md#eq_class) + +## Fields.eq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to a constant value. + +```typescript +// Check if the 'city' field is equal to "London" +Field.of("city").eq("London"); + +``` + +Signature: + +```typescript +eq(other: any): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for equality. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_.eq.md#eq_class) + +## Fields.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vectors. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance([37.7749, -122.4194]); + +``` + +Signature: + +```typescript +euclideanDistance(other: Constant): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) + +## Fields.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vectors. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +euclideanDistance(other: VectorValue): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) + +## Fields.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +euclideanDistance(other: number[]): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | | + +Returns: + +[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) + +## Fields.exists() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field exists in the document. + +```typescript +// Check if the document has a field named "phoneNumber" +Field.of("phoneNumber").exists(); + +``` + A new `Expr` representing the 'exists' check. + +Signature: + +```typescript +exists(): Exists; +``` +Returns: + +[Exists](./firestore_.exists.md#exists_class) + +## Fields.fieldList() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +fieldList(): Field[]; +``` +Returns: + +[Field](./firestore_.field.md#field_class)\[\] + +## Fields.gt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than another expression. + +```typescript +// Check if the 'age' field is greater than the 'limit' field +Field.of("age").gt(Field.of("limit")); + +``` + +Signature: + +```typescript +gt(other: Constant): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for greater than. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_.gt.md#gt_class) + +## Fields.gt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than a constant value. + +```typescript +// Check if the 'price' field is greater than 100 +Field.of("price").gt(100); + +``` + +Signature: + +```typescript +gt(other: any): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for greater than. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_.gt.md#gt_class) + +## Fields.gte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than or equal to another expression. + +```typescript +// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 +Field.of("quantity").gte(Field.of('requirement').add(1)); + +``` + +Signature: + +```typescript +gte(other: Constant): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_.gte.md#gte_class) + +## Fields.gte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than or equal to a constant value. + +```typescript +// Check if the 'score' field is greater than or equal to 80 +Field.of("score").gte(80); + +``` + +Signature: + +```typescript +gte(other: any): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_.gte.md#gte_class) + +## Fields.in() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to any of the provided values or expressions. + +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +Field.of("category").in("Electronics", Field.of("primaryType")); + +``` + +Signature: + +```typescript +in(...others: Constant[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| others | [Constant](./firestore_.constant.md#constant_class)\[\] | The values or expressions to check against. A new Expr representing the 'IN' comparison. | + +Returns: + +[In](./firestore_.in.md#in_class) + +## Fields.in() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +in(...others: any[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| others | any\[\] | | + +Returns: + +[In](./firestore_.in.md#in_class) + +## Fields.isNaN() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). + +```typescript +// Check if the result of a calculation is NaN +Field.of("value").divide(0).isNaN(); + +``` + A new `Expr` representing the 'isNaN' check. + +Signature: + +```typescript +isNaN(): IsNan; +``` +Returns: + +[IsNan](./firestore_.isnan.md#isnan_class) + +## Fields.like() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that performs a case-sensitive string comparison. + +```typescript +// Check if the 'title' field contains the word "guide" (case-sensitive) +Field.of("title").like("%guide%"); + +``` + +Signature: + +```typescript +like(pattern: string): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new Expr representing the 'like' comparison. | + +Returns: + +[Like](./firestore_.like.md#like_class) + +## Fields.like() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +like(pattern: Constant): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_.constant.md#constant_class) | | + +Returns: + +[Like](./firestore_.like.md#like_class) + +## Fields.logicalMax() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMax(Function.currentTimestamp()); + +``` + +Signature: + +```typescript +logicalMax(other: Constant): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare with. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) + +## Fields.logicalMax() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'value' field and 10. +Field.of("value").logicalMax(10); + +``` + +Signature: + +```typescript +logicalMax(other: any): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare with. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) + +## Fields.logicalMin() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMin(Function.currentTimestamp()); + +``` + +Signature: + +```typescript +logicalMin(other: Constant): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare with. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) + +## Fields.logicalMin() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'value' field and 10. +Field.of("value").logicalMin(10); + +``` + +Signature: + +```typescript +logicalMin(other: any): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare with. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) + +## Fields.lt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than another expression. + +```typescript +// Check if the 'age' field is less than 'limit' +Field.of("age").lt(Field.of('limit')); + +``` + +Signature: + +```typescript +lt(other: Constant): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for less than. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_.lt.md#lt_class) + +## Fields.lt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than a constant value. + +```typescript +// Check if the 'price' field is less than 50 +Field.of("price").lt(50); + +``` + +Signature: + +```typescript +lt(other: any): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for less than. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_.lt.md#lt_class) + +## Fields.lte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than or equal to another expression. + +```typescript +// Check if the 'quantity' field is less than or equal to 20 +Field.of("quantity").lte(Constant.of(20)); + +``` + +Signature: + +```typescript +lte(other: Constant): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_.lte.md#lte_class) + +## Fields.lte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than or equal to a constant value. + +```typescript +// Check if the 'score' field is less than or equal to 70 +Field.of("score").lte(70); + +``` + +Signature: + +```typescript +lte(other: any): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_.lte.md#lte_class) + +## Fields.mapGet() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Accesses a value from a map (object) field using the provided key. + +```typescript +// Get the 'city' value from the 'address' map field +Field.of("address").mapGet("city"); + +``` + +Signature: + +```typescript +mapGet(subfield: string): MapGet; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| subfield | string | The key to access in the map. A new Expr representing the value associated with the given key in the map. | + +Returns: + +[MapGet](./firestore_.mapget.md#mapget_class) + +## Fields.max() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that finds the maximum value of a field across multiple stage inputs. + +```typescript +// Find the highest score in a leaderboard +Field.of("score").max().as("highestScore"); + +``` + A new `Accumulator` representing the 'max' aggregation. + +Signature: + +```typescript +max(): Max; +``` +Returns: + +[Max](./firestore_.max.md#max_class) + +## Fields.min() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that finds the minimum value of a field across multiple stage inputs. + +```typescript +// Find the lowest price of all products +Field.of("price").min().as("lowestPrice"); + +``` + A new `Accumulator` representing the 'min' aggregation. + +Signature: + +```typescript +min(): Min; +``` +Returns: + +[Min](./firestore_.min.md#min_class) + +## Fields.mod() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. + +```typescript +// Calculate the remainder of dividing the 'value' field by the 'divisor' field +Field.of("value").mod(Field.of("divisor")); + +``` + +Signature: + +```typescript +mod(other: Constant): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new Expr representing the modulo operation. | + +Returns: + +[Mod](./firestore_.mod.md#mod_class) + +## Fields.mod() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. + +```typescript +// Calculate the remainder of dividing the 'value' field by 10 +Field.of("value").mod(10); + +``` + +Signature: + +```typescript +mod(other: any): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to divide by. A new Expr representing the modulo operation. | + +Returns: + +[Mod](./firestore_.mod.md#mod_class) + +## Fields.multiply() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies this expression by another expression. + +```typescript +// Multiply the 'quantity' field by the 'price' field +Field.of("quantity").multiply(Field.of("price")); + +``` + +Signature: + +```typescript +multiply(other: Constant): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to multiply by. A new Expr representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_.multiply.md#multiply_class) + +## Fields.multiply() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies this expression by a constant value. + +```typescript +// Multiply the 'value' field by 2 +Field.of("value").multiply(2); + +``` + +Signature: + +```typescript +multiply(other: any): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to multiply by. A new Expr representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_.multiply.md#multiply_class) + +## Fields.neq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is not equal to another expression. + +```typescript +// Check if the 'status' field is not equal to "completed" +Field.of("status").neq("completed"); + +``` + +Signature: + +```typescript +neq(other: Constant): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for inequality. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_.neq.md#neq_class) + +## Fields.neq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is not equal to a constant value. + +```typescript +// Check if the 'country' field is not equal to "USA" +Field.of("country").neq("USA"); + +``` + +Signature: + +```typescript +neq(other: any): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for inequality. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_.neq.md#neq_class) + +## Fields.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +static of(name: string, ...others: string[]): Fields; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | | +| others | string\[\] | | + +Returns: + +[Fields](./firestore_.fields.md#fields_class) + +## Fields.ofAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +static ofAll(): Fields; +``` +Returns: + +[Fields](./firestore_.fields.md#fields_class) + +## Fields.regexContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +Field.of("description").regexContains("(?i)example"); + +``` + +Signature: + +```typescript +regexContains(pattern: string): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_.regexcontains.md#regexcontains_class) + +## Fields.regexContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains the regular expression stored in field 'regex' +Field.of("description").regexContains(Field.of("regex")); + +``` + +Signature: + +```typescript +regexContains(pattern: Constant): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_.regexcontains.md#regexcontains_class) + +## Fields.regexMatch() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a valid email pattern +Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + +Signature: + +```typescript +regexMatch(pattern: string): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The regular expression to use for the match. A new Expr representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) + +## Fields.regexMatch() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a regular expression stored in field 'regex' +Field.of("email").regexMatch(Field.of("regex")); + +``` + +Signature: + +```typescript +regexMatch(pattern: Constant): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the match. A new Expr representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) + +## Fields.replaceAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within this string expression with another substring. + +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field +Field.of("message").replaceAll("hello", "hi"); + +``` + +Signature: + +```typescript +replaceAll(find: string, replace: string): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | string | The substring to search for. | +| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_.replaceall.md#replaceall_class) + +## Fields.replaceAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + +``` + +Signature: + +```typescript +replaceAll(find: Constant, replace: Constant): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_.replaceall.md#replaceall_class) + +## Fields.replaceFirst() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. + +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field +Field.of("message").replaceFirst("hello", "hi"); + +``` + +Signature: + +```typescript +replaceFirst(find: string, replace: string): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | string | The substring to search for. | +| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) + +## Fields.replaceFirst() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + +``` + +Signature: + +```typescript +replaceFirst(find: Constant, replace: Constant): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) + +## Fields.reverse() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that reverses this string expression. + +```typescript +// Reverse the value of the 'myString' field. +Field.of("myString").reverse(); + +``` + A new representing the reversed string. + +Signature: + +```typescript +reverse(): Reverse; +``` +Returns: + +[Reverse](./firestore_.reverse.md#reverse_class) + +## Fields.startsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string starts with a given prefix. + +```typescript +// Check if the 'name' field starts with "Mr." +Field.of("name").startsWith("Mr."); + +``` + +Signature: + +```typescript +startsWith(prefix: string): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| prefix | string | The prefix to check for. A new Expr representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_.startswith.md#startswith_class) + +## Fields.startsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string starts with a given prefix (represented as an expression). + +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +Field.of("fullName").startsWith(Field.of("firstName")); + +``` + +Signature: + +```typescript +startsWith(prefix: Constant): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| prefix | [Constant](./firestore_.constant.md#constant_class) | The prefix expression to check for. A new Expr representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_.startswith.md#startswith_class) + +## Fields.strConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates string expressions together. + +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + +``` + +Signature: + +```typescript +strConcat(...elements: Array): StrConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| elements | Array<string \| [Constant](./firestore_.constant.md#constant_class)> | The expressions (typically strings) to concatenate. A new Expr representing the concatenated string. | + +Returns: + +[StrConcat](./firestore_.strconcat.md#strconcat_class) + +## Fields.strContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified substring. + +```typescript +// Check if the 'description' field contains "example". +Field.of("description").strContains("example"); + +``` + +Signature: + +```typescript +strContains(substring: string): StrContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| substring | string | The substring to search for. A new Expr representing the 'contains' comparison. | + +Returns: + +[StrContains](./firestore_.strcontains.md#strcontains_class) + +## Fields.strContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains the string represented by another expression. + +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +Field.of("description").strContains(Field.of("keyword")); + +``` + +Signature: + +```typescript +strContains(expr: Constant): StrContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. A new Expr representing the 'contains' comparison. | + +Returns: + +[StrContains](./firestore_.strcontains.md#strcontains_class) + +## Fields.subtract() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts another expression from this expression. + +```typescript +// Subtract the 'discount' field from the 'price' field +Field.of("price").subtract(Field.of("discount")); + +``` + +Signature: + +```typescript +subtract(other: Constant): Subtract; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to subtract from this expression. A new Expr representing the subtraction operation. | + +Returns: + +[Subtract](./firestore_.subtract.md#subtract_class) + +## Fields.subtract() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a constant value from this expression. + +```typescript +// Subtract 20 from the value of the 'total' field +Field.of("total").subtract(20); + +``` + +Signature: + +```typescript +subtract(other: any): Subtract; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to subtract. A new Expr representing the subtraction operation. | + +Returns: + +[Subtract](./firestore_.subtract.md#subtract_class) + +## Fields.sum() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. + +```typescript +// Calculate the total revenue from a set of orders +Field.of("orderAmount").sum().as("totalRevenue"); + +``` + A new `Accumulator` representing the 'sum' aggregation. + +Signature: + +```typescript +sum(): Sum; +``` +Returns: + +[Sum](./firestore_.sum.md#sum_class) + +## Fields.timestampAdd() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to this timestamp expression. + +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + +``` + +Signature: + +```typescript +timestampAdd(unit: Constant, amount: Constant): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) + +## Fields.timestampAdd() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to this timestamp expression. + +```typescript +// Add 1 day to the 'timestamp' field. +Field.of("timestamp").timestampAdd("day", 1); + +``` + +Signature: + +```typescript +timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | +| amount | number | The amount of time to add. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) + +## Fields.timestampSub() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from this timestamp expression. + +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + +``` + +Signature: + +```typescript +timestampSub(unit: Constant, amount: Constant): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) + +## Fields.timestampSub() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from this timestamp expression. + +```typescript +// Subtract 1 day from the 'timestamp' field. +Field.of("timestamp").timestampSub("day", 1); + +``` + +Signature: + +```typescript +timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | +| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) + +## Fields.timestampToUnixMicros() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +Field.of("timestamp").timestampToUnixMicros(); + +``` + A new representing the number of microseconds since epoch. + +Signature: + +```typescript +timestampToUnixMicros(): TimestampToUnixMicros; +``` +Returns: + +[TimestampToUnixMicros](./firestore_.timestamptounixmicros.md#timestamptounixmicros_class) + +## Fields.timestampToUnixMillis() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +Field.of("timestamp").timestampToUnixMillis(); + +``` + A new representing the number of milliseconds since epoch. + +Signature: + +```typescript +timestampToUnixMillis(): TimestampToUnixMillis; +``` +Returns: + +[TimestampToUnixMillis](./firestore_.timestamptounixmillis.md#timestamptounixmillis_class) + +## Fields.timestampToUnixSeconds() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to seconds since epoch. +Field.of("timestamp").timestampToUnixSeconds(); + +``` + A new representing the number of seconds since epoch. + +Signature: + +```typescript +timestampToUnixSeconds(): TimestampToUnixSeconds; +``` +Returns: + +[TimestampToUnixSeconds](./firestore_.timestamptounixseconds.md#timestamptounixseconds_class) + +## Fields.toLower() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string to lowercase. + +```typescript +// Convert the 'name' field to lowercase +Field.of("name").toLower(); + +``` + A new `Expr` representing the lowercase string. + +Signature: + +```typescript +toLower(): ToLower; +``` +Returns: + +[ToLower](./firestore_.tolower.md#tolower_class) + +## Fields.toUpper() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string to uppercase. + +```typescript +// Convert the 'title' field to uppercase +Field.of("title").toUpper(); + +``` + A new `Expr` representing the uppercase string. + +Signature: + +```typescript +toUpper(): ToUpper; +``` +Returns: + +[ToUpper](./firestore_.toupper.md#toupper_class) + +## Fields.trim() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that removes leading and trailing whitespace from a string. + +```typescript +// Trim whitespace from the 'userInput' field +Field.of("userInput").trim(); + +``` + A new `Expr` representing the trimmed string. + +Signature: + +```typescript +trim(): Trim; +``` +Returns: + +[Trim](./firestore_.trim.md#trim_class) + +## Fields.unixMicrosToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +Field.of("microseconds").unixMicrosToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixMicrosToTimestamp(): UnixMicrosToTimestamp; +``` +Returns: + +[UnixMicrosToTimestamp](./firestore_.unixmicrostotimestamp.md#unixmicrostotimestamp_class) + +## Fields.unixMillisToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +Field.of("milliseconds").unixMillisToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixMillisToTimestamp(): UnixMillisToTimestamp; +``` +Returns: + +[UnixMillisToTimestamp](./firestore_.unixmillistotimestamp.md#unixmillistotimestamp_class) + +## Fields.unixSecondsToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'seconds' field as seconds since epoch. +Field.of("seconds").unixSecondsToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixSecondsToTimestamp(): UnixSecondsToTimestamp; +``` +Returns: + +[UnixSecondsToTimestamp](./firestore_.unixsecondstotimestamp.md#unixsecondstotimestamp_class) + +## Fields.vectorLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. + +```typescript +// Get the vector length (dimension) of the field 'embedding'. +Field.of("embedding").vectorLength(); + +``` + A new representing the length of the vector. + +Signature: + +```typescript +vectorLength(): VectorLength; +``` +Returns: + +[VectorLength](./firestore_.vectorlength.md#vectorlength_class) + diff --git a/docs-devsite/firestore_.filtercondition.md b/docs-devsite/firestore_.filtercondition.md new file mode 100644 index 00000000000..2665d872f9d --- /dev/null +++ b/docs-devsite/firestore_.filtercondition.md @@ -0,0 +1,39 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# FilterCondition interface +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +An interface that represents a filter condition. + +Signature: + +```typescript +export declare interface FilterCondition +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [filterable](./firestore_.filtercondition.md#filterconditionfilterable) | true | (BETA) | + +## FilterCondition.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_.findnearest.md b/docs-devsite/firestore_.findnearest.md new file mode 100644 index 00000000000..3b3f5c29744 --- /dev/null +++ b/docs-devsite/firestore_.findnearest.md @@ -0,0 +1,39 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# FindNearest class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class FindNearest implements Stage +``` +Implements: [Stage](./firestore_.stage.md#stage_interface) + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_.findnearest.md#findnearestname) | | string | (BETA) | + +## FindNearest.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_.findnearestoptions.md b/docs-devsite/firestore_.findnearestoptions.md new file mode 100644 index 00000000000..5a4835b418d --- /dev/null +++ b/docs-devsite/firestore_.findnearestoptions.md @@ -0,0 +1,86 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# FindNearestOptions interface +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare interface FindNearestOptions +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [distanceField](./firestore_.findnearestoptions.md#findnearestoptionsdistancefield) | string | (BETA) | +| [distanceMeasure](./firestore_.findnearestoptions.md#findnearestoptionsdistancemeasure) | 'euclidean' \| 'cosine' \| 'dot\_product' | (BETA) | +| [field](./firestore_.findnearestoptions.md#findnearestoptionsfield) | [Field](./firestore_.field.md#field_class) | (BETA) | +| [limit](./firestore_.findnearestoptions.md#findnearestoptionslimit) | number | (BETA) | +| [vectorValue](./firestore_.findnearestoptions.md#findnearestoptionsvectorvalue) | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) \| number\[\] | (BETA) | + +## FindNearestOptions.distanceField + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +distanceField?: string; +``` + +## FindNearestOptions.distanceMeasure + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +distanceMeasure: 'euclidean' | 'cosine' | 'dot_product'; +``` + +## FindNearestOptions.field + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +field: Field; +``` + +## FindNearestOptions.limit + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +limit?: number; +``` + +## FindNearestOptions.vectorValue + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +vectorValue: VectorValue | number[]; +``` diff --git a/docs-devsite/firestore_.firestore.md b/docs-devsite/firestore_.firestore.md index 01267d5b2d3..a8b7561a3ba 100644 --- a/docs-devsite/firestore_.firestore.md +++ b/docs-devsite/firestore_.firestore.md @@ -31,6 +31,7 @@ export declare class Firestore | Method | Modifiers | Description | | --- | --- | --- | +| [pipeline()](./firestore_.firestore.md#firestorepipeline) | | Pipeline query. | | [toJSON()](./firestore_.firestore.md#firestoretojson) | | Returns a JSON-serializable representation of this Firestore instance. | ## Firestore.app @@ -53,6 +54,19 @@ Whether it's a [Firestore](./firestore_.firestore.md#firestore_class) or Firesto type: 'firestore-lite' | 'firestore'; ``` +## Firestore.pipeline() + +Pipeline query. + +Signature: + +```typescript +pipeline(): PipelineSource; +``` +Returns: + +[PipelineSource](./firestore_.pipelinesource.md#pipelinesource_class) + ## Firestore.toJSON() Returns a JSON-serializable representation of this `Firestore` instance. diff --git a/docs-devsite/firestore_.firestorefunction.md b/docs-devsite/firestore_.firestorefunction.md new file mode 100644 index 00000000000..43022c17c72 --- /dev/null +++ b/docs-devsite/firestore_.firestorefunction.md @@ -0,0 +1,3173 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# FirestoreFunction class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +This class defines the base class for Firestore [Pipeline](./firestore_.pipeline.md#pipeline_class) functions, which can be evaluated within pipeline execution. + +Typically, you would not use this class or its children directly. Use either the functions like , , or the methods on (, , etc) to construct new Function instances. + +Signature: + +```typescript +export declare class FirestoreFunction +``` + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(name, params)](./firestore_.firestorefunction.md#firestorefunctionconstructor) | | (BETA) Constructs a new instance of the FirestoreFunction class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [exprType](./firestore_.firestorefunction.md#firestorefunctionexprtype) | | [ExprType](./firestore_.md#exprtype) | (BETA) | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [add(other)](./firestore_.firestorefunction.md#firestorefunctionadd) | | (BETA) Creates an expression that adds this expression to another expression. +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +Field.of("quantity").add(Field.of("reserve")); + +``` + | +| [add(other)](./firestore_.firestorefunction.md#firestorefunctionadd) | | (BETA) Creates an expression that adds this expression to a constant value. +```typescript +// Add 5 to the value of the 'age' field +Field.of("age").add(5); + +``` + | +| [arrayConcat(arrays)](./firestore_.firestorefunction.md#firestorefunctionarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. +```typescript +// Combine the 'items' array with another array field. +Field.of("items").arrayConcat(Field.of("otherItems")); + +``` + | +| [arrayConcat(arrays)](./firestore_.firestorefunction.md#firestorefunctionarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. +```typescript +// Combine the 'tags' array with a new array and an array field +Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + +``` + | +| [arrayContains(element)](./firestore_.firestorefunction.md#firestorefunctionarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific element. +```typescript +// Check if the 'sizes' array contains the value from the 'selectedSize' field +Field.of("sizes").arrayContains(Field.of("selectedSize")); + +``` + | +| [arrayContains(element)](./firestore_.firestorefunction.md#firestorefunctionarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific value. +```typescript +// Check if the 'colors' array contains "red" +Field.of("colors").arrayContains("red"); + +``` + | +| [arrayContainsAll(values)](./firestore_.firestorefunction.md#firestorefunctionarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. +```typescript +// Check if the 'tags' array contains both "news" and "sports" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + | +| [arrayContainsAll(values)](./firestore_.firestorefunction.md#firestorefunctionarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + | +| [arrayContainsAny(values)](./firestore_.firestorefunction.md#firestorefunctionarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "cate2" +Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + +``` + | +| [arrayContainsAny(values)](./firestore_.firestorefunction.md#firestorefunctionarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + +``` + | +| [arrayLength()](./firestore_.firestorefunction.md#firestorefunctionarraylength) | | (BETA) Creates an expression that calculates the length of an array. +```typescript +// Get the number of items in the 'cart' array +Field.of("cart").arrayLength(); + +``` + A new Expr representing the length of the array. | +| [as(name)](./firestore_.firestorefunction.md#firestorefunctionas) | | (BETA) Assigns an alias to this expression.Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. +```typescript +// Calculate the total price and assign it the alias "totalPrice" and add it to the output. +firestore.pipeline().collection("items") +.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + +``` + | +| [ascending()](./firestore_.firestorefunction.md#firestorefunctionascending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. +```typescript +// Sort documents by the 'name' field in ascending order +pipeline().collection("users") +.sort(Field.of("name").ascending()); + +``` + A new Ordering for ascending sorting. | +| [avg()](./firestore_.firestorefunction.md#firestorefunctionavg) | | (BETA) Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. +```typescript +// Calculate the average age of users +Field.of("age").avg().as("averageAge"); + +``` + A new Accumulator representing the 'avg' aggregation. | +| [byteLength()](./firestore_.firestorefunction.md#firestorefunctionbytelength) | | (BETA) Creates an expression that calculates the length of this string expression in bytes. +```typescript +// Calculate the length of the 'myString' field in bytes. +Field.of("myString").byteLength(); + +``` + A new representing the length of the string in bytes. | +| [charLength()](./firestore_.firestorefunction.md#firestorefunctioncharlength) | | (BETA) Creates an expression that calculates the character length of a string in UTF-8. +```typescript +// Get the character length of the 'name' field in its UTF-8 form. +Field.of("name").charLength(); + +``` + A new Expr representing the length of the string. | +| [cosineDistance(other)](./firestore_.firestorefunction.md#firestorefunctioncosinedistance) | | (BETA) Calculates the cosine distance between two vectors. +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +Field.of("userVector").cosineDistance(Field.of("itemVector")); + +``` + | +| [cosineDistance(other)](./firestore_.firestorefunction.md#firestorefunctioncosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + +``` + | +| [cosineDistance(other)](./firestore_.firestorefunction.md#firestorefunctioncosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance([37.7749, -122.4194]); + +``` + | +| [count()](./firestore_.firestorefunction.md#firestorefunctioncount) | | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. +```typescript +// Count the total number of products +Field.of("productId").count().as("totalProducts"); + +``` + A new Accumulator representing the 'count' aggregation. | +| [descending()](./firestore_.firestorefunction.md#firestorefunctiondescending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") +.sort(Field.of("createdAt").descending()); + +``` + A new Ordering for descending sorting. | +| [divide(other)](./firestore_.firestorefunction.md#firestorefunctiondivide) | | (BETA) Creates an expression that divides this expression by another expression. +```typescript +// Divide the 'total' field by the 'count' field +Field.of("total").divide(Field.of("count")); + +``` + | +| [divide(other)](./firestore_.firestorefunction.md#firestorefunctiondivide) | | (BETA) Creates an expression that divides this expression by a constant value. +```typescript +// Divide the 'value' field by 10 +Field.of("value").divide(10); + +``` + | +| [dotProduct(other)](./firestore_.firestorefunction.md#firestorefunctiondotproduct) | | (BETA) Calculates the dot product between two vectors. +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct([0.5, 0.8, 0.2]); + +``` + | +| [dotProduct(other)](./firestore_.firestorefunction.md#firestorefunctiondotproduct) | | (BETA) Calculates the dot product between two vectors. +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + +``` + | +| [dotProduct(other)](./firestore_.firestorefunction.md#firestorefunctiondotproduct) | | (BETA) | +| [endsWith(suffix)](./firestore_.firestorefunction.md#firestorefunctionendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix. +```typescript +// Check if the 'filename' field ends with ".txt" +Field.of("filename").endsWith(".txt"); + +``` + | +| [endsWith(suffix)](./firestore_.firestorefunction.md#firestorefunctionendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix (represented as an expression). +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +Field.of("url").endsWith(Field.of("extension")); + +``` + | +| [eq(other)](./firestore_.firestorefunction.md#firestorefunctioneq) | | (BETA) Creates an expression that checks if this expression is equal to another expression. +```typescript +// Check if the 'age' field is equal to 21 +Field.of("age").eq(21); + +``` + | +| [eq(other)](./firestore_.firestorefunction.md#firestorefunctioneq) | | (BETA) Creates an expression that checks if this expression is equal to a constant value. +```typescript +// Check if the 'city' field is equal to "London" +Field.of("city").eq("London"); + +``` + | +| [euclideanDistance(other)](./firestore_.firestorefunction.md#firestorefunctioneuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance([37.7749, -122.4194]); + +``` + | +| [euclideanDistance(other)](./firestore_.firestorefunction.md#firestorefunctioneuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + +``` + | +| [euclideanDistance(other)](./firestore_.firestorefunction.md#firestorefunctioneuclideandistance) | | (BETA) | +| [exists()](./firestore_.firestorefunction.md#firestorefunctionexists) | | (BETA) Creates an expression that checks if a field exists in the document. +```typescript +// Check if the document has a field named "phoneNumber" +Field.of("phoneNumber").exists(); + +``` + A new Expr representing the 'exists' check. | +| [gt(other)](./firestore_.firestorefunction.md#firestorefunctiongt) | | (BETA) Creates an expression that checks if this expression is greater than another expression. +```typescript +// Check if the 'age' field is greater than the 'limit' field +Field.of("age").gt(Field.of("limit")); + +``` + | +| [gt(other)](./firestore_.firestorefunction.md#firestorefunctiongt) | | (BETA) Creates an expression that checks if this expression is greater than a constant value. +```typescript +// Check if the 'price' field is greater than 100 +Field.of("price").gt(100); + +``` + | +| [gte(other)](./firestore_.firestorefunction.md#firestorefunctiongte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to another expression. +```typescript +// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 +Field.of("quantity").gte(Field.of('requirement').add(1)); + +``` + | +| [gte(other)](./firestore_.firestorefunction.md#firestorefunctiongte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to a constant value. +```typescript +// Check if the 'score' field is greater than or equal to 80 +Field.of("score").gte(80); + +``` + | +| [in(others)](./firestore_.firestorefunction.md#firestorefunctionin) | | (BETA) Creates an expression that checks if this expression is equal to any of the provided values or expressions. +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +Field.of("category").in("Electronics", Field.of("primaryType")); + +``` + | +| [in(others)](./firestore_.firestorefunction.md#firestorefunctionin) | | (BETA) | +| [isNaN()](./firestore_.firestorefunction.md#firestorefunctionisnan) | | (BETA) Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). +```typescript +// Check if the result of a calculation is NaN +Field.of("value").divide(0).isNaN(); + +``` + A new Expr representing the 'isNaN' check. | +| [like(pattern)](./firestore_.firestorefunction.md#firestorefunctionlike) | | (BETA) Creates an expression that performs a case-sensitive string comparison. +```typescript +// Check if the 'title' field contains the word "guide" (case-sensitive) +Field.of("title").like("%guide%"); + +``` + | +| [like(pattern)](./firestore_.firestorefunction.md#firestorefunctionlike) | | (BETA) | +| [logicalMax(other)](./firestore_.firestorefunction.md#firestorefunctionlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMax(Function.currentTimestamp()); + +``` + | +| [logicalMax(other)](./firestore_.firestorefunction.md#firestorefunctionlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'value' field and 10. +Field.of("value").logicalMax(10); + +``` + | +| [logicalMin(other)](./firestore_.firestorefunction.md#firestorefunctionlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMin(Function.currentTimestamp()); + +``` + | +| [logicalMin(other)](./firestore_.firestorefunction.md#firestorefunctionlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'value' field and 10. +Field.of("value").logicalMin(10); + +``` + | +| [lt(other)](./firestore_.firestorefunction.md#firestorefunctionlt) | | (BETA) Creates an expression that checks if this expression is less than another expression. +```typescript +// Check if the 'age' field is less than 'limit' +Field.of("age").lt(Field.of('limit')); + +``` + | +| [lt(other)](./firestore_.firestorefunction.md#firestorefunctionlt) | | (BETA) Creates an expression that checks if this expression is less than a constant value. +```typescript +// Check if the 'price' field is less than 50 +Field.of("price").lt(50); + +``` + | +| [lte(other)](./firestore_.firestorefunction.md#firestorefunctionlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to another expression. +```typescript +// Check if the 'quantity' field is less than or equal to 20 +Field.of("quantity").lte(Constant.of(20)); + +``` + | +| [lte(other)](./firestore_.firestorefunction.md#firestorefunctionlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to a constant value. +```typescript +// Check if the 'score' field is less than or equal to 70 +Field.of("score").lte(70); + +``` + | +| [mapGet(subfield)](./firestore_.firestorefunction.md#firestorefunctionmapget) | | (BETA) Accesses a value from a map (object) field using the provided key. +```typescript +// Get the 'city' value from the 'address' map field +Field.of("address").mapGet("city"); + +``` + | +| [max()](./firestore_.firestorefunction.md#firestorefunctionmax) | | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. +```typescript +// Find the highest score in a leaderboard +Field.of("score").max().as("highestScore"); + +``` + A new Accumulator representing the 'max' aggregation. | +| [min()](./firestore_.firestorefunction.md#firestorefunctionmin) | | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. +```typescript +// Find the lowest price of all products +Field.of("price").min().as("lowestPrice"); + +``` + A new Accumulator representing the 'min' aggregation. | +| [mod(other)](./firestore_.firestorefunction.md#firestorefunctionmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. +```typescript +// Calculate the remainder of dividing the 'value' field by the 'divisor' field +Field.of("value").mod(Field.of("divisor")); + +``` + | +| [mod(other)](./firestore_.firestorefunction.md#firestorefunctionmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. +```typescript +// Calculate the remainder of dividing the 'value' field by 10 +Field.of("value").mod(10); + +``` + | +| [multiply(other)](./firestore_.firestorefunction.md#firestorefunctionmultiply) | | (BETA) Creates an expression that multiplies this expression by another expression. +```typescript +// Multiply the 'quantity' field by the 'price' field +Field.of("quantity").multiply(Field.of("price")); + +``` + | +| [multiply(other)](./firestore_.firestorefunction.md#firestorefunctionmultiply) | | (BETA) Creates an expression that multiplies this expression by a constant value. +```typescript +// Multiply the 'value' field by 2 +Field.of("value").multiply(2); + +``` + | +| [neq(other)](./firestore_.firestorefunction.md#firestorefunctionneq) | | (BETA) Creates an expression that checks if this expression is not equal to another expression. +```typescript +// Check if the 'status' field is not equal to "completed" +Field.of("status").neq("completed"); + +``` + | +| [neq(other)](./firestore_.firestorefunction.md#firestorefunctionneq) | | (BETA) Creates an expression that checks if this expression is not equal to a constant value. +```typescript +// Check if the 'country' field is not equal to "USA" +Field.of("country").neq("USA"); + +``` + | +| [regexContains(pattern)](./firestore_.firestorefunction.md#firestorefunctionregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +Field.of("description").regexContains("(?i)example"); + +``` + | +| [regexContains(pattern)](./firestore_.firestorefunction.md#firestorefunctionregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains the regular expression stored in field 'regex' +Field.of("description").regexContains(Field.of("regex")); + +``` + | +| [regexMatch(pattern)](./firestore_.firestorefunction.md#firestorefunctionregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. +```typescript +// Check if the 'email' field matches a valid email pattern +Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + | +| [regexMatch(pattern)](./firestore_.firestorefunction.md#firestorefunctionregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. +```typescript +// Check if the 'email' field matches a regular expression stored in field 'regex' +Field.of("email").regexMatch(Field.of("regex")); + +``` + | +| [replaceAll(find, replace)](./firestore_.firestorefunction.md#firestorefunctionreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring. +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field +Field.of("message").replaceAll("hello", "hi"); + +``` + | +| [replaceAll(find, replace)](./firestore_.firestorefunction.md#firestorefunctionreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + +``` + | +| [replaceFirst(find, replace)](./firestore_.firestorefunction.md#firestorefunctionreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field +Field.of("message").replaceFirst("hello", "hi"); + +``` + | +| [replaceFirst(find, replace)](./firestore_.firestorefunction.md#firestorefunctionreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + +``` + | +| [reverse()](./firestore_.firestorefunction.md#firestorefunctionreverse) | | (BETA) Creates an expression that reverses this string expression. +```typescript +// Reverse the value of the 'myString' field. +Field.of("myString").reverse(); + +``` + A new representing the reversed string. | +| [startsWith(prefix)](./firestore_.firestorefunction.md#firestorefunctionstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix. +```typescript +// Check if the 'name' field starts with "Mr." +Field.of("name").startsWith("Mr."); + +``` + | +| [startsWith(prefix)](./firestore_.firestorefunction.md#firestorefunctionstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix (represented as an expression). +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +Field.of("fullName").startsWith(Field.of("firstName")); + +``` + | +| [strConcat(elements)](./firestore_.firestorefunction.md#firestorefunctionstrconcat) | | (BETA) Creates an expression that concatenates string expressions together. +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + +``` + | +| [strContains(substring)](./firestore_.firestorefunction.md#firestorefunctionstrcontains) | | (BETA) Creates an expression that checks if a string contains a specified substring. +```typescript +// Check if the 'description' field contains "example". +Field.of("description").strContains("example"); + +``` + | +| [strContains(expr)](./firestore_.firestorefunction.md#firestorefunctionstrcontains) | | (BETA) Creates an expression that checks if a string contains the string represented by another expression. +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +Field.of("description").strContains(Field.of("keyword")); + +``` + | +| [subtract(other)](./firestore_.firestorefunction.md#firestorefunctionsubtract) | | (BETA) Creates an expression that subtracts another expression from this expression. +```typescript +// Subtract the 'discount' field from the 'price' field +Field.of("price").subtract(Field.of("discount")); + +``` + | +| [subtract(other)](./firestore_.firestorefunction.md#firestorefunctionsubtract) | | (BETA) Creates an expression that subtracts a constant value from this expression. +```typescript +// Subtract 20 from the value of the 'total' field +Field.of("total").subtract(20); + +``` + | +| [sum()](./firestore_.firestorefunction.md#firestorefunctionsum) | | (BETA) Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. +```typescript +// Calculate the total revenue from a set of orders +Field.of("orderAmount").sum().as("totalRevenue"); + +``` + A new Accumulator representing the 'sum' aggregation. | +| [timestampAdd(unit, amount)](./firestore_.firestorefunction.md#firestorefunctiontimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampAdd(unit, amount)](./firestore_.firestorefunction.md#firestorefunctiontimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. +```typescript +// Add 1 day to the 'timestamp' field. +Field.of("timestamp").timestampAdd("day", 1); + +``` + | +| [timestampSub(unit, amount)](./firestore_.firestorefunction.md#firestorefunctiontimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampSub(unit, amount)](./firestore_.firestorefunction.md#firestorefunctiontimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. +```typescript +// Subtract 1 day from the 'timestamp' field. +Field.of("timestamp").timestampSub("day", 1); + +``` + | +| [timestampToUnixMicros()](./firestore_.firestorefunction.md#firestorefunctiontimestamptounixmicros) | | (BETA) Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +Field.of("timestamp").timestampToUnixMicros(); + +``` + A new representing the number of microseconds since epoch. | +| [timestampToUnixMillis()](./firestore_.firestorefunction.md#firestorefunctiontimestamptounixmillis) | | (BETA) Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +Field.of("timestamp").timestampToUnixMillis(); + +``` + A new representing the number of milliseconds since epoch. | +| [timestampToUnixSeconds()](./firestore_.firestorefunction.md#firestorefunctiontimestamptounixseconds) | | (BETA) Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to seconds since epoch. +Field.of("timestamp").timestampToUnixSeconds(); + +``` + A new representing the number of seconds since epoch. | +| [toLower()](./firestore_.firestorefunction.md#firestorefunctiontolower) | | (BETA) Creates an expression that converts a string to lowercase. +```typescript +// Convert the 'name' field to lowercase +Field.of("name").toLower(); + +``` + A new Expr representing the lowercase string. | +| [toUpper()](./firestore_.firestorefunction.md#firestorefunctiontoupper) | | (BETA) Creates an expression that converts a string to uppercase. +```typescript +// Convert the 'title' field to uppercase +Field.of("title").toUpper(); + +``` + A new Expr representing the uppercase string. | +| [trim()](./firestore_.firestorefunction.md#firestorefunctiontrim) | | (BETA) Creates an expression that removes leading and trailing whitespace from a string. +```typescript +// Trim whitespace from the 'userInput' field +Field.of("userInput").trim(); + +``` + A new Expr representing the trimmed string. | +| [unixMicrosToTimestamp()](./firestore_.firestorefunction.md#firestorefunctionunixmicrostotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +Field.of("microseconds").unixMicrosToTimestamp(); + +``` + A new representing the timestamp. | +| [unixMillisToTimestamp()](./firestore_.firestorefunction.md#firestorefunctionunixmillistotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +Field.of("milliseconds").unixMillisToTimestamp(); + +``` + A new representing the timestamp. | +| [unixSecondsToTimestamp()](./firestore_.firestorefunction.md#firestorefunctionunixsecondstotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'seconds' field as seconds since epoch. +Field.of("seconds").unixSecondsToTimestamp(); + +``` + A new representing the timestamp. | +| [vectorLength()](./firestore_.firestorefunction.md#firestorefunctionvectorlength) | | (BETA) Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. +```typescript +// Get the vector length (dimension) of the field 'embedding'. +Field.of("embedding").vectorLength(); + +``` + A new representing the length of the vector. | + +## FirestoreFunction.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `FirestoreFunction` class + +Signature: + +```typescript +constructor(name: string, params: Constant[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | | +| params | [Constant](./firestore_.constant.md#constant_class)\[\] | | + +## FirestoreFunction.exprType + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +exprType: ExprType; +``` + +## FirestoreFunction.add() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds this expression to another expression. + +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +Field.of("quantity").add(Field.of("reserve")); + +``` + +Signature: + +```typescript +add(other: Constant): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to add to this expression. A new Expr representing the addition operation. | + +Returns: + +[Add](./firestore_.add.md#add_class) + +## FirestoreFunction.add() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds this expression to a constant value. + +```typescript +// Add 5 to the value of the 'age' field +Field.of("age").add(5); + +``` + +Signature: + +```typescript +add(other: any): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to add. A new Expr representing the addition operation. | + +Returns: + +[Add](./firestore_.add.md#add_class) + +## FirestoreFunction.arrayConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with one or more other arrays. + +```typescript +// Combine the 'items' array with another array field. +Field.of("items").arrayConcat(Field.of("otherItems")); + +``` + +Signature: + +```typescript +arrayConcat(arrays: Constant[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrays | [Constant](./firestore_.constant.md#constant_class)\[\] | The array expressions to concatenate. A new Expr representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) + +## FirestoreFunction.arrayConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with one or more other arrays. + +```typescript +// Combine the 'tags' array with a new array and an array field +Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + +``` + +Signature: + +```typescript +arrayConcat(arrays: any[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrays | any\[\] | The array expressions or values to concatenate. A new Expr representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) + +## FirestoreFunction.arrayContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains a specific element. + +```typescript +// Check if the 'sizes' array contains the value from the 'selectedSize' field +Field.of("sizes").arrayContains(Field.of("selectedSize")); + +``` + +Signature: + +```typescript +arrayContains(element: Constant): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | [Constant](./firestore_.constant.md#constant_class) | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) + +## FirestoreFunction.arrayContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains a specific value. + +```typescript +// Check if the 'colors' array contains "red" +Field.of("colors").arrayContains("red"); + +``` + +Signature: + +```typescript +arrayContains(element: any): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | any | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) + +## FirestoreFunction.arrayContainsAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both "news" and "sports" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + +Signature: + +```typescript +arrayContainsAll(...values: Constant[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) + +## FirestoreFunction.arrayContainsAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + +Signature: + +```typescript +arrayContainsAll(...values: any[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) + +## FirestoreFunction.arrayContainsAny() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains any of the specified elements. + +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "cate2" +Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + +``` + +Signature: + +```typescript +arrayContainsAny(...values: Constant[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) + +## FirestoreFunction.arrayContainsAny() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains any of the specified elements. + +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + +``` + +Signature: + +```typescript +arrayContainsAny(...values: any[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) + +## FirestoreFunction.arrayLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of an array. + +```typescript +// Get the number of items in the 'cart' array +Field.of("cart").arrayLength(); + +``` + A new `Expr` representing the length of the array. + +Signature: + +```typescript +arrayLength(): ArrayLength; +``` +Returns: + +[ArrayLength](./firestore_.arraylength.md#arraylength_class) + +## FirestoreFunction.as() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Assigns an alias to this expression. + +Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. + +```typescript +// Calculate the total price and assign it the alias "totalPrice" and add it to the output. +firestore.pipeline().collection("items") +.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + +``` + +Signature: + +```typescript +as(name: string): ExprWithAlias; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | The alias to assign to this expression. A new [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) that wraps this expression and associates it with the provided alias. | + +Returns: + +[ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class)<this> + +## FirestoreFunction.ascending() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. + +```typescript +// Sort documents by the 'name' field in ascending order +pipeline().collection("users") +.sort(Field.of("name").ascending()); + +``` + A new `Ordering` for ascending sorting. + +Signature: + +```typescript +ascending(): Ordering; +``` +Returns: + +[Ordering](./firestore_.ordering.md#ordering_class) + +## FirestoreFunction.avg() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. + +```typescript +// Calculate the average age of users +Field.of("age").avg().as("averageAge"); + +``` + A new `Accumulator` representing the 'avg' aggregation. + +Signature: + +```typescript +avg(): Avg; +``` +Returns: + +[Avg](./firestore_.avg.md#avg_class) + +## FirestoreFunction.byteLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of this string expression in bytes. + +```typescript +// Calculate the length of the 'myString' field in bytes. +Field.of("myString").byteLength(); + +``` + A new representing the length of the string in bytes. + +Signature: + +```typescript +byteLength(): ByteLength; +``` +Returns: + +[ByteLength](./firestore_.bytelength.md#bytelength_class) + +## FirestoreFunction.charLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the character length of a string in UTF-8. + +```typescript +// Get the character length of the 'name' field in its UTF-8 form. +Field.of("name").charLength(); + +``` + A new `Expr` representing the length of the string. + +Signature: + +```typescript +charLength(): CharLength; +``` +Returns: + +[CharLength](./firestore_.charlength.md#charlength_class) + +## FirestoreFunction.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the cosine distance between two vectors. + +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +Field.of("userVector").cosineDistance(Field.of("itemVector")); + +``` + +Signature: + +```typescript +cosineDistance(other: Constant): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new Expr representing the cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) + +## FirestoreFunction.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vectors. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +cosineDistance(other: VectorValue): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) + +## FirestoreFunction.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vectors. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance([37.7749, -122.4194]); + +``` + +Signature: + +```typescript +cosineDistance(other: number[]): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | The other vector (as an array of numbers) to compare against. A new Expr representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) + +## FirestoreFunction.count() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. + +```typescript +// Count the total number of products +Field.of("productId").count().as("totalProducts"); + +``` + A new `Accumulator` representing the 'count' aggregation. + +Signature: + +```typescript +count(): Count; +``` +Returns: + +[Count](./firestore_.count.md#count_class) + +## FirestoreFunction.descending() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. + +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") +.sort(Field.of("createdAt").descending()); + +``` + A new `Ordering` for descending sorting. + +Signature: + +```typescript +descending(): Ordering; +``` +Returns: + +[Ordering](./firestore_.ordering.md#ordering_class) + +## FirestoreFunction.divide() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides this expression by another expression. + +```typescript +// Divide the 'total' field by the 'count' field +Field.of("total").divide(Field.of("count")); + +``` + +Signature: + +```typescript +divide(other: Constant): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new Expr representing the division operation. | + +Returns: + +[Divide](./firestore_.divide.md#divide_class) + +## FirestoreFunction.divide() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides this expression by a constant value. + +```typescript +// Divide the 'value' field by 10 +Field.of("value").divide(10); + +``` + +Signature: + +```typescript +divide(other: any): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to divide by. A new Expr representing the division operation. | + +Returns: + +[Divide](./firestore_.divide.md#divide_class) + +## FirestoreFunction.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vectors. + +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct([0.5, 0.8, 0.2]); + +``` + +Signature: + +```typescript +dotProduct(other: Constant): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_.dotproduct.md#dotproduct_class) + +## FirestoreFunction.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vectors. + +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + +``` + +Signature: + +```typescript +dotProduct(other: VectorValue): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_.dotproduct.md#dotproduct_class) + +## FirestoreFunction.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +dotProduct(other: number[]): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | | + +Returns: + +[DotProduct](./firestore_.dotproduct.md#dotproduct_class) + +## FirestoreFunction.endsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string ends with a given postfix. + +```typescript +// Check if the 'filename' field ends with ".txt" +Field.of("filename").endsWith(".txt"); + +``` + +Signature: + +```typescript +endsWith(suffix: string): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| suffix | string | The postfix to check for. A new Expr representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_.endswith.md#endswith_class) + +## FirestoreFunction.endsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string ends with a given postfix (represented as an expression). + +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +Field.of("url").endsWith(Field.of("extension")); + +``` + +Signature: + +```typescript +endsWith(suffix: Constant): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| suffix | [Constant](./firestore_.constant.md#constant_class) | The postfix expression to check for. A new Expr representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_.endswith.md#endswith_class) + +## FirestoreFunction.eq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to another expression. + +```typescript +// Check if the 'age' field is equal to 21 +Field.of("age").eq(21); + +``` + +Signature: + +```typescript +eq(other: Constant): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for equality. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_.eq.md#eq_class) + +## FirestoreFunction.eq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to a constant value. + +```typescript +// Check if the 'city' field is equal to "London" +Field.of("city").eq("London"); + +``` + +Signature: + +```typescript +eq(other: any): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for equality. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_.eq.md#eq_class) + +## FirestoreFunction.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vectors. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance([37.7749, -122.4194]); + +``` + +Signature: + +```typescript +euclideanDistance(other: Constant): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) + +## FirestoreFunction.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vectors. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +euclideanDistance(other: VectorValue): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) + +## FirestoreFunction.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +euclideanDistance(other: number[]): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | | + +Returns: + +[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) + +## FirestoreFunction.exists() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field exists in the document. + +```typescript +// Check if the document has a field named "phoneNumber" +Field.of("phoneNumber").exists(); + +``` + A new `Expr` representing the 'exists' check. + +Signature: + +```typescript +exists(): Exists; +``` +Returns: + +[Exists](./firestore_.exists.md#exists_class) + +## FirestoreFunction.gt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than another expression. + +```typescript +// Check if the 'age' field is greater than the 'limit' field +Field.of("age").gt(Field.of("limit")); + +``` + +Signature: + +```typescript +gt(other: Constant): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for greater than. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_.gt.md#gt_class) + +## FirestoreFunction.gt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than a constant value. + +```typescript +// Check if the 'price' field is greater than 100 +Field.of("price").gt(100); + +``` + +Signature: + +```typescript +gt(other: any): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for greater than. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_.gt.md#gt_class) + +## FirestoreFunction.gte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than or equal to another expression. + +```typescript +// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 +Field.of("quantity").gte(Field.of('requirement').add(1)); + +``` + +Signature: + +```typescript +gte(other: Constant): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_.gte.md#gte_class) + +## FirestoreFunction.gte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than or equal to a constant value. + +```typescript +// Check if the 'score' field is greater than or equal to 80 +Field.of("score").gte(80); + +``` + +Signature: + +```typescript +gte(other: any): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_.gte.md#gte_class) + +## FirestoreFunction.in() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to any of the provided values or expressions. + +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +Field.of("category").in("Electronics", Field.of("primaryType")); + +``` + +Signature: + +```typescript +in(...others: Constant[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| others | [Constant](./firestore_.constant.md#constant_class)\[\] | The values or expressions to check against. A new Expr representing the 'IN' comparison. | + +Returns: + +[In](./firestore_.in.md#in_class) + +## FirestoreFunction.in() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +in(...others: any[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| others | any\[\] | | + +Returns: + +[In](./firestore_.in.md#in_class) + +## FirestoreFunction.isNaN() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). + +```typescript +// Check if the result of a calculation is NaN +Field.of("value").divide(0).isNaN(); + +``` + A new `Expr` representing the 'isNaN' check. + +Signature: + +```typescript +isNaN(): IsNan; +``` +Returns: + +[IsNan](./firestore_.isnan.md#isnan_class) + +## FirestoreFunction.like() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that performs a case-sensitive string comparison. + +```typescript +// Check if the 'title' field contains the word "guide" (case-sensitive) +Field.of("title").like("%guide%"); + +``` + +Signature: + +```typescript +like(pattern: string): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new Expr representing the 'like' comparison. | + +Returns: + +[Like](./firestore_.like.md#like_class) + +## FirestoreFunction.like() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +like(pattern: Constant): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_.constant.md#constant_class) | | + +Returns: + +[Like](./firestore_.like.md#like_class) + +## FirestoreFunction.logicalMax() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMax(Function.currentTimestamp()); + +``` + +Signature: + +```typescript +logicalMax(other: Constant): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare with. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) + +## FirestoreFunction.logicalMax() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'value' field and 10. +Field.of("value").logicalMax(10); + +``` + +Signature: + +```typescript +logicalMax(other: any): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare with. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) + +## FirestoreFunction.logicalMin() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMin(Function.currentTimestamp()); + +``` + +Signature: + +```typescript +logicalMin(other: Constant): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare with. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) + +## FirestoreFunction.logicalMin() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'value' field and 10. +Field.of("value").logicalMin(10); + +``` + +Signature: + +```typescript +logicalMin(other: any): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare with. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) + +## FirestoreFunction.lt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than another expression. + +```typescript +// Check if the 'age' field is less than 'limit' +Field.of("age").lt(Field.of('limit')); + +``` + +Signature: + +```typescript +lt(other: Constant): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for less than. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_.lt.md#lt_class) + +## FirestoreFunction.lt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than a constant value. + +```typescript +// Check if the 'price' field is less than 50 +Field.of("price").lt(50); + +``` + +Signature: + +```typescript +lt(other: any): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for less than. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_.lt.md#lt_class) + +## FirestoreFunction.lte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than or equal to another expression. + +```typescript +// Check if the 'quantity' field is less than or equal to 20 +Field.of("quantity").lte(Constant.of(20)); + +``` + +Signature: + +```typescript +lte(other: Constant): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_.lte.md#lte_class) + +## FirestoreFunction.lte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than or equal to a constant value. + +```typescript +// Check if the 'score' field is less than or equal to 70 +Field.of("score").lte(70); + +``` + +Signature: + +```typescript +lte(other: any): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_.lte.md#lte_class) + +## FirestoreFunction.mapGet() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Accesses a value from a map (object) field using the provided key. + +```typescript +// Get the 'city' value from the 'address' map field +Field.of("address").mapGet("city"); + +``` + +Signature: + +```typescript +mapGet(subfield: string): MapGet; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| subfield | string | The key to access in the map. A new Expr representing the value associated with the given key in the map. | + +Returns: + +[MapGet](./firestore_.mapget.md#mapget_class) + +## FirestoreFunction.max() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that finds the maximum value of a field across multiple stage inputs. + +```typescript +// Find the highest score in a leaderboard +Field.of("score").max().as("highestScore"); + +``` + A new `Accumulator` representing the 'max' aggregation. + +Signature: + +```typescript +max(): Max; +``` +Returns: + +[Max](./firestore_.max.md#max_class) + +## FirestoreFunction.min() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that finds the minimum value of a field across multiple stage inputs. + +```typescript +// Find the lowest price of all products +Field.of("price").min().as("lowestPrice"); + +``` + A new `Accumulator` representing the 'min' aggregation. + +Signature: + +```typescript +min(): Min; +``` +Returns: + +[Min](./firestore_.min.md#min_class) + +## FirestoreFunction.mod() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. + +```typescript +// Calculate the remainder of dividing the 'value' field by the 'divisor' field +Field.of("value").mod(Field.of("divisor")); + +``` + +Signature: + +```typescript +mod(other: Constant): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new Expr representing the modulo operation. | + +Returns: + +[Mod](./firestore_.mod.md#mod_class) + +## FirestoreFunction.mod() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. + +```typescript +// Calculate the remainder of dividing the 'value' field by 10 +Field.of("value").mod(10); + +``` + +Signature: + +```typescript +mod(other: any): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to divide by. A new Expr representing the modulo operation. | + +Returns: + +[Mod](./firestore_.mod.md#mod_class) + +## FirestoreFunction.multiply() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies this expression by another expression. + +```typescript +// Multiply the 'quantity' field by the 'price' field +Field.of("quantity").multiply(Field.of("price")); + +``` + +Signature: + +```typescript +multiply(other: Constant): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to multiply by. A new Expr representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_.multiply.md#multiply_class) + +## FirestoreFunction.multiply() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies this expression by a constant value. + +```typescript +// Multiply the 'value' field by 2 +Field.of("value").multiply(2); + +``` + +Signature: + +```typescript +multiply(other: any): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to multiply by. A new Expr representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_.multiply.md#multiply_class) + +## FirestoreFunction.neq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is not equal to another expression. + +```typescript +// Check if the 'status' field is not equal to "completed" +Field.of("status").neq("completed"); + +``` + +Signature: + +```typescript +neq(other: Constant): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for inequality. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_.neq.md#neq_class) + +## FirestoreFunction.neq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is not equal to a constant value. + +```typescript +// Check if the 'country' field is not equal to "USA" +Field.of("country").neq("USA"); + +``` + +Signature: + +```typescript +neq(other: any): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for inequality. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_.neq.md#neq_class) + +## FirestoreFunction.regexContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +Field.of("description").regexContains("(?i)example"); + +``` + +Signature: + +```typescript +regexContains(pattern: string): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_.regexcontains.md#regexcontains_class) + +## FirestoreFunction.regexContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains the regular expression stored in field 'regex' +Field.of("description").regexContains(Field.of("regex")); + +``` + +Signature: + +```typescript +regexContains(pattern: Constant): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_.regexcontains.md#regexcontains_class) + +## FirestoreFunction.regexMatch() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a valid email pattern +Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + +Signature: + +```typescript +regexMatch(pattern: string): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The regular expression to use for the match. A new Expr representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) + +## FirestoreFunction.regexMatch() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a regular expression stored in field 'regex' +Field.of("email").regexMatch(Field.of("regex")); + +``` + +Signature: + +```typescript +regexMatch(pattern: Constant): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the match. A new Expr representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) + +## FirestoreFunction.replaceAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within this string expression with another substring. + +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field +Field.of("message").replaceAll("hello", "hi"); + +``` + +Signature: + +```typescript +replaceAll(find: string, replace: string): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | string | The substring to search for. | +| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_.replaceall.md#replaceall_class) + +## FirestoreFunction.replaceAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + +``` + +Signature: + +```typescript +replaceAll(find: Constant, replace: Constant): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_.replaceall.md#replaceall_class) + +## FirestoreFunction.replaceFirst() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. + +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field +Field.of("message").replaceFirst("hello", "hi"); + +``` + +Signature: + +```typescript +replaceFirst(find: string, replace: string): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | string | The substring to search for. | +| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) + +## FirestoreFunction.replaceFirst() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + +``` + +Signature: + +```typescript +replaceFirst(find: Constant, replace: Constant): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) + +## FirestoreFunction.reverse() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that reverses this string expression. + +```typescript +// Reverse the value of the 'myString' field. +Field.of("myString").reverse(); + +``` + A new representing the reversed string. + +Signature: + +```typescript +reverse(): Reverse; +``` +Returns: + +[Reverse](./firestore_.reverse.md#reverse_class) + +## FirestoreFunction.startsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string starts with a given prefix. + +```typescript +// Check if the 'name' field starts with "Mr." +Field.of("name").startsWith("Mr."); + +``` + +Signature: + +```typescript +startsWith(prefix: string): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| prefix | string | The prefix to check for. A new Expr representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_.startswith.md#startswith_class) + +## FirestoreFunction.startsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string starts with a given prefix (represented as an expression). + +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +Field.of("fullName").startsWith(Field.of("firstName")); + +``` + +Signature: + +```typescript +startsWith(prefix: Constant): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| prefix | [Constant](./firestore_.constant.md#constant_class) | The prefix expression to check for. A new Expr representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_.startswith.md#startswith_class) + +## FirestoreFunction.strConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates string expressions together. + +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + +``` + +Signature: + +```typescript +strConcat(...elements: Array): StrConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| elements | Array<string \| [Constant](./firestore_.constant.md#constant_class)> | The expressions (typically strings) to concatenate. A new Expr representing the concatenated string. | + +Returns: + +[StrConcat](./firestore_.strconcat.md#strconcat_class) + +## FirestoreFunction.strContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified substring. + +```typescript +// Check if the 'description' field contains "example". +Field.of("description").strContains("example"); + +``` + +Signature: + +```typescript +strContains(substring: string): StrContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| substring | string | The substring to search for. A new Expr representing the 'contains' comparison. | + +Returns: + +[StrContains](./firestore_.strcontains.md#strcontains_class) + +## FirestoreFunction.strContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains the string represented by another expression. + +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +Field.of("description").strContains(Field.of("keyword")); + +``` + +Signature: + +```typescript +strContains(expr: Constant): StrContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. A new Expr representing the 'contains' comparison. | + +Returns: + +[StrContains](./firestore_.strcontains.md#strcontains_class) + +## FirestoreFunction.subtract() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts another expression from this expression. + +```typescript +// Subtract the 'discount' field from the 'price' field +Field.of("price").subtract(Field.of("discount")); + +``` + +Signature: + +```typescript +subtract(other: Constant): Subtract; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_.constant.md#constant_class) | The expression to subtract from this expression. A new Expr representing the subtraction operation. | + +Returns: + +[Subtract](./firestore_.subtract.md#subtract_class) + +## FirestoreFunction.subtract() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a constant value from this expression. + +```typescript +// Subtract 20 from the value of the 'total' field +Field.of("total").subtract(20); + +``` + +Signature: + +```typescript +subtract(other: any): Subtract; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to subtract. A new Expr representing the subtraction operation. | + +Returns: + +[Subtract](./firestore_.subtract.md#subtract_class) + +## FirestoreFunction.sum() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. + +```typescript +// Calculate the total revenue from a set of orders +Field.of("orderAmount").sum().as("totalRevenue"); + +``` + A new `Accumulator` representing the 'sum' aggregation. + +Signature: + +```typescript +sum(): Sum; +``` +Returns: + +[Sum](./firestore_.sum.md#sum_class) + +## FirestoreFunction.timestampAdd() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to this timestamp expression. + +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + +``` + +Signature: + +```typescript +timestampAdd(unit: Constant, amount: Constant): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) + +## FirestoreFunction.timestampAdd() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to this timestamp expression. + +```typescript +// Add 1 day to the 'timestamp' field. +Field.of("timestamp").timestampAdd("day", 1); + +``` + +Signature: + +```typescript +timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | +| amount | number | The amount of time to add. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) + +## FirestoreFunction.timestampSub() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from this timestamp expression. + +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + +``` + +Signature: + +```typescript +timestampSub(unit: Constant, amount: Constant): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) + +## FirestoreFunction.timestampSub() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from this timestamp expression. + +```typescript +// Subtract 1 day from the 'timestamp' field. +Field.of("timestamp").timestampSub("day", 1); + +``` + +Signature: + +```typescript +timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | +| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) + +## FirestoreFunction.timestampToUnixMicros() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +Field.of("timestamp").timestampToUnixMicros(); + +``` + A new representing the number of microseconds since epoch. + +Signature: + +```typescript +timestampToUnixMicros(): TimestampToUnixMicros; +``` +Returns: + +[TimestampToUnixMicros](./firestore_.timestamptounixmicros.md#timestamptounixmicros_class) + +## FirestoreFunction.timestampToUnixMillis() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +Field.of("timestamp").timestampToUnixMillis(); + +``` + A new representing the number of milliseconds since epoch. + +Signature: + +```typescript +timestampToUnixMillis(): TimestampToUnixMillis; +``` +Returns: + +[TimestampToUnixMillis](./firestore_.timestamptounixmillis.md#timestamptounixmillis_class) + +## FirestoreFunction.timestampToUnixSeconds() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to seconds since epoch. +Field.of("timestamp").timestampToUnixSeconds(); + +``` + A new representing the number of seconds since epoch. + +Signature: + +```typescript +timestampToUnixSeconds(): TimestampToUnixSeconds; +``` +Returns: + +[TimestampToUnixSeconds](./firestore_.timestamptounixseconds.md#timestamptounixseconds_class) + +## FirestoreFunction.toLower() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string to lowercase. + +```typescript +// Convert the 'name' field to lowercase +Field.of("name").toLower(); + +``` + A new `Expr` representing the lowercase string. + +Signature: + +```typescript +toLower(): ToLower; +``` +Returns: + +[ToLower](./firestore_.tolower.md#tolower_class) + +## FirestoreFunction.toUpper() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string to uppercase. + +```typescript +// Convert the 'title' field to uppercase +Field.of("title").toUpper(); + +``` + A new `Expr` representing the uppercase string. + +Signature: + +```typescript +toUpper(): ToUpper; +``` +Returns: + +[ToUpper](./firestore_.toupper.md#toupper_class) + +## FirestoreFunction.trim() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that removes leading and trailing whitespace from a string. + +```typescript +// Trim whitespace from the 'userInput' field +Field.of("userInput").trim(); + +``` + A new `Expr` representing the trimmed string. + +Signature: + +```typescript +trim(): Trim; +``` +Returns: + +[Trim](./firestore_.trim.md#trim_class) + +## FirestoreFunction.unixMicrosToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +Field.of("microseconds").unixMicrosToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixMicrosToTimestamp(): UnixMicrosToTimestamp; +``` +Returns: + +[UnixMicrosToTimestamp](./firestore_.unixmicrostotimestamp.md#unixmicrostotimestamp_class) + +## FirestoreFunction.unixMillisToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +Field.of("milliseconds").unixMillisToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixMillisToTimestamp(): UnixMillisToTimestamp; +``` +Returns: + +[UnixMillisToTimestamp](./firestore_.unixmillistotimestamp.md#unixmillistotimestamp_class) + +## FirestoreFunction.unixSecondsToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'seconds' field as seconds since epoch. +Field.of("seconds").unixSecondsToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixSecondsToTimestamp(): UnixSecondsToTimestamp; +``` +Returns: + +[UnixSecondsToTimestamp](./firestore_.unixsecondstotimestamp.md#unixsecondstotimestamp_class) + +## FirestoreFunction.vectorLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. + +```typescript +// Get the vector length (dimension) of the field 'embedding'. +Field.of("embedding").vectorLength(); + +``` + A new representing the length of the vector. + +Signature: + +```typescript +vectorLength(): VectorLength; +``` +Returns: + +[VectorLength](./firestore_.vectorlength.md#vectorlength_class) + diff --git a/docs-devsite/firestore_.genericstage.md b/docs-devsite/firestore_.genericstage.md new file mode 100644 index 00000000000..765ef090d87 --- /dev/null +++ b/docs-devsite/firestore_.genericstage.md @@ -0,0 +1,65 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# GenericStage class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class GenericStage implements Stage +``` +Implements: [Stage](./firestore_.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(name, params)](./firestore_.genericstage.md#genericstageconstructor) | | (BETA) Constructs a new instance of the GenericStage class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_.genericstage.md#genericstagename) | | string | (BETA) | + +## GenericStage.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `GenericStage` class + +Signature: + +```typescript +constructor(name: string, params: unknown[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | | +| params | unknown\[\] | | + +## GenericStage.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_.gt.md b/docs-devsite/firestore_.gt.md new file mode 100644 index 00000000000..75843e172d7 --- /dev/null +++ b/docs-devsite/firestore_.gt.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Gt class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Gt extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_.gt.md#gtconstructor) | | (BETA) Constructs a new instance of the Gt class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_.gt.md#gtfilterable) | | true | (BETA) | + +## Gt.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Gt` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | | +| right | [Constant](./firestore_.constant.md#constant_class) | | + +## Gt.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_.gte.md b/docs-devsite/firestore_.gte.md new file mode 100644 index 00000000000..923ece3ab8d --- /dev/null +++ b/docs-devsite/firestore_.gte.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Gte class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Gte extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_.gte.md#gteconstructor) | | (BETA) Constructs a new instance of the Gte class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_.gte.md#gtefilterable) | | true | (BETA) | + +## Gte.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Gte` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | | +| right | [Constant](./firestore_.constant.md#constant_class) | | + +## Gte.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_.if.md b/docs-devsite/firestore_.if.md new file mode 100644 index 00000000000..4f756b032b4 --- /dev/null +++ b/docs-devsite/firestore_.if.md @@ -0,0 +1,68 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# If class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class If extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(condition, thenExpr, elseExpr)](./firestore_.if.md#ifconstructor) | | (BETA) Constructs a new instance of the If class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_.if.md#iffilterable) | | true | (BETA) | + +## If.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `If` class + +Signature: + +```typescript +constructor(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| condition | [FilterExpr](./firestore_.md#filterexpr) | | +| thenExpr | [Constant](./firestore_.constant.md#constant_class) | | +| elseExpr | [Constant](./firestore_.constant.md#constant_class) | | + +## If.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_.in.md b/docs-devsite/firestore_.in.md new file mode 100644 index 00000000000..76f38733041 --- /dev/null +++ b/docs-devsite/firestore_.in.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# In class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class In extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, others)](./firestore_.in.md#inconstructor) | | (BETA) Constructs a new instance of the In class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_.in.md#infilterable) | | true | (BETA) | + +## In.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `In` class + +Signature: + +```typescript +constructor(left: Constant, others: Constant[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | | +| others | [Constant](./firestore_.constant.md#constant_class)\[\] | | + +## In.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_.isnan.md b/docs-devsite/firestore_.isnan.md new file mode 100644 index 00000000000..bbeb8e4fa51 --- /dev/null +++ b/docs-devsite/firestore_.isnan.md @@ -0,0 +1,66 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# IsNan class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class IsNan extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr)](./firestore_.isnan.md#isnanconstructor) | | (BETA) Constructs a new instance of the IsNan class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_.isnan.md#isnanfilterable) | | true | (BETA) | + +## IsNan.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `IsNan` class + +Signature: + +```typescript +constructor(expr: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | | + +## IsNan.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_.like.md b/docs-devsite/firestore_.like.md new file mode 100644 index 00000000000..94e680dd723 --- /dev/null +++ b/docs-devsite/firestore_.like.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Like class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Like extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr, pattern)](./firestore_.like.md#likeconstructor) | | (BETA) Constructs a new instance of the Like class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_.like.md#likefilterable) | | true | (BETA) | + +## Like.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Like` class + +Signature: + +```typescript +constructor(expr: Constant, pattern: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | | +| pattern | [Constant](./firestore_.constant.md#constant_class) | | + +## Like.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_.limit.md b/docs-devsite/firestore_.limit.md new file mode 100644 index 00000000000..81ad7339037 --- /dev/null +++ b/docs-devsite/firestore_.limit.md @@ -0,0 +1,64 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Limit class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Limit implements Stage +``` +Implements: [Stage](./firestore_.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(limit)](./firestore_.limit.md#limitconstructor) | | (BETA) Constructs a new instance of the Limit class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_.limit.md#limitname) | | string | (BETA) | + +## Limit.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Limit` class + +Signature: + +```typescript +constructor(limit: number); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| limit | number | | + +## Limit.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_.logicalmax.md b/docs-devsite/firestore_.logicalmax.md new file mode 100644 index 00000000000..633947cdaba --- /dev/null +++ b/docs-devsite/firestore_.logicalmax.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# LogicalMax class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class LogicalMax extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_.logicalmax.md#logicalmaxconstructor) | | (BETA) Constructs a new instance of the LogicalMax class | + +## LogicalMax.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `LogicalMax` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | | +| right | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.logicalmin.md b/docs-devsite/firestore_.logicalmin.md new file mode 100644 index 00000000000..65bf7ad5dc1 --- /dev/null +++ b/docs-devsite/firestore_.logicalmin.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# LogicalMin class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class LogicalMin extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_.logicalmin.md#logicalminconstructor) | | (BETA) Constructs a new instance of the LogicalMin class | + +## LogicalMin.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `LogicalMin` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | | +| right | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.lt.md b/docs-devsite/firestore_.lt.md new file mode 100644 index 00000000000..54911158139 --- /dev/null +++ b/docs-devsite/firestore_.lt.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Lt class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Lt extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_.lt.md#ltconstructor) | | (BETA) Constructs a new instance of the Lt class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_.lt.md#ltfilterable) | | true | (BETA) | + +## Lt.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Lt` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | | +| right | [Constant](./firestore_.constant.md#constant_class) | | + +## Lt.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_.lte.md b/docs-devsite/firestore_.lte.md new file mode 100644 index 00000000000..7bd5cbe4420 --- /dev/null +++ b/docs-devsite/firestore_.lte.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Lte class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Lte extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_.lte.md#lteconstructor) | | (BETA) Constructs a new instance of the Lte class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_.lte.md#ltefilterable) | | true | (BETA) | + +## Lte.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Lte` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | | +| right | [Constant](./firestore_.constant.md#constant_class) | | + +## Lte.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_.mapget.md b/docs-devsite/firestore_.mapget.md new file mode 100644 index 00000000000..c2fe330f2f3 --- /dev/null +++ b/docs-devsite/firestore_.mapget.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# MapGet class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class MapGet extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(map, name)](./firestore_.mapget.md#mapgetconstructor) | | (BETA) Constructs a new instance of the MapGet class | + +## MapGet.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `MapGet` class + +Signature: + +```typescript +constructor(map: Constant, name: string); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| map | [Constant](./firestore_.constant.md#constant_class) | | +| name | string | | + diff --git a/docs-devsite/firestore_.max.md b/docs-devsite/firestore_.max.md new file mode 100644 index 00000000000..5fe1c376f93 --- /dev/null +++ b/docs-devsite/firestore_.max.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Max class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Max extends FirestoreFunction implements Accumulator +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [Accumulator](./firestore_.accumulator.md#accumulator_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value, distinct)](./firestore_.max.md#maxconstructor) | | (BETA) Constructs a new instance of the Max class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [accumulator](./firestore_.max.md#maxaccumulator) | | true | (BETA) | + +## Max.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Max` class + +Signature: + +```typescript +constructor(value: Constant, distinct: boolean); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_.constant.md#constant_class) | | +| distinct | boolean | | + +## Max.accumulator + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +accumulator: true; +``` diff --git a/docs-devsite/firestore_.md b/docs-devsite/firestore_.md index 74e960c833b..78db4044e17 100644 --- a/docs-devsite/firestore_.md +++ b/docs-devsite/firestore_.md @@ -34,6 +34,7 @@ https://github.com/firebase/firebase-js-sdk | [namedQuery(firestore, name)](./firestore_.md#namedquery_6438876) | Reads a Firestore [Query](./firestore_.query.md#query_class) from local cache, identified by the given name.The named queries are packaged into bundles on the server side (along with resulting documents), and loaded to local cache using loadBundle. Once in local cache, use this method to extract a [Query](./firestore_.query.md#query_class) by name. | | [onSnapshotsInSync(firestore, observer)](./firestore_.md#onsnapshotsinsync_2f0dfa4) | Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if a single server-generated change affects multiple listeners.NOTE: The snapshots-in-sync event only indicates that listeners are in sync with each other, but does not relate to whether those snapshots are in sync with the server. Use SnapshotMetadata in the individual listeners to determine if a snapshot is from the cache or the server. | | [onSnapshotsInSync(firestore, onSync)](./firestore_.md#onsnapshotsinsync_1901c06) | Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if a single server-generated change affects multiple listeners.NOTE: The snapshots-in-sync event only indicates that listeners are in sync with each other, but does not relate to whether those snapshots are in sync with the server. Use SnapshotMetadata in the individual listeners to determine if a snapshot is from the cache or the server. | +| [pipeline(firestore)](./firestore_.md#pipeline_231a8e0) | Experimental Modular API for console testing. | | [runTransaction(firestore, updateFunction, options)](./firestore_.md#runtransaction_6f03ec4) | Executes the given updateFunction and then attempts to commit the changes applied within the transaction. If any document read within the transaction has changed, Cloud Firestore retries the updateFunction. If it fails to commit after 5 attempts, the transaction fails.The maximum number of writes allowed in a single transaction is 500. | | [setIndexConfiguration(firestore, configuration)](./firestore_.md#setindexconfiguration_c362f04) | (BETA) Configures indexing for local query execution. Any previous index configuration is overridden. The Promise resolves once the index configuration has been persisted.The index entries themselves are created asynchronously. You can continue to use queries that require indexing even if the indices are not yet available. Query execution will automatically start using the index once the index entries have been written.Indexes are only supported with IndexedDb persistence. If IndexedDb is not enabled, any index configuration is ignored. | | [setIndexConfiguration(firestore, json)](./firestore_.md#setindexconfiguration_90d0285) | (BETA) Configures indexing for local query execution. Any previous index configuration is overridden. The Promise resolves once the index configuration has been persisted.The index entries themselves are created asynchronously. You can continue to use queries that require indexing even if the indices are not yet available. Query execution will automatically start using the index once the index entries have been written.Indexes are only supported with IndexedDb persistence. Invoke either enableIndexedDbPersistence() or enableMultiTabIndexedDbPersistence() before setting an index configuration. If IndexedDb is not enabled, any index configuration is ignored.The method accepts the JSON format exported by the Firebase CLI (firebase firestore:indexes). If the JSON format is invalid, this method throws an error. | @@ -42,2418 +43,9439 @@ https://github.com/firebase/firebase-js-sdk | [writeBatch(firestore)](./firestore_.md#writebatch_231a8e0) | Creates a write batch, used for performing multiple writes as a single atomic operation. The maximum number of writes allowed in a single [WriteBatch](./firestore_.writebatch.md#writebatch_class) is 500.Unlike transactions, write batches are persisted offline and therefore are preferable when you don't need to condition your writes on read data. | | function() | | [count()](./firestore_.md#count) | Create an AggregateField object that can be used to compute the count of documents in the result set of a query. | +| [countAll()](./firestore_.md#countall) | (BETA) Creates an aggregation that counts the total number of stage inputs. +```typescript +// Count the total number of users +countAll().as("totalUsers"); + +``` + A new representing the 'countAll' aggregation. | | [deleteField()](./firestore_.md#deletefield) | Returns a sentinel for use with [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) or [setDoc()](./firestore_lite.md#setdoc_ee215ad) with {merge: true} to mark a field for deletion. | | [documentId()](./firestore_.md#documentid) | Returns a special sentinel FieldPath to refer to the ID of a document. It can be used in queries to sort or filter by the document ID. | | [getFirestore()](./firestore_.md#getfirestore) | Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. | | [memoryEagerGarbageCollector()](./firestore_.md#memoryeagergarbagecollector) | Creates an instance of MemoryEagerGarbageCollector. This is also the default garbage collector unless it is explicitly specified otherwise. | | [persistentMultipleTabManager()](./firestore_.md#persistentmultipletabmanager) | Creates an instance of PersistentMultipleTabManager. | | [serverTimestamp()](./firestore_.md#servertimestamp) | Returns a sentinel used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) to include a server-generated timestamp in the written data. | +| [useFirestorePipelines()](./firestore_.md#usefirestorepipelines) | | +| function(array, ...) | +| [arrayConcat(array, elements)](./firestore_.md#arrayconcat_0b3ddb9) | (BETA) Creates an expression that concatenates an array expression with other arrays. +```typescript +// Combine the 'items' array with two new item arrays +arrayConcat(Field.of("items"), [Field.of("newItems"), Field.of("otherItems")]); + +``` + | +| [arrayConcat(array, elements)](./firestore_.md#arrayconcat_21991c1) | (BETA) Creates an expression that concatenates an array expression with other arrays and/or values. +```typescript +// Combine the 'tags' array with a new array +arrayConcat(Field.of("tags"), ["newTag1", "newTag2"]); + +``` + | +| [arrayConcat(array, elements)](./firestore_.md#arrayconcat_f8d5d5e) | (BETA) Creates an expression that concatenates a field's array value with other arrays. +```typescript +// Combine the 'items' array with two new item arrays +arrayConcat("items", [Field.of("newItems"), Field.of("otherItems")]); + +``` + | +| [arrayConcat(array, elements)](./firestore_.md#arrayconcat_5a66d99) | (BETA) Creates an expression that concatenates a field's array value with other arrays and/or values. +```typescript +// Combine the 'tags' array with a new array +arrayConcat("tags", ["newTag1", "newTag2"]); + +``` + | +| [arrayContains(array, element)](./firestore_.md#arraycontains_01ea7c0) | (BETA) Creates an expression that checks if an array expression contains a specific element. +```typescript +// Check if the 'colors' array contains the value of field 'selectedColor' +arrayContains(Field.of("colors"), Field.of("selectedColor")); + +``` + | +| [arrayContains(array, element)](./firestore_.md#arraycontains_60f8f2f) | (BETA) Creates an expression that checks if an array expression contains a specific element. +```typescript +// Check if the 'colors' array contains "red" +arrayContains(Field.of("colors"), "red"); + +``` + | +| [arrayContains(array, element)](./firestore_.md#arraycontains_0ebdbfe) | (BETA) Creates an expression that checks if a field's array value contains a specific element. +```typescript +// Check if the 'colors' array contains the value of field 'selectedColor' +arrayContains("colors", Field.of("selectedColor")); + +``` + | +| [arrayContains(array, element)](./firestore_.md#arraycontains_8f718df) | (BETA) Creates an expression that checks if a field's array value contains a specific value. +```typescript +// Check if the 'colors' array contains "red" +arrayContains("colors", "red"); + +``` + | +| [arrayContainsAll(array, values)](./firestore_.md#arraycontainsall_7b7433a) | (BETA) Creates an expression that checks if an array expression contains all the specified elements. +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" +arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); + +``` + | +| [arrayContainsAll(array, values)](./firestore_.md#arraycontainsall_d919466) | (BETA) Creates an expression that checks if an array expression contains all the specified elements. +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" +arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); + +``` + | +| [arrayContainsAll(array, values)](./firestore_.md#arraycontainsall_b40e2df) | (BETA) Creates an expression that checks if a field's array value contains all the specified values or expressions. +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); + +``` + | +| [arrayContainsAll(array, values)](./firestore_.md#arraycontainsall_b08efbb) | (BETA) Creates an expression that checks if a field's array value contains all the specified values or expressions. +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); + +``` + | +| [arrayContainsAny(array, values)](./firestore_.md#arraycontainsany_7b7433a) | (BETA) Creates an expression that checks if an array expression contains any of the specified elements. +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "Science" +arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); + +``` + | +| [arrayContainsAny(array, values)](./firestore_.md#arraycontainsany_d919466) | (BETA) Creates an expression that checks if an array expression contains any of the specified elements. +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "Science" +arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); + +``` + | +| [arrayContainsAny(array, values)](./firestore_.md#arraycontainsany_b40e2df) | (BETA) Creates an expression that checks if a field's array value contains any of the specified elements. +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +arrayContainsAny("categories", [Field.of("cate1"), "Science"]); + +``` + | +| [arrayContainsAny(array, values)](./firestore_.md#arraycontainsany_b08efbb) | (BETA) Creates an expression that checks if a field's array value contains any of the specified elements. +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +arrayContainsAny("categories", [Field.of("cate1"), "Science"]); + +``` + | +| [arrayLength(array)](./firestore_.md#arraylength_0bb5dbb) | (BETA) Creates an expression that calculates the length of an array expression. +```typescript +// Get the number of items in the 'cart' array +arrayLength(Field.of("cart")); + +``` + | +| function(condition, ...) | +| [ifFunction(condition, thenExpr, elseExpr)](./firestore_.md#iffunction_f7b2404) | (BETA) Creates a conditional expression that evaluates to a 'then' expression if a condition is true and an 'else' expression if the condition is false. +```typescript +// If 'age' is greater than 18, return "Adult"; otherwise, return "Minor". +ifFunction( + gt("age", 18), Constant.of("Adult"), Constant.of("Minor")); + +``` + | | function(databaseId, ...) | | [getFirestore(databaseId)](./firestore_.md#getfirestore_53dc891) | (BETA) Returns the existing named [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. | +| function(element, ...) | +| [inAny(element, others)](./firestore_.md#inany_a73b259) | (BETA) Creates an expression that checks if an expression is equal to any of the provided values or expressions. +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +inAny(Field.of("category"), [Constant.of("Electronics"), Field.of("primaryType")]); + +``` + | +| [inAny(element, others)](./firestore_.md#inany_f5721c6) | (BETA) Creates an expression that checks if an expression is equal to any of the provided values or expressions. +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +inAny(Field.of("category"), ["Electronics", Field.of("primaryType")]); + +``` + | +| [inAny(element, others)](./firestore_.md#inany_c6646ea) | (BETA) Creates an expression that checks if a field's value is equal to any of the provided values or expressions. +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +inAny("category", [Constant.of("Electronics"), Field.of("primaryType")]); + +``` + | +| [inAny(element, others)](./firestore_.md#inany_e6877aa) | (BETA) Creates an expression that checks if a field's value is equal to any of the provided values or expressions. +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +inAny("category", ["Electronics", Field.of("primaryType")]); + +``` + | +| [notInAny(element, others)](./firestore_.md#notinany_a73b259) | (BETA) Creates an expression that checks if an expression is not equal to any of the provided values or expressions. +```typescript +// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' +notInAny(Field.of("status"), [Constant.of("pending"), Field.of("rejectedStatus")]); + +``` + | +| [notInAny(element, others)](./firestore_.md#notinany_f5721c6) | (BETA) Creates an expression that checks if an expression is not equal to any of the provided values or expressions. +```typescript +// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' +notInAny(Field.of("status"), ["pending", Field.of("rejectedStatus")]); + +``` + | +| [notInAny(element, others)](./firestore_.md#notinany_c6646ea) | (BETA) Creates an expression that checks if a field's value is not equal to any of the provided values or expressions. +```typescript +// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' +notInAny("status", [Constant.of("pending"), Field.of("rejectedStatus")]); + +``` + | +| [notInAny(element, others)](./firestore_.md#notinany_e6877aa) | (BETA) Creates an expression that checks if a field's value is not equal to any of the provided values or expressions. +```typescript +// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' +notInAny("status", ["pending", Field.of("rejectedStatus")]); + +``` + | | function(elements, ...) | | [arrayRemove(elements)](./firestore_.md#arrayremove_7d853aa) | Returns a special value that can be used with [setDoc()](./firestore_.md#setdoc_ee215ad) or that tells the server to remove the given elements from any array value that already exists on the server. All instances of each element specified will be removed from the array. If the field being modified is not already an array it will be overwritten with an empty array. | | [arrayUnion(elements)](./firestore_.md#arrayunion_7d853aa) | Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to union the given elements with any array value that already exists on the server. Each specified element that doesn't already exist in the array will be added to the end. If the field being modified is not already an array it will be overwritten with an array containing exactly the specified elements. | -| function(field, ...) | -| [average(field)](./firestore_.md#average_aacc3a9) | Create an AggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query. | -| [sum(field)](./firestore_.md#sum_aacc3a9) | Create an AggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query. | -| function(fieldPath, ...) | -| [orderBy(fieldPath, directionStr)](./firestore_.md#orderby_006d61f) | Creates a [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) that sorts the query result by the specified field, optionally in descending order instead of ascending.Note: Documents that do not contain the specified field will not be present in the query result. | -| [where(fieldPath, opStr, value)](./firestore_.md#where_0fae4bf) | Creates a [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) that enforces that documents must contain the specified field and that the value should satisfy the relation constraint provided. | -| function(fieldValues, ...) | -| [endAt(fieldValues)](./firestore_.md#endat_8b2f2c8) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | -| [endBefore(fieldValues)](./firestore_.md#endbefore_8b2f2c8) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | -| [startAfter(fieldValues)](./firestore_.md#startafter_8b2f2c8) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | -| [startAt(fieldValues)](./firestore_.md#startat_8b2f2c8) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | -| function(indexManager, ...) | -| [deleteAllPersistentCacheIndexes(indexManager)](./firestore_.md#deleteallpersistentcacheindexes_98b2645) | Removes all persistent cache indexes.Please note this function will also deletes indexes generated by setIndexConfiguration(), which is deprecated. | -| [disablePersistentCacheIndexAutoCreation(indexManager)](./firestore_.md#disablepersistentcacheindexautocreation_98b2645) | Stops creating persistent cache indexes automatically for local query execution. The indexes which have been created by calling enablePersistentCacheIndexAutoCreation() still take effect. | -| [enablePersistentCacheIndexAutoCreation(indexManager)](./firestore_.md#enablepersistentcacheindexautocreation_98b2645) | Enables the SDK to create persistent cache indexes automatically for local query execution when the SDK believes cache indexes can help improve performance.This feature is disabled by default. | -| function(left, ...) | -| [aggregateFieldEqual(left, right)](./firestore_.md#aggregatefieldequal_e80a2b2) | Compares two 'AggregateField\` instances for equality. | -| [aggregateQuerySnapshotEqual(left, right)](./firestore_.md#aggregatequerysnapshotequal_1529a20) | Compares two AggregateQuerySnapshot instances for equality.Two AggregateQuerySnapshot instances are considered "equal" if they have underlying queries that compare equal, and the same data. | -| [queryEqual(left, right)](./firestore_.md#queryequal_7a1f045) | Returns true if the provided queries point to the same collection and apply the same constraints. | -| [refEqual(left, right)](./firestore_.md#refequal_598b780) | Returns true if the provided references are equal. | -| [snapshotEqual(left, right)](./firestore_.md#snapshotequal_5109204) | Returns true if the provided snapshots are equal. | -| function(limit, ...) | -| [limit(limit)](./firestore_.md#limit_ec46c78) | Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the first matching documents. | -| [limitToLast(limit)](./firestore_.md#limittolast_ec46c78) | Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the last matching documents.You must specify at least one orderBy clause for limitToLast queries, otherwise an exception will be thrown during execution. | -| function(logLevel, ...) | -| [setLogLevel(logLevel)](./firestore_.md#setloglevel_d02fda2) | Sets the verbosity of Cloud Firestore logs (debug, error, or silent). | -| function(n, ...) | -| [increment(n)](./firestore_.md#increment_5685735) | Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to increment the field's current value by the given value.If either the operand or the current field value uses floating point precision, all arithmetic follows IEEE 754 semantics. If both values are integers, values outside of JavaScript's safe number range (Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER) are also subject to precision loss. Furthermore, once processed by the Firestore backend, all integer operations are capped between -2^63 and 2^63-1.If the current field value is not of type number, or if the field does not yet exist, the transformation sets the field to the given value. | -| function(query, ...) | -| [getAggregateFromServer(query, aggregateSpec)](./firestore_.md#getaggregatefromserver_2073a74) | Calculates the specified aggregations over the documents in the result set of the given query without actually downloading the documents.Using this function to perform aggregations is efficient because only the final aggregation values, not the documents' data, are downloaded. This function can perform aggregations of the documents in cases where the result set is prohibitively large to download entirely (thousands of documents).The result received from the server is presented, unaltered, without considering any local state. That is, documents in the local cache are not taken into consideration, neither are local modifications not yet synchronized with the server. Previously-downloaded results, if any, are not used. Every invocation of this function necessarily involves a round trip to the server. | -| [getCountFromServer(query)](./firestore_.md#getcountfromserver_4e56953) | Calculates the number of documents in the result set of the given query without actually downloading the documents.Using this function to count the documents is efficient because only the final count, not the documents' data, is downloaded. This function can count the documents in cases where the result set is prohibitively large to download entirely (thousands of documents).The result received from the server is presented, unaltered, without considering any local state. That is, documents in the local cache are not taken into consideration, neither are local modifications not yet synchronized with the server. Previously-downloaded results, if any, are not used. Every invocation of this function necessarily involves a round trip to the server. | -| [getDocs(query)](./firestore_.md#getdocs_4e56953) | Executes the query and returns the results as a QuerySnapshot.Note: getDocs() attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. To specify this behavior, invoke [getDocsFromCache()](./firestore_.md#getdocsfromcache_4e56953) or [getDocsFromServer()](./firestore_.md#getdocsfromserver_4e56953). | -| [getDocsFromCache(query)](./firestore_.md#getdocsfromcache_4e56953) | Executes the query and returns the results as a QuerySnapshot from cache. Returns an empty result set if no documents matching the query are currently cached. | -| [getDocsFromServer(query)](./firestore_.md#getdocsfromserver_4e56953) | Executes the query and returns the results as a QuerySnapshot from the server. Returns an error if the network is not available. | -| [onSnapshot(query, observer)](./firestore_.md#onsnapshot_8d14049) | Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | -| [onSnapshot(query, options, observer)](./firestore_.md#onsnapshot_03dfff5) | Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | -| [onSnapshot(query, onNext, onError, onCompletion)](./firestore_.md#onsnapshot_3ebfbe2) | Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | -| [onSnapshot(query, options, onNext, onError, onCompletion)](./firestore_.md#onsnapshot_b8f9c47) | Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | -| [query(query, compositeFilter, queryConstraints)](./firestore_.md#query_9f7b0f4) | Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. | -| [query(query, queryConstraints)](./firestore_.md#query_0f46da1) | Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. | -| function(queryConstraints, ...) | -| [and(queryConstraints)](./firestore_.md#and_e72c712) | Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a conjunction of the given filter constraints. A conjunction filter includes a document if it satisfies all of the given filters. | -| [or(queryConstraints)](./firestore_.md#or_e72c712) | Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a disjunction of the given filter constraints. A disjunction filter includes a document if it satisfies any of the given filters. | -| function(reference, ...) | -| [addDoc(reference, data)](./firestore_.md#adddoc_6e783ff) | Add a new document to specified CollectionReference with the given data, assigning it a document ID automatically. | -| [collection(reference, path, pathSegments)](./firestore_.md#collection_568f98d) | Gets a CollectionReference instance that refers to a subcollection of reference at the specified relative path. | -| [collection(reference, path, pathSegments)](./firestore_.md#collection_70b4396) | Gets a CollectionReference instance that refers to a subcollection of reference at the specified relative path. | -| [deleteDoc(reference)](./firestore_.md#deletedoc_4569087) | Deletes the document referred to by the specified DocumentReference. | -| [doc(reference, path, pathSegments)](./firestore_.md#doc_568f98d) | Gets a DocumentReference instance that refers to a document within reference at the specified relative path. If no path is specified, an automatically-generated unique ID will be used for the returned DocumentReference. | -| [doc(reference, path, pathSegments)](./firestore_.md#doc_70b4396) | Gets a DocumentReference instance that refers to a document within reference at the specified relative path. | -| [getDoc(reference)](./firestore_.md#getdoc_4569087) | Reads the document referred to by this DocumentReference.Note: getDoc() attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. To specify this behavior, invoke [getDocFromCache()](./firestore_.md#getdocfromcache_4569087) or [getDocFromServer()](./firestore_.md#getdocfromserver_4569087). | -| [getDocFromCache(reference)](./firestore_.md#getdocfromcache_4569087) | Reads the document referred to by this DocumentReference from cache. Returns an error if the document is not currently cached. | -| [getDocFromServer(reference)](./firestore_.md#getdocfromserver_4569087) | Reads the document referred to by this DocumentReference from the server. Returns an error if the network is not available. | -| [onSnapshot(reference, observer)](./firestore_.md#onsnapshot_0312fd7) | Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | -| [onSnapshot(reference, options, observer)](./firestore_.md#onsnapshot_86b6b9e) | Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | -| [onSnapshot(reference, onNext, onError, onCompletion)](./firestore_.md#onsnapshot_905f42c) | Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | -| [onSnapshot(reference, options, onNext, onError, onCompletion)](./firestore_.md#onsnapshot_0c39991) | Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | -| [setDoc(reference, data)](./firestore_.md#setdoc_ee215ad) | Writes to the document referred to by this DocumentReference. If the document does not yet exist, it will be created. | -| [setDoc(reference, data, options)](./firestore_.md#setdoc_ff80739) | Writes to the document referred to by the specified DocumentReference. If the document does not yet exist, it will be created. If you provide merge or mergeFields, the provided data can be merged into an existing document. | -| [updateDoc(reference, data)](./firestore_.md#updatedoc_51a65e3) | Updates fields in the document referred to by the specified DocumentReference. The update will fail if applied to a document that does not exist. | -| [updateDoc(reference, field, value, moreFieldsAndValues)](./firestore_.md#updatedoc_7c28659) | Updates fields in the document referred to by the specified DocumentReference The update will fail if applied to a document that does not exist.Nested fields can be updated by providing dot-separated field path strings or by providing FieldPath objects. | -| function(settings, ...) | -| [memoryLocalCache(settings)](./firestore_.md#memorylocalcache_05f4bf2) | Creates an instance of MemoryLocalCache. The instance can be set to FirestoreSettings.cache to tell the SDK which cache layer to use. | -| [memoryLruGarbageCollector(settings)](./firestore_.md#memorylrugarbagecollector_5ee014c) | Creates an instance of MemoryLruGarbageCollector.A target size can be specified as part of the setting parameter. The collector will start deleting documents once the cache size exceeds the given size. The default cache size is 40MB (40 \* 1024 \* 1024 bytes). | -| [persistentLocalCache(settings)](./firestore_.md#persistentlocalcache_d312f71) | Creates an instance of PersistentLocalCache. The instance can be set to FirestoreSettings.cache to tell the SDK which cache layer to use.Persistent cache cannot be used in a Node.js environment. | -| [persistentSingleTabManager(settings)](./firestore_.md#persistentsingletabmanager_c99c68d) | Creates an instance of PersistentSingleTabManager. | -| function(snapshot, ...) | -| [endAt(snapshot)](./firestore_.md#endat_9a4477f) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided document (inclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. | -| [endBefore(snapshot)](./firestore_.md#endbefore_9a4477f) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided document (exclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. | -| [startAfter(snapshot)](./firestore_.md#startafter_9a4477f) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided document (exclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. | -| [startAt(snapshot)](./firestore_.md#startat_9a4477f) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided document (inclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of this query. | -| function(values, ...) | -| [vector(values)](./firestore_.md#vector_0dbdaf2) | Creates a new VectorValue constructed with a copy of the given array of numbers. | +| function(expr, ...) | +| [ascending(expr)](./firestore_.md#ascending_f3fb767) | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. +```typescript +// Sort documents by the 'name' field in ascending order +firestore.pipeline().collection("users") + .sort(ascending(Field.of("name"))); -## Classes +``` + | +| [byteLength(expr)](./firestore_.md#bytelength_f3fb767) | (BETA) Creates an expression that calculates the byte length of a string in UTF-8, or just the length of a Blob. +```typescript +// Calculate the length of the 'myString' field in bytes. +byteLength(Field.of("myString")); -| Class | Description | -| --- | --- | -| [AggregateField](./firestore_.aggregatefield.md#aggregatefield_class) | Represents an aggregation that can be performed by Firestore. | -| [AggregateQuerySnapshot](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshot_class) | The results of executing an aggregation query. | -| [Bytes](./firestore_.bytes.md#bytes_class) | An immutable object representing an array of bytes. | -| [CollectionReference](./firestore_.collectionreference.md#collectionreference_class) | A CollectionReference object can be used for adding documents, getting document references, and querying for documents (using [query()](./firestore_.md#query_9f7b0f4)). | -| [DocumentReference](./firestore_.documentreference.md#documentreference_class) | A DocumentReference refers to a document location in a Firestore database and can be used to write, read, or listen to the location. The document at the referenced location may or may not exist. | -| [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class) | A DocumentSnapshot contains data read from a document in your Firestore database. The data can be extracted with .data() or .get(<field>) to get a specific field.For a DocumentSnapshot that points to a non-existing document, any data access will return 'undefined'. You can use the exists() method to explicitly verify a document's existence. | -| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | A FieldPath refers to a field in a document. The path may consist of a single field name (referring to a top-level field in the document), or a list of field names (referring to a nested field in the document).Create a FieldPath by providing field names. If more than one field name is provided, the path will point to a nested field in a document. | -| [FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) | Sentinel values that can be used when writing document fields with set() or update(). | -| [Firestore](./firestore_.firestore.md#firestore_class) | The Cloud Firestore service interface.Do not call this constructor directly. Instead, use [getFirestore()](./firestore_.md#getfirestore). | -| [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) | An error returned by a Firestore operation. | -| [GeoPoint](./firestore_.geopoint.md#geopoint_class) | An immutable object representing a geographic location in Firestore. The location is represented as latitude/longitude pair.Latitude values are in the range of \[-90, 90\]. Longitude values are in the range of \[-180, 180\]. | -| [LoadBundleTask](./firestore_.loadbundletask.md#loadbundletask_class) | Represents the task of loading a Firestore bundle. It provides progress of bundle loading, as well as task completion and error events.The API is compatible with Promise<LoadBundleTaskProgress>. | -| [PersistentCacheIndexManager](./firestore_.persistentcacheindexmanager.md#persistentcacheindexmanager_class) | A PersistentCacheIndexManager for configuring persistent cache indexes used for local query execution.To use, call getPersistentCacheIndexManager() to get an instance. | -| [Query](./firestore_.query.md#query_class) | A Query refers to a query which you can read or listen to. You can also construct refined Query objects by adding filters and ordering. | -| [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) | A QueryCompositeFilterConstraint is used to narrow the set of documents returned by a Firestore query by performing the logical OR or AND of multiple [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class)s or [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class)s. QueryCompositeFilterConstraints are created by invoking [or()](./firestore_.md#or_e72c712) or [and()](./firestore_.md#and_e72c712) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the QueryCompositeFilterConstraint. | -| [QueryConstraint](./firestore_.queryconstraint.md#queryconstraint_class) | A QueryConstraint is used to narrow the set of documents returned by a Firestore query. QueryConstraints are created by invoking [where()](./firestore_.md#where_0fae4bf), [orderBy()](./firestore_.md#orderby_006d61f), [startAt()](./firestore_.md#startat_9a4477f), [startAfter()](./firestore_.md#startafter_9a4477f), [endBefore()](./firestore_.md#endbefore_9a4477f), [endAt()](./firestore_.md#endat_9a4477f), [limit()](./firestore_.md#limit_ec46c78), [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryConstraint. | -| [QueryDocumentSnapshot](./firestore_.querydocumentsnapshot.md#querydocumentsnapshot_class) | A QueryDocumentSnapshot contains data read from a document in your Firestore database as part of a query. The document is guaranteed to exist and its data can be extracted with .data() or .get(<field>) to get a specific field.A QueryDocumentSnapshot offers the same API surface as a DocumentSnapshot. Since query results contain only existing documents, the exists property will always be true and data() will never return 'undefined'. | -| [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) | A QueryEndAtConstraint is used to exclude documents from the end of a result set returned by a Firestore query. QueryEndAtConstraints are created by invoking [endAt()](./firestore_.md#endat_9a4477f) or [endBefore()](./firestore_.md#endbefore_9a4477f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryEndAtConstraint. | -| [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) | A QueryFieldFilterConstraint is used to narrow the set of documents returned by a Firestore query by filtering on one or more document fields. QueryFieldFilterConstraints are created by invoking [where()](./firestore_.md#where_0fae4bf) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryFieldFilterConstraint. | -| [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) | A QueryLimitConstraint is used to limit the number of documents returned by a Firestore query. QueryLimitConstraints are created by invoking [limit()](./firestore_.md#limit_ec46c78) or [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryLimitConstraint. | -| [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) | A QueryOrderByConstraint is used to sort the set of documents returned by a Firestore query. QueryOrderByConstraints are created by invoking [orderBy()](./firestore_.md#orderby_006d61f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryOrderByConstraint.Note: Documents that do not contain the orderBy field will not be present in the query result. | -| [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class) | A QuerySnapshot contains zero or more DocumentSnapshot objects representing the results of a query. The documents can be accessed as an array via the docs property or enumerated using the forEach method. The number of documents can be determined via the empty and size properties. | -| [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) | A QueryStartAtConstraint is used to exclude documents from the start of a result set returned by a Firestore query. QueryStartAtConstraints are created by invoking [startAt()](./firestore_.md#startat_9a4477f) or [startAfter()](./firestore_.md#startafter_9a4477f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryStartAtConstraint. | -| [SnapshotMetadata](./firestore_.snapshotmetadata.md#snapshotmetadata_class) | Metadata about a snapshot, describing the state of the snapshot. | -| [Timestamp](./firestore_.timestamp.md#timestamp_class) | A Timestamp represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time.It is encoded using the Proleptic Gregorian Calendar which extends the Gregorian calendar backwards to year one. It is encoded assuming all minutes are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.For examples and further specifications, refer to the [Timestamp definition](https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto). | -| [Transaction](./firestore_.transaction.md#transaction_class) | A reference to a transaction.The Transaction object passed to a transaction's updateFunction provides the methods to read and write data within the transaction context. See [runTransaction()](./firestore_.md#runtransaction_6f03ec4). | -| [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | Represents a vector type in Firestore documents. Create an instance with . VectorValue | -| [WriteBatch](./firestore_.writebatch.md#writebatch_class) | A write batch, used to perform multiple writes as a single atomic unit.A WriteBatch object can be acquired by calling [writeBatch()](./firestore_.md#writebatch_231a8e0). It provides methods for adding writes to the write batch. None of the writes will be committed (or visible locally) until [WriteBatch.commit()](./firestore_.writebatch.md#writebatchcommit) is called. | +``` + | +| [charLength(expr)](./firestore_.md#charlength_f3fb767) | (BETA) Creates an expression that calculates the character length of a string expression in UTF-8. +```typescript +// Get the character length of the 'name' field in UTF-8. +strLength(Field.of("name")); -## Interfaces +``` + | +| [cosineDistance(expr, other)](./firestore_.md#cosinedistance_b4c7dc2) | (BETA) Calculates the Cosine distance between a field's vector value and a double array. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +cosineDistance("location", [37.7749, -122.4194]); -| Interface | Description | -| --- | --- | -| [AggregateSpec](./firestore_.aggregatespec.md#aggregatespec_interface) | Specifies a set of aggregations and their aliases. | -| [DocumentChange](./firestore_.documentchange.md#documentchange_interface) | A DocumentChange represents a change to the documents matching a query. It contains the document affected and the type of change that occurred. | -| [DocumentData](./firestore_.documentdata.md#documentdata_interface) | Document data (for use with [setDoc()](./firestore_lite.md#setdoc_ee215ad)) consists of fields mapped to values. | -| [ExperimentalLongPollingOptions](./firestore_.experimentallongpollingoptions.md#experimentallongpollingoptions_interface) | Options that configure the SDK’s underlying network transport (WebChannel) when long-polling is used.Note: This interface is "experimental" and is subject to change.See FirestoreSettings.experimentalAutoDetectLongPolling, FirestoreSettings.experimentalForceLongPolling, and FirestoreSettings.experimentalLongPollingOptions. | -| [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface) | Converter used by withConverter() to transform user objects of type AppModelType into Firestore data of type DbModelType.Using the converter allows you to specify generic type arguments when storing and retrieving objects from Firestore.In this context, an "AppModel" is a class that is used in an application to package together related information and functionality. Such a class could, for example, have properties with complex, nested data types, properties used for memoization, properties of types not supported by Firestore (such as symbol and bigint), and helper functions that perform compound operations. Such classes are not suitable and/or possible to store into a Firestore database. Instead, instances of such classes need to be converted to "plain old JavaScript objects" (POJOs) with exclusively primitive properties, potentially nested inside other POJOs or arrays of POJOs. In this context, this type is referred to as the "DbModel" and would be an object suitable for persisting into Firestore. For convenience, applications can implement FirestoreDataConverter and register the converter with Firestore objects, such as DocumentReference or Query, to automatically convert AppModel to DbModel when storing into Firestore, and convert DbModel to AppModel when retrieving from Firestore. | -| [FirestoreSettings](./firestore_.firestoresettings.md#firestoresettings_interface) | Specifies custom configurations for your Cloud Firestore instance. You must set these before invoking any other methods. | -| [Index](./firestore_.index.md#index_interface) | (BETA) The SDK definition of a Firestore index. | -| [IndexConfiguration](./firestore_.indexconfiguration.md#indexconfiguration_interface) | (BETA) A list of Firestore indexes to speed up local query execution.See [JSON Format](https://firebase.google.com/docs/reference/firestore/indexes/#json_format) for a description of the format of the index definition. | -| [IndexField](./firestore_.indexfield.md#indexfield_interface) | (BETA) A single field element in an index configuration. | -| [LoadBundleTaskProgress](./firestore_.loadbundletaskprogress.md#loadbundletaskprogress_interface) | Represents a progress update or a final state from loading bundles. | -| [MemoryCacheSettings](./firestore_.memorycachesettings.md#memorycachesettings_interface) | An settings object to configure an MemoryLocalCache instance. | -| [MemoryEagerGarbageCollector](./firestore_.memoryeagergarbagecollector.md#memoryeagergarbagecollector_interface) | A garbage collector deletes documents whenever they are not part of any active queries, and have no local mutations attached to them.This collector tries to ensure lowest memory footprints from the SDK, at the risk of documents not being cached for offline queries or for direct queries to the cache.Use factory function to create an instance of this collector. | -| [MemoryLocalCache](./firestore_.memorylocalcache.md#memorylocalcache_interface) | Provides an in-memory cache to the SDK. This is the default cache unless explicitly configured otherwise.To use, create an instance using the factory function , then set the instance to FirestoreSettings.cache and call initializeFirestore using the settings object. | -| [MemoryLruGarbageCollector](./firestore_.memorylrugarbagecollector.md#memorylrugarbagecollector_interface) | A garbage collector deletes Least-Recently-Used documents in multiple batches.This collector is configured with a target size, and will only perform collection when the cached documents exceed the target size. It avoids querying backend repeated for the same query or document, at the risk of having a larger memory footprint.Use factory function to create a instance of this collector. | -| [PersistenceSettings](./firestore_.persistencesettings.md#persistencesettings_interface) | Settings that can be passed to enableIndexedDbPersistence() to configure Firestore persistence.Persistence cannot be used in a Node.js environment. | -| [PersistentCacheSettings](./firestore_.persistentcachesettings.md#persistentcachesettings_interface) | An settings object to configure an PersistentLocalCache instance.Persistent cache cannot be used in a Node.js environment. | -| [PersistentLocalCache](./firestore_.persistentlocalcache.md#persistentlocalcache_interface) | Provides a persistent cache backed by IndexedDb to the SDK.To use, create an instance using the factory function , then set the instance to FirestoreSettings.cache and call initializeFirestore using the settings object. | -| [PersistentMultipleTabManager](./firestore_.persistentmultipletabmanager.md#persistentmultipletabmanager_interface) | A tab manager supporting multiple tabs. SDK will synchronize queries and mutations done across all tabs using the SDK. | -| [PersistentSingleTabManager](./firestore_.persistentsingletabmanager.md#persistentsingletabmanager_interface) | A tab manager supporting only one tab, no synchronization will be performed across tabs. | -| [PersistentSingleTabManagerSettings](./firestore_.persistentsingletabmanagersettings.md#persistentsingletabmanagersettings_interface) | Type to configure an PersistentSingleTabManager instance. | -| [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | An options object that can be passed to [onSnapshot()](./firestore_.md#onsnapshot_0312fd7) and [QuerySnapshot.docChanges()](./firestore_.querysnapshot.md#querysnapshotdocchanges) to control which types of changes to include in the result set. | -| [SnapshotOptions](./firestore_.snapshotoptions.md#snapshotoptions_interface) | Options that configure how data is retrieved from a DocumentSnapshot (for example the desired behavior for server timestamps that have not yet been set to their final value). | -| [TransactionOptions](./firestore_.transactionoptions.md#transactionoptions_interface) | Options to customize transaction behavior. | -| [Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) | A function returned by onSnapshot() that removes the listener when invoked. | +``` + | +| [cosineDistance(expr, other)](./firestore_.md#cosinedistance_8d2bd9d) | (BETA) Calculates the Cosine distance between a field's vector value and a VectorValue. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +cosineDistance("location", new VectorValue([37.7749, -122.4194])); -## Variables +``` + | +| [cosineDistance(expr, other)](./firestore_.md#cosinedistance_c9ae0bc) | (BETA) Calculates the Cosine distance between a field's vector value and a vector expression. +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +cosineDistance("userVector", Field.of("itemVector")); -| Variable | Description | -| --- | --- | -| [CACHE\_SIZE\_UNLIMITED](./firestore_.md#cache_size_unlimited) | Constant used to indicate the LRU garbage collection should be disabled. Set this value as the cacheSizeBytes on the settings passed to the [Firestore](./firestore_.firestore.md#firestore_class) instance. | +``` + | +| [cosineDistance(expr, other)](./firestore_.md#cosinedistance_e701952) | (BETA) Calculates the Cosine distance between a vector expression and a double array. +```typescript +// Calculate the cosine distance between the 'location' field and a target location +cosineDistance(Field.of("location"), [37.7749, -122.4194]); -## Type Aliases +``` + | +| [cosineDistance(expr, other)](./firestore_.md#cosinedistance_cc2e83e) | (BETA) Calculates the Cosine distance between a vector expression and a VectorValue. +```typescript +// Calculate the cosine distance between the 'location' field and a target location +cosineDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); -| Type Alias | Description | -| --- | --- | -| [AddPrefixToKeys](./firestore_.md#addprefixtokeys) | Returns a new map where every key is prefixed with the outer key appended to a dot. | -| [AggregateFieldType](./firestore_.md#aggregatefieldtype) | The union of all AggregateField types that are supported by Firestore. | -| [AggregateSpecData](./firestore_.md#aggregatespecdata) | A type whose keys are taken from an AggregateSpec, and whose values are the result of the aggregation performed by the corresponding AggregateField from the input AggregateSpec. | -| [AggregateType](./firestore_.md#aggregatetype) | Union type representing the aggregate type to be performed. | -| [ChildUpdateFields](./firestore_.md#childupdatefields) | Helper for calculating the nested fields for a given type T1. This is needed to distribute union types such as undefined | {...} (happens for optional props) or {a: A} | {b: B}.In this use case, V is used to distribute the union types of T[K] on Record, since T[K] is evaluated as an expression and not distributed.See https://www.typescriptlang.org/docs/handbook/advanced-types.html\#distributive-conditional-types | -| [DocumentChangeType](./firestore_.md#documentchangetype) | The type of a DocumentChange may be 'added', 'removed', or 'modified'. | -| [FirestoreErrorCode](./firestore_.md#firestoreerrorcode) | The set of Firestore status codes. The codes are the same at the ones exposed by gRPC here: https://github.com/grpc/grpc/blob/master/doc/statuscodes.mdPossible values: - 'cancelled': The operation was cancelled (typically by the caller). - 'unknown': Unknown error or an error from a different error domain. - 'invalid-argument': Client specified an invalid argument. Note that this differs from 'failed-precondition'. 'invalid-argument' indicates arguments that are problematic regardless of the state of the system (e.g. an invalid field name). - 'deadline-exceeded': Deadline expired before operation could complete. For operations that change the state of the system, this error may be returned even if the operation has completed successfully. For example, a successful response from a server could have been delayed long enough for the deadline to expire. - 'not-found': Some requested document was not found. - 'already-exists': Some document that we attempted to create already exists. - 'permission-denied': The caller does not have permission to execute the specified operation. - 'resource-exhausted': Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space. - 'failed-precondition': Operation was rejected because the system is not in a state required for the operation's execution. - 'aborted': The operation was aborted, typically due to a concurrency issue like transaction aborts, etc. - 'out-of-range': Operation was attempted past the valid range. - 'unimplemented': Operation is not implemented or not supported/enabled. - 'internal': Internal errors. Means some invariants expected by underlying system has been broken. If you see one of these errors, something is very broken. - 'unavailable': The service is currently unavailable. This is most likely a transient condition and may be corrected by retrying with a backoff. - 'data-loss': Unrecoverable data loss or corruption. - 'unauthenticated': The request does not have valid authentication credentials for the operation. | -| [FirestoreLocalCache](./firestore_.md#firestorelocalcache) | Union type from all supported SDK cache layer. | -| [ListenSource](./firestore_.md#listensource) | Describe the source a query listens to.Set to default to listen to both cache and server changes. Set to cache to listen to changes in cache only. | -| [MemoryGarbageCollector](./firestore_.md#memorygarbagecollector) | Union type from all support garbage collectors for memory local cache. | -| [NestedUpdateFields](./firestore_.md#nestedupdatefields) | For each field (e.g. 'bar'), find all nested keys (e.g. {'bar.baz': T1, 'bar.qux': T2}). Intersect them together to make a single map containing all possible keys that are all marked as optional | -| [OrderByDirection](./firestore_.md#orderbydirection) | The direction of a [orderBy()](./firestore_.md#orderby_006d61f) clause is specified as 'desc' or 'asc' (descending or ascending). | -| [PartialWithFieldValue](./firestore_.md#partialwithfieldvalue) | Similar to TypeScript's Partial<T>, but allows nested fields to be omitted and FieldValues to be passed in as property values. | -| [PersistentTabManager](./firestore_.md#persistenttabmanager) | A union of all available tab managers. | -| [Primitive](./firestore_.md#primitive) | Primitive types. | -| [QueryConstraintType](./firestore_.md#queryconstrainttype) | Describes the different query constraints available in this SDK. | -| [QueryFilterConstraint](./firestore_.md#queryfilterconstraint) | QueryFilterConstraint is a helper union type that represents [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) and [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). | -| [QueryNonFilterConstraint](./firestore_.md#querynonfilterconstraint) | QueryNonFilterConstraint is a helper union type that represents QueryConstraints which are used to narrow or order the set of documents, but that do not explicitly filter on a document field. QueryNonFilterConstraints are created by invoking [orderBy()](./firestore_.md#orderby_006d61f), [startAt()](./firestore_.md#startat_9a4477f), [startAfter()](./firestore_.md#startafter_9a4477f), [endBefore()](./firestore_.md#endbefore_9a4477f), [endAt()](./firestore_.md#endat_9a4477f), [limit()](./firestore_.md#limit_ec46c78) or [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the QueryConstraint. | -| [SetOptions](./firestore_.md#setoptions) | An options object that configures the behavior of [setDoc()](./firestore_lite.md#setdoc_ee215ad), and calls. These calls can be configured to perform granular merges instead of overwriting the target documents in their entirety by providing a SetOptions with merge: true. | -| [TaskState](./firestore_.md#taskstate) | Represents the state of bundle loading tasks.Both 'Error' and 'Success' are sinking state: task will abort or complete and there will be no more updates after they are reported. | -| [UnionToIntersection](./firestore_.md#uniontointersection) | Given a union type U = T1 | T2 | ..., returns an intersected type (T1 & T2 & ...).Uses distributive conditional types and inference from conditional types. This works because multiple candidates for the same type variable in contra-variant positions causes an intersection type to be inferred. https://www.typescriptlang.org/docs/handbook/advanced-types.html\#type-inference-in-conditional-types https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type | -| [UpdateData](./firestore_.md#updatedata) | Update data (for use with [updateDoc()](./firestore_.md#updatedoc_51a65e3)) that consists of field paths (e.g. 'foo' or 'foo.baz') mapped to values. Fields that contain dots reference nested fields within the document. FieldValues can be passed in as property values. | -| [WhereFilterOp](./firestore_.md#wherefilterop) | Filter conditions in a [where()](./firestore_.md#where_0fae4bf) clause are specified using the strings '&lt;', '&lt;=', '==', '!=', '&gt;=', '&gt;', 'array-contains', 'in', 'array-contains-any', and 'not-in'. | +``` + | +| [cosineDistance(expr, other)](./firestore_.md#cosinedistance_0896fbd) | (BETA) Calculates the Cosine distance between two vector expressions. +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +cosineDistance(Field.of("userVector"), Field.of("itemVector")); + +``` + | +| [descending(expr)](./firestore_.md#descending_f3fb767) | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") + .sort(descending(Field.of("createdAt"))); + +``` + | +| [dotProduct(expr, other)](./firestore_.md#dotproduct_b4c7dc2) | (BETA) Calculates the dot product between a field's vector value and a double array. +```typescript +// Calculate the dot product distance between a feature vector and a target vector +dotProduct("features", [0.5, 0.8, 0.2]); + +``` + | +| [dotProduct(expr, other)](./firestore_.md#dotproduct_8d2bd9d) | (BETA) Calculates the dot product between a field's vector value and a VectorValue. +```typescript +// Calculate the dot product distance between a feature vector and a target vector +dotProduct("features", new VectorValue([0.5, 0.8, 0.2])); + +``` + | +| [dotProduct(expr, other)](./firestore_.md#dotproduct_c9ae0bc) | (BETA) Calculates the dot product between a field's vector value and a vector expression. +```typescript +// Calculate the dot product distance between two document vectors: 'docVector1' and 'docVector2' +dotProduct("docVector1", Field.of("docVector2")); + +``` + | +| [dotProduct(expr, other)](./firestore_.md#dotproduct_e701952) | (BETA) Calculates the dot product between a vector expression and a double array. +```typescript +// Calculate the dot product between a feature vector and a target vector +dotProduct(Field.of("features"), [0.5, 0.8, 0.2]); + +``` + | +| [dotProduct(expr, other)](./firestore_.md#dotproduct_cc2e83e) | (BETA) Calculates the dot product between a vector expression and a VectorValue. +```typescript +// Calculate the dot product between a feature vector and a target vector +dotProduct(Field.of("features"), new VectorValue([0.5, 0.8, 0.2])); + +``` + | +| [dotProduct(expr, other)](./firestore_.md#dotproduct_0896fbd) | (BETA) Calculates the dot product between two vector expressions. +```typescript +// Calculate the dot product between two document vectors: 'docVector1' and 'docVector2' +dotProduct(Field.of("docVector1"), Field.of("docVector2")); + +``` + | +| [endsWith(expr, suffix)](./firestore_.md#endswith_88569cd) | (BETA) Creates an expression that checks if a field's value ends with a given postfix. +```typescript +// Check if the 'filename' field ends with ".txt" +endsWith("filename", ".txt"); + +``` + | +| [endsWith(expr, suffix)](./firestore_.md#endswith_e2e794e) | (BETA) Creates an expression that checks if a field's value ends with a given postfix. +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +endsWith("url", Field.of("extension")); + +``` + | +| [endsWith(expr, suffix)](./firestore_.md#endswith_6308b81) | (BETA) Creates an expression that checks if a string expression ends with a given postfix. +```typescript +// Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." +endsWith(Field.of("fullName"), "Jr."); + +``` + | +| [endsWith(expr, suffix)](./firestore_.md#endswith_ab1cc39) | (BETA) Creates an expression that checks if a string expression ends with a given postfix. +```typescript +// Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." +endsWith(Field.of("fullName"), Constant.of("Jr.")); + +``` + | +| [euclideanDistance(expr, other)](./firestore_.md#euclideandistance_b4c7dc2) | (BETA) Calculates the Euclidean distance between a field's vector value and a double array. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +euclideanDistance("location", [37.7749, -122.4194]); + +``` + | +| [euclideanDistance(expr, other)](./firestore_.md#euclideandistance_8d2bd9d) | (BETA) Calculates the Euclidean distance between a field's vector value and a VectorValue. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +euclideanDistance("location", new VectorValue([37.7749, -122.4194])); + +``` + | +| [euclideanDistance(expr, other)](./firestore_.md#euclideandistance_c9ae0bc) | (BETA) Calculates the Euclidean distance between a field's vector value and a vector expression. +```typescript +// Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' +euclideanDistance("pointA", Field.of("pointB")); + +``` + | +| [euclideanDistance(expr, other)](./firestore_.md#euclideandistance_e701952) | (BETA) Calculates the Euclidean distance between a vector expression and a double array. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location + +euclideanDistance(Field.of("location"), [37.7749, -122.4194]); + +``` + | +| [euclideanDistance(expr, other)](./firestore_.md#euclideandistance_cc2e83e) | (BETA) Calculates the Euclidean distance between a vector expression and a VectorValue. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +euclideanDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); + +``` + | +| [euclideanDistance(expr, other)](./firestore_.md#euclideandistance_0896fbd) | (BETA) Calculates the Euclidean distance between two vector expressions. +```typescript +// Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' +euclideanDistance(Field.of("pointA"), Field.of("pointB")); + +``` + | +| [reverse(expr)](./firestore_.md#reverse_f3fb767) | (BETA) Creates an expression that reverses a string. +```typescript +// Reverse the value of the 'myString' field. +reverse(Field.of("myString")); + +``` + | +| [startsWith(expr, prefix)](./firestore_.md#startswith_484d9f3) | (BETA) Creates an expression that checks if a field's value starts with a given prefix. +```typescript +// Check if the 'name' field starts with "Mr." +startsWith("name", "Mr."); + +``` + | +| [startsWith(expr, prefix)](./firestore_.md#startswith_7deb5c7) | (BETA) Creates an expression that checks if a field's value starts with a given prefix. +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +startsWith("fullName", Field.of("firstName")); + +``` + | +| [startsWith(expr, prefix)](./firestore_.md#startswith_68300d1) | (BETA) Creates an expression that checks if a string expression starts with a given prefix. +```typescript +// Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." +startsWith(Field.of("fullName"), "Mr."); + +``` + | +| [startsWith(expr, prefix)](./firestore_.md#startswith_5774b68) | (BETA) Creates an expression that checks if a string expression starts with a given prefix. +```typescript +// Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." +startsWith(Field.of("fullName"), Field.of("prefix")); + +``` + | +| [timestampToUnixMicros(expr)](./firestore_.md#timestamptounixmicros_f3fb767) | (BETA) Creates an expression that converts a timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +timestampToUnixMicros(Field.of("timestamp")); + +``` + | +| [timestampToUnixMillis(expr)](./firestore_.md#timestamptounixmillis_f3fb767) | (BETA) Creates an expression that converts a timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +timestampToUnixMillis(Field.of("timestamp")); + +``` + | +| [timestampToUnixSeconds(expr)](./firestore_.md#timestamptounixseconds_f3fb767) | (BETA) Creates an expression that converts a timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to seconds since epoch. +timestampToUnixSeconds(Field.of("timestamp")); + +``` + | +| [toLower(expr)](./firestore_.md#tolower_1e536ed) | (BETA) Creates an expression that converts a string field to lowercase. +```typescript +// Convert the 'name' field to lowercase +toLower("name"); + +``` + | +| [toLower(expr)](./firestore_.md#tolower_f3fb767) | (BETA) Creates an expression that converts a string expression to lowercase. +```typescript +// Convert the 'name' field to lowercase +toLower(Field.of("name")); + +``` + | +| [toUpper(expr)](./firestore_.md#toupper_1e536ed) | (BETA) Creates an expression that converts a string field to uppercase. +```typescript +// Convert the 'title' field to uppercase +toUpper("title"); + +``` + | +| [toUpper(expr)](./firestore_.md#toupper_f3fb767) | (BETA) Creates an expression that converts a string expression to uppercase. +```typescript +// Convert the 'title' field to uppercase +toUppercase(Field.of("title")); + +``` + | +| [trim(expr)](./firestore_.md#trim_1e536ed) | (BETA) Creates an expression that removes leading and trailing whitespace from a string field. +```typescript +// Trim whitespace from the 'userInput' field +trim("userInput"); + +``` + | +| [trim(expr)](./firestore_.md#trim_f3fb767) | (BETA) Creates an expression that removes leading and trailing whitespace from a string expression. +```typescript +// Trim whitespace from the 'userInput' field +trim(Field.of("userInput")); + +``` + | +| [unixMicrosToTimestamp(expr)](./firestore_.md#unixmicrostotimestamp_f3fb767) | (BETA) Creates an expression that interprets an expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +unixMicrosToTimestamp(Field.of("microseconds")); + +``` + | +| [unixMillisToTimestamp(expr)](./firestore_.md#unixmillistotimestamp_f3fb767) | (BETA) Creates an expression that interprets an expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +unixMillisToTimestamp(Field.of("milliseconds")); + +``` + | +| [unixSecondsToTimestamp(expr)](./firestore_.md#unixsecondstotimestamp_f3fb767) | (BETA) Creates an expression that interprets an expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'seconds' field as seconds since epoch. +unixSecondsToTimestamp(Field.of("seconds")); + +``` + | +| [vectorLength(expr)](./firestore_.md#vectorlength_f3fb767) | (BETA) Creates an expression that calculates the length of a Firestore Vector. +```typescript +// Get the vector length (dimension) of the field 'embedding'. +vectorLength(Field.of("embedding")); + +``` + | +| function(field, ...) | +| [average(field)](./firestore_.md#average_aacc3a9) | Create an AggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query. | +| [byteLength(field)](./firestore_.md#bytelength_0fb8cd4) | (BETA) Creates an expression that calculates the length of a string represented by a field in UTF-8 bytes, or just the length of a Blob. +```typescript +// Calculate the length of the 'myString' field in bytes. +byteLength("myString"); + +``` + | +| [charLength(field)](./firestore_.md#charlength_0fb8cd4) | (BETA) Creates an expression that calculates the character length of a string field in UTF8. +```typescript +// Get the character length of the 'name' field in UTF-8. +strLength("name"); + +``` + | +| [exists(field)](./firestore_.md#exists_0fb8cd4) | (BETA) Creates an expression that checks if a field exists. +```typescript +// Check if the document has a field named "phoneNumber" +exists("phoneNumber"); + +``` + | +| [replaceAll(field, find, replace)](./firestore_.md#replaceall_b257ab0) | (BETA) Creates an expression that replaces all occurrences of a substring within a string represented by a field with another substring. +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field. +replaceAll("message", "hello", "hi"); + +``` + | +| [replaceFirst(field, find, replace)](./firestore_.md#replacefirst_b257ab0) | (BETA) Creates an expression that replaces the first occurrence of a substring within a string represented by a field with another substring. +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field. +replaceFirst("message", "hello", "hi"); + +``` + | +| [reverse(field)](./firestore_.md#reverse_0fb8cd4) | (BETA) Creates an expression that reverses a string represented by a field. +```typescript +// Reverse the value of the 'myString' field. +reverse("myString"); + +``` + | +| [sum(field)](./firestore_.md#sum_aacc3a9) | Create an AggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query. | +| [timestampAdd(field, unit, amount)](./firestore_.md#timestampadd_565792c) | (BETA) Creates an expression that adds a specified amount of time to a timestamp represented by a field. +```typescript +// Add 1 day to the 'timestamp' field. +timestampAdd("timestamp", "day", 1); + +``` + | +| [timestampSub(field, unit, amount)](./firestore_.md#timestampsub_565792c) | (BETA) Creates an expression that subtracts a specified amount of time from a timestamp represented by a field. +```typescript +// Subtract 1 day from the 'timestamp' field. +timestampSub("timestamp", "day", 1); + +``` + | +| [timestampToUnixMicros(field)](./firestore_.md#timestamptounixmicros_0fb8cd4) | (BETA) Creates an expression that converts a timestamp field to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +timestampToUnixMicros("timestamp"); + +``` + | +| [timestampToUnixMillis(field)](./firestore_.md#timestamptounixmillis_0fb8cd4) | (BETA) Creates an expression that converts a timestamp field to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +timestampToUnixMillis("timestamp"); + +``` + | +| [timestampToUnixSeconds(field)](./firestore_.md#timestamptounixseconds_0fb8cd4) | (BETA) Creates an expression that converts a timestamp field to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to seconds since epoch. +timestampToUnixSeconds("timestamp"); + +``` + | +| [unixMicrosToTimestamp(field)](./firestore_.md#unixmicrostotimestamp_0fb8cd4) | (BETA) Creates an expression that interprets a field's value as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +unixMicrosToTimestamp("microseconds"); + +``` + | +| [unixMillisToTimestamp(field)](./firestore_.md#unixmillistotimestamp_0fb8cd4) | (BETA) Creates an expression that interprets a field's value as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +unixMillisToTimestamp("milliseconds"); + +``` + | +| [unixSecondsToTimestamp(field)](./firestore_.md#unixsecondstotimestamp_0fb8cd4) | (BETA) Creates an expression that interprets a field's value as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'seconds' field as seconds since epoch. +unixSecondsToTimestamp("seconds"); + +``` + | +| [vectorLength(field)](./firestore_.md#vectorlength_0fb8cd4) | (BETA) Creates an expression that calculates the length of a Firestore Vector represented by a field. +```typescript +// Get the vector length (dimension) of the field 'embedding'. +vectorLength("embedding"); + +``` + | +| function(fieldPath, ...) | +| [orderBy(fieldPath, directionStr)](./firestore_.md#orderby_006d61f) | Creates a [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) that sorts the query result by the specified field, optionally in descending order instead of ascending.Note: Documents that do not contain the specified field will not be present in the query result. | +| [where(fieldPath, opStr, value)](./firestore_.md#where_0fae4bf) | Creates a [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) that enforces that documents must contain the specified field and that the value should satisfy the relation constraint provided. | +| function(fieldValues, ...) | +| [endAt(fieldValues)](./firestore_.md#endat_8b2f2c8) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | +| [endBefore(fieldValues)](./firestore_.md#endbefore_8b2f2c8) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | +| [startAfter(fieldValues)](./firestore_.md#startafter_8b2f2c8) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | +| [startAt(fieldValues)](./firestore_.md#startat_8b2f2c8) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | +| function(filter, ...) | +| [not(filter)](./firestore_.md#not_5520849) | (BETA) Creates an expression that negates a filter condition. +```typescript +// Find documents where the 'completed' field is NOT true +not(eq("completed", true)); + +``` + | +| function(first, ...) | +| [strConcat(first, elements)](./firestore_.md#strconcat_0f1bdbf) | (BETA) Creates an expression that concatenates string functions, fields or constants together. +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +strConcat("firstName", " ", Field.of("lastName")); + +``` + | +| [strConcat(first, elements)](./firestore_.md#strconcat_1eb0ac1) | (BETA) Creates an expression that concatenates string expressions together. +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +strConcat(Field.of("firstName"), " ", Field.of("lastName")); + +``` + | +| function(indexManager, ...) | +| [deleteAllPersistentCacheIndexes(indexManager)](./firestore_.md#deleteallpersistentcacheindexes_98b2645) | Removes all persistent cache indexes.Please note this function will also deletes indexes generated by setIndexConfiguration(), which is deprecated. | +| [disablePersistentCacheIndexAutoCreation(indexManager)](./firestore_.md#disablepersistentcacheindexautocreation_98b2645) | Stops creating persistent cache indexes automatically for local query execution. The indexes which have been created by calling enablePersistentCacheIndexAutoCreation() still take effect. | +| [enablePersistentCacheIndexAutoCreation(indexManager)](./firestore_.md#enablepersistentcacheindexautocreation_98b2645) | Enables the SDK to create persistent cache indexes automatically for local query execution when the SDK believes cache indexes can help improve performance.This feature is disabled by default. | +| function(left, ...) | +| [add(left, right)](./firestore_.md#add_be96f75) | (BETA) Creates an expression that adds two expressions together. +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +add(Field.of("quantity"), Field.of("reserve")); + +``` + | +| [add(left, right)](./firestore_.md#add_010ba9e) | (BETA) Creates an expression that adds an expression to a constant value. +```typescript +// Add 5 to the value of the 'age' field +add(Field.of("age"), 5); + +``` + | +| [add(left, right)](./firestore_.md#add_674c63f) | (BETA) Creates an expression that adds a field's value to an expression. +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +add("quantity", Field.of("reserve")); + +``` + | +| [add(left, right)](./firestore_.md#add_1f46a76) | (BETA) Creates an expression that adds a field's value to a constant value. +```typescript +// Add 5 to the value of the 'age' field +add("age", 5); + +``` + | +| [aggregateFieldEqual(left, right)](./firestore_.md#aggregatefieldequal_e80a2b2) | Compares two 'AggregateField\` instances for equality. | +| [aggregateQuerySnapshotEqual(left, right)](./firestore_.md#aggregatequerysnapshotequal_1529a20) | Compares two AggregateQuerySnapshot instances for equality.Two AggregateQuerySnapshot instances are considered "equal" if they have underlying queries that compare equal, and the same data. | +| [and(left, right)](./firestore_.md#and_eba7e36) | (BETA) Creates an expression that performs a logical 'AND' operation on multiple filter conditions. +```typescript +// Check if the 'age' field is greater than 18 AND the 'city' field is "London" AND +// the 'status' field is "active" +const condition = and(gt("age", 18), eq("city", "London"), eq("status", "active")); + +``` + | +| [divide(left, right)](./firestore_.md#divide_be96f75) | (BETA) Creates an expression that divides two expressions. +```typescript +// Divide the 'total' field by the 'count' field +divide(Field.of("total"), Field.of("count")); + +``` + | +| [divide(left, right)](./firestore_.md#divide_010ba9e) | (BETA) Creates an expression that divides an expression by a constant value. +```typescript +// Divide the 'value' field by 10 +divide(Field.of("value"), 10); + +``` + | +| [divide(left, right)](./firestore_.md#divide_674c63f) | (BETA) Creates an expression that divides a field's value by an expression. +```typescript +// Divide the 'total' field by the 'count' field +divide("total", Field.of("count")); + +``` + | +| [divide(left, right)](./firestore_.md#divide_1f46a76) | (BETA) Creates an expression that divides a field's value by a constant value. +```typescript +// Divide the 'value' field by 10 +divide("value", 10); + +``` + | +| [eq(left, right)](./firestore_.md#eq_be96f75) | (BETA) Creates an expression that checks if two expressions are equal. +```typescript +// Check if the 'age' field is equal to an expression +eq(Field.of("age"), Field.of("minAge").add(10)); + +``` + | +| [eq(left, right)](./firestore_.md#eq_010ba9e) | (BETA) Creates an expression that checks if an expression is equal to a constant value. +```typescript +// Check if the 'age' field is equal to 21 +eq(Field.of("age"), 21); + +``` + | +| [eq(left, right)](./firestore_.md#eq_674c63f) | (BETA) Creates an expression that checks if a field's value is equal to an expression. +```typescript +// Check if the 'age' field is equal to the 'limit' field +eq("age", Field.of("limit")); + +``` + | +| [eq(left, right)](./firestore_.md#eq_1f46a76) | (BETA) Creates an expression that checks if a field's value is equal to a constant value. +```typescript +// Check if the 'city' field is equal to string constant "London" +eq("city", "London"); + +``` + | +| [gt(left, right)](./firestore_.md#gt_be96f75) | (BETA) Creates an expression that checks if the first expression is greater than the second expression. +```typescript +// Check if the 'age' field is greater than 18 +gt(Field.of("age"), Constant(9).add(9)); + +``` + | +| [gt(left, right)](./firestore_.md#gt_010ba9e) | (BETA) Creates an expression that checks if an expression is greater than a constant value. +```typescript +// Check if the 'age' field is greater than 18 +gt(Field.of("age"), 18); + +``` + | +| [gt(left, right)](./firestore_.md#gt_674c63f) | (BETA) Creates an expression that checks if a field's value is greater than an expression. +```typescript +// Check if the value of field 'age' is greater than the value of field 'limit' +gt("age", Field.of("limit")); + +``` + | +| [gt(left, right)](./firestore_.md#gt_1f46a76) | (BETA) Creates an expression that checks if a field's value is greater than a constant value. +```typescript +// Check if the 'price' field is greater than 100 +gt("price", 100); + +``` + | +| [gte(left, right)](./firestore_.md#gte_be96f75) | (BETA) Creates an expression that checks if the first expression is greater than or equal to the second expression. +```typescript +// Check if the 'quantity' field is greater than or equal to the field "threshold" +gte(Field.of("quantity"), Field.of("threshold")); + +``` + | +| [gte(left, right)](./firestore_.md#gte_010ba9e) | (BETA) Creates an expression that checks if an expression is greater than or equal to a constant value. +```typescript +// Check if the 'quantity' field is greater than or equal to 10 +gte(Field.of("quantity"), 10); + +``` + | +| [gte(left, right)](./firestore_.md#gte_674c63f) | (BETA) Creates an expression that checks if a field's value is greater than or equal to an expression. +```typescript +// Check if the value of field 'age' is greater than or equal to the value of field 'limit' +gte("age", Field.of("limit")); + +``` + | +| [gte(left, right)](./firestore_.md#gte_1f46a76) | (BETA) Creates an expression that checks if a field's value is greater than or equal to a constant value. +```typescript +// Check if the 'score' field is greater than or equal to 80 +gte("score", 80); + +``` + | +| [like(left, pattern)](./firestore_.md#like_33ec01b) | (BETA) Creates an expression that performs a case-sensitive wildcard string comparison against a field. +```typescript +// Check if the 'title' field contains the string "guide" +like("title", "%guide%"); + +``` + | +| [like(left, pattern)](./firestore_.md#like_dd84184) | (BETA) Creates an expression that performs a case-sensitive wildcard string comparison against a field. +```typescript +// Check if the 'title' field contains the string "guide" +like("title", Field.of("pattern")); + +``` + | +| [like(left, pattern)](./firestore_.md#like_3aaffe0) | (BETA) Creates an expression that performs a case-sensitive wildcard string comparison. +```typescript +// Check if the 'title' field contains the string "guide" +like(Field.of("title"), "%guide%"); + +``` + | +| [like(left, pattern)](./firestore_.md#like_a2c3e8b) | (BETA) Creates an expression that performs a case-sensitive wildcard string comparison. +```typescript +// Check if the 'title' field contains the string "guide" +like(Field.of("title"), Field.of("pattern")); + +``` + | +| [logicalMax(left, right)](./firestore_.md#logicalmax_be96f75) | (BETA) Creates an expression that returns the larger value between two expressions, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'field1' field and the 'field2' field. +logicalMax(Field.of("field1"), Field.of("field2")); + +``` + | +| [logicalMax(left, right)](./firestore_.md#logicalmax_010ba9e) | (BETA) Creates an expression that returns the larger value between an expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'value' field and 10. +logicalMax(Field.of("value"), 10); + +``` + | +| [logicalMax(left, right)](./firestore_.md#logicalmax_674c63f) | (BETA) Creates an expression that returns the larger value between a field and an expression, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'field1' field and the 'field2' field. +logicalMax("field1", Field.of('field2')); + +``` + | +| [logicalMax(left, right)](./firestore_.md#logicalmax_1f46a76) | (BETA) Creates an expression that returns the larger value between a field and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'value' field and 10. +logicalMax("value", 10); + +``` + | +| [logicalMin(left, right)](./firestore_.md#logicalmin_be96f75) | (BETA) Creates an expression that returns the smaller value between two expressions, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'field1' field and the 'field2' field. +logicalMin(Field.of("field1"), Field.of("field2")); + +``` + | +| [logicalMin(left, right)](./firestore_.md#logicalmin_010ba9e) | (BETA) Creates an expression that returns the smaller value between an expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'value' field and 10. +logicalMin(Field.of("value"), 10); + +``` + | +| [logicalMin(left, right)](./firestore_.md#logicalmin_674c63f) | (BETA) Creates an expression that returns the smaller value between a field and an expression, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'field1' field and the 'field2' field. +logicalMin("field1", Field.of("field2")); + +``` + | +| [logicalMin(left, right)](./firestore_.md#logicalmin_1f46a76) | (BETA) Creates an expression that returns the smaller value between a field and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'value' field and 10. +logicalMin("value", 10); + +``` + | +| [lt(left, right)](./firestore_.md#lt_be96f75) | (BETA) Creates an expression that checks if the first expression is less than the second expression. +```typescript +// Check if the 'age' field is less than 30 +lt(Field.of("age"), Field.of("limit")); + +``` + | +| [lt(left, right)](./firestore_.md#lt_010ba9e) | (BETA) Creates an expression that checks if an expression is less than a constant value. +```typescript +// Check if the 'age' field is less than 30 +lt(Field.of("age"), 30); + +``` + | +| [lt(left, right)](./firestore_.md#lt_674c63f) | (BETA) Creates an expression that checks if a field's value is less than an expression. +```typescript +// Check if the 'age' field is less than the 'limit' field +lt("age", Field.of("limit")); + +``` + | +| [lt(left, right)](./firestore_.md#lt_1f46a76) | (BETA) Creates an expression that checks if a field's value is less than a constant value. +```typescript +// Check if the 'price' field is less than 50 +lt("price", 50); + +``` + | +| [lte(left, right)](./firestore_.md#lte_be96f75) | (BETA) Creates an expression that checks if the first expression is less than or equal to the second expression. +```typescript +// Check if the 'quantity' field is less than or equal to 20 +lte(Field.of("quantity"), Field.of("limit")); + +``` + | +| [lte(left, right)](./firestore_.md#lte_010ba9e) | (BETA) Creates an expression that checks if an expression is less than or equal to a constant value. +```typescript +// Check if the 'quantity' field is less than or equal to 20 +lte(Field.of("quantity"), 20); + +``` + | +| [lte(left, right)](./firestore_.md#lte_674c63f) | Creates an expression that checks if a field's value is less than or equal to an expression. +```typescript +// Check if the 'quantity' field is less than or equal to the 'limit' field +lte("quantity", Field.of("limit")); + +``` + | +| [lte(left, right)](./firestore_.md#lte_1f46a76) | (BETA) Creates an expression that checks if a field's value is less than or equal to a constant value. +```typescript +// Check if the 'score' field is less than or equal to 70 +lte("score", 70); + +``` + | +| [mod(left, right)](./firestore_.md#mod_be96f75) | (BETA) Creates an expression that calculates the modulo (remainder) of dividing two expressions. +```typescript +// Calculate the remainder of dividing 'field1' by 'field2'. +mod(Field.of("field1"), Field.of("field2")); + +``` + | +| [mod(left, right)](./firestore_.md#mod_010ba9e) | (BETA) Creates an expression that calculates the modulo (remainder) of dividing an expression by a constant. +```typescript +// Calculate the remainder of dividing 'field1' by 5. +mod(Field.of("field1"), 5); + +``` + | +| [mod(left, right)](./firestore_.md#mod_674c63f) | (BETA) Creates an expression that calculates the modulo (remainder) of dividing a field's value by an expression. +```typescript +// Calculate the remainder of dividing 'field1' by 'field2'. +mod("field1", Field.of("field2")); + +``` + | +| [mod(left, right)](./firestore_.md#mod_1f46a76) | (BETA) Creates an expression that calculates the modulo (remainder) of dividing a field's value by a constant. +```typescript +// Calculate the remainder of dividing 'field1' by 5. +mod("field1", 5); + +``` + | +| [multiply(left, right)](./firestore_.md#multiply_be96f75) | (BETA) Creates an expression that multiplies two expressions together. +```typescript +// Multiply the 'quantity' field by the 'price' field +multiply(Field.of("quantity"), Field.of("price")); + +``` + | +| [multiply(left, right)](./firestore_.md#multiply_010ba9e) | (BETA) Creates an expression that multiplies an expression by a constant value. +```typescript +// Multiply the value of the 'price' field by 2 +multiply(Field.of("price"), 2); + +``` + | +| [multiply(left, right)](./firestore_.md#multiply_674c63f) | (BETA) Creates an expression that multiplies a field's value by an expression. +```typescript +// Multiply the 'quantity' field by the 'price' field +multiply("quantity", Field.of("price")); + +``` + | +| [multiply(left, right)](./firestore_.md#multiply_1f46a76) | (BETA) Creates an expression that multiplies a field's value by a constant value. +```typescript +// Multiply the 'value' field by 2 +multiply("value", 2); + +``` + | +| [neq(left, right)](./firestore_.md#neq_be96f75) | (BETA) Creates an expression that checks if two expressions are not equal. +```typescript +// Check if the 'status' field is not equal to field 'finalState' +neq(Field.of("status"), Field.of("finalState")); + +``` + | +| [neq(left, right)](./firestore_.md#neq_010ba9e) | (BETA) Creates an expression that checks if an expression is not equal to a constant value. +```typescript +// Check if the 'status' field is not equal to "completed" +neq(Field.of("status"), "completed"); + +``` + | +| [neq(left, right)](./firestore_.md#neq_674c63f) | (BETA) Creates an expression that checks if a field's value is not equal to an expression. +```typescript +// Check if the 'status' field is not equal to the value of 'expectedStatus' +neq("status", Field.of("expectedStatus")); + +``` + | +| [neq(left, right)](./firestore_.md#neq_1f46a76) | (BETA) Creates an expression that checks if a field's value is not equal to a constant value. +```typescript +// Check if the 'country' field is not equal to "USA" +neq("country", "USA"); + +``` + | +| [or(left, right)](./firestore_.md#or_eba7e36) | (BETA) Creates an expression that performs a logical 'OR' operation on multiple filter conditions. +```typescript +// Check if the 'age' field is greater than 18 OR the 'city' field is "London" OR +// the 'status' field is "active" +const condition = or(gt("age", 18), eq("city", "London"), eq("status", "active")); + +``` + | +| [queryEqual(left, right)](./firestore_.md#queryequal_7a1f045) | Returns true if the provided queries point to the same collection and apply the same constraints. | +| [refEqual(left, right)](./firestore_.md#refequal_598b780) | Returns true if the provided references are equal. | +| [regexContains(left, pattern)](./firestore_.md#regexcontains_33ec01b) | (BETA) Creates an expression that checks if a string field contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +regexContains("description", "(?i)example"); + +``` + | +| [regexContains(left, pattern)](./firestore_.md#regexcontains_dd84184) | (BETA) Creates an expression that checks if a string field contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +regexContains("description", Field.of("pattern")); + +``` + | +| [regexContains(left, pattern)](./firestore_.md#regexcontains_3aaffe0) | (BETA) Creates an expression that checks if a string expression contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +regexContains(Field.of("description"), "(?i)example"); + +``` + | +| [regexContains(left, pattern)](./firestore_.md#regexcontains_a2c3e8b) | (BETA) Creates an expression that checks if a string expression contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +regexContains(Field.of("description"), Field.of("pattern")); + +``` + | +| [regexMatch(left, pattern)](./firestore_.md#regexmatch_33ec01b) | (BETA) Creates an expression that checks if a string field matches a specified regular expression. +```typescript +// Check if the 'email' field matches a valid email pattern +regexMatch("email", "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + | +| [regexMatch(left, pattern)](./firestore_.md#regexmatch_dd84184) | (BETA) Creates an expression that checks if a string field matches a specified regular expression. +```typescript +// Check if the 'email' field matches a valid email pattern +regexMatch("email", Field.of("pattern")); + +``` + | +| [regexMatch(left, pattern)](./firestore_.md#regexmatch_3aaffe0) | (BETA) Creates an expression that checks if a string expression matches a specified regular expression. +```typescript +// Check if the 'email' field matches a valid email pattern +regexMatch(Field.of("email"), "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + | +| [regexMatch(left, pattern)](./firestore_.md#regexmatch_a2c3e8b) | (BETA) Creates an expression that checks if a string expression matches a specified regular expression. +```typescript +// Check if the 'email' field matches a valid email pattern +regexMatch(Field.of("email"), Field.of("pattern")); + +``` + | +| [snapshotEqual(left, right)](./firestore_.md#snapshotequal_5109204) | Returns true if the provided snapshots are equal. | +| [strContains(left, substring)](./firestore_.md#strcontains_18eaf5d) | (BETA) Creates an expression that checks if a string field contains a specified substring. +```typescript +// Check if the 'description' field contains "example". +strContains("description", "example"); + +``` + | +| [strContains(left, substring)](./firestore_.md#strcontains_f0f1f2f) | (BETA) Creates an expression that checks if a string field contains a substring specified by an expression. +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +strContains("description", Field.of("keyword")); + +``` + | +| [strContains(left, substring)](./firestore_.md#strcontains_5fdbd29) | (BETA) Creates an expression that checks if a string expression contains a specified substring. +```typescript +// Check if the 'description' field contains "example". +strContains(Field.of("description"), "example"); + +``` + | +| [strContains(left, substring)](./firestore_.md#strcontains_d9d749f) | (BETA) Creates an expression that checks if a string expression contains a substring specified by another expression. +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +strContains(Field.of("description"), Field.of("keyword")); + +``` + | +| [subtract(left, right)](./firestore_.md#subtract_be96f75) | (BETA) Creates an expression that subtracts two expressions. +```typescript +// Subtract the 'discount' field from the 'price' field +subtract(Field.of("price"), Field.of("discount")); + +``` + | +| [subtract(left, right)](./firestore_.md#subtract_010ba9e) | (BETA) Creates an expression that subtracts a constant value from an expression. +```typescript +// Subtract the constant value 2 from the 'value' field +subtract(Field.of("value"), 2); + +``` + | +| [subtract(left, right)](./firestore_.md#subtract_674c63f) | (BETA) Creates an expression that subtracts an expression from a field's value. +```typescript +// Subtract the 'discount' field from the 'price' field +subtract("price", Field.of("discount")); + +``` + | +| [subtract(left, right)](./firestore_.md#subtract_1f46a76) | (BETA) Creates an expression that subtracts a constant value from a field's value. +```typescript +// Subtract 20 from the value of the 'total' field +subtract("total", 20); + +``` + | +| [xor(left, right)](./firestore_.md#xor_eba7e36) | (BETA) Creates an expression that performs a logical 'XOR' (exclusive OR) operation on multiple filter conditions. +```typescript +// Check if only one of the conditions is true: 'age' greater than 18, 'city' is "London", +// or 'status' is "active". +const condition = xor( + gt("age", 18), + eq("city", "London"), + eq("status", "active")); + +``` + | +| function(limit, ...) | +| [limit(limit)](./firestore_.md#limit_ec46c78) | Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the first matching documents. | +| [limitToLast(limit)](./firestore_.md#limittolast_ec46c78) | Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the last matching documents.You must specify at least one orderBy clause for limitToLast queries, otherwise an exception will be thrown during execution. | +| function(logLevel, ...) | +| [setLogLevel(logLevel)](./firestore_.md#setloglevel_d02fda2) | Sets the verbosity of Cloud Firestore logs (debug, error, or silent). | +| function(mapExpr, ...) | +| [mapGet(mapExpr, subField)](./firestore_.md#mapget_9715f90) | (BETA) Accesses a value from a map (object) expression using the provided key. +```typescript +// Get the 'city' value from the 'address' map field +mapGet(Field.of("address"), "city"); + +``` + | +| function(mapField, ...) | +| [mapGet(mapField, subField)](./firestore_.md#mapget_b37bbb6) | (BETA) Accesses a value from a map (object) field using the provided key. +```typescript +// Get the 'city' value from the 'address' map field +mapGet("address", "city"); + +``` + | +| function(n, ...) | +| [increment(n)](./firestore_.md#increment_5685735) | Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to increment the field's current value by the given value.If either the operand or the current field value uses floating point precision, all arithmetic follows IEEE 754 semantics. If both values are integers, values outside of JavaScript's safe number range (Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER) are also subject to precision loss. Furthermore, once processed by the Firestore backend, all integer operations are capped between -2^63 and 2^63-1.If the current field value is not of type number, or if the field does not yet exist, the transformation sets the field to the given value. | +| function(name, ...) | +| [genericFunction(name, params)](./firestore_.md#genericfunction_b886545) | (BETA) Creates functions that work on the backend but do not exist in the SDK yet. +```typescript +// Call a user defined function named "myFunc" with the arguments 10 and 20 +// This is the same of the 'sum(Field.of("price"))', if it did not exist +genericFunction("sum", [Field.of("price")]); + +``` + | +| function(pipeline, ...) | +| [execute(pipeline)](./firestore_.md#execute_86486e6) | (BETA) Modular API for console experimentation. | +| function(query, ...) | +| [getAggregateFromServer(query, aggregateSpec)](./firestore_.md#getaggregatefromserver_2073a74) | Calculates the specified aggregations over the documents in the result set of the given query without actually downloading the documents.Using this function to perform aggregations is efficient because only the final aggregation values, not the documents' data, are downloaded. This function can perform aggregations of the documents in cases where the result set is prohibitively large to download entirely (thousands of documents).The result received from the server is presented, unaltered, without considering any local state. That is, documents in the local cache are not taken into consideration, neither are local modifications not yet synchronized with the server. Previously-downloaded results, if any, are not used. Every invocation of this function necessarily involves a round trip to the server. | +| [getCountFromServer(query)](./firestore_.md#getcountfromserver_4e56953) | Calculates the number of documents in the result set of the given query without actually downloading the documents.Using this function to count the documents is efficient because only the final count, not the documents' data, is downloaded. This function can count the documents in cases where the result set is prohibitively large to download entirely (thousands of documents).The result received from the server is presented, unaltered, without considering any local state. That is, documents in the local cache are not taken into consideration, neither are local modifications not yet synchronized with the server. Previously-downloaded results, if any, are not used. Every invocation of this function necessarily involves a round trip to the server. | +| [getDocs(query)](./firestore_.md#getdocs_4e56953) | Executes the query and returns the results as a QuerySnapshot.Note: getDocs() attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. To specify this behavior, invoke [getDocsFromCache()](./firestore_.md#getdocsfromcache_4e56953) or [getDocsFromServer()](./firestore_.md#getdocsfromserver_4e56953). | +| [getDocsFromCache(query)](./firestore_.md#getdocsfromcache_4e56953) | Executes the query and returns the results as a QuerySnapshot from cache. Returns an empty result set if no documents matching the query are currently cached. | +| [getDocsFromServer(query)](./firestore_.md#getdocsfromserver_4e56953) | Executes the query and returns the results as a QuerySnapshot from the server. Returns an error if the network is not available. | +| [onSnapshot(query, observer)](./firestore_.md#onsnapshot_8d14049) | Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [onSnapshot(query, options, observer)](./firestore_.md#onsnapshot_03dfff5) | Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [onSnapshot(query, onNext, onError, onCompletion)](./firestore_.md#onsnapshot_3ebfbe2) | Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [onSnapshot(query, options, onNext, onError, onCompletion)](./firestore_.md#onsnapshot_b8f9c47) | Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [pipeline(query)](./firestore_.md#pipeline_20b2416) | Experimental Modular API for console testing. | +| [query(query, compositeFilter, queryConstraints)](./firestore_.md#query_9f7b0f4) | Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. | +| [query(query, queryConstraints)](./firestore_.md#query_0f46da1) | Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. | +| function(queryConstraints, ...) | +| [and(queryConstraints)](./firestore_.md#and_e72c712) | Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a conjunction of the given filter constraints. A conjunction filter includes a document if it satisfies all of the given filters. | +| [or(queryConstraints)](./firestore_.md#or_e72c712) | Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a disjunction of the given filter constraints. A disjunction filter includes a document if it satisfies any of the given filters. | +| function(reference, ...) | +| [addDoc(reference, data)](./firestore_.md#adddoc_6e783ff) | Add a new document to specified CollectionReference with the given data, assigning it a document ID automatically. | +| [collection(reference, path, pathSegments)](./firestore_.md#collection_568f98d) | Gets a CollectionReference instance that refers to a subcollection of reference at the specified relative path. | +| [collection(reference, path, pathSegments)](./firestore_.md#collection_70b4396) | Gets a CollectionReference instance that refers to a subcollection of reference at the specified relative path. | +| [deleteDoc(reference)](./firestore_.md#deletedoc_4569087) | Deletes the document referred to by the specified DocumentReference. | +| [doc(reference, path, pathSegments)](./firestore_.md#doc_568f98d) | Gets a DocumentReference instance that refers to a document within reference at the specified relative path. If no path is specified, an automatically-generated unique ID will be used for the returned DocumentReference. | +| [doc(reference, path, pathSegments)](./firestore_.md#doc_70b4396) | Gets a DocumentReference instance that refers to a document within reference at the specified relative path. | +| [getDoc(reference)](./firestore_.md#getdoc_4569087) | Reads the document referred to by this DocumentReference.Note: getDoc() attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. To specify this behavior, invoke [getDocFromCache()](./firestore_.md#getdocfromcache_4569087) or [getDocFromServer()](./firestore_.md#getdocfromserver_4569087). | +| [getDocFromCache(reference)](./firestore_.md#getdocfromcache_4569087) | Reads the document referred to by this DocumentReference from cache. Returns an error if the document is not currently cached. | +| [getDocFromServer(reference)](./firestore_.md#getdocfromserver_4569087) | Reads the document referred to by this DocumentReference from the server. Returns an error if the network is not available. | +| [onSnapshot(reference, observer)](./firestore_.md#onsnapshot_0312fd7) | Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [onSnapshot(reference, options, observer)](./firestore_.md#onsnapshot_86b6b9e) | Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [onSnapshot(reference, onNext, onError, onCompletion)](./firestore_.md#onsnapshot_905f42c) | Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [onSnapshot(reference, options, onNext, onError, onCompletion)](./firestore_.md#onsnapshot_0c39991) | Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [setDoc(reference, data)](./firestore_.md#setdoc_ee215ad) | Writes to the document referred to by this DocumentReference. If the document does not yet exist, it will be created. | +| [setDoc(reference, data, options)](./firestore_.md#setdoc_ff80739) | Writes to the document referred to by the specified DocumentReference. If the document does not yet exist, it will be created. If you provide merge or mergeFields, the provided data can be merged into an existing document. | +| [updateDoc(reference, data)](./firestore_.md#updatedoc_51a65e3) | Updates fields in the document referred to by the specified DocumentReference. The update will fail if applied to a document that does not exist. | +| [updateDoc(reference, field, value, moreFieldsAndValues)](./firestore_.md#updatedoc_7c28659) | Updates fields in the document referred to by the specified DocumentReference The update will fail if applied to a document that does not exist.Nested fields can be updated by providing dot-separated field path strings or by providing FieldPath objects. | +| function(settings, ...) | +| [memoryLocalCache(settings)](./firestore_.md#memorylocalcache_05f4bf2) | Creates an instance of MemoryLocalCache. The instance can be set to FirestoreSettings.cache to tell the SDK which cache layer to use. | +| [memoryLruGarbageCollector(settings)](./firestore_.md#memorylrugarbagecollector_5ee014c) | Creates an instance of MemoryLruGarbageCollector.A target size can be specified as part of the setting parameter. The collector will start deleting documents once the cache size exceeds the given size. The default cache size is 40MB (40 \* 1024 \* 1024 bytes). | +| [persistentLocalCache(settings)](./firestore_.md#persistentlocalcache_d312f71) | Creates an instance of PersistentLocalCache. The instance can be set to FirestoreSettings.cache to tell the SDK which cache layer to use.Persistent cache cannot be used in a Node.js environment. | +| [persistentSingleTabManager(settings)](./firestore_.md#persistentsingletabmanager_c99c68d) | Creates an instance of PersistentSingleTabManager. | +| function(snapshot, ...) | +| [endAt(snapshot)](./firestore_.md#endat_9a4477f) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided document (inclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. | +| [endBefore(snapshot)](./firestore_.md#endbefore_9a4477f) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided document (exclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. | +| [startAfter(snapshot)](./firestore_.md#startafter_9a4477f) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided document (exclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. | +| [startAt(snapshot)](./firestore_.md#startat_9a4477f) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided document (inclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of this query. | +| function(timestamp, ...) | +| [timestampAdd(timestamp, unit, amount)](./firestore_.md#timestampadd_87db576) | (BETA) Creates an expression that adds a specified amount of time to a timestamp. +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +timestampAdd(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampAdd(timestamp, unit, amount)](./firestore_.md#timestampadd_46a2d7e) | (BETA) Creates an expression that adds a specified amount of time to a timestamp. +```typescript +// Add 1 day to the 'timestamp' field. +timestampAdd(Field.of("timestamp"), "day", 1); + +``` + | +| [timestampSub(timestamp, unit, amount)](./firestore_.md#timestampsub_87db576) | (BETA) Creates an expression that subtracts a specified amount of time from a timestamp. +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +timestampSub(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampSub(timestamp, unit, amount)](./firestore_.md#timestampsub_46a2d7e) | (BETA) Creates an expression that subtracts a specified amount of time from a timestamp. +```typescript +// Subtract 1 day from the 'timestamp' field. +timestampSub(Field.of("timestamp"), "day", 1); + +``` + | +| function(value, ...) | +| [avg(value)](./firestore_.md#avg_f83680a) | (BETA) Creates an aggregation that calculates the average (mean) of values from an expression across multiple stage inputs. +```typescript +// Calculate the average age of users +avg(Field.of("age")).as("averageAge"); + +``` + | +| [avg(value)](./firestore_.md#avg_7c807cd) | (BETA) Creates an aggregation that calculates the average (mean) of a field's values across multiple stage inputs. +```typescript +// Calculate the average age of users +avg("age").as("averageAge"); + +``` + | +| [countExpression(value)](./firestore_.md#countexpression_f83680a) | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the provided expression. +```typescript +// Count the number of items where the price is greater than 10 +count(Field.of("price").gt(10)).as("expensiveItemCount"); + +``` + | +| [countExpression(value)](./firestore_.md#countexpression_7c807cd) | Creates an aggregation that counts the number of stage inputs with valid evaluations of the provided field. +```typescript +// Count the total number of products +count("productId").as("totalProducts"); + +``` + | +| [exists(value)](./firestore_.md#exists_f83680a) | (BETA) Creates an expression that checks if a field exists. +```typescript +// Check if the document has a field named "phoneNumber" +exists(Field.of("phoneNumber")); + +``` + | +| [isNan(value)](./firestore_.md#isnan_f83680a) | (BETA) Creates an expression that checks if an expression evaluates to 'NaN' (Not a Number). +```typescript +// Check if the result of a calculation is NaN +isNaN(Field.of("value").divide(0)); + +``` + | +| [isNan(value)](./firestore_.md#isnan_7c807cd) | (BETA) Creates an expression that checks if a field's value evaluates to 'NaN' (Not a Number). +```typescript +// Check if the result of a calculation is NaN +isNaN("value"); + +``` + | +| [max(value)](./firestore_.md#max_f83680a) | (BETA) Creates an aggregation that finds the maximum value of an expression across multiple stage inputs. +```typescript +// Find the highest score in a leaderboard +max(Field.of("score")).as("highestScore"); + +``` + | +| [max(value)](./firestore_.md#max_7c807cd) | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. +```typescript +// Find the highest score in a leaderboard +max("score").as("highestScore"); + +``` + | +| [min(value)](./firestore_.md#min_f83680a) | (BETA) Creates an aggregation that finds the minimum value of an expression across multiple stage inputs. +```typescript +// Find the lowest price of all products +min(Field.of("price")).as("lowestPrice"); + +``` + | +| [min(value)](./firestore_.md#min_7c807cd) | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. +```typescript +// Find the lowest price of all products +min("price").as("lowestPrice"); + +``` + | +| [replaceAll(value, find, replace)](./firestore_.md#replaceall_f06d323) | (BETA) Creates an expression that replaces all occurrences of a substring within a string with another substring. +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field. +replaceAll(Field.of("message"), "hello", "hi"); + +``` + | +| [replaceAll(value, find, replace)](./firestore_.md#replaceall_26a7926) | (BETA) Creates an expression that replaces all occurrences of a substring within a string with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field. +replaceAll(Field.of("message"), Field.of("findField"), Field.of("replaceField")); + +``` + | +| [replaceFirst(value, find, replace)](./firestore_.md#replacefirst_f06d323) | (BETA) Creates an expression that replaces the first occurrence of a substring within a string with another substring. +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field. +replaceFirst(Field.of("message"), "hello", "hi"); + +``` + | +| [replaceFirst(value, find, replace)](./firestore_.md#replacefirst_26a7926) | (BETA) Creates an expression that replaces the first occurrence of a substring within a string with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field. +replaceFirst(Field.of("message"), Field.of("findField"), Field.of("replaceField")); + +``` + | +| [sumExpression(value)](./firestore_.md#sumexpression_f83680a) | (BETA) Creates an aggregation that calculates the sum of values from an expression across multiple stage inputs. +```typescript +// Calculate the total revenue from a set of orders +sum(Field.of("orderAmount")).as("totalRevenue"); + +``` + | +| [sumExpression(value)](./firestore_.md#sumexpression_7c807cd) | (BETA) Creates an aggregation that calculates the sum of a field's values across multiple stage inputs. +```typescript +// Calculate the total revenue from a set of orders +sum("orderAmount").as("totalRevenue"); + +``` + | +| function(values, ...) | +| [vector(values)](./firestore_.md#vector_0dbdaf2) | Creates a new VectorValue constructed with a copy of the given array of numbers. | + +## Classes + +| Class | Description | +| --- | --- | +| [Add](./firestore_.add.md#add_class) | (BETA) | +| [AddFields](./firestore_.addfields.md#addfields_class) | (BETA) | +| [Aggregate](./firestore_.aggregate.md#aggregate_class) | (BETA) | +| [AggregateField](./firestore_.aggregatefield.md#aggregatefield_class) | Represents an aggregation that can be performed by Firestore. | +| [AggregateQuerySnapshot](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshot_class) | The results of executing an aggregation query. | +| [And](./firestore_.and.md#and_class) | (BETA) | +| [ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) | (BETA) | +| [ArrayContains](./firestore_.arraycontains.md#arraycontains_class) | (BETA) | +| [ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) | (BETA) | +| [ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) | (BETA) | +| [ArrayElement](./firestore_.arrayelement.md#arrayelement_class) | (BETA) | +| [ArrayLength](./firestore_.arraylength.md#arraylength_class) | (BETA) | +| [ArrayReverse](./firestore_.arrayreverse.md#arrayreverse_class) | (BETA) | +| [Avg](./firestore_.avg.md#avg_class) | (BETA) | +| [ByteLength](./firestore_.bytelength.md#bytelength_class) | (BETA) | +| [Bytes](./firestore_.bytes.md#bytes_class) | An immutable object representing an array of bytes. | +| [CharLength](./firestore_.charlength.md#charlength_class) | (BETA) | +| [CollectionGroupSource](./firestore_.collectiongroupsource.md#collectiongroupsource_class) | (BETA) | +| [CollectionReference](./firestore_.collectionreference.md#collectionreference_class) | A CollectionReference object can be used for adding documents, getting document references, and querying for documents (using [query()](./firestore_.md#query_9f7b0f4)). | +| [CollectionSource](./firestore_.collectionsource.md#collectionsource_class) | (BETA) | +| [Constant](./firestore_.constant.md#constant_class) | (BETA) Represents a constant value that can be used in a Firestore pipeline expression.You can create a Constant instance using the static method: +```typescript +// Create a Constant instance for the number 10 +const ten = Constant.of(10); + +// Create a Constant instance for the string "hello" +const hello = Constant.of("hello"); + +``` + | +| [CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) | (BETA) | +| [Count](./firestore_.count.md#count_class) | (BETA) | +| [DatabaseSource](./firestore_.databasesource.md#databasesource_class) | (BETA) | +| [Distinct](./firestore_.distinct.md#distinct_class) | (BETA) | +| [Divide](./firestore_.divide.md#divide_class) | (BETA) | +| [DocumentReference](./firestore_.documentreference.md#documentreference_class) | A DocumentReference refers to a document location in a Firestore database and can be used to write, read, or listen to the location. The document at the referenced location may or may not exist. | +| [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class) | A DocumentSnapshot contains data read from a document in your Firestore database. The data can be extracted with .data() or .get(<field>) to get a specific field.For a DocumentSnapshot that points to a non-existing document, any data access will return 'undefined'. You can use the exists() method to explicitly verify a document's existence. | +| [DocumentsSource](./firestore_.documentssource.md#documentssource_class) | (BETA) | +| [DotProduct](./firestore_.dotproduct.md#dotproduct_class) | (BETA) | +| [EndsWith](./firestore_.endswith.md#endswith_class) | (BETA) | +| [Eq](./firestore_.eq.md#eq_class) | (BETA) | +| [EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) | (BETA) | +| [Exists](./firestore_.exists.md#exists_class) | (BETA) | +| [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) | (BETA) | +| [Field](./firestore_.field.md#field_class) | (BETA) Represents a reference to a field in a Firestore document, or outputs of a [Pipeline](./firestore_.pipeline.md#pipeline_class) stage.

Field references are used to access document field values in expressions and to specify fields for sorting, filtering, and projecting data in Firestore pipelines.

You can create a Field instance using the static method: +```typescript +// Create a Field instance for the 'name' field +const nameField = Field.of("name"); + +// Create a Field instance for a nested field 'address.city' +const cityField = Field.of("address.city"); + +``` + | +| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | A FieldPath refers to a field in a document. The path may consist of a single field name (referring to a top-level field in the document), or a list of field names (referring to a nested field in the document).Create a FieldPath by providing field names. If more than one field name is provided, the path will point to a nested field in a document. | +| [Fields](./firestore_.fields.md#fields_class) | (BETA) | +| [FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) | Sentinel values that can be used when writing document fields with set() or update(). | +| [FindNearest](./firestore_.findnearest.md#findnearest_class) | (BETA) | +| [Firestore](./firestore_.firestore.md#firestore_class) | The Cloud Firestore service interface.Do not call this constructor directly. Instead, use [getFirestore()](./firestore_.md#getfirestore). | +| [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) | An error returned by a Firestore operation. | +| [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) | (BETA) This class defines the base class for Firestore [Pipeline](./firestore_.pipeline.md#pipeline_class) functions, which can be evaluated within pipeline execution.Typically, you would not use this class or its children directly. Use either the functions like , , or the methods on (, , etc) to construct new Function instances. | +| [GenericStage](./firestore_.genericstage.md#genericstage_class) | (BETA) | +| [GeoPoint](./firestore_.geopoint.md#geopoint_class) | An immutable object representing a geographic location in Firestore. The location is represented as latitude/longitude pair.Latitude values are in the range of \[-90, 90\]. Longitude values are in the range of \[-180, 180\]. | +| [Gt](./firestore_.gt.md#gt_class) | (BETA) | +| [Gte](./firestore_.gte.md#gte_class) | (BETA) | +| [If](./firestore_.if.md#if_class) | (BETA) | +| [In](./firestore_.in.md#in_class) | (BETA) | +| [IsNan](./firestore_.isnan.md#isnan_class) | (BETA) | +| [Like](./firestore_.like.md#like_class) | (BETA) | +| [Limit](./firestore_.limit.md#limit_class) | (BETA) | +| [LoadBundleTask](./firestore_.loadbundletask.md#loadbundletask_class) | Represents the task of loading a Firestore bundle. It provides progress of bundle loading, as well as task completion and error events.The API is compatible with Promise<LoadBundleTaskProgress>. | +| [LogicalMax](./firestore_.logicalmax.md#logicalmax_class) | (BETA) | +| [LogicalMin](./firestore_.logicalmin.md#logicalmin_class) | (BETA) | +| [Lt](./firestore_.lt.md#lt_class) | (BETA) | +| [Lte](./firestore_.lte.md#lte_class) | (BETA) | +| [MapGet](./firestore_.mapget.md#mapget_class) | (BETA) | +| [Max](./firestore_.max.md#max_class) | (BETA) | +| [Min](./firestore_.min.md#min_class) | (BETA) | +| [Mod](./firestore_.mod.md#mod_class) | (BETA) | +| [Multiply](./firestore_.multiply.md#multiply_class) | (BETA) | +| [Neq](./firestore_.neq.md#neq_class) | (BETA) | +| [Not](./firestore_.not.md#not_class) | (BETA) | +| [Offset](./firestore_.offset.md#offset_class) | (BETA) | +| [Or](./firestore_.or.md#or_class) | (BETA) | +| [Ordering](./firestore_.ordering.md#ordering_class) | (BETA) Represents an ordering criterion for sorting documents in a Firestore pipeline.You create Ordering instances using the ascending and descending helper functions. | +| [PersistentCacheIndexManager](./firestore_.persistentcacheindexmanager.md#persistentcacheindexmanager_class) | A PersistentCacheIndexManager for configuring persistent cache indexes used for local query execution.To use, call getPersistentCacheIndexManager() to get an instance. | +| [Pipeline](./firestore_.pipeline.md#pipeline_class) | | +| [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) | (BETA) A PipelineResult contains data read from a Firestore Pipeline. The data can be extracted with the or methods.

If the PipelineResult represents a non-document result, ref will return a undefined value. | +| [PipelineSource](./firestore_.pipelinesource.md#pipelinesource_class) | (BETA) Represents the source of a Firestore [Pipeline](./firestore_.pipeline.md#pipeline_class). | +| [Query](./firestore_.query.md#query_class) | A Query refers to a query which you can read or listen to. You can also construct refined Query objects by adding filters and ordering. | +| [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) | A QueryCompositeFilterConstraint is used to narrow the set of documents returned by a Firestore query by performing the logical OR or AND of multiple [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class)s or [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class)s. QueryCompositeFilterConstraints are created by invoking or and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the QueryCompositeFilterConstraint. | +| [QueryConstraint](./firestore_.queryconstraint.md#queryconstraint_class) | A QueryConstraint is used to narrow the set of documents returned by a Firestore query. QueryConstraints are created by invoking [where()](./firestore_.md#where_0fae4bf), [orderBy()](./firestore_.md#orderby_006d61f), [startAt()](./firestore_.md#startat_9a4477f), [startAfter()](./firestore_.md#startafter_9a4477f), [endBefore()](./firestore_.md#endbefore_9a4477f), [endAt()](./firestore_.md#endat_9a4477f), [limit()](./firestore_.md#limit_ec46c78), [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryConstraint. | +| [QueryDocumentSnapshot](./firestore_.querydocumentsnapshot.md#querydocumentsnapshot_class) | A QueryDocumentSnapshot contains data read from a document in your Firestore database as part of a query. The document is guaranteed to exist and its data can be extracted with .data() or .get(<field>) to get a specific field.A QueryDocumentSnapshot offers the same API surface as a DocumentSnapshot. Since query results contain only existing documents, the exists property will always be true and data() will never return 'undefined'. | +| [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) | A QueryEndAtConstraint is used to exclude documents from the end of a result set returned by a Firestore query. QueryEndAtConstraints are created by invoking [endAt()](./firestore_.md#endat_9a4477f) or [endBefore()](./firestore_.md#endbefore_9a4477f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryEndAtConstraint. | +| [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) | A QueryFieldFilterConstraint is used to narrow the set of documents returned by a Firestore query by filtering on one or more document fields. QueryFieldFilterConstraints are created by invoking [where()](./firestore_.md#where_0fae4bf) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryFieldFilterConstraint. | +| [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) | A QueryLimitConstraint is used to limit the number of documents returned by a Firestore query. QueryLimitConstraints are created by invoking [limit()](./firestore_.md#limit_ec46c78) or [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryLimitConstraint. | +| [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) | A QueryOrderByConstraint is used to sort the set of documents returned by a Firestore query. QueryOrderByConstraints are created by invoking [orderBy()](./firestore_.md#orderby_006d61f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryOrderByConstraint.Note: Documents that do not contain the orderBy field will not be present in the query result. | +| [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class) | A QuerySnapshot contains zero or more DocumentSnapshot objects representing the results of a query. The documents can be accessed as an array via the docs property or enumerated using the forEach method. The number of documents can be determined via the empty and size properties. | +| [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) | A QueryStartAtConstraint is used to exclude documents from the start of a result set returned by a Firestore query. QueryStartAtConstraints are created by invoking [startAt()](./firestore_.md#startat_9a4477f) or [startAfter()](./firestore_.md#startafter_9a4477f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryStartAtConstraint. | +| [RegexContains](./firestore_.regexcontains.md#regexcontains_class) | (BETA) | +| [RegexMatch](./firestore_.regexmatch.md#regexmatch_class) | (BETA) | +| [ReplaceAll](./firestore_.replaceall.md#replaceall_class) | (BETA) | +| [ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) | (BETA) | +| [Reverse](./firestore_.reverse.md#reverse_class) | (BETA) | +| [Select](./firestore_.select.md#select_class) | (BETA) | +| [SnapshotMetadata](./firestore_.snapshotmetadata.md#snapshotmetadata_class) | Metadata about a snapshot, describing the state of the snapshot. | +| [Sort](./firestore_.sort.md#sort_class) | (BETA) | +| [StartsWith](./firestore_.startswith.md#startswith_class) | (BETA) | +| [StrConcat](./firestore_.strconcat.md#strconcat_class) | (BETA) | +| [StrContains](./firestore_.strcontains.md#strcontains_class) | (BETA) | +| [Subtract](./firestore_.subtract.md#subtract_class) | (BETA) | +| [Sum](./firestore_.sum.md#sum_class) | (BETA) | +| [Timestamp](./firestore_.timestamp.md#timestamp_class) | A Timestamp represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time.It is encoded using the Proleptic Gregorian Calendar which extends the Gregorian calendar backwards to year one. It is encoded assuming all minutes are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.For examples and further specifications, refer to the [Timestamp definition](https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto). | +| [TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) | (BETA) | +| [TimestampSub](./firestore_.timestampsub.md#timestampsub_class) | (BETA) | +| [TimestampToUnixMicros](./firestore_.timestamptounixmicros.md#timestamptounixmicros_class) | (BETA) | +| [TimestampToUnixMillis](./firestore_.timestamptounixmillis.md#timestamptounixmillis_class) | (BETA) | +| [TimestampToUnixSeconds](./firestore_.timestamptounixseconds.md#timestamptounixseconds_class) | (BETA) | +| [ToLower](./firestore_.tolower.md#tolower_class) | (BETA) | +| [ToUpper](./firestore_.toupper.md#toupper_class) | (BETA) | +| [Transaction](./firestore_.transaction.md#transaction_class) | A reference to a transaction.The Transaction object passed to a transaction's updateFunction provides the methods to read and write data within the transaction context. See [runTransaction()](./firestore_.md#runtransaction_6f03ec4). | +| [Trim](./firestore_.trim.md#trim_class) | (BETA) | +| [UnixMicrosToTimestamp](./firestore_.unixmicrostotimestamp.md#unixmicrostotimestamp_class) | (BETA) | +| [UnixMillisToTimestamp](./firestore_.unixmillistotimestamp.md#unixmillistotimestamp_class) | (BETA) | +| [UnixSecondsToTimestamp](./firestore_.unixsecondstotimestamp.md#unixsecondstotimestamp_class) | (BETA) | +| [VectorLength](./firestore_.vectorlength.md#vectorlength_class) | (BETA) | +| [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | Represents a vector type in Firestore documents. Create an instance with . VectorValue | +| [Where](./firestore_.where.md#where_class) | (BETA) | +| [WriteBatch](./firestore_.writebatch.md#writebatch_class) | A write batch, used to perform multiple writes as a single atomic unit.A WriteBatch object can be acquired by calling [writeBatch()](./firestore_.md#writebatch_231a8e0). It provides methods for adding writes to the write batch. None of the writes will be committed (or visible locally) until [WriteBatch.commit()](./firestore_.writebatch.md#writebatchcommit) is called. | +| [Xor](./firestore_.xor.md#xor_class) | (BETA) | + +## Interfaces + +| Interface | Description | +| --- | --- | +| [Accumulator](./firestore_.accumulator.md#accumulator_interface) | (BETA) An interface that represents an accumulator. | +| [AggregateSpec](./firestore_.aggregatespec.md#aggregatespec_interface) | Specifies a set of aggregations and their aliases. | +| [DocumentChange](./firestore_.documentchange.md#documentchange_interface) | A DocumentChange represents a change to the documents matching a query. It contains the document affected and the type of change that occurred. | +| [DocumentData](./firestore_.documentdata.md#documentdata_interface) | Document data (for use with [setDoc()](./firestore_lite.md#setdoc_ee215ad)) consists of fields mapped to values. | +| [ExperimentalLongPollingOptions](./firestore_.experimentallongpollingoptions.md#experimentallongpollingoptions_interface) | Options that configure the SDK’s underlying network transport (WebChannel) when long-polling is used.Note: This interface is "experimental" and is subject to change.See FirestoreSettings.experimentalAutoDetectLongPolling, FirestoreSettings.experimentalForceLongPolling, and FirestoreSettings.experimentalLongPollingOptions. | +| [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) | (BETA) An interface that represents a filter condition. | +| [FindNearestOptions](./firestore_.findnearestoptions.md#findnearestoptions_interface) | (BETA) | +| [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface) | Converter used by withConverter() to transform user objects of type AppModelType into Firestore data of type DbModelType.Using the converter allows you to specify generic type arguments when storing and retrieving objects from Firestore.In this context, an "AppModel" is a class that is used in an application to package together related information and functionality. Such a class could, for example, have properties with complex, nested data types, properties used for memoization, properties of types not supported by Firestore (such as symbol and bigint), and helper functions that perform compound operations. Such classes are not suitable and/or possible to store into a Firestore database. Instead, instances of such classes need to be converted to "plain old JavaScript objects" (POJOs) with exclusively primitive properties, potentially nested inside other POJOs or arrays of POJOs. In this context, this type is referred to as the "DbModel" and would be an object suitable for persisting into Firestore. For convenience, applications can implement FirestoreDataConverter and register the converter with Firestore objects, such as DocumentReference or Query, to automatically convert AppModel to DbModel when storing into Firestore, and convert DbModel to AppModel when retrieving from Firestore. | +| [FirestoreSettings](./firestore_.firestoresettings.md#firestoresettings_interface) | Specifies custom configurations for your Cloud Firestore instance. You must set these before invoking any other methods. | +| [Index](./firestore_.index.md#index_interface) | (BETA) The SDK definition of a Firestore index. | +| [IndexConfiguration](./firestore_.indexconfiguration.md#indexconfiguration_interface) | (BETA) A list of Firestore indexes to speed up local query execution.See [JSON Format](https://firebase.google.com/docs/reference/firestore/indexes/#json_format) for a description of the format of the index definition. | +| [IndexField](./firestore_.indexfield.md#indexfield_interface) | (BETA) A single field element in an index configuration. | +| [LoadBundleTaskProgress](./firestore_.loadbundletaskprogress.md#loadbundletaskprogress_interface) | Represents a progress update or a final state from loading bundles. | +| [MemoryCacheSettings](./firestore_.memorycachesettings.md#memorycachesettings_interface) | An settings object to configure an MemoryLocalCache instance. | +| [MemoryEagerGarbageCollector](./firestore_.memoryeagergarbagecollector.md#memoryeagergarbagecollector_interface) | A garbage collector deletes documents whenever they are not part of any active queries, and have no local mutations attached to them.This collector tries to ensure lowest memory footprints from the SDK, at the risk of documents not being cached for offline queries or for direct queries to the cache.Use factory function to create an instance of this collector. | +| [MemoryLocalCache](./firestore_.memorylocalcache.md#memorylocalcache_interface) | Provides an in-memory cache to the SDK. This is the default cache unless explicitly configured otherwise.To use, create an instance using the factory function , then set the instance to FirestoreSettings.cache and call initializeFirestore using the settings object. | +| [MemoryLruGarbageCollector](./firestore_.memorylrugarbagecollector.md#memorylrugarbagecollector_interface) | A garbage collector deletes Least-Recently-Used documents in multiple batches.This collector is configured with a target size, and will only perform collection when the cached documents exceed the target size. It avoids querying backend repeated for the same query or document, at the risk of having a larger memory footprint.Use factory function to create a instance of this collector. | +| [PersistenceSettings](./firestore_.persistencesettings.md#persistencesettings_interface) | Settings that can be passed to enableIndexedDbPersistence() to configure Firestore persistence.Persistence cannot be used in a Node.js environment. | +| [PersistentCacheSettings](./firestore_.persistentcachesettings.md#persistentcachesettings_interface) | An settings object to configure an PersistentLocalCache instance.Persistent cache cannot be used in a Node.js environment. | +| [PersistentLocalCache](./firestore_.persistentlocalcache.md#persistentlocalcache_interface) | Provides a persistent cache backed by IndexedDb to the SDK.To use, create an instance using the factory function , then set the instance to FirestoreSettings.cache and call initializeFirestore using the settings object. | +| [PersistentMultipleTabManager](./firestore_.persistentmultipletabmanager.md#persistentmultipletabmanager_interface) | A tab manager supporting multiple tabs. SDK will synchronize queries and mutations done across all tabs using the SDK. | +| [PersistentSingleTabManager](./firestore_.persistentsingletabmanager.md#persistentsingletabmanager_interface) | A tab manager supporting only one tab, no synchronization will be performed across tabs. | +| [PersistentSingleTabManagerSettings](./firestore_.persistentsingletabmanagersettings.md#persistentsingletabmanagersettings_interface) | Type to configure an PersistentSingleTabManager instance. | +| [Selectable](./firestore_.selectable.md#selectable_interface) | (BETA) An interface that represents a selectable expression. | +| [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | An options object that can be passed to [onSnapshot()](./firestore_.md#onsnapshot_0312fd7) and [QuerySnapshot.docChanges()](./firestore_.querysnapshot.md#querysnapshotdocchanges) to control which types of changes to include in the result set. | +| [SnapshotOptions](./firestore_.snapshotoptions.md#snapshotoptions_interface) | Options that configure how data is retrieved from a DocumentSnapshot (for example the desired behavior for server timestamps that have not yet been set to their final value). | +| [Stage](./firestore_.stage.md#stage_interface) | (BETA) | +| [TransactionOptions](./firestore_.transactionoptions.md#transactionoptions_interface) | Options to customize transaction behavior. | +| [Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) | A function returned by onSnapshot() that removes the listener when invoked. | + +## Namespaces + +| Namespace | Description | +| --- | --- | +| [and](./firestore_.and.md#and_namespace) | | +| [or](./firestore_.or.md#or_namespace) | | + +## Variables + +| Variable | Description | +| --- | --- | +| [CACHE\_SIZE\_UNLIMITED](./firestore_.md#cache_size_unlimited) | Constant used to indicate the LRU garbage collection should be disabled. Set this value as the cacheSizeBytes on the settings passed to the [Firestore](./firestore_.firestore.md#firestore_class) instance. | + +## Type Aliases + +| Type Alias | Description | +| --- | --- | +| [AccumulatorTarget](./firestore_.md#accumulatortarget) | (BETA) An accumulator target, which is an expression with an alias that also implements the Accumulator interface. | +| [AddPrefixToKeys](./firestore_.md#addprefixtokeys) | Returns a new map where every key is prefixed with the outer key appended to a dot. | +| [AggregateFieldType](./firestore_.md#aggregatefieldtype) | The union of all AggregateField types that are supported by Firestore. | +| [AggregateSpecData](./firestore_.md#aggregatespecdata) | A type whose keys are taken from an AggregateSpec, and whose values are the result of the aggregation performed by the corresponding AggregateField from the input AggregateSpec. | +| [AggregateType](./firestore_.md#aggregatetype) | Union type representing the aggregate type to be performed. | +| [ChildUpdateFields](./firestore_.md#childupdatefields) | Helper for calculating the nested fields for a given type T1. This is needed to distribute union types such as undefined | {...} (happens for optional props) or {a: A} | {b: B}.In this use case, V is used to distribute the union types of T[K] on Record, since T[K] is evaluated as an expression and not distributed.See https://www.typescriptlang.org/docs/handbook/advanced-types.html\#distributive-conditional-types | +| [DocumentChangeType](./firestore_.md#documentchangetype) | The type of a DocumentChange may be 'added', 'removed', or 'modified'. | +| [ExprType](./firestore_.md#exprtype) | (BETA) An enumeration of the different types of expressions. | +| [FilterExpr](./firestore_.md#filterexpr) | (BETA) A filter expression, which is an expression that also implements the FilterCondition interface. | +| [FirestoreErrorCode](./firestore_.md#firestoreerrorcode) | The set of Firestore status codes. The codes are the same at the ones exposed by gRPC here: https://github.com/grpc/grpc/blob/master/doc/statuscodes.mdPossible values: - 'cancelled': The operation was cancelled (typically by the caller). - 'unknown': Unknown error or an error from a different error domain. - 'invalid-argument': Client specified an invalid argument. Note that this differs from 'failed-precondition'. 'invalid-argument' indicates arguments that are problematic regardless of the state of the system (e.g. an invalid field name). - 'deadline-exceeded': Deadline expired before operation could complete. For operations that change the state of the system, this error may be returned even if the operation has completed successfully. For example, a successful response from a server could have been delayed long enough for the deadline to expire. - 'not-found': Some requested document was not found. - 'already-exists': Some document that we attempted to create already exists. - 'permission-denied': The caller does not have permission to execute the specified operation. - 'resource-exhausted': Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space. - 'failed-precondition': Operation was rejected because the system is not in a state required for the operation's execution. - 'aborted': The operation was aborted, typically due to a concurrency issue like transaction aborts, etc. - 'out-of-range': Operation was attempted past the valid range. - 'unimplemented': Operation is not implemented or not supported/enabled. - 'internal': Internal errors. Means some invariants expected by underlying system has been broken. If you see one of these errors, something is very broken. - 'unavailable': The service is currently unavailable. This is most likely a transient condition and may be corrected by retrying with a backoff. - 'data-loss': Unrecoverable data loss or corruption. - 'unauthenticated': The request does not have valid authentication credentials for the operation. | +| [FirestoreLocalCache](./firestore_.md#firestorelocalcache) | Union type from all supported SDK cache layer. | +| [ListenSource](./firestore_.md#listensource) | Describe the source a query listens to.Set to default to listen to both cache and server changes. Set to cache to listen to changes in cache only. | +| [MemoryGarbageCollector](./firestore_.md#memorygarbagecollector) | Union type from all support garbage collectors for memory local cache. | +| [NestedUpdateFields](./firestore_.md#nestedupdatefields) | For each field (e.g. 'bar'), find all nested keys (e.g. {'bar.baz': T1, 'bar.qux': T2}). Intersect them together to make a single map containing all possible keys that are all marked as optional | +| [OrderByDirection](./firestore_.md#orderbydirection) | The direction of a [orderBy()](./firestore_.md#orderby_006d61f) clause is specified as 'desc' or 'asc' (descending or ascending). | +| [PartialWithFieldValue](./firestore_.md#partialwithfieldvalue) | Similar to TypeScript's Partial<T>, but allows nested fields to be omitted and FieldValues to be passed in as property values. | +| [PersistentTabManager](./firestore_.md#persistenttabmanager) | A union of all available tab managers. | +| [Primitive](./firestore_.md#primitive) | Primitive types. | +| [QueryConstraintType](./firestore_.md#queryconstrainttype) | Describes the different query constraints available in this SDK. | +| [QueryFilterConstraint](./firestore_.md#queryfilterconstraint) | QueryFilterConstraint is a helper union type that represents [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) and [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). | +| [QueryNonFilterConstraint](./firestore_.md#querynonfilterconstraint) | QueryNonFilterConstraint is a helper union type that represents QueryConstraints which are used to narrow or order the set of documents, but that do not explicitly filter on a document field. QueryNonFilterConstraints are created by invoking [orderBy()](./firestore_.md#orderby_006d61f), [startAt()](./firestore_.md#startat_9a4477f), [startAfter()](./firestore_.md#startafter_9a4477f), [endBefore()](./firestore_.md#endbefore_9a4477f), [endAt()](./firestore_.md#endat_9a4477f), [limit()](./firestore_.md#limit_ec46c78) or [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the QueryConstraint. | +| [SelectableExpr](./firestore_.md#selectableexpr) | (BETA) A selectable expression, which is an expression that also implements the Selectable interface. | +| [SetOptions](./firestore_.md#setoptions) | An options object that configures the behavior of [setDoc()](./firestore_lite.md#setdoc_ee215ad), and calls. These calls can be configured to perform granular merges instead of overwriting the target documents in their entirety by providing a SetOptions with merge: true. | +| [TaskState](./firestore_.md#taskstate) | Represents the state of bundle loading tasks.Both 'Error' and 'Success' are sinking state: task will abort or complete and there will be no more updates after they are reported. | +| [UnionToIntersection](./firestore_.md#uniontointersection) | Given a union type U = T1 | T2 | ..., returns an intersected type (T1 & T2 & ...).Uses distributive conditional types and inference from conditional types. This works because multiple candidates for the same type variable in contra-variant positions causes an intersection type to be inferred. https://www.typescriptlang.org/docs/handbook/advanced-types.html\#type-inference-in-conditional-types https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type | +| [UpdateData](./firestore_.md#updatedata) | Update data (for use with [updateDoc()](./firestore_.md#updatedoc_51a65e3)) that consists of field paths (e.g. 'foo' or 'foo.baz') mapped to values. Fields that contain dots reference nested fields within the document. FieldValues can be passed in as property values. | +| [WhereFilterOp](./firestore_.md#wherefilterop) | Filter conditions in a [where()](./firestore_.md#where_0fae4bf) clause are specified using the strings '&lt;', '&lt;=', '==', '!=', '&gt;=', '&gt;', 'array-contains', 'in', 'array-contains-any', and 'not-in'. | | [WithFieldValue](./firestore_.md#withfieldvalue) | Allows FieldValues to be passed in as a property value while maintaining type safety. | -## function(app, ...) +## function(app, ...) + +### getFirestore(app) {:#getfirestore_cf608e1} + +Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. + +Signature: + +```typescript +export declare function getFirestore(app: FirebaseApp): Firestore; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) instance that the returned [Firestore](./firestore_.firestore.md#firestore_class) instance is associated with. | + +Returns: + +[Firestore](./firestore_.firestore.md#firestore_class) + +The default [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. + +### getFirestore(app, databaseId) {:#getfirestore_48de6cb} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Returns the existing named [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. + +Signature: + +```typescript +export declare function getFirestore(app: FirebaseApp, databaseId: string): Firestore; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) instance that the returned [Firestore](./firestore_.firestore.md#firestore_class) instance is associated with. | +| databaseId | string | The name of the database. | + +Returns: + +[Firestore](./firestore_.firestore.md#firestore_class) + +The named [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. + +### initializeFirestore(app, settings, databaseId) {:#initializefirestore_fc7d200} + +Initializes a new instance of [Firestore](./firestore_.firestore.md#firestore_class) with the provided settings. Can only be called before any other function, including [getFirestore()](./firestore_.md#getfirestore). If the custom settings are empty, this function is equivalent to calling [getFirestore()](./firestore_.md#getfirestore). + +Signature: + +```typescript +export declare function initializeFirestore(app: FirebaseApp, settings: FirestoreSettings, databaseId?: string): Firestore; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) with which the [Firestore](./firestore_.firestore.md#firestore_class) instance will be associated. | +| settings | [FirestoreSettings](./firestore_.firestoresettings.md#firestoresettings_interface) | A settings object to configure the [Firestore](./firestore_.firestore.md#firestore_class) instance. | +| databaseId | string | The name of the database. | + +Returns: + +[Firestore](./firestore_.firestore.md#firestore_class) + +A newly initialized [Firestore](./firestore_.firestore.md#firestore_class) instance. + +## function(firestore, ...) + +### clearIndexedDbPersistence(firestore) {:#clearindexeddbpersistence_231a8e0} + +Clears the persistent storage. This includes pending writes and cached documents. + +Must be called while the [Firestore](./firestore_.firestore.md#firestore_class) instance is not started (after the app is terminated or when the app is first initialized). On startup, this function must be called before other functions (other than [initializeFirestore()](./firestore_.md#initializefirestore_fc7d200) or [getFirestore()](./firestore_.md#getfirestore))). If the [Firestore](./firestore_.firestore.md#firestore_class) instance is still running, the promise will be rejected with the error code of `failed-precondition`. + +Note: `clearIndexedDbPersistence()` is primarily intended to help write reliable tests that use Cloud Firestore. It uses an efficient mechanism for dropping existing data but does not attempt to securely overwrite or otherwise make cached data unrecoverable. For applications that are sensitive to the disclosure of cached data in between user sessions, we strongly recommend not enabling persistence at all. + +Signature: + +```typescript +export declare function clearIndexedDbPersistence(firestore: Firestore): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to clear persistence for. | + +Returns: + +Promise<void> + +A `Promise` that is resolved when the persistent storage is cleared. Otherwise, the promise is rejected with an error. + +### collection(firestore, path, pathSegments) {:#collection_1eb4c23} + +Gets a `CollectionReference` instance that refers to the collection at the specified absolute path. + +Signature: + +```typescript +export declare function collection(firestore: Firestore, path: string, ...pathSegments: string[]): CollectionReference; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | A reference to the root Firestore instance. | +| path | string | A slash-separated path to a collection. | +| pathSegments | string\[\] | Additional path segments to apply relative to the first argument. | + +Returns: + +[CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> + +The `CollectionReference` instance. + +#### Exceptions + +If the final path has an even number of segments and does not point to a collection. + +### collectionGroup(firestore, collectionId) {:#collectiongroup_1838fc3} + +Creates and returns a new `Query` instance that includes all documents in the database that are contained in a collection or subcollection with the given `collectionId`. + +Signature: + +```typescript +export declare function collectionGroup(firestore: Firestore, collectionId: string): Query; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | A reference to the root Firestore instance. | +| collectionId | string | Identifies the collections to query over. Every collection or subcollection with this ID as the last segment of its path will be included. Cannot contain a slash. | + +Returns: + +[Query](./firestore_.query.md#query_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> + +The created `Query`. + +### connectFirestoreEmulator(firestore, host, port, options) {:#connectfirestoreemulator_7c247cd} + +Modify this instance to communicate with the Cloud Firestore emulator. + +Note: This must be called before this instance has been used to do any operations. + +Signature: + +```typescript +export declare function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: { + mockUserToken?: EmulatorMockTokenOptions | string; +}): void; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The Firestore instance to configure to connect to the emulator. | +| host | string | the emulator host (ex: localhost). | +| port | number | the emulator port (ex: 9000). | +| options | { mockUserToken?: [EmulatorMockTokenOptions](./util.md#emulatormocktokenoptions) \| string; } | | + +Returns: + +void + +### disableNetwork(firestore) {:#disablenetwork_231a8e0} + +Disables network usage for this instance. It can be re-enabled via [enableNetwork()](./firestore_.md#enablenetwork_231a8e0). While the network is disabled, any snapshot listeners, `getDoc()` or `getDocs()` calls will return results from cache, and any write operations will be queued until the network is restored. + +Signature: + +```typescript +export declare function disableNetwork(firestore: Firestore): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | + +Returns: + +Promise<void> + +A `Promise` that is resolved once the network has been disabled. + +### doc(firestore, path, pathSegments) {:#doc_1eb4c23} + +Gets a `DocumentReference` instance that refers to the document at the specified absolute path. + +Signature: + +```typescript +export declare function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | A reference to the root Firestore instance. | +| path | string | A slash-separated path to a document. | +| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | + +Returns: + +[DocumentReference](./firestore_.documentreference.md#documentreference_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> + +The `DocumentReference` instance. + +#### Exceptions + +If the final path has an odd number of segments and does not point to a document. + +### enableIndexedDbPersistence(firestore, persistenceSettings) {:#enableindexeddbpersistence_224174f} + +> Warning: This API is now obsolete. +> +> This function will be removed in a future major release. Instead, set `FirestoreSettings.localCache` to an instance of `PersistentLocalCache` to turn on IndexedDb cache. Calling this function when `FirestoreSettings.localCache` is already specified will throw an exception. +> + +Attempts to enable persistent storage, if possible. + +On failure, `enableIndexedDbPersistence()` will reject the promise or throw an exception. There are several reasons why this can fail, which can be identified by the `code` on the error. + +\* failed-precondition: The app is already open in another browser tab. \* unimplemented: The browser is incompatible with the offline persistence implementation. + +Note that even after a failure, the [Firestore](./firestore_.firestore.md#firestore_class) instance will remain usable, however offline persistence will be disabled. + +Note: `enableIndexedDbPersistence()` must be called before any other functions (other than [initializeFirestore()](./firestore_.md#initializefirestore_fc7d200), [getFirestore()](./firestore_.md#getfirestore) or [clearIndexedDbPersistence()](./firestore_.md#clearindexeddbpersistence_231a8e0). + +Persistence cannot be used in a Node.js environment. + +Signature: + +```typescript +export declare function enableIndexedDbPersistence(firestore: Firestore, persistenceSettings?: PersistenceSettings): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to enable persistence for. | +| persistenceSettings | [PersistenceSettings](./firestore_.persistencesettings.md#persistencesettings_interface) | Optional settings object to configure persistence. | + +Returns: + +Promise<void> + +A `Promise` that represents successfully enabling persistent storage. + +### enableMultiTabIndexedDbPersistence(firestore) {:#enablemultitabindexeddbpersistence_231a8e0} + +> Warning: This API is now obsolete. +> +> This function will be removed in a future major release. Instead, set `FirestoreSettings.localCache` to an instance of `PersistentLocalCache` to turn on indexeddb cache. Calling this function when `FirestoreSettings.localCache` is already specified will throw an exception. +> + +Attempts to enable multi-tab persistent storage, if possible. If enabled across all tabs, all operations share access to local persistence, including shared execution of queries and latency-compensated local document updates across all connected instances. + +On failure, `enableMultiTabIndexedDbPersistence()` will reject the promise or throw an exception. There are several reasons why this can fail, which can be identified by the `code` on the error. + +\* failed-precondition: The app is already open in another browser tab and multi-tab is not enabled. \* unimplemented: The browser is incompatible with the offline persistence implementation. + +Note that even after a failure, the [Firestore](./firestore_.firestore.md#firestore_class) instance will remain usable, however offline persistence will be disabled. + +Signature: + +```typescript +export declare function enableMultiTabIndexedDbPersistence(firestore: Firestore): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to enable persistence for. | + +Returns: + +Promise<void> + +A `Promise` that represents successfully enabling persistent storage. + +### enableNetwork(firestore) {:#enablenetwork_231a8e0} + +Re-enables use of the network for this [Firestore](./firestore_.firestore.md#firestore_class) instance after a prior call to [disableNetwork()](./firestore_.md#disablenetwork_231a8e0). + +Signature: + +```typescript +export declare function enableNetwork(firestore: Firestore): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | + +Returns: + +Promise<void> + +A `Promise` that is resolved once the network has been enabled. + +### getPersistentCacheIndexManager(firestore) {:#getpersistentcacheindexmanager_231a8e0} + +Returns the PersistentCache Index Manager used by the given `Firestore` object. + + The `PersistentCacheIndexManager` instance, or `null` if local persistent storage is not in use. + +Signature: + +```typescript +export declare function getPersistentCacheIndexManager(firestore: Firestore): PersistentCacheIndexManager | null; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | + +Returns: + +[PersistentCacheIndexManager](./firestore_.persistentcacheindexmanager.md#persistentcacheindexmanager_class) \| null + +### loadBundle(firestore, bundleData) {:#loadbundle_bec5b75} + +Loads a Firestore bundle into the local cache. + +Signature: + +```typescript +export declare function loadBundle(firestore: Firestore, bundleData: ReadableStream | ArrayBuffer | string): LoadBundleTask; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to load bundles for. | +| bundleData | ReadableStream<Uint8Array> \| ArrayBuffer \| string | An object representing the bundle to be loaded. Valid objects are ArrayBuffer, ReadableStream<Uint8Array> or string. | + +Returns: + +[LoadBundleTask](./firestore_.loadbundletask.md#loadbundletask_class) + +A `LoadBundleTask` object, which notifies callers with progress updates, and completion or error events. It can be used as a `Promise`. + +### namedQuery(firestore, name) {:#namedquery_6438876} + +Reads a Firestore [Query](./firestore_.query.md#query_class) from local cache, identified by the given name. + +The named queries are packaged into bundles on the server side (along with resulting documents), and loaded to local cache using `loadBundle`. Once in local cache, use this method to extract a [Query](./firestore_.query.md#query_class) by name. + +Signature: + +```typescript +export declare function namedQuery(firestore: Firestore, name: string): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to read the query from. | +| name | string | The name of the query. | + +Returns: + +Promise<[Query](./firestore_.query.md#query_class) \| null> + +A `Promise` that is resolved with the Query or `null`. + +### onSnapshotsInSync(firestore, observer) {:#onsnapshotsinsync_2f0dfa4} + +Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if a single server-generated change affects multiple listeners. + +NOTE: The snapshots-in-sync event only indicates that listeners are in sync with each other, but does not relate to whether those snapshots are in sync with the server. Use SnapshotMetadata in the individual listeners to determine if a snapshot is from the cache or the server. + +Signature: + +```typescript +export declare function onSnapshotsInSync(firestore: Firestore, observer: { + next?: (value: void) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; +}): Unsubscribe; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The instance of Firestore for synchronizing snapshots. | +| observer | { next?: (value: void) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | + +Returns: + +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) + +An unsubscribe function that can be called to cancel the snapshot listener. + +### onSnapshotsInSync(firestore, onSync) {:#onsnapshotsinsync_1901c06} + +Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if a single server-generated change affects multiple listeners. + +NOTE: The snapshots-in-sync event only indicates that listeners are in sync with each other, but does not relate to whether those snapshots are in sync with the server. Use `SnapshotMetadata` in the individual listeners to determine if a snapshot is from the cache or the server. + +Signature: + +```typescript +export declare function onSnapshotsInSync(firestore: Firestore, onSync: () => void): Unsubscribe; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The Firestore instance for synchronizing snapshots. | +| onSync | () => void | A callback to be called every time all snapshot listeners are in sync with each other. | + +Returns: + +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) + +An unsubscribe function that can be called to cancel the snapshot listener. + +### pipeline(firestore) {:#pipeline_231a8e0} + +Experimental Modular API for console testing. + +Signature: + +```typescript +export declare function pipeline(firestore: Firestore): PipelineSource; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | + +Returns: + +[PipelineSource](./firestore_.pipelinesource.md#pipelinesource_class) + +### runTransaction(firestore, updateFunction, options) {:#runtransaction_6f03ec4} + +Executes the given `updateFunction` and then attempts to commit the changes applied within the transaction. If any document read within the transaction has changed, Cloud Firestore retries the `updateFunction`. If it fails to commit after 5 attempts, the transaction fails. + +The maximum number of writes allowed in a single transaction is 500. + +Signature: + +```typescript +export declare function runTransaction(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise, options?: TransactionOptions): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | A reference to the Firestore database to run this transaction against. | +| updateFunction | (transaction: [Transaction](./firestore_.transaction.md#transaction_class)) => Promise<T> | The function to execute within the transaction context. | +| options | [TransactionOptions](./firestore_.transactionoptions.md#transactionoptions_interface) | An options object to configure maximum number of attempts to commit. | + +Returns: + +Promise<T> + +If the transaction completed successfully or was explicitly aborted (the `updateFunction` returned a failed promise), the promise returned by the `updateFunction `is returned here. Otherwise, if the transaction failed, a rejected promise with the corresponding failure error is returned. + +### setIndexConfiguration(firestore, configuration) {:#setindexconfiguration_c362f04} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +> Warning: This API is now obsolete. +> +> Instead of creating cache indexes manually, consider using `enablePersistentCacheIndexAutoCreation()` to let the SDK decide whether to create cache indexes for queries running locally. +> + +Configures indexing for local query execution. Any previous index configuration is overridden. The `Promise` resolves once the index configuration has been persisted. + +The index entries themselves are created asynchronously. You can continue to use queries that require indexing even if the indices are not yet available. Query execution will automatically start using the index once the index entries have been written. + +Indexes are only supported with IndexedDb persistence. If IndexedDb is not enabled, any index configuration is ignored. + +Signature: + +```typescript +export declare function setIndexConfiguration(firestore: Firestore, configuration: IndexConfiguration): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to configure indexes for. | +| configuration | [IndexConfiguration](./firestore_.indexconfiguration.md#indexconfiguration_interface) | The index definition. | + +Returns: + +Promise<void> + +A `Promise` that resolves once all indices are successfully configured. + +#### Exceptions + +FirestoreError if the JSON format is invalid. + +### setIndexConfiguration(firestore, json) {:#setindexconfiguration_90d0285} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +> Warning: This API is now obsolete. +> +> Instead of creating cache indexes manually, consider using `enablePersistentCacheIndexAutoCreation()` to let the SDK decide whether to create cache indexes for queries running locally. +> + +Configures indexing for local query execution. Any previous index configuration is overridden. The `Promise` resolves once the index configuration has been persisted. + +The index entries themselves are created asynchronously. You can continue to use queries that require indexing even if the indices are not yet available. Query execution will automatically start using the index once the index entries have been written. + +Indexes are only supported with IndexedDb persistence. Invoke either `enableIndexedDbPersistence()` or `enableMultiTabIndexedDbPersistence()` before setting an index configuration. If IndexedDb is not enabled, any index configuration is ignored. + +The method accepts the JSON format exported by the Firebase CLI (`firebase firestore:indexes`). If the JSON format is invalid, this method throws an error. + +Signature: + +```typescript +export declare function setIndexConfiguration(firestore: Firestore, json: string): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to configure indexes for. | +| json | string | The JSON format exported by the Firebase CLI. | + +Returns: + +Promise<void> + +A `Promise` that resolves once all indices are successfully configured. + +#### Exceptions + +FirestoreError if the JSON format is invalid. + +### terminate(firestore) {:#terminate_231a8e0} + +Terminates the provided [Firestore](./firestore_.firestore.md#firestore_class) instance. + +After calling `terminate()` only the `clearIndexedDbPersistence()` function may be used. Any other function will throw a `FirestoreError`. + +To restart after termination, create a new instance of FirebaseFirestore with [getFirestore()](./firestore_.md#getfirestore). + +Termination does not cancel any pending writes, and any promises that are awaiting a response from the server will not be resolved. If you have persistence enabled, the next time you start this instance, it will resume sending these writes to the server. + +Note: Under normal circumstances, calling `terminate()` is not required. This function is useful only when you want to force this instance to release all of its resources or in combination with `clearIndexedDbPersistence()` to ensure that all local state is destroyed between test runs. + +Signature: + +```typescript +export declare function terminate(firestore: Firestore): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | + +Returns: + +Promise<void> + +A `Promise` that is resolved when the instance has been successfully terminated. + +### waitForPendingWrites(firestore) {:#waitforpendingwrites_231a8e0} + +Waits until all currently pending writes for the active user have been acknowledged by the backend. + +The returned promise resolves immediately if there are no outstanding writes. Otherwise, the promise waits for all previously issued writes (including those written in a previous app session), but it does not wait for writes that were added after the function is called. If you want to wait for additional writes, call `waitForPendingWrites()` again. + +Any outstanding `waitForPendingWrites()` promises are rejected during user changes. + +Signature: + +```typescript +export declare function waitForPendingWrites(firestore: Firestore): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | + +Returns: + +Promise<void> + +A `Promise` which resolves when all currently pending writes have been acknowledged by the backend. + +### writeBatch(firestore) {:#writebatch_231a8e0} + +Creates a write batch, used for performing multiple writes as a single atomic operation. The maximum number of writes allowed in a single [WriteBatch](./firestore_.writebatch.md#writebatch_class) is 500. + +Unlike transactions, write batches are persisted offline and therefore are preferable when you don't need to condition your writes on read data. + +Signature: + +```typescript +export declare function writeBatch(firestore: Firestore): WriteBatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | + +Returns: + +[WriteBatch](./firestore_.writebatch.md#writebatch_class) + +A [WriteBatch](./firestore_.writebatch.md#writebatch_class) that can be used to atomically execute multiple writes. + +## function() + +### count() {:#count} + +Create an AggregateField object that can be used to compute the count of documents in the result set of a query. + +Signature: + +```typescript +export declare function count(): AggregateField; +``` +Returns: + +[AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<number> + +### countAll() {:#countall} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that counts the total number of stage inputs. + +```typescript +// Count the total number of users +countAll().as("totalUsers"); + +``` + A new representing the 'countAll' aggregation. + +Signature: + +```typescript +export declare function countAll(): Count; +``` +Returns: + +[Count](./firestore_.count.md#count_class) + +### deleteField() {:#deletefield} + +Returns a sentinel for use with [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) or [setDoc()](./firestore_lite.md#setdoc_ee215ad) with `{merge: true}` to mark a field for deletion. + +Signature: + +```typescript +export declare function deleteField(): FieldValue; +``` +Returns: + +[FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) + +### documentId() {:#documentid} + +Returns a special sentinel `FieldPath` to refer to the ID of a document. It can be used in queries to sort or filter by the document ID. + +Signature: + +```typescript +export declare function documentId(): FieldPath; +``` +Returns: + +[FieldPath](./firestore_.fieldpath.md#fieldpath_class) + +### getFirestore() {:#getfirestore} + +Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. + +Signature: + +```typescript +export declare function getFirestore(): Firestore; +``` +Returns: + +[Firestore](./firestore_.firestore.md#firestore_class) + +The default [Firestore](./firestore_.firestore.md#firestore_class) instance of the default app. + +### memoryEagerGarbageCollector() {:#memoryeagergarbagecollector} + +Creates an instance of `MemoryEagerGarbageCollector`. This is also the default garbage collector unless it is explicitly specified otherwise. + +Signature: + +```typescript +export declare function memoryEagerGarbageCollector(): MemoryEagerGarbageCollector; +``` +Returns: + +[MemoryEagerGarbageCollector](./firestore_.memoryeagergarbagecollector.md#memoryeagergarbagecollector_interface) + +### persistentMultipleTabManager() {:#persistentmultipletabmanager} + +Creates an instance of `PersistentMultipleTabManager`. + +Signature: + +```typescript +export declare function persistentMultipleTabManager(): PersistentMultipleTabManager; +``` +Returns: + +[PersistentMultipleTabManager](./firestore_.persistentmultipletabmanager.md#persistentmultipletabmanager_interface) + +### serverTimestamp() {:#servertimestamp} + +Returns a sentinel used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) to include a server-generated timestamp in the written data. + +Signature: + +```typescript +export declare function serverTimestamp(): FieldValue; +``` +Returns: + +[FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) + +### useFirestorePipelines() {:#usefirestorepipelines} + +Signature: + +```typescript +export declare function useFirestorePipelines(): void; +``` +Returns: + +void + +## function(array, ...) + +### arrayConcat(array, elements) {:#arrayconcat_0b3ddb9} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with other arrays. + +```typescript +// Combine the 'items' array with two new item arrays +arrayConcat(Field.of("items"), [Field.of("newItems"), Field.of("otherItems")]); + +``` + +Signature: + +```typescript +export declare function arrayConcat(array: Constant, elements: Constant[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_.constant.md#constant_class) | The array expression to concatenate to. | +| elements | [Constant](./firestore_.constant.md#constant_class)\[\] | The array expressions to concatenate. A new representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) + +### arrayConcat(array, elements) {:#arrayconcat_21991c1} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with other arrays and/or values. + +```typescript +// Combine the 'tags' array with a new array +arrayConcat(Field.of("tags"), ["newTag1", "newTag2"]); + +``` + +Signature: + +```typescript +export declare function arrayConcat(array: Constant, elements: any[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_.constant.md#constant_class) | The array expression to concatenate to. | +| elements | any\[\] | The array expressions or single values to concatenate. A new representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) + +### arrayConcat(array, elements) {:#arrayconcat_f8d5d5e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates a field's array value with other arrays. + +```typescript +// Combine the 'items' array with two new item arrays +arrayConcat("items", [Field.of("newItems"), Field.of("otherItems")]); + +``` + +Signature: + +```typescript +export declare function arrayConcat(array: string, elements: Constant[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | string | The field name containing array values. | +| elements | [Constant](./firestore_.constant.md#constant_class)\[\] | The array expressions to concatenate. A new representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) + +### arrayConcat(array, elements) {:#arrayconcat_5a66d99} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates a field's array value with other arrays and/or values. + +```typescript +// Combine the 'tags' array with a new array +arrayConcat("tags", ["newTag1", "newTag2"]); + +``` + +Signature: + +```typescript +export declare function arrayConcat(array: string, elements: any[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | string | The field name containing array values. | +| elements | any\[\] | The array expressions or single values to concatenate. A new representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) + +### arrayContains(array, element) {:#arraycontains_01ea7c0} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array expression contains a specific element. + +```typescript +// Check if the 'colors' array contains the value of field 'selectedColor' +arrayContains(Field.of("colors"), Field.of("selectedColor")); + +``` + +Signature: + +```typescript +export declare function arrayContains(array: Constant, element: Constant): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_.constant.md#constant_class) | The array expression to check. | +| element | [Constant](./firestore_.constant.md#constant_class) | The element to search for in the array. A new representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) + +### arrayContains(array, element) {:#arraycontains_60f8f2f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array expression contains a specific element. + +```typescript +// Check if the 'colors' array contains "red" +arrayContains(Field.of("colors"), "red"); + +``` + +Signature: + +```typescript +export declare function arrayContains(array: Constant, element: any): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_.constant.md#constant_class) | The array expression to check. | +| element | any | The element to search for in the array. A new representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) + +### arrayContains(array, element) {:#arraycontains_0ebdbfe} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's array value contains a specific element. + +```typescript +// Check if the 'colors' array contains the value of field 'selectedColor' +arrayContains("colors", Field.of("selectedColor")); + +``` + +Signature: + +```typescript +export declare function arrayContains(array: string, element: Constant): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | string | The field name to check. | +| element | [Constant](./firestore_.constant.md#constant_class) | The element to search for in the array. A new representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) + +### arrayContains(array, element) {:#arraycontains_8f718df} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's array value contains a specific value. + +```typescript +// Check if the 'colors' array contains "red" +arrayContains("colors", "red"); + +``` + +Signature: + +```typescript +export declare function arrayContains(array: string, element: any): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | string | The field name to check. | +| element | any | The element to search for in the array. A new representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) + +### arrayContainsAll(array, values) {:#arraycontainsall_7b7433a} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array expression contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" +arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); + +``` + +Signature: + +```typescript +export declare function arrayContainsAll(array: Constant, values: Constant[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_.constant.md#constant_class) | The array expression to check. | +| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) + +### arrayContainsAll(array, values) {:#arraycontainsall_d919466} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array expression contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" +arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); + +``` + +Signature: + +```typescript +export declare function arrayContainsAll(array: Constant, values: any[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_.constant.md#constant_class) | The array expression to check. | +| values | any\[\] | The elements to check for in the array. A new representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) + +### arrayContainsAll(array, values) {:#arraycontainsall_b40e2df} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's array value contains all the specified values or expressions. + +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); + +``` + +Signature: + +```typescript +export declare function arrayContainsAll(array: string, values: Constant[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | string | The field name to check. | +| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) + +### arrayContainsAll(array, values) {:#arraycontainsall_b08efbb} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's array value contains all the specified values or expressions. + +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); + +``` + +Signature: + +```typescript +export declare function arrayContainsAll(array: string, values: any[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | string | The field name to check. | +| values | any\[\] | The elements to check for in the array. A new representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) + +### arrayContainsAny(array, values) {:#arraycontainsany_7b7433a} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array expression contains any of the specified elements. + +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "Science" +arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); + +``` + +Signature: + +```typescript +export declare function arrayContainsAny(array: Constant, values: Constant[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_.constant.md#constant_class) | The array expression to check. | +| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) + +### arrayContainsAny(array, values) {:#arraycontainsany_d919466} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array expression contains any of the specified elements. + +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "Science" +arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); + +``` + +Signature: + +```typescript +export declare function arrayContainsAny(array: Constant, values: any[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_.constant.md#constant_class) | The array expression to check. | +| values | any\[\] | The elements to check for in the array. A new representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) + +### arrayContainsAny(array, values) {:#arraycontainsany_b40e2df} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's array value contains any of the specified elements. + +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +arrayContainsAny("categories", [Field.of("cate1"), "Science"]); + +``` + +Signature: + +```typescript +export declare function arrayContainsAny(array: string, values: Constant[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | string | The field name to check. | +| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) + +### arrayContainsAny(array, values) {:#arraycontainsany_b08efbb} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's array value contains any of the specified elements. + +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +arrayContainsAny("categories", [Field.of("cate1"), "Science"]); + +``` + +Signature: + +```typescript +export declare function arrayContainsAny(array: string, values: any[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | string | The field name to check. | +| values | any\[\] | The elements to check for in the array. A new representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) + +### arrayLength(array) {:#arraylength_0bb5dbb} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of an array expression. + +```typescript +// Get the number of items in the 'cart' array +arrayLength(Field.of("cart")); + +``` + +Signature: + +```typescript +export declare function arrayLength(array: Constant): ArrayLength; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_.constant.md#constant_class) | The array expression to calculate the length of. A new representing the length of the array. | + +Returns: + +[ArrayLength](./firestore_.arraylength.md#arraylength_class) + +## function(condition, ...) + +### ifFunction(condition, thenExpr, elseExpr) {:#iffunction_f7b2404} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a conditional expression that evaluates to a 'then' expression if a condition is true and an 'else' expression if the condition is false. + +```typescript +// If 'age' is greater than 18, return "Adult"; otherwise, return "Minor". +ifFunction( + gt("age", 18), Constant.of("Adult"), Constant.of("Minor")); + +``` + +Signature: + +```typescript +export declare function ifFunction(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant): If; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| condition | [FilterExpr](./firestore_.md#filterexpr) | The condition to evaluate. | +| thenExpr | [Constant](./firestore_.constant.md#constant_class) | The expression to evaluate if the condition is true. | +| elseExpr | [Constant](./firestore_.constant.md#constant_class) | The expression to evaluate if the condition is false. A new representing the conditional expression. | + +Returns: + +[If](./firestore_.if.md#if_class) + +## function(databaseId, ...) + +### getFirestore(databaseId) {:#getfirestore_53dc891} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Returns the existing named [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. + +Signature: + +```typescript +export declare function getFirestore(databaseId: string): Firestore; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| databaseId | string | The name of the database. | + +Returns: + +[Firestore](./firestore_.firestore.md#firestore_class) + +The named [Firestore](./firestore_.firestore.md#firestore_class) instance of the default app. + +## function(element, ...) + +### inAny(element, others) {:#inany_a73b259} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an expression is equal to any of the provided values or expressions. + +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +inAny(Field.of("category"), [Constant.of("Electronics"), Field.of("primaryType")]); + +``` + +Signature: + +```typescript +export declare function inAny(element: Constant, others: Constant[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | [Constant](./firestore_.constant.md#constant_class) | The expression to compare. | +| others | [Constant](./firestore_.constant.md#constant_class)\[\] | The values to check against. A new representing the 'IN' comparison. | + +Returns: + +[In](./firestore_.in.md#in_class) + +### inAny(element, others) {:#inany_f5721c6} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an expression is equal to any of the provided values or expressions. + +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +inAny(Field.of("category"), ["Electronics", Field.of("primaryType")]); + +``` + +Signature: + +```typescript +export declare function inAny(element: Constant, others: any[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | [Constant](./firestore_.constant.md#constant_class) | The expression to compare. | +| others | any\[\] | The values to check against. A new representing the 'IN' comparison. | + +Returns: + +[In](./firestore_.in.md#in_class) + +### inAny(element, others) {:#inany_c6646ea} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is equal to any of the provided values or expressions. + +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +inAny("category", [Constant.of("Electronics"), Field.of("primaryType")]); + +``` + +Signature: + +```typescript +export declare function inAny(element: string, others: Constant[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | string | The field to compare. | +| others | [Constant](./firestore_.constant.md#constant_class)\[\] | The values to check against. A new representing the 'IN' comparison. | + +Returns: + +[In](./firestore_.in.md#in_class) + +### inAny(element, others) {:#inany_e6877aa} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is equal to any of the provided values or expressions. + +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +inAny("category", ["Electronics", Field.of("primaryType")]); + +``` + +Signature: + +```typescript +export declare function inAny(element: string, others: any[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | string | The field to compare. | +| others | any\[\] | The values to check against. A new representing the 'IN' comparison. | + +Returns: + +[In](./firestore_.in.md#in_class) + +### notInAny(element, others) {:#notinany_a73b259} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an expression is not equal to any of the provided values or expressions. + +```typescript +// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' +notInAny(Field.of("status"), [Constant.of("pending"), Field.of("rejectedStatus")]); + +``` + +Signature: + +```typescript +export declare function notInAny(element: Constant, others: Constant[]): Not; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | [Constant](./firestore_.constant.md#constant_class) | The expression to compare. | +| others | [Constant](./firestore_.constant.md#constant_class)\[\] | The values to check against. A new representing the 'NOT IN' comparison. | + +Returns: + +[Not](./firestore_.not.md#not_class) + +### notInAny(element, others) {:#notinany_f5721c6} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an expression is not equal to any of the provided values or expressions. + +```typescript +// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' +notInAny(Field.of("status"), ["pending", Field.of("rejectedStatus")]); + +``` + +Signature: + +```typescript +export declare function notInAny(element: Constant, others: any[]): Not; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | [Constant](./firestore_.constant.md#constant_class) | The expression to compare. | +| others | any\[\] | The values to check against. A new representing the 'NOT IN' comparison. | + +Returns: + +[Not](./firestore_.not.md#not_class) + +### notInAny(element, others) {:#notinany_c6646ea} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is not equal to any of the provided values or expressions. + +```typescript +// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' +notInAny("status", [Constant.of("pending"), Field.of("rejectedStatus")]); + +``` + +Signature: + +```typescript +export declare function notInAny(element: string, others: Constant[]): Not; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | string | The field name to compare. | +| others | [Constant](./firestore_.constant.md#constant_class)\[\] | The values to check against. A new representing the 'NOT IN' comparison. | + +Returns: + +[Not](./firestore_.not.md#not_class) + +### notInAny(element, others) {:#notinany_e6877aa} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is not equal to any of the provided values or expressions. + +```typescript +// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' +notInAny("status", ["pending", Field.of("rejectedStatus")]); + +``` + +Signature: + +```typescript +export declare function notInAny(element: string, others: any[]): Not; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | string | The field name to compare. | +| others | any\[\] | The values to check against. A new representing the 'NOT IN' comparison. | + +Returns: + +[Not](./firestore_.not.md#not_class) + +## function(elements, ...) + +### arrayRemove(elements) {:#arrayremove_7d853aa} + +Returns a special value that can be used with [setDoc()](./firestore_.md#setdoc_ee215ad) or that tells the server to remove the given elements from any array value that already exists on the server. All instances of each element specified will be removed from the array. If the field being modified is not already an array it will be overwritten with an empty array. + +Signature: + +```typescript +export declare function arrayRemove(...elements: unknown[]): FieldValue; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| elements | unknown\[\] | The elements to remove from the array. | + +Returns: + +[FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) + +The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()` + +### arrayUnion(elements) {:#arrayunion_7d853aa} + +Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to union the given elements with any array value that already exists on the server. Each specified element that doesn't already exist in the array will be added to the end. If the field being modified is not already an array it will be overwritten with an array containing exactly the specified elements. + +Signature: + +```typescript +export declare function arrayUnion(...elements: unknown[]): FieldValue; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| elements | unknown\[\] | The elements to union into the array. | + +Returns: + +[FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) + +The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()`. + +## function(expr, ...) + +### ascending(expr) {:#ascending_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. + +```typescript +// Sort documents by the 'name' field in ascending order +firestore.pipeline().collection("users") + .sort(ascending(Field.of("name"))); + +``` + +Signature: + +```typescript +export declare function ascending(expr: Constant): Ordering; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression to create an ascending ordering for. A new Ordering for ascending sorting. | + +Returns: + +[Ordering](./firestore_.ordering.md#ordering_class) + +### byteLength(expr) {:#bytelength_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the byte length of a string in UTF-8, or just the length of a Blob. + +```typescript +// Calculate the length of the 'myString' field in bytes. +byteLength(Field.of("myString")); + +``` + +Signature: + +```typescript +export declare function byteLength(expr: Constant): ByteLength; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string. A new representing the length of the string in bytes. | + +Returns: + +[ByteLength](./firestore_.bytelength.md#bytelength_class) + +### charLength(expr) {:#charlength_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the character length of a string expression in UTF-8. + +```typescript +// Get the character length of the 'name' field in UTF-8. +strLength(Field.of("name")); + +``` + +Signature: + +```typescript +export declare function charLength(expr: Constant): CharLength; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to calculate the length of. A new representing the length of the string. | + +Returns: + +[CharLength](./firestore_.charlength.md#charlength_class) + +### cosineDistance(expr, other) {:#cosinedistance_b4c7dc2} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between a field's vector value and a double array. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +cosineDistance("location", [37.7749, -122.4194]); + +``` + +Signature: + +```typescript +export declare function cosineDistance(expr: string, other: number[]): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the first vector. | +| other | number\[\] | The other vector (as an array of doubles) to compare against. A new representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) + +### cosineDistance(expr, other) {:#cosinedistance_8d2bd9d} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between a field's vector value and a VectorValue. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +cosineDistance("location", new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +export declare function cosineDistance(expr: string, other: VectorValue): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the first vector. | +| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) + +### cosineDistance(expr, other) {:#cosinedistance_c9ae0bc} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between a field's vector value and a vector expression. + +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +cosineDistance("userVector", Field.of("itemVector")); + +``` + +Signature: + +```typescript +export declare function cosineDistance(expr: string, other: Constant): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the first vector. | +| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new representing the cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) + +### cosineDistance(expr, other) {:#cosinedistance_e701952} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between a vector expression and a double array. + +```typescript +// Calculate the cosine distance between the 'location' field and a target location +cosineDistance(Field.of("location"), [37.7749, -122.4194]); + +``` + +Signature: + +```typescript +export declare function cosineDistance(expr: Constant, other: number[]): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | +| other | number\[\] | The other vector (as an array of doubles) to compare against. A new representing the cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) + +### cosineDistance(expr, other) {:#cosinedistance_cc2e83e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between a vector expression and a VectorValue. + +```typescript +// Calculate the cosine distance between the 'location' field and a target location +cosineDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +export declare function cosineDistance(expr: Constant, other: VectorValue): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | +| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new representing the cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) + +### cosineDistance(expr, other) {:#cosinedistance_0896fbd} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vector expressions. + +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +cosineDistance(Field.of("userVector"), Field.of("itemVector")); + +``` + +Signature: + +```typescript +export declare function cosineDistance(expr: Constant, other: Constant): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | +| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new representing the cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) + +### descending(expr) {:#descending_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. + +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") + .sort(descending(Field.of("createdAt"))); + +``` + +Signature: + +```typescript +export declare function descending(expr: Constant): Ordering; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression to create a descending ordering for. A new Ordering for descending sorting. | + +Returns: + +[Ordering](./firestore_.ordering.md#ordering_class) + +### dotProduct(expr, other) {:#dotproduct_b4c7dc2} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between a field's vector value and a double array. + +```typescript +// Calculate the dot product distance between a feature vector and a target vector +dotProduct("features", [0.5, 0.8, 0.2]); + +``` + +Signature: + +```typescript +export declare function dotProduct(expr: string, other: number[]): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the first vector. | +| other | number\[\] | The other vector (as an array of doubles) to calculate with. A new representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_.dotproduct.md#dotproduct_class) + +### dotProduct(expr, other) {:#dotproduct_8d2bd9d} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between a field's vector value and a VectorValue. + +```typescript +// Calculate the dot product distance between a feature vector and a target vector +dotProduct("features", new VectorValue([0.5, 0.8, 0.2])); + +``` + +Signature: + +```typescript +export declare function dotProduct(expr: string, other: VectorValue): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the first vector. | +| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to calculate with. A new representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_.dotproduct.md#dotproduct_class) + +### dotProduct(expr, other) {:#dotproduct_c9ae0bc} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between a field's vector value and a vector expression. + +```typescript +// Calculate the dot product distance between two document vectors: 'docVector1' and 'docVector2' +dotProduct("docVector1", Field.of("docVector2")); + +``` + +Signature: + +```typescript +export declare function dotProduct(expr: string, other: Constant): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the first vector. | +| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to calculate with. A new representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_.dotproduct.md#dotproduct_class) + +### dotProduct(expr, other) {:#dotproduct_e701952} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between a vector expression and a double array. + +```typescript +// Calculate the dot product between a feature vector and a target vector +dotProduct(Field.of("features"), [0.5, 0.8, 0.2]); + +``` + +Signature: + +```typescript +export declare function dotProduct(expr: Constant, other: number[]): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The first vector (represented as an Expr) to calculate with. | +| other | number\[\] | The other vector (as an array of doubles) to calculate with. A new representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_.dotproduct.md#dotproduct_class) + +### dotProduct(expr, other) {:#dotproduct_cc2e83e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between a vector expression and a VectorValue. + +```typescript +// Calculate the dot product between a feature vector and a target vector +dotProduct(Field.of("features"), new VectorValue([0.5, 0.8, 0.2])); + +``` + +Signature: + +```typescript +export declare function dotProduct(expr: Constant, other: VectorValue): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The first vector (represented as an Expr) to calculate with. | +| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to calculate with. A new representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_.dotproduct.md#dotproduct_class) + +### dotProduct(expr, other) {:#dotproduct_0896fbd} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vector expressions. + +```typescript +// Calculate the dot product between two document vectors: 'docVector1' and 'docVector2' +dotProduct(Field.of("docVector1"), Field.of("docVector2")); + +``` + +Signature: + +```typescript +export declare function dotProduct(expr: Constant, other: Constant): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The first vector (represented as an Expr) to calculate with. | +| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to calculate with. A new representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_.dotproduct.md#dotproduct_class) + +### endsWith(expr, suffix) {:#endswith_88569cd} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value ends with a given postfix. + +```typescript +// Check if the 'filename' field ends with ".txt" +endsWith("filename", ".txt"); + +``` + +Signature: + +```typescript +export declare function endsWith(expr: string, suffix: string): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The field name to check. | +| suffix | string | The postfix to check for. A new representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_.endswith.md#endswith_class) + +### endsWith(expr, suffix) {:#endswith_e2e794e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value ends with a given postfix. + +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +endsWith("url", Field.of("extension")); + +``` + +Signature: + +```typescript +export declare function endsWith(expr: string, suffix: Constant): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The field name to check. | +| suffix | [Constant](./firestore_.constant.md#constant_class) | The expression representing the postfix. A new representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_.endswith.md#endswith_class) + +### endsWith(expr, suffix) {:#endswith_6308b81} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string expression ends with a given postfix. + +```typescript +// Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." +endsWith(Field.of("fullName"), "Jr."); + +``` + +Signature: + +```typescript +export declare function endsWith(expr: Constant, suffix: string): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression to check. | +| suffix | string | The postfix to check for. A new representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_.endswith.md#endswith_class) + +### endsWith(expr, suffix) {:#endswith_ab1cc39} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string expression ends with a given postfix. + +```typescript +// Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." +endsWith(Field.of("fullName"), Constant.of("Jr.")); + +``` + +Signature: + +```typescript +export declare function endsWith(expr: Constant, suffix: Constant): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression to check. | +| suffix | [Constant](./firestore_.constant.md#constant_class) | The postfix to check for. A new representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_.endswith.md#endswith_class) + +### euclideanDistance(expr, other) {:#euclideandistance_b4c7dc2} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between a field's vector value and a double array. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +euclideanDistance("location", [37.7749, -122.4194]); + +``` + +Signature: + +```typescript +export declare function euclideanDistance(expr: string, other: number[]): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the first vector. | +| other | number\[\] | The other vector (as an array of doubles) to compare against. A new representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) + +### euclideanDistance(expr, other) {:#euclideandistance_8d2bd9d} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between a field's vector value and a VectorValue. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +euclideanDistance("location", new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +export declare function euclideanDistance(expr: string, other: VectorValue): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the first vector. | +| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) + +### euclideanDistance(expr, other) {:#euclideandistance_c9ae0bc} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between a field's vector value and a vector expression. + +```typescript +// Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' +euclideanDistance("pointA", Field.of("pointB")); + +``` + +Signature: + +```typescript +export declare function euclideanDistance(expr: string, other: Constant): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the first vector. | +| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) + +### euclideanDistance(expr, other) {:#euclideandistance_e701952} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between a vector expression and a double array. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location + +euclideanDistance(Field.of("location"), [37.7749, -122.4194]); + +``` + +Signature: + +```typescript +export declare function euclideanDistance(expr: Constant, other: number[]): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | +| other | number\[\] | The other vector (as an array of doubles) to compare against. A new representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) + +### euclideanDistance(expr, other) {:#euclideandistance_cc2e83e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between a vector expression and a VectorValue. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +euclideanDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +export declare function euclideanDistance(expr: Constant, other: VectorValue): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | +| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) + +### euclideanDistance(expr, other) {:#euclideandistance_0896fbd} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vector expressions. + +```typescript +// Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' +euclideanDistance(Field.of("pointA"), Field.of("pointB")); + +``` + +Signature: + +```typescript +export declare function euclideanDistance(expr: Constant, other: Constant): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | +| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) + +### reverse(expr) {:#reverse_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that reverses a string. + +```typescript +// Reverse the value of the 'myString' field. +reverse(Field.of("myString")); + +``` + +Signature: + +```typescript +export declare function reverse(expr: Constant): Reverse; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to reverse. A new representing the reversed string. | + +Returns: + +[Reverse](./firestore_.reverse.md#reverse_class) + +### startsWith(expr, prefix) {:#startswith_484d9f3} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value starts with a given prefix. + +```typescript +// Check if the 'name' field starts with "Mr." +startsWith("name", "Mr."); + +``` + +Signature: + +```typescript +export declare function startsWith(expr: string, prefix: string): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The field name to check. | +| prefix | string | The prefix to check for. A new representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_.startswith.md#startswith_class) + +### startsWith(expr, prefix) {:#startswith_7deb5c7} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value starts with a given prefix. + +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +startsWith("fullName", Field.of("firstName")); + +``` + +Signature: + +```typescript +export declare function startsWith(expr: string, prefix: Constant): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The field name to check. | +| prefix | [Constant](./firestore_.constant.md#constant_class) | The expression representing the prefix. A new representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_.startswith.md#startswith_class) + +### startsWith(expr, prefix) {:#startswith_68300d1} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string expression starts with a given prefix. + +```typescript +// Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." +startsWith(Field.of("fullName"), "Mr."); + +``` + +Signature: + +```typescript +export declare function startsWith(expr: Constant, prefix: string): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression to check. | +| prefix | string | The prefix to check for. A new representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_.startswith.md#startswith_class) + +### startsWith(expr, prefix) {:#startswith_5774b68} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string expression starts with a given prefix. + +```typescript +// Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." +startsWith(Field.of("fullName"), Field.of("prefix")); + +``` + +Signature: + +```typescript +export declare function startsWith(expr: Constant, prefix: Constant): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression to check. | +| prefix | [Constant](./firestore_.constant.md#constant_class) | The prefix to check for. A new representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_.startswith.md#startswith_class) + +### timestampToUnixMicros(expr) {:#timestamptounixmicros_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +timestampToUnixMicros(Field.of("timestamp")); + +``` + +Signature: + +```typescript +export declare function timestampToUnixMicros(expr: Constant): TimestampToUnixMicros; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the timestamp. A new representing the number of microseconds since epoch. | + +Returns: + +[TimestampToUnixMicros](./firestore_.timestamptounixmicros.md#timestamptounixmicros_class) + +### timestampToUnixMillis(expr) {:#timestamptounixmillis_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +timestampToUnixMillis(Field.of("timestamp")); + +``` + +Signature: + +```typescript +export declare function timestampToUnixMillis(expr: Constant): TimestampToUnixMillis; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the timestamp. A new representing the number of milliseconds since epoch. | + +Returns: + +[TimestampToUnixMillis](./firestore_.timestamptounixmillis.md#timestamptounixmillis_class) + +### timestampToUnixSeconds(expr) {:#timestamptounixseconds_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to seconds since epoch. +timestampToUnixSeconds(Field.of("timestamp")); + +``` + +Signature: + +```typescript +export declare function timestampToUnixSeconds(expr: Constant): TimestampToUnixSeconds; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the timestamp. A new representing the number of seconds since epoch. | + +Returns: + +[TimestampToUnixSeconds](./firestore_.timestamptounixseconds.md#timestamptounixseconds_class) + +### toLower(expr) {:#tolower_1e536ed} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string field to lowercase. + +```typescript +// Convert the 'name' field to lowercase +toLower("name"); + +``` + +Signature: + +```typescript +export declare function toLower(expr: string): ToLower; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the string. A new representing the lowercase string. | + +Returns: + +[ToLower](./firestore_.tolower.md#tolower_class) + +### toLower(expr) {:#tolower_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string expression to lowercase. + +```typescript +// Convert the 'name' field to lowercase +toLower(Field.of("name")); + +``` + +Signature: + +```typescript +export declare function toLower(expr: Constant): ToLower; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to convert to lowercase. A new representing the lowercase string. | + +Returns: + +[ToLower](./firestore_.tolower.md#tolower_class) + +### toUpper(expr) {:#toupper_1e536ed} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string field to uppercase. + +```typescript +// Convert the 'title' field to uppercase +toUpper("title"); + +``` + +Signature: + +```typescript +export declare function toUpper(expr: string): ToUpper; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the string. A new representing the uppercase string. | + +Returns: + +[ToUpper](./firestore_.toupper.md#toupper_class) + +### toUpper(expr) {:#toupper_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string expression to uppercase. + +```typescript +// Convert the 'title' field to uppercase +toUppercase(Field.of("title")); + +``` + +Signature: + +```typescript +export declare function toUpper(expr: Constant): ToUpper; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to convert to uppercase. A new representing the uppercase string. | + +Returns: + +[ToUpper](./firestore_.toupper.md#toupper_class) + +### trim(expr) {:#trim_1e536ed} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that removes leading and trailing whitespace from a string field. + +```typescript +// Trim whitespace from the 'userInput' field +trim("userInput"); + +``` + +Signature: + +```typescript +export declare function trim(expr: string): Trim; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the string. A new representing the trimmed string. | + +Returns: + +[Trim](./firestore_.trim.md#trim_class) + +### trim(expr) {:#trim_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that removes leading and trailing whitespace from a string expression. + +```typescript +// Trim whitespace from the 'userInput' field +trim(Field.of("userInput")); + +``` + +Signature: + +```typescript +export declare function trim(expr: Constant): Trim; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to trim. A new representing the trimmed string. | + +Returns: + +[Trim](./firestore_.trim.md#trim_class) + +### unixMicrosToTimestamp(expr) {:#unixmicrostotimestamp_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets an expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +unixMicrosToTimestamp(Field.of("microseconds")); + +``` + +Signature: + +```typescript +export declare function unixMicrosToTimestamp(expr: Constant): UnixMicrosToTimestamp; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the number of microseconds since epoch. A new representing the timestamp. | + +Returns: + +[UnixMicrosToTimestamp](./firestore_.unixmicrostotimestamp.md#unixmicrostotimestamp_class) + +### unixMillisToTimestamp(expr) {:#unixmillistotimestamp_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets an expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +unixMillisToTimestamp(Field.of("milliseconds")); + +``` + +Signature: + +```typescript +export declare function unixMillisToTimestamp(expr: Constant): UnixMillisToTimestamp; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the number of milliseconds since epoch. A new representing the timestamp. | + +Returns: + +[UnixMillisToTimestamp](./firestore_.unixmillistotimestamp.md#unixmillistotimestamp_class) + +### unixSecondsToTimestamp(expr) {:#unixsecondstotimestamp_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets an expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'seconds' field as seconds since epoch. +unixSecondsToTimestamp(Field.of("seconds")); + +``` + +Signature: + +```typescript +export declare function unixSecondsToTimestamp(expr: Constant): UnixSecondsToTimestamp; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the number of seconds since epoch. A new representing the timestamp. | + +Returns: + +[UnixSecondsToTimestamp](./firestore_.unixsecondstotimestamp.md#unixsecondstotimestamp_class) + +### vectorLength(expr) {:#vectorlength_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of a Firestore Vector. + +```typescript +// Get the vector length (dimension) of the field 'embedding'. +vectorLength(Field.of("embedding")); + +``` + +Signature: + +```typescript +export declare function vectorLength(expr: Constant): VectorLength; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the Firestore Vector. A new representing the length of the array. | + +Returns: + +[VectorLength](./firestore_.vectorlength.md#vectorlength_class) + +## function(field, ...) + +### average(field) {:#average_aacc3a9} + +Create an AggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query. + +Signature: + +```typescript +export declare function average(field: string | FieldPath): AggregateField; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | Specifies the field to average across the result set. | + +Returns: + +[AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<number \| null> + +### byteLength(field) {:#bytelength_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of a string represented by a field in UTF-8 bytes, or just the length of a Blob. + +```typescript +// Calculate the length of the 'myString' field in bytes. +byteLength("myString"); + +``` + +Signature: + +```typescript +export declare function byteLength(field: string): ByteLength; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the string. A new representing the length of the string in bytes. | + +Returns: + +[ByteLength](./firestore_.bytelength.md#bytelength_class) + +### charLength(field) {:#charlength_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the character length of a string field in UTF8. + +```typescript +// Get the character length of the 'name' field in UTF-8. +strLength("name"); + +``` + +Signature: + +```typescript +export declare function charLength(field: string): CharLength; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field containing the string. A new representing the length of the string. | + +Returns: + +[CharLength](./firestore_.charlength.md#charlength_class) + +### exists(field) {:#exists_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field exists. + +```typescript +// Check if the document has a field named "phoneNumber" +exists("phoneNumber"); + +``` + +Signature: + +```typescript +export declare function exists(field: string): Exists; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The field name to check. A new representing the 'exists' check. | + +Returns: + +[Exists](./firestore_.exists.md#exists_class) + +### replaceAll(field, find, replace) {:#replaceall_b257ab0} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within a string represented by a field with another substring. + +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field. +replaceAll("message", "hello", "hi"); + +``` + +Signature: + +```typescript +export declare function replaceAll(field: string, find: string, replace: string): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the string to perform the replacement on. | +| find | string | The substring to search for. | +| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_.replaceall.md#replaceall_class) + +### replaceFirst(field, find, replace) {:#replacefirst_b257ab0} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within a string represented by a field with another substring. + +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field. +replaceFirst("message", "hello", "hi"); + +``` + +Signature: + +```typescript +export declare function replaceFirst(field: string, find: string, replace: string): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the string to perform the replacement on. | +| find | string | The substring to search for. | +| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) + +### reverse(field) {:#reverse_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that reverses a string represented by a field. + +```typescript +// Reverse the value of the 'myString' field. +reverse("myString"); + +``` + +Signature: + +```typescript +export declare function reverse(field: string): Reverse; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the string to reverse. A new representing the reversed string. | + +Returns: + +[Reverse](./firestore_.reverse.md#reverse_class) + +### sum(field) {:#sum_aacc3a9} + +Create an AggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query. + +Signature: + +```typescript +export declare function sum(field: string | FieldPath): AggregateField; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | Specifies the field to sum across the result set. | + +Returns: + +[AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<number> + +### timestampAdd(field, unit, amount) {:#timestampadd_565792c} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to a timestamp represented by a field. + +```typescript +// Add 1 day to the 'timestamp' field. +timestampAdd("timestamp", "day", 1); + +``` + +Signature: + +```typescript +export declare function timestampAdd(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the timestamp. | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | +| amount | number | The amount of time to add. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) + +### timestampSub(field, unit, amount) {:#timestampsub_565792c} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from a timestamp represented by a field. + +```typescript +// Subtract 1 day from the 'timestamp' field. +timestampSub("timestamp", "day", 1); + +``` + +Signature: + +```typescript +export declare function timestampSub(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the timestamp. | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | +| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) + +### timestampToUnixMicros(field) {:#timestamptounixmicros_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a timestamp field to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +timestampToUnixMicros("timestamp"); + +``` + +Signature: + +```typescript +export declare function timestampToUnixMicros(field: string): TimestampToUnixMicros; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the timestamp. A new representing the number of microseconds since epoch. | + +Returns: + +[TimestampToUnixMicros](./firestore_.timestamptounixmicros.md#timestamptounixmicros_class) + +### timestampToUnixMillis(field) {:#timestamptounixmillis_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a timestamp field to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +timestampToUnixMillis("timestamp"); + +``` + +Signature: + +```typescript +export declare function timestampToUnixMillis(field: string): TimestampToUnixMillis; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the timestamp. A new representing the number of milliseconds since epoch. | + +Returns: + +[TimestampToUnixMillis](./firestore_.timestamptounixmillis.md#timestamptounixmillis_class) + +### timestampToUnixSeconds(field) {:#timestamptounixseconds_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a timestamp field to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to seconds since epoch. +timestampToUnixSeconds("timestamp"); + +``` + +Signature: + +```typescript +export declare function timestampToUnixSeconds(field: string): TimestampToUnixSeconds; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the timestamp. A new representing the number of seconds since epoch. | + +Returns: + +[TimestampToUnixSeconds](./firestore_.timestamptounixseconds.md#timestamptounixseconds_class) + +### unixMicrosToTimestamp(field) {:#unixmicrostotimestamp_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets a field's value as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +unixMicrosToTimestamp("microseconds"); + +``` + +Signature: + +```typescript +export declare function unixMicrosToTimestamp(field: string): UnixMicrosToTimestamp; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the number of microseconds since epoch. A new representing the timestamp. | + +Returns: + +[UnixMicrosToTimestamp](./firestore_.unixmicrostotimestamp.md#unixmicrostotimestamp_class) + +### unixMillisToTimestamp(field) {:#unixmillistotimestamp_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets a field's value as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +unixMillisToTimestamp("milliseconds"); + +``` + +Signature: + +```typescript +export declare function unixMillisToTimestamp(field: string): UnixMillisToTimestamp; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the number of milliseconds since epoch. A new representing the timestamp. | + +Returns: + +[UnixMillisToTimestamp](./firestore_.unixmillistotimestamp.md#unixmillistotimestamp_class) + +### unixSecondsToTimestamp(field) {:#unixsecondstotimestamp_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets a field's value as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'seconds' field as seconds since epoch. +unixSecondsToTimestamp("seconds"); + +``` + +Signature: + +```typescript +export declare function unixSecondsToTimestamp(field: string): UnixSecondsToTimestamp; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the number of seconds since epoch. A new representing the timestamp. | + +Returns: + +[UnixSecondsToTimestamp](./firestore_.unixsecondstotimestamp.md#unixsecondstotimestamp_class) + +### vectorLength(field) {:#vectorlength_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of a Firestore Vector represented by a field. + +```typescript +// Get the vector length (dimension) of the field 'embedding'. +vectorLength("embedding"); + +``` + +Signature: + +```typescript +export declare function vectorLength(field: string): VectorLength; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the Firestore Vector. A new representing the length of the array. | + +Returns: + +[VectorLength](./firestore_.vectorlength.md#vectorlength_class) + +## function(fieldPath, ...) + +### orderBy(fieldPath, directionStr) {:#orderby_006d61f} + +Creates a [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) that sorts the query result by the specified field, optionally in descending order instead of ascending. + +Note: Documents that do not contain the specified field will not be present in the query result. + +Signature: + +```typescript +export declare function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryOrderByConstraint; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| fieldPath | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | The field to sort by. | +| directionStr | [OrderByDirection](./firestore_.md#orderbydirection) | Optional direction to sort by ('asc' or 'desc'). If not specified, order will be ascending. | + +Returns: + +[QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) + +The created [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class). + +### where(fieldPath, opStr, value) {:#where_0fae4bf} + +Creates a [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) that enforces that documents must contain the specified field and that the value should satisfy the relation constraint provided. + +Signature: + +```typescript +export declare function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryFieldFilterConstraint; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| fieldPath | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | The path to compare | +| opStr | [WhereFilterOp](./firestore_.md#wherefilterop) | The operation string (e.g "&lt;", "&lt;=", "==", "&lt;", "&lt;=", "!="). | +| value | unknown | The value for comparison | + +Returns: + +[QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) + +The created [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class). + +## function(fieldValues, ...) + +### endAt(fieldValues) {:#endat_8b2f2c8} + +Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. + +Signature: + +```typescript +export declare function endAt(...fieldValues: unknown[]): QueryEndAtConstraint; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| fieldValues | unknown\[\] | The field values to end this query at, in order of the query's order by. | + +Returns: + +[QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) + +A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` + +### endBefore(fieldValues) {:#endbefore_8b2f2c8} + +Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. + +Signature: + +```typescript +export declare function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| fieldValues | unknown\[\] | The field values to end this query before, in order of the query's order by. | + +Returns: + +[QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) + +A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` + +### startAfter(fieldValues) {:#startafter_8b2f2c8} + +Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. + +Signature: + +```typescript +export declare function startAfter(...fieldValues: unknown[]): QueryStartAtConstraint; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| fieldValues | unknown\[\] | The field values to start this query after, in order of the query's order by. | + +Returns: + +[QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) + +A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()` + +### startAt(fieldValues) {:#startat_8b2f2c8} + +Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. + +Signature: + +```typescript +export declare function startAt(...fieldValues: unknown[]): QueryStartAtConstraint; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| fieldValues | unknown\[\] | The field values to start this query at, in order of the query's order by. | + +Returns: + +[QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) + +A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()`. + +## function(filter, ...) + +### not(filter) {:#not_5520849} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that negates a filter condition. + +```typescript +// Find documents where the 'completed' field is NOT true +not(eq("completed", true)); + +``` + +Signature: + +```typescript +export declare function not(filter: FilterExpr): Not; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| filter | [FilterExpr](./firestore_.md#filterexpr) | The filter condition to negate. A new representing the negated filter condition. | + +Returns: + +[Not](./firestore_.not.md#not_class) + +## function(first, ...) + +### strConcat(first, elements) {:#strconcat_0f1bdbf} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates string functions, fields or constants together. + +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +strConcat("firstName", " ", Field.of("lastName")); + +``` + +Signature: + +```typescript +export declare function strConcat(first: string, ...elements: Array): StrConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| first | string | The field name containing the initial string value. | +| elements | Array<[Constant](./firestore_.constant.md#constant_class) \| string> | The expressions (typically strings) to concatenate. A new representing the concatenated string. | + +Returns: + +[StrConcat](./firestore_.strconcat.md#strconcat_class) + +### strConcat(first, elements) {:#strconcat_1eb0ac1} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates string expressions together. + +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +strConcat(Field.of("firstName"), " ", Field.of("lastName")); + +``` + +Signature: + +```typescript +export declare function strConcat(first: Constant, ...elements: Array): StrConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| first | [Constant](./firestore_.constant.md#constant_class) | The initial string expression to concatenate to. | +| elements | Array<[Constant](./firestore_.constant.md#constant_class) \| string> | The expressions (typically strings) to concatenate. A new representing the concatenated string. | + +Returns: + +[StrConcat](./firestore_.strconcat.md#strconcat_class) + +## function(indexManager, ...) + +### deleteAllPersistentCacheIndexes(indexManager) {:#deleteallpersistentcacheindexes_98b2645} + +Removes all persistent cache indexes. + +Please note this function will also deletes indexes generated by `setIndexConfiguration()`, which is deprecated. + +Signature: + +```typescript +export declare function deleteAllPersistentCacheIndexes(indexManager: PersistentCacheIndexManager): void; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| indexManager | [PersistentCacheIndexManager](./firestore_.persistentcacheindexmanager.md#persistentcacheindexmanager_class) | | + +Returns: + +void + +### disablePersistentCacheIndexAutoCreation(indexManager) {:#disablepersistentcacheindexautocreation_98b2645} + +Stops creating persistent cache indexes automatically for local query execution. The indexes which have been created by calling `enablePersistentCacheIndexAutoCreation()` still take effect. + +Signature: + +```typescript +export declare function disablePersistentCacheIndexAutoCreation(indexManager: PersistentCacheIndexManager): void; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| indexManager | [PersistentCacheIndexManager](./firestore_.persistentcacheindexmanager.md#persistentcacheindexmanager_class) | | + +Returns: + +void + +### enablePersistentCacheIndexAutoCreation(indexManager) {:#enablepersistentcacheindexautocreation_98b2645} + +Enables the SDK to create persistent cache indexes automatically for local query execution when the SDK believes cache indexes can help improve performance. + +This feature is disabled by default. + +Signature: + +```typescript +export declare function enablePersistentCacheIndexAutoCreation(indexManager: PersistentCacheIndexManager): void; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| indexManager | [PersistentCacheIndexManager](./firestore_.persistentcacheindexmanager.md#persistentcacheindexmanager_class) | | + +Returns: + +void + +## function(left, ...) + +### add(left, right) {:#add_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds two expressions together. + +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +add(Field.of("quantity"), Field.of("reserve")); + +``` + +Signature: + +```typescript +export declare function add(left: Constant, right: Constant): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The first expression to add. | +| right | [Constant](./firestore_.constant.md#constant_class) | The second expression to add. A new representing the addition operation. | + +Returns: + +[Add](./firestore_.add.md#add_class) + +### add(left, right) {:#add_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds an expression to a constant value. + +```typescript +// Add 5 to the value of the 'age' field +add(Field.of("age"), 5); + +``` + +Signature: + +```typescript +export declare function add(left: Constant, right: any): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The expression to add to. | +| right | any | The constant value to add. A new representing the addition operation. | + +Returns: + +[Add](./firestore_.add.md#add_class) + +### add(left, right) {:#add_674c63f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a field's value to an expression. + +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +add("quantity", Field.of("reserve")); + +``` + +Signature: + +```typescript +export declare function add(left: string, right: Constant): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to add to. | +| right | [Constant](./firestore_.constant.md#constant_class) | The expression to add. A new representing the addition operation. | + +Returns: + +[Add](./firestore_.add.md#add_class) + +### add(left, right) {:#add_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a field's value to a constant value. + +```typescript +// Add 5 to the value of the 'age' field +add("age", 5); + +``` + +Signature: + +```typescript +export declare function add(left: string, right: any): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to add to. | +| right | any | The constant value to add. A new representing the addition operation. | + +Returns: + +[Add](./firestore_.add.md#add_class) + +### aggregateFieldEqual(left, right) {:#aggregatefieldequal_e80a2b2} + +Compares two 'AggregateField\` instances for equality. + +Signature: + +```typescript +export declare function aggregateFieldEqual(left: AggregateField, right: AggregateField): boolean; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<unknown> | Compare this AggregateField to the right. | +| right | [AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<unknown> | Compare this AggregateField to the left. | + +Returns: + +boolean + +### aggregateQuerySnapshotEqual(left, right) {:#aggregatequerysnapshotequal_1529a20} + +Compares two `AggregateQuerySnapshot` instances for equality. + +Two `AggregateQuerySnapshot` instances are considered "equal" if they have underlying queries that compare equal, and the same data. + +Signature: + +```typescript +export declare function aggregateQuerySnapshotEqual(left: AggregateQuerySnapshot, right: AggregateQuerySnapshot): boolean; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [AggregateQuerySnapshot](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType> | The first AggregateQuerySnapshot to compare. | +| right | [AggregateQuerySnapshot](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType> | The second AggregateQuerySnapshot to compare. | + +Returns: + +boolean + +`true` if the objects are "equal", as defined above, or `false` otherwise. + +### and(left, right) {:#and_eba7e36} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that performs a logical 'AND' operation on multiple filter conditions. + +```typescript +// Check if the 'age' field is greater than 18 AND the 'city' field is "London" AND +// the 'status' field is "active" +const condition = and(gt("age", 18), eq("city", "London"), eq("status", "active")); + +``` + +Signature: + +```typescript +export declare function and(left: FilterExpr, ...right: FilterExpr[]): And; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [FilterExpr](./firestore_.md#filterexpr) | The first filter condition. | +| right | [FilterExpr](./firestore_.md#filterexpr)\[\] | Additional filter conditions to 'AND' together. A new representing the logical 'AND' operation. | + +Returns: + +[And](./firestore_.and.md#and_class) + +### divide(left, right) {:#divide_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides two expressions. + +```typescript +// Divide the 'total' field by the 'count' field +divide(Field.of("total"), Field.of("count")); + +``` + +Signature: + +```typescript +export declare function divide(left: Constant, right: Constant): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The expression to be divided. | +| right | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new representing the division operation. | + +Returns: + +[Divide](./firestore_.divide.md#divide_class) + +### divide(left, right) {:#divide_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides an expression by a constant value. + +```typescript +// Divide the 'value' field by 10 +divide(Field.of("value"), 10); + +``` + +Signature: + +```typescript +export declare function divide(left: Constant, right: any): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The expression to be divided. | +| right | any | The constant value to divide by. A new representing the division operation. | + +Returns: + +[Divide](./firestore_.divide.md#divide_class) + +### divide(left, right) {:#divide_674c63f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides a field's value by an expression. + +```typescript +// Divide the 'total' field by the 'count' field +divide("total", Field.of("count")); + +``` + +Signature: + +```typescript +export declare function divide(left: string, right: Constant): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to be divided. | +| right | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new representing the division operation. | + +Returns: + +[Divide](./firestore_.divide.md#divide_class) + +### divide(left, right) {:#divide_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides a field's value by a constant value. + +```typescript +// Divide the 'value' field by 10 +divide("value", 10); + +``` + +Signature: + +```typescript +export declare function divide(left: string, right: any): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to be divided. | +| right | any | The constant value to divide by. A new representing the division operation. | + +Returns: + +[Divide](./firestore_.divide.md#divide_class) + +### eq(left, right) {:#eq_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if two expressions are equal. + +```typescript +// Check if the 'age' field is equal to an expression +eq(Field.of("age"), Field.of("minAge").add(10)); + +``` + +Signature: + +```typescript +export declare function eq(left: Constant, right: Constant): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The first expression to compare. | +| right | [Constant](./firestore_.constant.md#constant_class) | The second expression to compare. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_.eq.md#eq_class) + +### eq(left, right) {:#eq_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an expression is equal to a constant value. + +```typescript +// Check if the 'age' field is equal to 21 +eq(Field.of("age"), 21); + +``` + +Signature: + +```typescript +export declare function eq(left: Constant, right: any): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The expression to compare. | +| right | any | The constant value to compare to. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_.eq.md#eq_class) + +### eq(left, right) {:#eq_674c63f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is equal to an expression. + +```typescript +// Check if the 'age' field is equal to the 'limit' field +eq("age", Field.of("limit")); + +``` + +Signature: + +```typescript +export declare function eq(left: string, right: Constant): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | [Constant](./firestore_.constant.md#constant_class) | The expression to compare to. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_.eq.md#eq_class) + +### eq(left, right) {:#eq_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is equal to a constant value. + +```typescript +// Check if the 'city' field is equal to string constant "London" +eq("city", "London"); + +``` + +Signature: + +```typescript +export declare function eq(left: string, right: any): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | any | The constant value to compare to. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_.eq.md#eq_class) + +### gt(left, right) {:#gt_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if the first expression is greater than the second expression. + +```typescript +// Check if the 'age' field is greater than 18 +gt(Field.of("age"), Constant(9).add(9)); + +``` + +Signature: + +```typescript +export declare function gt(left: Constant, right: Constant): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The first expression to compare. | +| right | [Constant](./firestore_.constant.md#constant_class) | The second expression to compare. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_.gt.md#gt_class) + +### gt(left, right) {:#gt_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an expression is greater than a constant value. + +```typescript +// Check if the 'age' field is greater than 18 +gt(Field.of("age"), 18); + +``` + +Signature: + +```typescript +export declare function gt(left: Constant, right: any): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The expression to compare. | +| right | any | The constant value to compare to. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_.gt.md#gt_class) + +### gt(left, right) {:#gt_674c63f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is greater than an expression. + +```typescript +// Check if the value of field 'age' is greater than the value of field 'limit' +gt("age", Field.of("limit")); + +``` + +Signature: + +```typescript +export declare function gt(left: string, right: Constant): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | [Constant](./firestore_.constant.md#constant_class) | The expression to compare to. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_.gt.md#gt_class) + +### gt(left, right) {:#gt_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is greater than a constant value. + +```typescript +// Check if the 'price' field is greater than 100 +gt("price", 100); + +``` + +Signature: + +```typescript +export declare function gt(left: string, right: any): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | any | The constant value to compare to. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_.gt.md#gt_class) + +### gte(left, right) {:#gte_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if the first expression is greater than or equal to the second expression. + +```typescript +// Check if the 'quantity' field is greater than or equal to the field "threshold" +gte(Field.of("quantity"), Field.of("threshold")); + +``` + +Signature: + +```typescript +export declare function gte(left: Constant, right: Constant): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The first expression to compare. | +| right | [Constant](./firestore_.constant.md#constant_class) | The second expression to compare. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_.gte.md#gte_class) + +### gte(left, right) {:#gte_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an expression is greater than or equal to a constant value. + +```typescript +// Check if the 'quantity' field is greater than or equal to 10 +gte(Field.of("quantity"), 10); + +``` + +Signature: + +```typescript +export declare function gte(left: Constant, right: any): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The expression to compare. | +| right | any | The constant value to compare to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_.gte.md#gte_class) + +### gte(left, right) {:#gte_674c63f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is greater than or equal to an expression. + +```typescript +// Check if the value of field 'age' is greater than or equal to the value of field 'limit' +gte("age", Field.of("limit")); + +``` + +Signature: + +```typescript +export declare function gte(left: string, right: Constant): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | [Constant](./firestore_.constant.md#constant_class) | The expression to compare to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_.gte.md#gte_class) + +### gte(left, right) {:#gte_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is greater than or equal to a constant value. + +```typescript +// Check if the 'score' field is greater than or equal to 80 +gte("score", 80); + +``` + +Signature: + +```typescript +export declare function gte(left: string, right: any): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | any | The constant value to compare to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_.gte.md#gte_class) + +### like(left, pattern) {:#like_33ec01b} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that performs a case-sensitive wildcard string comparison against a field. + +```typescript +// Check if the 'title' field contains the string "guide" +like("title", "%guide%"); + +``` + +Signature: + +```typescript +export declare function like(left: string, pattern: string): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The name of the field containing the string. | +| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new representing the 'like' comparison. | + +Returns: + +[Like](./firestore_.like.md#like_class) + +### like(left, pattern) {:#like_dd84184} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that performs a case-sensitive wildcard string comparison against a field. + +```typescript +// Check if the 'title' field contains the string "guide" +like("title", Field.of("pattern")); + +``` + +Signature: + +```typescript +export declare function like(left: string, pattern: Constant): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The name of the field containing the string. | +| pattern | [Constant](./firestore_.constant.md#constant_class) | The pattern to search for. You can use "%" as a wildcard character. A new representing the 'like' comparison. | + +Returns: + +[Like](./firestore_.like.md#like_class) + +### like(left, pattern) {:#like_3aaffe0} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that performs a case-sensitive wildcard string comparison. + +```typescript +// Check if the 'title' field contains the string "guide" +like(Field.of("title"), "%guide%"); + +``` + +Signature: + +```typescript +export declare function like(left: Constant, pattern: string): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to perform the comparison on. | +| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new representing the 'like' comparison. | + +Returns: + +[Like](./firestore_.like.md#like_class) + +### like(left, pattern) {:#like_a2c3e8b} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that performs a case-sensitive wildcard string comparison. + +```typescript +// Check if the 'title' field contains the string "guide" +like(Field.of("title"), Field.of("pattern")); + +``` + +Signature: + +```typescript +export declare function like(left: Constant, pattern: Constant): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to perform the comparison on. | +| pattern | [Constant](./firestore_.constant.md#constant_class) | The pattern to search for. You can use "%" as a wildcard character. A new representing the 'like' comparison. | + +Returns: + +[Like](./firestore_.like.md#like_class) + +### logicalMax(left, right) {:#logicalmax_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between two expressions, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'field1' field and the 'field2' field. +logicalMax(Field.of("field1"), Field.of("field2")); + +``` + +Signature: + +```typescript +export declare function logicalMax(left: Constant, right: Constant): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The left operand expression. | +| right | [Constant](./firestore_.constant.md#constant_class) | The right operand expression. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) + +### logicalMax(left, right) {:#logicalmax_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between an expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'value' field and 10. +logicalMax(Field.of("value"), 10); + +``` + +Signature: + +```typescript +export declare function logicalMax(left: Constant, right: any): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The left operand expression. | +| right | any | The right operand constant. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) + +### logicalMax(left, right) {:#logicalmax_674c63f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between a field and an expression, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'field1' field and the 'field2' field. +logicalMax("field1", Field.of('field2')); + +``` + +Signature: + +```typescript +export declare function logicalMax(left: string, right: Constant): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The left operand field name. | +| right | [Constant](./firestore_.constant.md#constant_class) | The right operand expression. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) + +### logicalMax(left, right) {:#logicalmax_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between a field and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'value' field and 10. +logicalMax("value", 10); + +``` + +Signature: + +```typescript +export declare function logicalMax(left: string, right: any): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The left operand field name. | +| right | any | The right operand constant. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) + +### logicalMin(left, right) {:#logicalmin_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between two expressions, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'field1' field and the 'field2' field. +logicalMin(Field.of("field1"), Field.of("field2")); + +``` + +Signature: + +```typescript +export declare function logicalMin(left: Constant, right: Constant): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The left operand expression. | +| right | [Constant](./firestore_.constant.md#constant_class) | The right operand expression. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) + +### logicalMin(left, right) {:#logicalmin_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between an expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'value' field and 10. +logicalMin(Field.of("value"), 10); + +``` + +Signature: + +```typescript +export declare function logicalMin(left: Constant, right: any): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The left operand expression. | +| right | any | The right operand constant. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) + +### logicalMin(left, right) {:#logicalmin_674c63f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between a field and an expression, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'field1' field and the 'field2' field. +logicalMin("field1", Field.of("field2")); + +``` + +Signature: + +```typescript +export declare function logicalMin(left: string, right: Constant): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The left operand field name. | +| right | [Constant](./firestore_.constant.md#constant_class) | The right operand expression. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) + +### logicalMin(left, right) {:#logicalmin_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between a field and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'value' field and 10. +logicalMin("value", 10); + +``` + +Signature: + +```typescript +export declare function logicalMin(left: string, right: any): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The left operand field name. | +| right | any | The right operand constant. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) + +### lt(left, right) {:#lt_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if the first expression is less than the second expression. + +```typescript +// Check if the 'age' field is less than 30 +lt(Field.of("age"), Field.of("limit")); + +``` + +Signature: + +```typescript +export declare function lt(left: Constant, right: Constant): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The first expression to compare. | +| right | [Constant](./firestore_.constant.md#constant_class) | The second expression to compare. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_.lt.md#lt_class) + +### lt(left, right) {:#lt_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an expression is less than a constant value. + +```typescript +// Check if the 'age' field is less than 30 +lt(Field.of("age"), 30); + +``` + +Signature: + +```typescript +export declare function lt(left: Constant, right: any): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The expression to compare. | +| right | any | The constant value to compare to. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_.lt.md#lt_class) + +### lt(left, right) {:#lt_674c63f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is less than an expression. + +```typescript +// Check if the 'age' field is less than the 'limit' field +lt("age", Field.of("limit")); + +``` + +Signature: + +```typescript +export declare function lt(left: string, right: Constant): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | [Constant](./firestore_.constant.md#constant_class) | The expression to compare to. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_.lt.md#lt_class) + +### lt(left, right) {:#lt_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is less than a constant value. + +```typescript +// Check if the 'price' field is less than 50 +lt("price", 50); + +``` + +Signature: + +```typescript +export declare function lt(left: string, right: any): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | any | The constant value to compare to. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_.lt.md#lt_class) + +### lte(left, right) {:#lte_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if the first expression is less than or equal to the second expression. + +```typescript +// Check if the 'quantity' field is less than or equal to 20 +lte(Field.of("quantity"), Field.of("limit")); + +``` + +Signature: + +```typescript +export declare function lte(left: Constant, right: Constant): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The first expression to compare. | +| right | [Constant](./firestore_.constant.md#constant_class) | The second expression to compare. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_.lte.md#lte_class) + +### lte(left, right) {:#lte_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an expression is less than or equal to a constant value. + +```typescript +// Check if the 'quantity' field is less than or equal to 20 +lte(Field.of("quantity"), 20); + +``` + +Signature: + +```typescript +export declare function lte(left: Constant, right: any): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The expression to compare. | +| right | any | The constant value to compare to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_.lte.md#lte_class) + +### lte(left, right) {:#lte_674c63f} + +Creates an expression that checks if a field's value is less than or equal to an expression. + +```typescript +// Check if the 'quantity' field is less than or equal to the 'limit' field +lte("quantity", Field.of("limit")); + +``` + +Signature: + +```typescript +export declare function lte(left: string, right: Constant): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | [Constant](./firestore_.constant.md#constant_class) | The expression to compare to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_.lte.md#lte_class) + +### lte(left, right) {:#lte_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is less than or equal to a constant value. + +```typescript +// Check if the 'score' field is less than or equal to 70 +lte("score", 70); + +``` + +Signature: + +```typescript +export declare function lte(left: string, right: any): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | any | The constant value to compare to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_.lte.md#lte_class) + +### mod(left, right) {:#mod_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing two expressions. + +```typescript +// Calculate the remainder of dividing 'field1' by 'field2'. +mod(Field.of("field1"), Field.of("field2")); + +``` + +Signature: + +```typescript +export declare function mod(left: Constant, right: Constant): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The dividend expression. | +| right | [Constant](./firestore_.constant.md#constant_class) | The divisor expression. A new representing the modulo operation. | + +Returns: + +[Mod](./firestore_.mod.md#mod_class) + +### mod(left, right) {:#mod_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing an expression by a constant. + +```typescript +// Calculate the remainder of dividing 'field1' by 5. +mod(Field.of("field1"), 5); + +``` + +Signature: + +```typescript +export declare function mod(left: Constant, right: any): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The dividend expression. | +| right | any | The divisor constant. A new representing the modulo operation. | + +Returns: + +[Mod](./firestore_.mod.md#mod_class) + +### mod(left, right) {:#mod_674c63f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing a field's value by an expression. + +```typescript +// Calculate the remainder of dividing 'field1' by 'field2'. +mod("field1", Field.of("field2")); + +``` + +Signature: + +```typescript +export declare function mod(left: string, right: Constant): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The dividend field name. | +| right | [Constant](./firestore_.constant.md#constant_class) | The divisor expression. A new representing the modulo operation. | + +Returns: + +[Mod](./firestore_.mod.md#mod_class) + +### mod(left, right) {:#mod_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing a field's value by a constant. + +```typescript +// Calculate the remainder of dividing 'field1' by 5. +mod("field1", 5); + +``` + +Signature: + +```typescript +export declare function mod(left: string, right: any): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The dividend field name. | +| right | any | The divisor constant. A new representing the modulo operation. | + +Returns: + +[Mod](./firestore_.mod.md#mod_class) + +### multiply(left, right) {:#multiply_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies two expressions together. + +```typescript +// Multiply the 'quantity' field by the 'price' field +multiply(Field.of("quantity"), Field.of("price")); + +``` + +Signature: + +```typescript +export declare function multiply(left: Constant, right: Constant): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The first expression to multiply. | +| right | [Constant](./firestore_.constant.md#constant_class) | The second expression to multiply. A new representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_.multiply.md#multiply_class) + +### multiply(left, right) {:#multiply_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies an expression by a constant value. + +```typescript +// Multiply the value of the 'price' field by 2 +multiply(Field.of("price"), 2); + +``` + +Signature: + +```typescript +export declare function multiply(left: Constant, right: any): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The expression to multiply. | +| right | any | The constant value to multiply by. A new representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_.multiply.md#multiply_class) + +### multiply(left, right) {:#multiply_674c63f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies a field's value by an expression. + +```typescript +// Multiply the 'quantity' field by the 'price' field +multiply("quantity", Field.of("price")); + +``` + +Signature: + +```typescript +export declare function multiply(left: string, right: Constant): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to multiply. | +| right | [Constant](./firestore_.constant.md#constant_class) | The expression to multiply by. A new representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_.multiply.md#multiply_class) + +### multiply(left, right) {:#multiply_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies a field's value by a constant value. + +```typescript +// Multiply the 'value' field by 2 +multiply("value", 2); + +``` + +Signature: + +```typescript +export declare function multiply(left: string, right: any): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to multiply. | +| right | any | The constant value to multiply by. A new representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_.multiply.md#multiply_class) + +### neq(left, right) {:#neq_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if two expressions are not equal. + +```typescript +// Check if the 'status' field is not equal to field 'finalState' +neq(Field.of("status"), Field.of("finalState")); + +``` + +Signature: + +```typescript +export declare function neq(left: Constant, right: Constant): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The first expression to compare. | +| right | [Constant](./firestore_.constant.md#constant_class) | The second expression to compare. A new Expr representing the inequality comparison. | + +Returns: -### getFirestore(app) {:#getfirestore_cf608e1} +[Neq](./firestore_.neq.md#neq_class) -Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. +### neq(left, right) {:#neq_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an expression is not equal to a constant value. + +```typescript +// Check if the 'status' field is not equal to "completed" +neq(Field.of("status"), "completed"); + +``` Signature: ```typescript -export declare function getFirestore(app: FirebaseApp): Firestore; +export declare function neq(left: Constant, right: any): Neq; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) instance that the returned [Firestore](./firestore_.firestore.md#firestore_class) instance is associated with. | +| left | [Constant](./firestore_.constant.md#constant_class) | The expression to compare. | +| right | any | The constant value to compare to. A new Expr representing the inequality comparison. | Returns: -[Firestore](./firestore_.firestore.md#firestore_class) - -The default [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. +[Neq](./firestore_.neq.md#neq_class) -### getFirestore(app, databaseId) {:#getfirestore_48de6cb} +### neq(left, right) {:#neq_674c63f} > This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. > -Returns the existing named [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. +Creates an expression that checks if a field's value is not equal to an expression. + +```typescript +// Check if the 'status' field is not equal to the value of 'expectedStatus' +neq("status", Field.of("expectedStatus")); + +``` Signature: ```typescript -export declare function getFirestore(app: FirebaseApp, databaseId: string): Firestore; +export declare function neq(left: string, right: Constant): Neq; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) instance that the returned [Firestore](./firestore_.firestore.md#firestore_class) instance is associated with. | -| databaseId | string | The name of the database. | +| left | string | The field name to compare. | +| right | [Constant](./firestore_.constant.md#constant_class) | The expression to compare to. A new Expr representing the inequality comparison. | Returns: -[Firestore](./firestore_.firestore.md#firestore_class) +[Neq](./firestore_.neq.md#neq_class) -The named [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. +### neq(left, right) {:#neq_1f46a76} -### initializeFirestore(app, settings, databaseId) {:#initializefirestore_fc7d200} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Initializes a new instance of [Firestore](./firestore_.firestore.md#firestore_class) with the provided settings. Can only be called before any other function, including [getFirestore()](./firestore_.md#getfirestore). If the custom settings are empty, this function is equivalent to calling [getFirestore()](./firestore_.md#getfirestore). +Creates an expression that checks if a field's value is not equal to a constant value. + +```typescript +// Check if the 'country' field is not equal to "USA" +neq("country", "USA"); + +``` Signature: ```typescript -export declare function initializeFirestore(app: FirebaseApp, settings: FirestoreSettings, databaseId?: string): Firestore; +export declare function neq(left: string, right: any): Neq; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) with which the [Firestore](./firestore_.firestore.md#firestore_class) instance will be associated. | -| settings | [FirestoreSettings](./firestore_.firestoresettings.md#firestoresettings_interface) | A settings object to configure the [Firestore](./firestore_.firestore.md#firestore_class) instance. | -| databaseId | string | The name of the database. | +| left | string | The field name to compare. | +| right | any | The constant value to compare to. A new Expr representing the inequality comparison. | Returns: -[Firestore](./firestore_.firestore.md#firestore_class) +[Neq](./firestore_.neq.md#neq_class) -A newly initialized [Firestore](./firestore_.firestore.md#firestore_class) instance. +### or(left, right) {:#or_eba7e36} -## function(firestore, ...) +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -### clearIndexedDbPersistence(firestore) {:#clearindexeddbpersistence_231a8e0} +Creates an expression that performs a logical 'OR' operation on multiple filter conditions. -Clears the persistent storage. This includes pending writes and cached documents. +```typescript +// Check if the 'age' field is greater than 18 OR the 'city' field is "London" OR +// the 'status' field is "active" +const condition = or(gt("age", 18), eq("city", "London"), eq("status", "active")); -Must be called while the [Firestore](./firestore_.firestore.md#firestore_class) instance is not started (after the app is terminated or when the app is first initialized). On startup, this function must be called before other functions (other than [initializeFirestore()](./firestore_.md#initializefirestore_fc7d200) or [getFirestore()](./firestore_.md#getfirestore))). If the [Firestore](./firestore_.firestore.md#firestore_class) instance is still running, the promise will be rejected with the error code of `failed-precondition`. +``` -Note: `clearIndexedDbPersistence()` is primarily intended to help write reliable tests that use Cloud Firestore. It uses an efficient mechanism for dropping existing data but does not attempt to securely overwrite or otherwise make cached data unrecoverable. For applications that are sensitive to the disclosure of cached data in between user sessions, we strongly recommend not enabling persistence at all. +Signature: + +```typescript +export declare function or(left: FilterExpr, ...right: FilterExpr[]): Or; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [FilterExpr](./firestore_.md#filterexpr) | The first filter condition. | +| right | [FilterExpr](./firestore_.md#filterexpr)\[\] | Additional filter conditions to 'OR' together. A new representing the logical 'OR' operation. | + +Returns: + +[Or](./firestore_.or.md#or_class) + +### queryEqual(left, right) {:#queryequal_7a1f045} + +Returns true if the provided queries point to the same collection and apply the same constraints. Signature: ```typescript -export declare function clearIndexedDbPersistence(firestore: Firestore): Promise; +export declare function queryEqual(left: Query, right: Query): boolean; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to clear persistence for. | +| left | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | A Query to compare. | +| right | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | A Query to compare. | Returns: -Promise<void> +boolean -A `Promise` that is resolved when the persistent storage is cleared. Otherwise, the promise is rejected with an error. +true if the references point to the same location in the same Firestore database. -### collection(firestore, path, pathSegments) {:#collection_1eb4c23} +### refEqual(left, right) {:#refequal_598b780} -Gets a `CollectionReference` instance that refers to the collection at the specified absolute path. +Returns true if the provided references are equal. Signature: ```typescript -export declare function collection(firestore: Firestore, path: string, ...pathSegments: string[]): CollectionReference; +export declare function refEqual(left: DocumentReference | CollectionReference, right: DocumentReference | CollectionReference): boolean; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | A reference to the root Firestore instance. | -| path | string | A slash-separated path to a collection. | -| pathSegments | string\[\] | Additional path segments to apply relative to the first argument. | +| left | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> \| [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to compare. | +| right | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> \| [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to compare. | Returns: -[CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> +boolean -The `CollectionReference` instance. +true if the references point to the same location in the same Firestore database. -#### Exceptions +### regexContains(left, pattern) {:#regexcontains_33ec01b} -If the final path has an even number of segments and does not point to a collection. +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -### collectionGroup(firestore, collectionId) {:#collectiongroup_1838fc3} +Creates an expression that checks if a string field contains a specified regular expression as a substring. -Creates and returns a new `Query` instance that includes all documents in the database that are contained in a collection or subcollection with the given `collectionId`. +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +regexContains("description", "(?i)example"); + +``` Signature: ```typescript -export declare function collectionGroup(firestore: Firestore, collectionId: string): Query; +export declare function regexContains(left: string, pattern: string): RegexContains; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | A reference to the root Firestore instance. | -| collectionId | string | Identifies the collections to query over. Every collection or subcollection with this ID as the last segment of its path will be included. Cannot contain a slash. | +| left | string | The name of the field containing the string. | +| pattern | string | The regular expression to use for the search. A new representing the 'contains' comparison. | Returns: -[Query](./firestore_.query.md#query_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> +[RegexContains](./firestore_.regexcontains.md#regexcontains_class) -The created `Query`. +### regexContains(left, pattern) {:#regexcontains_dd84184} -### connectFirestoreEmulator(firestore, host, port, options) {:#connectfirestoreemulator_7c247cd} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Modify this instance to communicate with the Cloud Firestore emulator. +Creates an expression that checks if a string field contains a specified regular expression as a substring. -Note: This must be called before this instance has been used to do any operations. +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +regexContains("description", Field.of("pattern")); + +``` Signature: ```typescript -export declare function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: { - mockUserToken?: EmulatorMockTokenOptions | string; -}): void; +export declare function regexContains(left: string, pattern: Constant): RegexContains; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The Firestore instance to configure to connect to the emulator. | -| host | string | the emulator host (ex: localhost). | -| port | number | the emulator port (ex: 9000). | -| options | { mockUserToken?: [EmulatorMockTokenOptions](./util.md#emulatormocktokenoptions) \| string; } | | +| left | string | The name of the field containing the string. | +| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the search. A new representing the 'contains' comparison. | Returns: -void +[RegexContains](./firestore_.regexcontains.md#regexcontains_class) -### disableNetwork(firestore) {:#disablenetwork_231a8e0} +### regexContains(left, pattern) {:#regexcontains_3aaffe0} -Disables network usage for this instance. It can be re-enabled via [enableNetwork()](./firestore_.md#enablenetwork_231a8e0). While the network is disabled, any snapshot listeners, `getDoc()` or `getDocs()` calls will return results from cache, and any write operations will be queued until the network is restored. +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string expression contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +regexContains(Field.of("description"), "(?i)example"); + +``` Signature: ```typescript -export declare function disableNetwork(firestore: Firestore): Promise; +export declare function regexContains(left: Constant, pattern: string): RegexContains; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | +| left | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to perform the comparison on. | +| pattern | string | The regular expression to use for the search. A new representing the 'contains' comparison. | Returns: -Promise<void> +[RegexContains](./firestore_.regexcontains.md#regexcontains_class) -A `Promise` that is resolved once the network has been disabled. +### regexContains(left, pattern) {:#regexcontains_a2c3e8b} -### doc(firestore, path, pathSegments) {:#doc_1eb4c23} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Gets a `DocumentReference` instance that refers to the document at the specified absolute path. +Creates an expression that checks if a string expression contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +regexContains(Field.of("description"), Field.of("pattern")); + +``` Signature: ```typescript -export declare function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference; +export declare function regexContains(left: Constant, pattern: Constant): RegexContains; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | A reference to the root Firestore instance. | -| path | string | A slash-separated path to a document. | -| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | +| left | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to perform the comparison on. | +| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the search. A new representing the 'contains' comparison. | Returns: -[DocumentReference](./firestore_.documentreference.md#documentreference_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> +[RegexContains](./firestore_.regexcontains.md#regexcontains_class) -The `DocumentReference` instance. +### regexMatch(left, pattern) {:#regexmatch_33ec01b} -#### Exceptions +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -If the final path has an odd number of segments and does not point to a document. +Creates an expression that checks if a string field matches a specified regular expression. -### enableIndexedDbPersistence(firestore, persistenceSettings) {:#enableindexeddbpersistence_224174f} +```typescript +// Check if the 'email' field matches a valid email pattern +regexMatch("email", "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); -> Warning: This API is now obsolete. -> -> This function will be removed in a future major release. Instead, set `FirestoreSettings.localCache` to an instance of `PersistentLocalCache` to turn on IndexedDb cache. Calling this function when `FirestoreSettings.localCache` is already specified will throw an exception. -> +``` -Attempts to enable persistent storage, if possible. +Signature: -On failure, `enableIndexedDbPersistence()` will reject the promise or throw an exception. There are several reasons why this can fail, which can be identified by the `code` on the error. +```typescript +export declare function regexMatch(left: string, pattern: string): RegexMatch; +``` -\* failed-precondition: The app is already open in another browser tab. \* unimplemented: The browser is incompatible with the offline persistence implementation. +#### Parameters -Note that even after a failure, the [Firestore](./firestore_.firestore.md#firestore_class) instance will remain usable, however offline persistence will be disabled. +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The name of the field containing the string. | +| pattern | string | The regular expression to use for the match. A new representing the regular expression match. | -Note: `enableIndexedDbPersistence()` must be called before any other functions (other than [initializeFirestore()](./firestore_.md#initializefirestore_fc7d200), [getFirestore()](./firestore_.md#getfirestore) or [clearIndexedDbPersistence()](./firestore_.md#clearindexeddbpersistence_231a8e0). +Returns: -Persistence cannot be used in a Node.js environment. +[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) + +### regexMatch(left, pattern) {:#regexmatch_dd84184} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string field matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a valid email pattern +regexMatch("email", Field.of("pattern")); + +``` Signature: ```typescript -export declare function enableIndexedDbPersistence(firestore: Firestore, persistenceSettings?: PersistenceSettings): Promise; +export declare function regexMatch(left: string, pattern: Constant): RegexMatch; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to enable persistence for. | -| persistenceSettings | [PersistenceSettings](./firestore_.persistencesettings.md#persistencesettings_interface) | Optional settings object to configure persistence. | +| left | string | The name of the field containing the string. | +| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the match. A new representing the regular expression match. | Returns: -Promise<void> - -A `Promise` that represents successfully enabling persistent storage. +[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) -### enableMultiTabIndexedDbPersistence(firestore) {:#enablemultitabindexeddbpersistence_231a8e0} +### regexMatch(left, pattern) {:#regexmatch_3aaffe0} -> Warning: This API is now obsolete. +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. > -> This function will be removed in a future major release. Instead, set `FirestoreSettings.localCache` to an instance of `PersistentLocalCache` to turn on indexeddb cache. Calling this function when `FirestoreSettings.localCache` is already specified will throw an exception. + +Creates an expression that checks if a string expression matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a valid email pattern +regexMatch(Field.of("email"), "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + +Signature: + +```typescript +export declare function regexMatch(left: Constant, pattern: string): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to match against. | +| pattern | string | The regular expression to use for the match. A new representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) + +### regexMatch(left, pattern) {:#regexmatch_a2c3e8b} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. > -Attempts to enable multi-tab persistent storage, if possible. If enabled across all tabs, all operations share access to local persistence, including shared execution of queries and latency-compensated local document updates across all connected instances. +Creates an expression that checks if a string expression matches a specified regular expression. -On failure, `enableMultiTabIndexedDbPersistence()` will reject the promise or throw an exception. There are several reasons why this can fail, which can be identified by the `code` on the error. +```typescript +// Check if the 'email' field matches a valid email pattern +regexMatch(Field.of("email"), Field.of("pattern")); -\* failed-precondition: The app is already open in another browser tab and multi-tab is not enabled. \* unimplemented: The browser is incompatible with the offline persistence implementation. +``` -Note that even after a failure, the [Firestore](./firestore_.firestore.md#firestore_class) instance will remain usable, however offline persistence will be disabled. +Signature: + +```typescript +export declare function regexMatch(left: Constant, pattern: Constant): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to match against. | +| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the match. A new representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) + +### snapshotEqual(left, right) {:#snapshotequal_5109204} + +Returns true if the provided snapshots are equal. Signature: ```typescript -export declare function enableMultiTabIndexedDbPersistence(firestore: Firestore): Promise; +export declare function snapshotEqual(left: DocumentSnapshot | QuerySnapshot, right: DocumentSnapshot | QuerySnapshot): boolean; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to enable persistence for. | +| left | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> \| [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType> | A snapshot to compare. | +| right | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> \| [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType> | A snapshot to compare. | Returns: -Promise<void> +boolean -A `Promise` that represents successfully enabling persistent storage. +true if the snapshots are equal. -### enableNetwork(firestore) {:#enablenetwork_231a8e0} +### strContains(left, substring) {:#strcontains_18eaf5d} -Re-enables use of the network for this [Firestore](./firestore_.firestore.md#firestore_class) instance after a prior call to [disableNetwork()](./firestore_.md#disablenetwork_231a8e0). +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string field contains a specified substring. + +```typescript +// Check if the 'description' field contains "example". +strContains("description", "example"); + +``` Signature: ```typescript -export declare function enableNetwork(firestore: Firestore): Promise; +export declare function strContains(left: string, substring: string): StrContains; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | +| left | string | The name of the field containing the string. | +| substring | string | The substring to search for. A new representing the 'contains' comparison. | Returns: -Promise<void> +[StrContains](./firestore_.strcontains.md#strcontains_class) + +### strContains(left, substring) {:#strcontains_f0f1f2f} -A `Promise` that is resolved once the network has been enabled. +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -### getPersistentCacheIndexManager(firestore) {:#getpersistentcacheindexmanager_231a8e0} +Creates an expression that checks if a string field contains a substring specified by an expression. -Returns the PersistentCache Index Manager used by the given `Firestore` object. +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +strContains("description", Field.of("keyword")); - The `PersistentCacheIndexManager` instance, or `null` if local persistent storage is not in use. +``` Signature: ```typescript -export declare function getPersistentCacheIndexManager(firestore: Firestore): PersistentCacheIndexManager | null; +export declare function strContains(left: string, substring: Constant): StrContains; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | +| left | string | The name of the field containing the string. | +| substring | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. A new representing the 'contains' comparison. | Returns: -[PersistentCacheIndexManager](./firestore_.persistentcacheindexmanager.md#persistentcacheindexmanager_class) \| null +[StrContains](./firestore_.strcontains.md#strcontains_class) -### loadBundle(firestore, bundleData) {:#loadbundle_bec5b75} +### strContains(left, substring) {:#strcontains_5fdbd29} -Loads a Firestore bundle into the local cache. +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string expression contains a specified substring. + +```typescript +// Check if the 'description' field contains "example". +strContains(Field.of("description"), "example"); + +``` Signature: ```typescript -export declare function loadBundle(firestore: Firestore, bundleData: ReadableStream | ArrayBuffer | string): LoadBundleTask; +export declare function strContains(left: Constant, substring: string): StrContains; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to load bundles for. | -| bundleData | ReadableStream<Uint8Array> \| ArrayBuffer \| string | An object representing the bundle to be loaded. Valid objects are ArrayBuffer, ReadableStream<Uint8Array> or string. | +| left | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to perform the comparison on. | +| substring | string | The substring to search for. A new representing the 'contains' comparison. | Returns: -[LoadBundleTask](./firestore_.loadbundletask.md#loadbundletask_class) +[StrContains](./firestore_.strcontains.md#strcontains_class) -A `LoadBundleTask` object, which notifies callers with progress updates, and completion or error events. It can be used as a `Promise`. +### strContains(left, substring) {:#strcontains_d9d749f} -### namedQuery(firestore, name) {:#namedquery_6438876} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Reads a Firestore [Query](./firestore_.query.md#query_class) from local cache, identified by the given name. +Creates an expression that checks if a string expression contains a substring specified by another expression. -The named queries are packaged into bundles on the server side (along with resulting documents), and loaded to local cache using `loadBundle`. Once in local cache, use this method to extract a [Query](./firestore_.query.md#query_class) by name. +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +strContains(Field.of("description"), Field.of("keyword")); + +``` Signature: ```typescript -export declare function namedQuery(firestore: Firestore, name: string): Promise; +export declare function strContains(left: Constant, substring: Constant): StrContains; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to read the query from. | -| name | string | The name of the query. | +| left | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to perform the comparison on. | +| substring | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. A new representing the 'contains' comparison. | Returns: -Promise<[Query](./firestore_.query.md#query_class) \| null> +[StrContains](./firestore_.strcontains.md#strcontains_class) -A `Promise` that is resolved with the Query or `null`. +### subtract(left, right) {:#subtract_be96f75} -### onSnapshotsInSync(firestore, observer) {:#onsnapshotsinsync_2f0dfa4} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if a single server-generated change affects multiple listeners. +Creates an expression that subtracts two expressions. -NOTE: The snapshots-in-sync event only indicates that listeners are in sync with each other, but does not relate to whether those snapshots are in sync with the server. Use SnapshotMetadata in the individual listeners to determine if a snapshot is from the cache or the server. +```typescript +// Subtract the 'discount' field from the 'price' field +subtract(Field.of("price"), Field.of("discount")); + +``` Signature: ```typescript -export declare function onSnapshotsInSync(firestore: Firestore, observer: { - next?: (value: void) => void; - error?: (error: FirestoreError) => void; - complete?: () => void; -}): Unsubscribe; +export declare function subtract(left: Constant, right: Constant): Subtract; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The instance of Firestore for synchronizing snapshots. | -| observer | { next?: (value: void) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | +| left | [Constant](./firestore_.constant.md#constant_class) | The expression to subtract from. | +| right | [Constant](./firestore_.constant.md#constant_class) | The expression to subtract. A new representing the subtraction operation. | Returns: -[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) +[Subtract](./firestore_.subtract.md#subtract_class) -An unsubscribe function that can be called to cancel the snapshot listener. +### subtract(left, right) {:#subtract_010ba9e} -### onSnapshotsInSync(firestore, onSync) {:#onsnapshotsinsync_1901c06} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if a single server-generated change affects multiple listeners. +Creates an expression that subtracts a constant value from an expression. -NOTE: The snapshots-in-sync event only indicates that listeners are in sync with each other, but does not relate to whether those snapshots are in sync with the server. Use `SnapshotMetadata` in the individual listeners to determine if a snapshot is from the cache or the server. +```typescript +// Subtract the constant value 2 from the 'value' field +subtract(Field.of("value"), 2); + +``` Signature: ```typescript -export declare function onSnapshotsInSync(firestore: Firestore, onSync: () => void): Unsubscribe; +export declare function subtract(left: Constant, right: any): Subtract; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The Firestore instance for synchronizing snapshots. | -| onSync | () => void | A callback to be called every time all snapshot listeners are in sync with each other. | +| left | [Constant](./firestore_.constant.md#constant_class) | The expression to subtract from. | +| right | any | The constant value to subtract. A new representing the subtraction operation. | Returns: -[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) +[Subtract](./firestore_.subtract.md#subtract_class) -An unsubscribe function that can be called to cancel the snapshot listener. +### subtract(left, right) {:#subtract_674c63f} -### runTransaction(firestore, updateFunction, options) {:#runtransaction_6f03ec4} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Executes the given `updateFunction` and then attempts to commit the changes applied within the transaction. If any document read within the transaction has changed, Cloud Firestore retries the `updateFunction`. If it fails to commit after 5 attempts, the transaction fails. +Creates an expression that subtracts an expression from a field's value. -The maximum number of writes allowed in a single transaction is 500. +```typescript +// Subtract the 'discount' field from the 'price' field +subtract("price", Field.of("discount")); + +``` Signature: ```typescript -export declare function runTransaction(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise, options?: TransactionOptions): Promise; +export declare function subtract(left: string, right: Constant): Subtract; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | A reference to the Firestore database to run this transaction against. | -| updateFunction | (transaction: [Transaction](./firestore_.transaction.md#transaction_class)) => Promise<T> | The function to execute within the transaction context. | -| options | [TransactionOptions](./firestore_.transactionoptions.md#transactionoptions_interface) | An options object to configure maximum number of attempts to commit. | +| left | string | The field name to subtract from. | +| right | [Constant](./firestore_.constant.md#constant_class) | The expression to subtract. A new representing the subtraction operation. | Returns: -Promise<T> - -If the transaction completed successfully or was explicitly aborted (the `updateFunction` returned a failed promise), the promise returned by the `updateFunction `is returned here. Otherwise, if the transaction failed, a rejected promise with the corresponding failure error is returned. +[Subtract](./firestore_.subtract.md#subtract_class) -### setIndexConfiguration(firestore, configuration) {:#setindexconfiguration_c362f04} +### subtract(left, right) {:#subtract_1f46a76} > This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. > -> Warning: This API is now obsolete. -> -> Instead of creating cache indexes manually, consider using `enablePersistentCacheIndexAutoCreation()` to let the SDK decide whether to create cache indexes for queries running locally. -> - -Configures indexing for local query execution. Any previous index configuration is overridden. The `Promise` resolves once the index configuration has been persisted. +Creates an expression that subtracts a constant value from a field's value. -The index entries themselves are created asynchronously. You can continue to use queries that require indexing even if the indices are not yet available. Query execution will automatically start using the index once the index entries have been written. +```typescript +// Subtract 20 from the value of the 'total' field +subtract("total", 20); -Indexes are only supported with IndexedDb persistence. If IndexedDb is not enabled, any index configuration is ignored. +``` Signature: ```typescript -export declare function setIndexConfiguration(firestore: Firestore, configuration: IndexConfiguration): Promise; +export declare function subtract(left: string, right: any): Subtract; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to configure indexes for. | -| configuration | [IndexConfiguration](./firestore_.indexconfiguration.md#indexconfiguration_interface) | The index definition. | +| left | string | The field name to subtract from. | +| right | any | The constant value to subtract. A new representing the subtraction operation. | Returns: -Promise<void> - -A `Promise` that resolves once all indices are successfully configured. - -#### Exceptions - -FirestoreError if the JSON format is invalid. +[Subtract](./firestore_.subtract.md#subtract_class) -### setIndexConfiguration(firestore, json) {:#setindexconfiguration_90d0285} +### xor(left, right) {:#xor_eba7e36} > This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. > -> Warning: This API is now obsolete. -> -> Instead of creating cache indexes manually, consider using `enablePersistentCacheIndexAutoCreation()` to let the SDK decide whether to create cache indexes for queries running locally. -> - -Configures indexing for local query execution. Any previous index configuration is overridden. The `Promise` resolves once the index configuration has been persisted. - -The index entries themselves are created asynchronously. You can continue to use queries that require indexing even if the indices are not yet available. Query execution will automatically start using the index once the index entries have been written. +Creates an expression that performs a logical 'XOR' (exclusive OR) operation on multiple filter conditions. -Indexes are only supported with IndexedDb persistence. Invoke either `enableIndexedDbPersistence()` or `enableMultiTabIndexedDbPersistence()` before setting an index configuration. If IndexedDb is not enabled, any index configuration is ignored. +```typescript +// Check if only one of the conditions is true: 'age' greater than 18, 'city' is "London", +// or 'status' is "active". +const condition = xor( + gt("age", 18), + eq("city", "London"), + eq("status", "active")); -The method accepts the JSON format exported by the Firebase CLI (`firebase firestore:indexes`). If the JSON format is invalid, this method throws an error. +``` Signature: ```typescript -export declare function setIndexConfiguration(firestore: Firestore, json: string): Promise; +export declare function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to configure indexes for. | -| json | string | The JSON format exported by the Firebase CLI. | +| left | [FilterExpr](./firestore_.md#filterexpr) | The first filter condition. | +| right | [FilterExpr](./firestore_.md#filterexpr)\[\] | Additional filter conditions to 'XOR' together. A new representing the logical 'XOR' operation. | Returns: -Promise<void> - -A `Promise` that resolves once all indices are successfully configured. - -#### Exceptions - -FirestoreError if the JSON format is invalid. - -### terminate(firestore) {:#terminate_231a8e0} - -Terminates the provided [Firestore](./firestore_.firestore.md#firestore_class) instance. - -After calling `terminate()` only the `clearIndexedDbPersistence()` function may be used. Any other function will throw a `FirestoreError`. +[Xor](./firestore_.xor.md#xor_class) -To restart after termination, create a new instance of FirebaseFirestore with [getFirestore()](./firestore_.md#getfirestore). +## function(limit, ...) -Termination does not cancel any pending writes, and any promises that are awaiting a response from the server will not be resolved. If you have persistence enabled, the next time you start this instance, it will resume sending these writes to the server. +### limit(limit) {:#limit_ec46c78} -Note: Under normal circumstances, calling `terminate()` is not required. This function is useful only when you want to force this instance to release all of its resources or in combination with `clearIndexedDbPersistence()` to ensure that all local state is destroyed between test runs. +Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the first matching documents. Signature: ```typescript -export declare function terminate(firestore: Firestore): Promise; +export declare function limit(limit: number): QueryLimitConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | +| limit | number | The maximum number of items to return. | Returns: -Promise<void> - -A `Promise` that is resolved when the instance has been successfully terminated. +[QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) -### waitForPendingWrites(firestore) {:#waitforpendingwrites_231a8e0} +The created [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class). -Waits until all currently pending writes for the active user have been acknowledged by the backend. +### limitToLast(limit) {:#limittolast_ec46c78} -The returned promise resolves immediately if there are no outstanding writes. Otherwise, the promise waits for all previously issued writes (including those written in a previous app session), but it does not wait for writes that were added after the function is called. If you want to wait for additional writes, call `waitForPendingWrites()` again. +Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the last matching documents. -Any outstanding `waitForPendingWrites()` promises are rejected during user changes. +You must specify at least one `orderBy` clause for `limitToLast` queries, otherwise an exception will be thrown during execution. Signature: ```typescript -export declare function waitForPendingWrites(firestore: Firestore): Promise; +export declare function limitToLast(limit: number): QueryLimitConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | +| limit | number | The maximum number of items to return. | Returns: -Promise<void> +[QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) -A `Promise` which resolves when all currently pending writes have been acknowledged by the backend. +The created [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class). -### writeBatch(firestore) {:#writebatch_231a8e0} +## function(logLevel, ...) -Creates a write batch, used for performing multiple writes as a single atomic operation. The maximum number of writes allowed in a single [WriteBatch](./firestore_.writebatch.md#writebatch_class) is 500. +### setLogLevel(logLevel) {:#setloglevel_d02fda2} -Unlike transactions, write batches are persisted offline and therefore are preferable when you don't need to condition your writes on read data. +Sets the verbosity of Cloud Firestore logs (debug, error, or silent). Signature: ```typescript -export declare function writeBatch(firestore: Firestore): WriteBatch; +export declare function setLogLevel(logLevel: LogLevel): void; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | +| logLevel | LogLevel | The verbosity you set for activity and error logging. Can be any of the following values:

  • debug for the most verbose logging level, primarily for debugging.
  • error to log errors only.
  • silent to turn off logging.
| Returns: -[WriteBatch](./firestore_.writebatch.md#writebatch_class) +void -A [WriteBatch](./firestore_.writebatch.md#writebatch_class) that can be used to atomically execute multiple writes. +## function(mapExpr, ...) -## function() +### mapGet(mapExpr, subField) {:#mapget_9715f90} -### count() {:#count} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Create an AggregateField object that can be used to compute the count of documents in the result set of a query. +Accesses a value from a map (object) expression using the provided key. + +```typescript +// Get the 'city' value from the 'address' map field +mapGet(Field.of("address"), "city"); + +``` Signature: ```typescript -export declare function count(): AggregateField; +export declare function mapGet(mapExpr: Constant, subField: string): MapGet; ``` -Returns: -[AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<number> +#### Parameters -### deleteField() {:#deletefield} +| Parameter | Type | Description | +| --- | --- | --- | +| mapExpr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the map. | +| subField | string | The key to access in the map. A new representing the value associated with the given key in the map. | -Returns a sentinel for use with [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) or [setDoc()](./firestore_lite.md#setdoc_ee215ad) with `{merge: true}` to mark a field for deletion. +Returns: -Signature: +[MapGet](./firestore_.mapget.md#mapget_class) -```typescript -export declare function deleteField(): FieldValue; -``` -Returns: +## function(mapField, ...) -[FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) +### mapGet(mapField, subField) {:#mapget_b37bbb6} -### documentId() {:#documentid} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Returns a special sentinel `FieldPath` to refer to the ID of a document. It can be used in queries to sort or filter by the document ID. +Accesses a value from a map (object) field using the provided key. + +```typescript +// Get the 'city' value from the 'address' map field +mapGet("address", "city"); + +``` Signature: ```typescript -export declare function documentId(): FieldPath; +export declare function mapGet(mapField: string, subField: string): MapGet; ``` -Returns: -[FieldPath](./firestore_.fieldpath.md#fieldpath_class) +#### Parameters -### getFirestore() {:#getfirestore} +| Parameter | Type | Description | +| --- | --- | --- | +| mapField | string | The field name of the map field. | +| subField | string | The key to access in the map. A new representing the value associated with the given key in the map. | -Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. +Returns: -Signature: +[MapGet](./firestore_.mapget.md#mapget_class) -```typescript -export declare function getFirestore(): Firestore; -``` -Returns: +## function(n, ...) -[Firestore](./firestore_.firestore.md#firestore_class) +### increment(n) {:#increment_5685735} -The default [Firestore](./firestore_.firestore.md#firestore_class) instance of the default app. +Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to increment the field's current value by the given value. -### memoryEagerGarbageCollector() {:#memoryeagergarbagecollector} +If either the operand or the current field value uses floating point precision, all arithmetic follows IEEE 754 semantics. If both values are integers, values outside of JavaScript's safe number range (`Number.MIN_SAFE_INTEGER` to `Number.MAX_SAFE_INTEGER`) are also subject to precision loss. Furthermore, once processed by the Firestore backend, all integer operations are capped between -2^63 and 2^63-1. -Creates an instance of `MemoryEagerGarbageCollector`. This is also the default garbage collector unless it is explicitly specified otherwise. +If the current field value is not of type `number`, or if the field does not yet exist, the transformation sets the field to the given value. Signature: ```typescript -export declare function memoryEagerGarbageCollector(): MemoryEagerGarbageCollector; +export declare function increment(n: number): FieldValue; ``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| n | number | The value to increment by. | + Returns: -[MemoryEagerGarbageCollector](./firestore_.memoryeagergarbagecollector.md#memoryeagergarbagecollector_interface) +[FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) -### persistentMultipleTabManager() {:#persistentmultipletabmanager} +The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()` -Creates an instance of `PersistentMultipleTabManager`. +## function(name, ...) -Signature: +### genericFunction(name, params) {:#genericfunction_b886545} -```typescript -export declare function persistentMultipleTabManager(): PersistentMultipleTabManager; -``` -Returns: +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -[PersistentMultipleTabManager](./firestore_.persistentmultipletabmanager.md#persistentmultipletabmanager_interface) +Creates functions that work on the backend but do not exist in the SDK yet. -### serverTimestamp() {:#servertimestamp} +```typescript +// Call a user defined function named "myFunc" with the arguments 10 and 20 +// This is the same of the 'sum(Field.of("price"))', if it did not exist +genericFunction("sum", [Field.of("price")]); -Returns a sentinel used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) to include a server-generated timestamp in the written data. +``` Signature: ```typescript -export declare function serverTimestamp(): FieldValue; +export declare function genericFunction(name: string, params: Constant[]): FirestoreFunction; ``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | The name of the user defined function. | +| params | [Constant](./firestore_.constant.md#constant_class)\[\] | The arguments to pass to the function. A new representing the function call. | + Returns: -[FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) +[FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) -## function(databaseId, ...) +## function(pipeline, ...) -### getFirestore(databaseId) {:#getfirestore_53dc891} +### execute(pipeline) {:#execute_86486e6} > This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. > -Returns the existing named [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. +Modular API for console experimentation. Signature: ```typescript -export declare function getFirestore(databaseId: string): Firestore; +export declare function execute(pipeline: Pipeline): Promise>>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| databaseId | string | The name of the database. | +| pipeline | [Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> | Execute this pipeline. | Returns: -[Firestore](./firestore_.firestore.md#firestore_class) +Promise<Array<[PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class)<AppModelType>>> -The named [Firestore](./firestore_.firestore.md#firestore_class) instance of the default app. +## function(query, ...) -## function(elements, ...) +### getAggregateFromServer(query, aggregateSpec) {:#getaggregatefromserver_2073a74} -### arrayRemove(elements) {:#arrayremove_7d853aa} +Calculates the specified aggregations over the documents in the result set of the given query without actually downloading the documents. -Returns a special value that can be used with [setDoc()](./firestore_.md#setdoc_ee215ad) or that tells the server to remove the given elements from any array value that already exists on the server. All instances of each element specified will be removed from the array. If the field being modified is not already an array it will be overwritten with an empty array. +Using this function to perform aggregations is efficient because only the final aggregation values, not the documents' data, are downloaded. This function can perform aggregations of the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). + +The result received from the server is presented, unaltered, without considering any local state. That is, documents in the local cache are not taken into consideration, neither are local modifications not yet synchronized with the server. Previously-downloaded results, if any, are not used. Every invocation of this function necessarily involves a round trip to the server. Signature: ```typescript -export declare function arrayRemove(...elements: unknown[]): FieldValue; +export declare function getAggregateFromServer(query: Query, aggregateSpec: AggregateSpecType): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| elements | unknown\[\] | The elements to remove from the array. | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query whose result set is aggregated over. | +| aggregateSpec | AggregateSpecType | An AggregateSpec object that specifies the aggregates to perform over the result set. The AggregateSpec specifies aliases for each aggregate, which can be used to retrieve the aggregate result. | Returns: -[FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) +Promise<[AggregateQuerySnapshot](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType>> -The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()` +### Example -### arrayUnion(elements) {:#arrayunion_7d853aa} -Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to union the given elements with any array value that already exists on the server. Each specified element that doesn't already exist in the array will be added to the end. If the field being modified is not already an array it will be overwritten with an array containing exactly the specified elements. +```typescript +const aggregateSnapshot = await getAggregateFromServer(query, { + countOfDocs: count(), + totalHours: sum('hours'), + averageScore: average('score') +}); + +const countOfDocs: number = aggregateSnapshot.data().countOfDocs; +const totalHours: number = aggregateSnapshot.data().totalHours; +const averageScore: number | null = aggregateSnapshot.data().averageScore; + +``` + +### getCountFromServer(query) {:#getcountfromserver_4e56953} + +Calculates the number of documents in the result set of the given query without actually downloading the documents. + +Using this function to count the documents is efficient because only the final count, not the documents' data, is downloaded. This function can count the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). + +The result received from the server is presented, unaltered, without considering any local state. That is, documents in the local cache are not taken into consideration, neither are local modifications not yet synchronized with the server. Previously-downloaded results, if any, are not used. Every invocation of this function necessarily involves a round trip to the server. Signature: ```typescript -export declare function arrayUnion(...elements: unknown[]): FieldValue; +export declare function getCountFromServer(query: Query): Promise; +}, AppModelType, DbModelType>>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| elements | unknown\[\] | The elements to union into the array. | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query whose result set size is calculated. | Returns: -[FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) +Promise<[AggregateQuerySnapshot](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<{ count: [AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<number>; }, AppModelType, DbModelType>> -The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()`. +A Promise that will be resolved with the count; the count can be retrieved from `snapshot.data().count`, where `snapshot` is the `AggregateQuerySnapshot` to which the returned Promise resolves. -## function(field, ...) +### getDocs(query) {:#getdocs_4e56953} -### average(field) {:#average_aacc3a9} +Executes the query and returns the results as a `QuerySnapshot`. -Create an AggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query. +Note: `getDocs()` attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. To specify this behavior, invoke [getDocsFromCache()](./firestore_.md#getdocsfromcache_4e56953) or [getDocsFromServer()](./firestore_.md#getdocsfromserver_4e56953). Signature: ```typescript -export declare function average(field: string | FieldPath): AggregateField; +export declare function getDocs(query: Query): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| field | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | Specifies the field to average across the result set. | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | | Returns: -[AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<number \| null> +Promise<[QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>> -### sum(field) {:#sum_aacc3a9} +A `Promise` that will be resolved with the results of the query. -Create an AggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query. +### getDocsFromCache(query) {:#getdocsfromcache_4e56953} + +Executes the query and returns the results as a `QuerySnapshot` from cache. Returns an empty result set if no documents matching the query are currently cached. Signature: ```typescript -export declare function sum(field: string | FieldPath): AggregateField; +export declare function getDocsFromCache(query: Query): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| field | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | Specifies the field to sum across the result set. | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | | Returns: -[AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<number> - -## function(fieldPath, ...) +Promise<[QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>> -### orderBy(fieldPath, directionStr) {:#orderby_006d61f} +A `Promise` that will be resolved with the results of the query. -Creates a [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) that sorts the query result by the specified field, optionally in descending order instead of ascending. +### getDocsFromServer(query) {:#getdocsfromserver_4e56953} -Note: Documents that do not contain the specified field will not be present in the query result. +Executes the query and returns the results as a `QuerySnapshot` from the server. Returns an error if the network is not available. Signature: ```typescript -export declare function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryOrderByConstraint; +export declare function getDocsFromServer(query: Query): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| fieldPath | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | The field to sort by. | -| directionStr | [OrderByDirection](./firestore_.md#orderbydirection) | Optional direction to sort by ('asc' or 'desc'). If not specified, order will be ascending. | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | | Returns: -[QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) +Promise<[QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>> -The created [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class). +A `Promise` that will be resolved with the results of the query. -### where(fieldPath, opStr, value) {:#where_0fae4bf} +### onSnapshot(query, observer) {:#onsnapshot_8d14049} -Creates a [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) that enforces that documents must contain the specified field and that the value should satisfy the relation constraint provided. +Attaches a listener for `QuerySnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. + +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. Signature: ```typescript -export declare function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryFieldFilterConstraint; +export declare function onSnapshot(query: Query, observer: { + next?: (snapshot: QuerySnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; +}): Unsubscribe; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| fieldPath | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | The path to compare | -| opStr | [WhereFilterOp](./firestore_.md#wherefilterop) | The operation string (e.g "&lt;", "&lt;=", "==", "&lt;", "&lt;=", "!="). | -| value | unknown | The value for comparison | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query to listen to. | +| observer | { next?: (snapshot: [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | Returns: -[QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) -The created [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class). +An unsubscribe function that can be called to cancel the snapshot listener. -## function(fieldValues, ...) +### onSnapshot(query, options, observer) {:#onsnapshot_03dfff5} -### endAt(fieldValues) {:#endat_8b2f2c8} +Attaches a listener for `QuerySnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. -Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. Signature: ```typescript -export declare function endAt(...fieldValues: unknown[]): QueryEndAtConstraint; +export declare function onSnapshot(query: Query, options: SnapshotListenOptions, observer: { + next?: (snapshot: QuerySnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; +}): Unsubscribe; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| fieldValues | unknown\[\] | The field values to end this query at, in order of the query's order by. | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query to listen to. | +| options | [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | Options controlling the listen behavior. | +| observer | { next?: (snapshot: [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | Returns: -[QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) -A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` +An unsubscribe function that can be called to cancel the snapshot listener. -### endBefore(fieldValues) {:#endbefore_8b2f2c8} +### onSnapshot(query, onNext, onError, onCompletion) {:#onsnapshot_3ebfbe2} -Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. +Attaches a listener for `QuerySnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. + +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. Signature: ```typescript -export declare function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint; +export declare function onSnapshot(query: Query, onNext: (snapshot: QuerySnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| fieldValues | unknown\[\] | The field values to end this query before, in order of the query's order by. | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query to listen to. | +| onNext | (snapshot: [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>) => void | A callback to be called every time a new QuerySnapshot is available. | +| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void | A callback to be called if the listen fails or is cancelled. No further callbacks will occur. | +| onCompletion | () => void | Can be provided, but will not be called since streams are never ending. | Returns: -[QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) -A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` +An unsubscribe function that can be called to cancel the snapshot listener. -### startAfter(fieldValues) {:#startafter_8b2f2c8} +### onSnapshot(query, options, onNext, onError, onCompletion) {:#onsnapshot_b8f9c47} -Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. +Attaches a listener for `QuerySnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. + +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. Signature: ```typescript -export declare function startAfter(...fieldValues: unknown[]): QueryStartAtConstraint; +export declare function onSnapshot(query: Query, options: SnapshotListenOptions, onNext: (snapshot: QuerySnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| fieldValues | unknown\[\] | The field values to start this query after, in order of the query's order by. | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query to listen to. | +| options | [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | Options controlling the listen behavior. | +| onNext | (snapshot: [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>) => void | A callback to be called every time a new QuerySnapshot is available. | +| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void | A callback to be called if the listen fails or is cancelled. No further callbacks will occur. | +| onCompletion | () => void | Can be provided, but will not be called since streams are never ending. | Returns: -[QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) -A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()` +An unsubscribe function that can be called to cancel the snapshot listener. -### startAt(fieldValues) {:#startat_8b2f2c8} +### pipeline(query) {:#pipeline_20b2416} -Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. +Experimental Modular API for console testing. Signature: ```typescript -export declare function startAt(...fieldValues: unknown[]): QueryStartAtConstraint; +export declare function pipeline(query: Query): Pipeline; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| fieldValues | unknown\[\] | The field values to start this query at, in order of the query's order by. | +| query | [Query](./firestore_.query.md#query_class) | | Returns: -[QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) - -A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()`. - -## function(indexManager, ...) - -### deleteAllPersistentCacheIndexes(indexManager) {:#deleteallpersistentcacheindexes_98b2645} +[Pipeline](./firestore_.pipeline.md#pipeline_class) -Removes all persistent cache indexes. +### query(query, compositeFilter, queryConstraints) {:#query_9f7b0f4} -Please note this function will also deletes indexes generated by `setIndexConfiguration()`, which is deprecated. +Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. Signature: ```typescript -export declare function deleteAllPersistentCacheIndexes(indexManager: PersistentCacheIndexManager): void; +export declare function query(query: Query, compositeFilter: QueryCompositeFilterConstraint, ...queryConstraints: QueryNonFilterConstraint[]): Query; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| indexManager | [PersistentCacheIndexManager](./firestore_.persistentcacheindexmanager.md#persistentcacheindexmanager_class) | | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The [Query](./firestore_.query.md#query_class) instance to use as a base for the new constraints. | +| compositeFilter | [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) | The [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) to apply. Create [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) using or . | +| queryConstraints | [QueryNonFilterConstraint](./firestore_.md#querynonfilterconstraint)\[\] | Additional [QueryNonFilterConstraint](./firestore_.md#querynonfilterconstraint)s to apply (e.g. [orderBy()](./firestore_.md#orderby_006d61f), [limit()](./firestore_.md#limit_ec46c78)). | Returns: -void +[Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> -### disablePersistentCacheIndexAutoCreation(indexManager) {:#disablepersistentcacheindexautocreation_98b2645} +#### Exceptions -Stops creating persistent cache indexes automatically for local query execution. The indexes which have been created by calling `enablePersistentCacheIndexAutoCreation()` still take effect. +if any of the provided query constraints cannot be combined with the existing or new constraints. + +### query(query, queryConstraints) {:#query_0f46da1} + +Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. Signature: ```typescript -export declare function disablePersistentCacheIndexAutoCreation(indexManager: PersistentCacheIndexManager): void; +export declare function query(query: Query, ...queryConstraints: QueryConstraint[]): Query; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| indexManager | [PersistentCacheIndexManager](./firestore_.persistentcacheindexmanager.md#persistentcacheindexmanager_class) | | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The [Query](./firestore_.query.md#query_class) instance to use as a base for the new constraints. | +| queryConstraints | [QueryConstraint](./firestore_.queryconstraint.md#queryconstraint_class)\[\] | The list of [QueryConstraint](./firestore_.queryconstraint.md#queryconstraint_class)s to apply. | Returns: -void +[Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> -### enablePersistentCacheIndexAutoCreation(indexManager) {:#enablepersistentcacheindexautocreation_98b2645} +#### Exceptions -Enables the SDK to create persistent cache indexes automatically for local query execution when the SDK believes cache indexes can help improve performance. +if any of the provided query constraints cannot be combined with the existing or new constraints. -This feature is disabled by default. +## function(queryConstraints, ...) + +### and(queryConstraints) {:#and_e72c712} + +Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a conjunction of the given filter constraints. A conjunction filter includes a document if it satisfies all of the given filters. Signature: ```typescript -export declare function enablePersistentCacheIndexAutoCreation(indexManager: PersistentCacheIndexManager): void; +export declare function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| indexManager | [PersistentCacheIndexManager](./firestore_.persistentcacheindexmanager.md#persistentcacheindexmanager_class) | | +| queryConstraints | [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)\[\] | Optional. The list of [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)s to perform a conjunction for. These must be created with calls to [where()](./firestore_.md#where_0fae4bf), , or . | Returns: -void +[QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) -## function(left, ...) +The newly created [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). -### aggregateFieldEqual(left, right) {:#aggregatefieldequal_e80a2b2} +### or(queryConstraints) {:#or_e72c712} -Compares two 'AggregateField\` instances for equality. +Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a disjunction of the given filter constraints. A disjunction filter includes a document if it satisfies any of the given filters. Signature: ```typescript -export declare function aggregateFieldEqual(left: AggregateField, right: AggregateField): boolean; +export declare function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<unknown> | Compare this AggregateField to the right. | -| right | [AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<unknown> | Compare this AggregateField to the left. | +| queryConstraints | [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)\[\] | Optional. The list of [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)s to perform a disjunction for. These must be created with calls to [where()](./firestore_.md#where_0fae4bf), , or . | Returns: -boolean +[QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) -### aggregateQuerySnapshotEqual(left, right) {:#aggregatequerysnapshotequal_1529a20} +The newly created [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). -Compares two `AggregateQuerySnapshot` instances for equality. +## function(reference, ...) -Two `AggregateQuerySnapshot` instances are considered "equal" if they have underlying queries that compare equal, and the same data. +### addDoc(reference, data) {:#adddoc_6e783ff} + +Add a new document to specified `CollectionReference` with the given data, assigning it a document ID automatically. Signature: ```typescript -export declare function aggregateQuerySnapshotEqual(left: AggregateQuerySnapshot, right: AggregateQuerySnapshot): boolean; +export declare function addDoc(reference: CollectionReference, data: WithFieldValue): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [AggregateQuerySnapshot](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType> | The first AggregateQuerySnapshot to compare. | -| right | [AggregateQuerySnapshot](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType> | The second AggregateQuerySnapshot to compare. | +| reference | [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to the collection to add this document to. | +| data | [WithFieldValue](./firestore_.md#withfieldvalue)<AppModelType> | An Object containing the data for the new document. | Returns: -boolean +Promise<[DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType>> -`true` if the objects are "equal", as defined above, or `false` otherwise. +A `Promise` resolved with a `DocumentReference` pointing to the newly created document after it has been written to the backend (Note that it won't resolve while you're offline). -### queryEqual(left, right) {:#queryequal_7a1f045} +### collection(reference, path, pathSegments) {:#collection_568f98d} -Returns true if the provided queries point to the same collection and apply the same constraints. +Gets a `CollectionReference` instance that refers to a subcollection of `reference` at the specified relative path. Signature: ```typescript -export declare function queryEqual(left: Query, right: Query): boolean; +export declare function collection(reference: CollectionReference, path: string, ...pathSegments: string[]): CollectionReference; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | A Query to compare. | -| right | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | A Query to compare. | +| reference | [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to a collection. | +| path | string | A slash-separated path to a collection. | +| pathSegments | string\[\] | Additional path segments to apply relative to the first argument. | Returns: -boolean +[CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> -true if the references point to the same location in the same Firestore database. +The `CollectionReference` instance. -### refEqual(left, right) {:#refequal_598b780} +#### Exceptions -Returns true if the provided references are equal. +If the final path has an even number of segments and does not point to a collection. + +### collection(reference, path, pathSegments) {:#collection_70b4396} + +Gets a `CollectionReference` instance that refers to a subcollection of `reference` at the specified relative path. Signature: ```typescript -export declare function refEqual(left: DocumentReference | CollectionReference, right: DocumentReference | CollectionReference): boolean; +export declare function collection(reference: DocumentReference, path: string, ...pathSegments: string[]): CollectionReference; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> \| [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to compare. | -| right | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> \| [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to compare. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to a Firestore document. | +| path | string | A slash-separated path to a collection. | +| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | Returns: -boolean +[CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> -true if the references point to the same location in the same Firestore database. +The `CollectionReference` instance. -### snapshotEqual(left, right) {:#snapshotequal_5109204} +#### Exceptions -Returns true if the provided snapshots are equal. +If the final path has an even number of segments and does not point to a collection. + +### deleteDoc(reference) {:#deletedoc_4569087} + +Deletes the document referred to by the specified `DocumentReference`. Signature: ```typescript -export declare function snapshotEqual(left: DocumentSnapshot | QuerySnapshot, right: DocumentSnapshot | QuerySnapshot): boolean; +export declare function deleteDoc(reference: DocumentReference): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> \| [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType> | A snapshot to compare. | -| right | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> \| [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType> | A snapshot to compare. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to delete. | Returns: -boolean - -true if the snapshots are equal. +Promise<void> -## function(limit, ...) +A Promise resolved once the document has been successfully deleted from the backend (note that it won't resolve while you're offline). -### limit(limit) {:#limit_ec46c78} +### doc(reference, path, pathSegments) {:#doc_568f98d} -Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the first matching documents. +Gets a `DocumentReference` instance that refers to a document within `reference` at the specified relative path. If no path is specified, an automatically-generated unique ID will be used for the returned `DocumentReference`. Signature: ```typescript -export declare function limit(limit: number): QueryLimitConstraint; +export declare function doc(reference: CollectionReference, path?: string, ...pathSegments: string[]): DocumentReference; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| limit | number | The maximum number of items to return. | +| reference | [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to a collection. | +| path | string | A slash-separated path to a document. Has to be omitted to use auto-generated IDs. | +| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | Returns: -[QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) +[DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> -The created [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class). +The `DocumentReference` instance. -### limitToLast(limit) {:#limittolast_ec46c78} +#### Exceptions -Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the last matching documents. +If the final path has an odd number of segments and does not point to a document. -You must specify at least one `orderBy` clause for `limitToLast` queries, otherwise an exception will be thrown during execution. +### doc(reference, path, pathSegments) {:#doc_70b4396} + +Gets a `DocumentReference` instance that refers to a document within `reference` at the specified relative path. Signature: ```typescript -export declare function limitToLast(limit: number): QueryLimitConstraint; +export declare function doc(reference: DocumentReference, path: string, ...pathSegments: string[]): DocumentReference; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| limit | number | The maximum number of items to return. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to a Firestore document. | +| path | string | A slash-separated path to a document. | +| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | Returns: -[QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) +[DocumentReference](./firestore_.documentreference.md#documentreference_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> -The created [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class). +The `DocumentReference` instance. -## function(logLevel, ...) +#### Exceptions -### setLogLevel(logLevel) {:#setloglevel_d02fda2} +If the final path has an odd number of segments and does not point to a document. -Sets the verbosity of Cloud Firestore logs (debug, error, or silent). +### getDoc(reference) {:#getdoc_4569087} + +Reads the document referred to by this `DocumentReference`. + +Note: `getDoc()` attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. To specify this behavior, invoke [getDocFromCache()](./firestore_.md#getdocfromcache_4569087) or [getDocFromServer()](./firestore_.md#getdocfromserver_4569087). Signature: ```typescript -export declare function setLogLevel(logLevel: LogLevel): void; +export declare function getDoc(reference: DocumentReference): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| logLevel | LogLevel | The verbosity you set for activity and error logging. Can be any of the following values:
  • debug for the most verbose logging level, primarily for debugging.
  • error to log errors only.
  • silent to turn off logging.
| +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | The reference of the document to fetch. | Returns: -void - -## function(n, ...) - -### increment(n) {:#increment_5685735} +Promise<[DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>> -Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to increment the field's current value by the given value. +A Promise resolved with a `DocumentSnapshot` containing the current document contents. -If either the operand or the current field value uses floating point precision, all arithmetic follows IEEE 754 semantics. If both values are integers, values outside of JavaScript's safe number range (`Number.MIN_SAFE_INTEGER` to `Number.MAX_SAFE_INTEGER`) are also subject to precision loss. Furthermore, once processed by the Firestore backend, all integer operations are capped between -2^63 and 2^63-1. +### getDocFromCache(reference) {:#getdocfromcache_4569087} -If the current field value is not of type `number`, or if the field does not yet exist, the transformation sets the field to the given value. +Reads the document referred to by this `DocumentReference` from cache. Returns an error if the document is not currently cached. Signature: ```typescript -export declare function increment(n: number): FieldValue; +export declare function getDocFromCache(reference: DocumentReference): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| n | number | The value to increment by. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | | Returns: -[FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) - -The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()` - -## function(query, ...) - -### getAggregateFromServer(query, aggregateSpec) {:#getaggregatefromserver_2073a74} +Promise<[DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>> -Calculates the specified aggregations over the documents in the result set of the given query without actually downloading the documents. +A `Promise` resolved with a `DocumentSnapshot` containing the current document contents. -Using this function to perform aggregations is efficient because only the final aggregation values, not the documents' data, are downloaded. This function can perform aggregations of the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). +### getDocFromServer(reference) {:#getdocfromserver_4569087} -The result received from the server is presented, unaltered, without considering any local state. That is, documents in the local cache are not taken into consideration, neither are local modifications not yet synchronized with the server. Previously-downloaded results, if any, are not used. Every invocation of this function necessarily involves a round trip to the server. +Reads the document referred to by this `DocumentReference` from the server. Returns an error if the network is not available. Signature: ```typescript -export declare function getAggregateFromServer(query: Query, aggregateSpec: AggregateSpecType): Promise>; +export declare function getDocFromServer(reference: DocumentReference): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query whose result set is aggregated over. | -| aggregateSpec | AggregateSpecType | An AggregateSpec object that specifies the aggregates to perform over the result set. The AggregateSpec specifies aliases for each aggregate, which can be used to retrieve the aggregate result. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | | Returns: -Promise<[AggregateQuerySnapshot](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType>> - -### Example - - -```typescript -const aggregateSnapshot = await getAggregateFromServer(query, { - countOfDocs: count(), - totalHours: sum('hours'), - averageScore: average('score') -}); - -const countOfDocs: number = aggregateSnapshot.data().countOfDocs; -const totalHours: number = aggregateSnapshot.data().totalHours; -const averageScore: number | null = aggregateSnapshot.data().averageScore; - -``` +Promise<[DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>> -### getCountFromServer(query) {:#getcountfromserver_4e56953} +A `Promise` resolved with a `DocumentSnapshot` containing the current document contents. -Calculates the number of documents in the result set of the given query without actually downloading the documents. +### onSnapshot(reference, observer) {:#onsnapshot_0312fd7} -Using this function to count the documents is efficient because only the final count, not the documents' data, is downloaded. This function can count the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). +Attaches a listener for `DocumentSnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. -The result received from the server is presented, unaltered, without considering any local state. That is, documents in the local cache are not taken into consideration, neither are local modifications not yet synchronized with the server. Previously-downloaded results, if any, are not used. Every invocation of this function necessarily involves a round trip to the server. +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. Signature: ```typescript -export declare function getCountFromServer(query: Query): Promise; -}, AppModelType, DbModelType>>; +export declare function onSnapshot(reference: DocumentReference, observer: { + next?: (snapshot: DocumentSnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; +}): Unsubscribe; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query whose result set size is calculated. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to listen to. | +| observer | { next?: (snapshot: [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | Returns: -Promise<[AggregateQuerySnapshot](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<{ count: [AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<number>; }, AppModelType, DbModelType>> +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) -A Promise that will be resolved with the count; the count can be retrieved from `snapshot.data().count`, where `snapshot` is the `AggregateQuerySnapshot` to which the returned Promise resolves. +An unsubscribe function that can be called to cancel the snapshot listener. -### getDocs(query) {:#getdocs_4e56953} +### onSnapshot(reference, options, observer) {:#onsnapshot_86b6b9e} -Executes the query and returns the results as a `QuerySnapshot`. +Attaches a listener for `DocumentSnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. -Note: `getDocs()` attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. To specify this behavior, invoke [getDocsFromCache()](./firestore_.md#getdocsfromcache_4e56953) or [getDocsFromServer()](./firestore_.md#getdocsfromserver_4e56953). +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. Signature: ```typescript -export declare function getDocs(query: Query): Promise>; +export declare function onSnapshot(reference: DocumentReference, options: SnapshotListenOptions, observer: { + next?: (snapshot: DocumentSnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; +}): Unsubscribe; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to listen to. | +| options | [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | Options controlling the listen behavior. | +| observer | { next?: (snapshot: [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | Returns: -Promise<[QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>> +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) -A `Promise` that will be resolved with the results of the query. +An unsubscribe function that can be called to cancel the snapshot listener. -### getDocsFromCache(query) {:#getdocsfromcache_4e56953} +### onSnapshot(reference, onNext, onError, onCompletion) {:#onsnapshot_905f42c} -Executes the query and returns the results as a `QuerySnapshot` from cache. Returns an empty result set if no documents matching the query are currently cached. +Attaches a listener for `DocumentSnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. + +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. Signature: ```typescript -export declare function getDocsFromCache(query: Query): Promise>; +export declare function onSnapshot(reference: DocumentReference, onNext: (snapshot: DocumentSnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to listen to. | +| onNext | (snapshot: [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>) => void | A callback to be called every time a new DocumentSnapshot is available. | +| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void | A callback to be called if the listen fails or is cancelled. No further callbacks will occur. | +| onCompletion | () => void | Can be provided, but will not be called since streams are never ending. | Returns: -Promise<[QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>> +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) -A `Promise` that will be resolved with the results of the query. +An unsubscribe function that can be called to cancel the snapshot listener. -### getDocsFromServer(query) {:#getdocsfromserver_4e56953} +### onSnapshot(reference, options, onNext, onError, onCompletion) {:#onsnapshot_0c39991} -Executes the query and returns the results as a `QuerySnapshot` from the server. Returns an error if the network is not available. +Attaches a listener for `DocumentSnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. + +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. Signature: ```typescript -export declare function getDocsFromServer(query: Query): Promise>; +export declare function onSnapshot(reference: DocumentReference, options: SnapshotListenOptions, onNext: (snapshot: DocumentSnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to listen to. | +| options | [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | Options controlling the listen behavior. | +| onNext | (snapshot: [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>) => void | A callback to be called every time a new DocumentSnapshot is available. | +| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void | A callback to be called if the listen fails or is cancelled. No further callbacks will occur. | +| onCompletion | () => void | Can be provided, but will not be called since streams are never ending. | Returns: -Promise<[QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>> - -A `Promise` that will be resolved with the results of the query. +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) -### onSnapshot(query, observer) {:#onsnapshot_8d14049} +An unsubscribe function that can be called to cancel the snapshot listener. -Attaches a listener for `QuerySnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. +### setDoc(reference, data) {:#setdoc_ee215ad} -NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. +Writes to the document referred to by this `DocumentReference`. If the document does not yet exist, it will be created. Signature: ```typescript -export declare function onSnapshot(query: Query, observer: { - next?: (snapshot: QuerySnapshot) => void; - error?: (error: FirestoreError) => void; - complete?: () => void; -}): Unsubscribe; +export declare function setDoc(reference: DocumentReference, data: WithFieldValue): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query to listen to. | -| observer | { next?: (snapshot: [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to write. | +| data | [WithFieldValue](./firestore_.md#withfieldvalue)<AppModelType> | A map of the fields and values for the document. | Returns: -[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) - -An unsubscribe function that can be called to cancel the snapshot listener. +Promise<void> -### onSnapshot(query, options, observer) {:#onsnapshot_03dfff5} +A `Promise` resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline). -Attaches a listener for `QuerySnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. +### setDoc(reference, data, options) {:#setdoc_ff80739} -NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. +Writes to the document referred to by the specified `DocumentReference`. If the document does not yet exist, it will be created. If you provide `merge` or `mergeFields`, the provided data can be merged into an existing document. Signature: ```typescript -export declare function onSnapshot(query: Query, options: SnapshotListenOptions, observer: { - next?: (snapshot: QuerySnapshot) => void; - error?: (error: FirestoreError) => void; - complete?: () => void; -}): Unsubscribe; +export declare function setDoc(reference: DocumentReference, data: PartialWithFieldValue, options: SetOptions): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query to listen to. | -| options | [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | Options controlling the listen behavior. | -| observer | { next?: (snapshot: [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to write. | +| data | [PartialWithFieldValue](./firestore_.md#partialwithfieldvalue)<AppModelType> | A map of the fields and values for the document. | +| options | [SetOptions](./firestore_.md#setoptions) | An object to configure the set behavior. | Returns: -[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) - -An unsubscribe function that can be called to cancel the snapshot listener. +Promise<void> -### onSnapshot(query, onNext, onError, onCompletion) {:#onsnapshot_3ebfbe2} +A Promise resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline). -Attaches a listener for `QuerySnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. +### updateDoc(reference, data) {:#updatedoc_51a65e3} -NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. +Updates fields in the document referred to by the specified `DocumentReference`. The update will fail if applied to a document that does not exist. Signature: ```typescript -export declare function onSnapshot(query: Query, onNext: (snapshot: QuerySnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe; +export declare function updateDoc(reference: DocumentReference, data: UpdateData): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query to listen to. | -| onNext | (snapshot: [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>) => void | A callback to be called every time a new QuerySnapshot is available. | -| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void | A callback to be called if the listen fails or is cancelled. No further callbacks will occur. | -| onCompletion | () => void | Can be provided, but will not be called since streams are never ending. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to update. | +| data | [UpdateData](./firestore_.md#updatedata)<DbModelType> | An object containing the fields and values with which to update the document. Fields can contain dots to reference nested fields within the document. | Returns: -[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) +Promise<void> -An unsubscribe function that can be called to cancel the snapshot listener. +A `Promise` resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline). -### onSnapshot(query, options, onNext, onError, onCompletion) {:#onsnapshot_b8f9c47} +### updateDoc(reference, field, value, moreFieldsAndValues) {:#updatedoc_7c28659} -Attaches a listener for `QuerySnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. +Updates fields in the document referred to by the specified `DocumentReference` The update will fail if applied to a document that does not exist. -NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. +Nested fields can be updated by providing dot-separated field path strings or by providing `FieldPath` objects. Signature: ```typescript -export declare function onSnapshot(query: Query, options: SnapshotListenOptions, onNext: (snapshot: QuerySnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe; +export declare function updateDoc(reference: DocumentReference, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query to listen to. | -| options | [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | Options controlling the listen behavior. | -| onNext | (snapshot: [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>) => void | A callback to be called every time a new QuerySnapshot is available. | -| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void | A callback to be called if the listen fails or is cancelled. No further callbacks will occur. | -| onCompletion | () => void | Can be provided, but will not be called since streams are never ending. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to update. | +| field | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | The first field to update. | +| value | unknown | The first value. | +| moreFieldsAndValues | unknown\[\] | Additional key value pairs. | Returns: -[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) +Promise<void> -An unsubscribe function that can be called to cancel the snapshot listener. +A `Promise` resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline). -### query(query, compositeFilter, queryConstraints) {:#query_9f7b0f4} +## function(settings, ...) -Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. +### memoryLocalCache(settings) {:#memorylocalcache_05f4bf2} + +Creates an instance of `MemoryLocalCache`. The instance can be set to `FirestoreSettings.cache` to tell the SDK which cache layer to use. Signature: ```typescript -export declare function query(query: Query, compositeFilter: QueryCompositeFilterConstraint, ...queryConstraints: QueryNonFilterConstraint[]): Query; +export declare function memoryLocalCache(settings?: MemoryCacheSettings): MemoryLocalCache; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The [Query](./firestore_.query.md#query_class) instance to use as a base for the new constraints. | -| compositeFilter | [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) | The [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) to apply. Create [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) using [and()](./firestore_.md#and_e72c712) or [or()](./firestore_.md#or_e72c712). | -| queryConstraints | [QueryNonFilterConstraint](./firestore_.md#querynonfilterconstraint)\[\] | Additional [QueryNonFilterConstraint](./firestore_.md#querynonfilterconstraint)s to apply (e.g. [orderBy()](./firestore_.md#orderby_006d61f), [limit()](./firestore_.md#limit_ec46c78)). | +| settings | [MemoryCacheSettings](./firestore_.memorycachesettings.md#memorycachesettings_interface) | | Returns: -[Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> - -#### Exceptions +[MemoryLocalCache](./firestore_.memorylocalcache.md#memorylocalcache_interface) -if any of the provided query constraints cannot be combined with the existing or new constraints. +### memoryLruGarbageCollector(settings) {:#memorylrugarbagecollector_5ee014c} -### query(query, queryConstraints) {:#query_0f46da1} +Creates an instance of `MemoryLruGarbageCollector`. -Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. +A target size can be specified as part of the setting parameter. The collector will start deleting documents once the cache size exceeds the given size. The default cache size is 40MB (40 \* 1024 \* 1024 bytes). Signature: ```typescript -export declare function query(query: Query, ...queryConstraints: QueryConstraint[]): Query; +export declare function memoryLruGarbageCollector(settings?: { + cacheSizeBytes?: number; +}): MemoryLruGarbageCollector; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The [Query](./firestore_.query.md#query_class) instance to use as a base for the new constraints. | -| queryConstraints | [QueryConstraint](./firestore_.queryconstraint.md#queryconstraint_class)\[\] | The list of [QueryConstraint](./firestore_.queryconstraint.md#queryconstraint_class)s to apply. | +| settings | { cacheSizeBytes?: number; } | | Returns: -[Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> - -#### Exceptions - -if any of the provided query constraints cannot be combined with the existing or new constraints. +[MemoryLruGarbageCollector](./firestore_.memorylrugarbagecollector.md#memorylrugarbagecollector_interface) -## function(queryConstraints, ...) +### persistentLocalCache(settings) {:#persistentlocalcache_d312f71} -### and(queryConstraints) {:#and_e72c712} +Creates an instance of `PersistentLocalCache`. The instance can be set to `FirestoreSettings.cache` to tell the SDK which cache layer to use. -Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a conjunction of the given filter constraints. A conjunction filter includes a document if it satisfies all of the given filters. +Persistent cache cannot be used in a Node.js environment. Signature: ```typescript -export declare function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; +export declare function persistentLocalCache(settings?: PersistentCacheSettings): PersistentLocalCache; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| queryConstraints | [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)\[\] | Optional. The list of [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)s to perform a conjunction for. These must be created with calls to [where()](./firestore_.md#where_0fae4bf), [or()](./firestore_.md#or_e72c712), or [and()](./firestore_.md#and_e72c712). | +| settings | [PersistentCacheSettings](./firestore_.persistentcachesettings.md#persistentcachesettings_interface) | | Returns: -[QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) - -The newly created [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). +[PersistentLocalCache](./firestore_.persistentlocalcache.md#persistentlocalcache_interface) -### or(queryConstraints) {:#or_e72c712} +### persistentSingleTabManager(settings) {:#persistentsingletabmanager_c99c68d} -Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a disjunction of the given filter constraints. A disjunction filter includes a document if it satisfies any of the given filters. +Creates an instance of `PersistentSingleTabManager`. Signature: ```typescript -export declare function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; +export declare function persistentSingleTabManager(settings: PersistentSingleTabManagerSettings | undefined): PersistentSingleTabManager; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| queryConstraints | [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)\[\] | Optional. The list of [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)s to perform a disjunction for. These must be created with calls to [where()](./firestore_.md#where_0fae4bf), [or()](./firestore_.md#or_e72c712), or [and()](./firestore_.md#and_e72c712). | +| settings | [PersistentSingleTabManagerSettings](./firestore_.persistentsingletabmanagersettings.md#persistentsingletabmanagersettings_interface) \| undefined | Configures the created tab manager. | Returns: -[QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) - -The newly created [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). +[PersistentSingleTabManager](./firestore_.persistentsingletabmanager.md#persistentsingletabmanager_interface) -## function(reference, ...) +## function(snapshot, ...) -### addDoc(reference, data) {:#adddoc_6e783ff} +### endAt(snapshot) {:#endat_9a4477f} -Add a new document to specified `CollectionReference` with the given data, assigning it a document ID automatically. +Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided document (inclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. Signature: ```typescript -export declare function addDoc(reference: CollectionReference, data: WithFieldValue): Promise>; +export declare function endAt(snapshot: DocumentSnapshot): QueryEndAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to the collection to add this document to. | -| data | [WithFieldValue](./firestore_.md#withfieldvalue)<AppModelType> | An Object containing the data for the new document. | +| snapshot | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to end at. | Returns: -Promise<[DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType>> +[QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) -A `Promise` resolved with a `DocumentReference` pointing to the newly created document after it has been written to the backend (Note that it won't resolve while you're offline). +A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` -### collection(reference, path, pathSegments) {:#collection_568f98d} +### endBefore(snapshot) {:#endbefore_9a4477f} -Gets a `CollectionReference` instance that refers to a subcollection of `reference` at the specified relative path. +Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided document (exclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. Signature: ```typescript -export declare function collection(reference: CollectionReference, path: string, ...pathSegments: string[]): CollectionReference; +export declare function endBefore(snapshot: DocumentSnapshot): QueryEndAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to a collection. | -| path | string | A slash-separated path to a collection. | -| pathSegments | string\[\] | Additional path segments to apply relative to the first argument. | +| snapshot | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to end before. | Returns: -[CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> - -The `CollectionReference` instance. - -#### Exceptions +[QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) -If the final path has an even number of segments and does not point to a collection. +A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` -### collection(reference, path, pathSegments) {:#collection_70b4396} +### startAfter(snapshot) {:#startafter_9a4477f} -Gets a `CollectionReference` instance that refers to a subcollection of `reference` at the specified relative path. +Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided document (exclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. Signature: ```typescript -export declare function collection(reference: DocumentReference, path: string, ...pathSegments: string[]): CollectionReference; +export declare function startAfter(snapshot: DocumentSnapshot): QueryStartAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to a Firestore document. | -| path | string | A slash-separated path to a collection. | -| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | +| snapshot | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to start after. | Returns: -[CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> - -The `CollectionReference` instance. - -#### Exceptions +[QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) -If the final path has an even number of segments and does not point to a collection. +A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()` -### deleteDoc(reference) {:#deletedoc_4569087} +### startAt(snapshot) {:#startat_9a4477f} -Deletes the document referred to by the specified `DocumentReference`. +Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided document (inclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the `orderBy` of this query. Signature: ```typescript -export declare function deleteDoc(reference: DocumentReference): Promise; +export declare function startAt(snapshot: DocumentSnapshot): QueryStartAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to delete. | +| snapshot | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to start at. | Returns: -Promise<void> +[QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) -A Promise resolved once the document has been successfully deleted from the backend (note that it won't resolve while you're offline). +A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()`. -### doc(reference, path, pathSegments) {:#doc_568f98d} +## function(timestamp, ...) -Gets a `DocumentReference` instance that refers to a document within `reference` at the specified relative path. If no path is specified, an automatically-generated unique ID will be used for the returned `DocumentReference`. +### timestampAdd(timestamp, unit, amount) {:#timestampadd_87db576} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to a timestamp. + +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +timestampAdd(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); + +``` Signature: ```typescript -export declare function doc(reference: CollectionReference, path?: string, ...pathSegments: string[]): DocumentReference; +export declare function timestampAdd(timestamp: Constant, unit: Constant, amount: Constant): TimestampAdd; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to a collection. | -| path | string | A slash-separated path to a document. Has to be omitted to use auto-generated IDs. | -| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | +| timestamp | [Constant](./firestore_.constant.md#constant_class) | The expression representing the timestamp. | +| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | Returns: -[DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> +[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) -The `DocumentReference` instance. +### timestampAdd(timestamp, unit, amount) {:#timestampadd_46a2d7e} -#### Exceptions +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -If the final path has an odd number of segments and does not point to a document. +Creates an expression that adds a specified amount of time to a timestamp. -### doc(reference, path, pathSegments) {:#doc_70b4396} +```typescript +// Add 1 day to the 'timestamp' field. +timestampAdd(Field.of("timestamp"), "day", 1); -Gets a `DocumentReference` instance that refers to a document within `reference` at the specified relative path. +``` Signature: ```typescript -export declare function doc(reference: DocumentReference, path: string, ...pathSegments: string[]): DocumentReference; +export declare function timestampAdd(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to a Firestore document. | -| path | string | A slash-separated path to a document. | -| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | +| timestamp | [Constant](./firestore_.constant.md#constant_class) | The expression representing the timestamp. | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | +| amount | number | The amount of time to add. A new representing the resulting timestamp. | Returns: -[DocumentReference](./firestore_.documentreference.md#documentreference_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> - -The `DocumentReference` instance. +[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) -#### Exceptions +### timestampSub(timestamp, unit, amount) {:#timestampsub_87db576} -If the final path has an odd number of segments and does not point to a document. +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -### getDoc(reference) {:#getdoc_4569087} +Creates an expression that subtracts a specified amount of time from a timestamp. -Reads the document referred to by this `DocumentReference`. +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +timestampSub(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); -Note: `getDoc()` attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. To specify this behavior, invoke [getDocFromCache()](./firestore_.md#getdocfromcache_4569087) or [getDocFromServer()](./firestore_.md#getdocfromserver_4569087). +``` Signature: ```typescript -export declare function getDoc(reference: DocumentReference): Promise>; +export declare function timestampSub(timestamp: Constant, unit: Constant, amount: Constant): TimestampSub; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | The reference of the document to fetch. | +| timestamp | [Constant](./firestore_.constant.md#constant_class) | The expression representing the timestamp. | +| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | Returns: -Promise<[DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>> +[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) -A Promise resolved with a `DocumentSnapshot` containing the current document contents. +### timestampSub(timestamp, unit, amount) {:#timestampsub_46a2d7e} -### getDocFromCache(reference) {:#getdocfromcache_4569087} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Reads the document referred to by this `DocumentReference` from cache. Returns an error if the document is not currently cached. +Creates an expression that subtracts a specified amount of time from a timestamp. + +```typescript +// Subtract 1 day from the 'timestamp' field. +timestampSub(Field.of("timestamp"), "day", 1); + +``` Signature: ```typescript -export declare function getDocFromCache(reference: DocumentReference): Promise>; +export declare function timestampSub(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | | +| timestamp | [Constant](./firestore_.constant.md#constant_class) | The expression representing the timestamp. | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | +| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | Returns: -Promise<[DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>> +[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) -A `Promise` resolved with a `DocumentSnapshot` containing the current document contents. +## function(value, ...) -### getDocFromServer(reference) {:#getdocfromserver_4569087} +### avg(value) {:#avg_f83680a} -Reads the document referred to by this `DocumentReference` from the server. Returns an error if the network is not available. +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that calculates the average (mean) of values from an expression across multiple stage inputs. + +```typescript +// Calculate the average age of users +avg(Field.of("age")).as("averageAge"); + +``` Signature: ```typescript -export declare function getDocFromServer(reference: DocumentReference): Promise>; +export declare function avg(value: Constant): Avg; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | | +| value | [Constant](./firestore_.constant.md#constant_class) | The expression representing the values to average. A new representing the 'avg' aggregation. | Returns: -Promise<[DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>> +[Avg](./firestore_.avg.md#avg_class) -A `Promise` resolved with a `DocumentSnapshot` containing the current document contents. +### avg(value) {:#avg_7c807cd} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -### onSnapshot(reference, observer) {:#onsnapshot_0312fd7} +Creates an aggregation that calculates the average (mean) of a field's values across multiple stage inputs. -Attaches a listener for `DocumentSnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. +```typescript +// Calculate the average age of users +avg("age").as("averageAge"); -NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. +``` Signature: ```typescript -export declare function onSnapshot(reference: DocumentReference, observer: { - next?: (snapshot: DocumentSnapshot) => void; - error?: (error: FirestoreError) => void; - complete?: () => void; -}): Unsubscribe; +export declare function avg(value: string): Avg; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to listen to. | -| observer | { next?: (snapshot: [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | +| value | string | The name of the field containing numeric values to average. A new representing the 'avg' aggregation. | Returns: -[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) +[Avg](./firestore_.avg.md#avg_class) -An unsubscribe function that can be called to cancel the snapshot listener. +### countExpression(value) {:#countexpression_f83680a} -### onSnapshot(reference, options, observer) {:#onsnapshot_86b6b9e} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Attaches a listener for `DocumentSnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. +Creates an aggregation that counts the number of stage inputs with valid evaluations of the provided expression. -NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. +```typescript +// Count the number of items where the price is greater than 10 +count(Field.of("price").gt(10)).as("expensiveItemCount"); + +``` Signature: ```typescript -export declare function onSnapshot(reference: DocumentReference, options: SnapshotListenOptions, observer: { - next?: (snapshot: DocumentSnapshot) => void; - error?: (error: FirestoreError) => void; - complete?: () => void; -}): Unsubscribe; +export declare function countExpression(value: Constant): Count; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to listen to. | -| options | [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | Options controlling the listen behavior. | -| observer | { next?: (snapshot: [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | +| value | [Constant](./firestore_.constant.md#constant_class) | The expression to count. A new representing the 'count' aggregation. | Returns: -[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) +[Count](./firestore_.count.md#count_class) -An unsubscribe function that can be called to cancel the snapshot listener. +### countExpression(value) {:#countexpression_7c807cd} -### onSnapshot(reference, onNext, onError, onCompletion) {:#onsnapshot_905f42c} +Creates an aggregation that counts the number of stage inputs with valid evaluations of the provided field. -Attaches a listener for `DocumentSnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. +```typescript +// Count the total number of products +count("productId").as("totalProducts"); -NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. +``` Signature: ```typescript -export declare function onSnapshot(reference: DocumentReference, onNext: (snapshot: DocumentSnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe; +export declare function countExpression(value: string): Count; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to listen to. | -| onNext | (snapshot: [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>) => void | A callback to be called every time a new DocumentSnapshot is available. | -| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void | A callback to be called if the listen fails or is cancelled. No further callbacks will occur. | -| onCompletion | () => void | Can be provided, but will not be called since streams are never ending. | +| value | string | The name of the field to count. A new representing the 'count' aggregation. | Returns: -[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) +[Count](./firestore_.count.md#count_class) -An unsubscribe function that can be called to cancel the snapshot listener. +### exists(value) {:#exists_f83680a} -### onSnapshot(reference, options, onNext, onError, onCompletion) {:#onsnapshot_0c39991} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Attaches a listener for `DocumentSnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. +Creates an expression that checks if a field exists. -NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. +```typescript +// Check if the document has a field named "phoneNumber" +exists(Field.of("phoneNumber")); + +``` Signature: ```typescript -export declare function onSnapshot(reference: DocumentReference, options: SnapshotListenOptions, onNext: (snapshot: DocumentSnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe; +export declare function exists(value: Constant): Exists; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to listen to. | -| options | [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | Options controlling the listen behavior. | -| onNext | (snapshot: [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>) => void | A callback to be called every time a new DocumentSnapshot is available. | -| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void | A callback to be called if the listen fails or is cancelled. No further callbacks will occur. | -| onCompletion | () => void | Can be provided, but will not be called since streams are never ending. | +| value | [Constant](./firestore_.constant.md#constant_class) | An expression evaluates to the name of the field to check. A new representing the 'exists' check. | Returns: -[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) +[Exists](./firestore_.exists.md#exists_class) -An unsubscribe function that can be called to cancel the snapshot listener. +### isNan(value) {:#isnan_f83680a} -### setDoc(reference, data) {:#setdoc_ee215ad} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Writes to the document referred to by this `DocumentReference`. If the document does not yet exist, it will be created. +Creates an expression that checks if an expression evaluates to 'NaN' (Not a Number). + +```typescript +// Check if the result of a calculation is NaN +isNaN(Field.of("value").divide(0)); + +``` Signature: ```typescript -export declare function setDoc(reference: DocumentReference, data: WithFieldValue): Promise; +export declare function isNan(value: Constant): IsNan; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to write. | -| data | [WithFieldValue](./firestore_.md#withfieldvalue)<AppModelType> | A map of the fields and values for the document. | +| value | [Constant](./firestore_.constant.md#constant_class) | The expression to check. A new representing the 'isNaN' check. | Returns: -Promise<void> +[IsNan](./firestore_.isnan.md#isnan_class) -A `Promise` resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline). +### isNan(value) {:#isnan_7c807cd} -### setDoc(reference, data, options) {:#setdoc_ff80739} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Writes to the document referred to by the specified `DocumentReference`. If the document does not yet exist, it will be created. If you provide `merge` or `mergeFields`, the provided data can be merged into an existing document. +Creates an expression that checks if a field's value evaluates to 'NaN' (Not a Number). + +```typescript +// Check if the result of a calculation is NaN +isNaN("value"); + +``` Signature: ```typescript -export declare function setDoc(reference: DocumentReference, data: PartialWithFieldValue, options: SetOptions): Promise; +export declare function isNan(value: string): IsNan; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to write. | -| data | [PartialWithFieldValue](./firestore_.md#partialwithfieldvalue)<AppModelType> | A map of the fields and values for the document. | -| options | [SetOptions](./firestore_.md#setoptions) | An object to configure the set behavior. | +| value | string | The name of the field to check. A new representing the 'isNaN' check. | Returns: -Promise<void> +[IsNan](./firestore_.isnan.md#isnan_class) -A Promise resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline). +### max(value) {:#max_f83680a} -### updateDoc(reference, data) {:#updatedoc_51a65e3} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Updates fields in the document referred to by the specified `DocumentReference`. The update will fail if applied to a document that does not exist. +Creates an aggregation that finds the maximum value of an expression across multiple stage inputs. + +```typescript +// Find the highest score in a leaderboard +max(Field.of("score")).as("highestScore"); + +``` Signature: ```typescript -export declare function updateDoc(reference: DocumentReference, data: UpdateData): Promise; +export declare function max(value: Constant): Max; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to update. | -| data | [UpdateData](./firestore_.md#updatedata)<DbModelType> | An object containing the fields and values with which to update the document. Fields can contain dots to reference nested fields within the document. | +| value | [Constant](./firestore_.constant.md#constant_class) | The expression to find the maximum value of. A new representing the 'max' aggregation. | Returns: -Promise<void> +[Max](./firestore_.max.md#max_class) -A `Promise` resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline). +### max(value) {:#max_7c807cd} -### updateDoc(reference, field, value, moreFieldsAndValues) {:#updatedoc_7c28659} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Updates fields in the document referred to by the specified `DocumentReference` The update will fail if applied to a document that does not exist. +Creates an aggregation that finds the maximum value of a field across multiple stage inputs. -Nested fields can be updated by providing dot-separated field path strings or by providing `FieldPath` objects. +```typescript +// Find the highest score in a leaderboard +max("score").as("highestScore"); + +``` Signature: ```typescript -export declare function updateDoc(reference: DocumentReference, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise; +export declare function max(value: string): Max; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to update. | -| field | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | The first field to update. | -| value | unknown | The first value. | -| moreFieldsAndValues | unknown\[\] | Additional key value pairs. | +| value | string | The name of the field to find the maximum value of. A new representing the 'max' aggregation. | Returns: -Promise<void> +[Max](./firestore_.max.md#max_class) -A `Promise` resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline). +### min(value) {:#min_f83680a} -## function(settings, ...) +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -### memoryLocalCache(settings) {:#memorylocalcache_05f4bf2} +Creates an aggregation that finds the minimum value of an expression across multiple stage inputs. -Creates an instance of `MemoryLocalCache`. The instance can be set to `FirestoreSettings.cache` to tell the SDK which cache layer to use. +```typescript +// Find the lowest price of all products +min(Field.of("price")).as("lowestPrice"); + +``` Signature: ```typescript -export declare function memoryLocalCache(settings?: MemoryCacheSettings): MemoryLocalCache; +export declare function min(value: Constant): Min; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| settings | [MemoryCacheSettings](./firestore_.memorycachesettings.md#memorycachesettings_interface) | | +| value | [Constant](./firestore_.constant.md#constant_class) | The expression to find the minimum value of. A new representing the 'min' aggregation. | Returns: -[MemoryLocalCache](./firestore_.memorylocalcache.md#memorylocalcache_interface) +[Min](./firestore_.min.md#min_class) -### memoryLruGarbageCollector(settings) {:#memorylrugarbagecollector_5ee014c} +### min(value) {:#min_7c807cd} -Creates an instance of `MemoryLruGarbageCollector`. +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -A target size can be specified as part of the setting parameter. The collector will start deleting documents once the cache size exceeds the given size. The default cache size is 40MB (40 \* 1024 \* 1024 bytes). +Creates an aggregation that finds the minimum value of a field across multiple stage inputs. + +```typescript +// Find the lowest price of all products +min("price").as("lowestPrice"); + +``` Signature: ```typescript -export declare function memoryLruGarbageCollector(settings?: { - cacheSizeBytes?: number; -}): MemoryLruGarbageCollector; +export declare function min(value: string): Min; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| settings | { cacheSizeBytes?: number; } | | +| value | string | The name of the field to find the minimum value of. A new representing the 'min' aggregation. | Returns: -[MemoryLruGarbageCollector](./firestore_.memorylrugarbagecollector.md#memorylrugarbagecollector_interface) +[Min](./firestore_.min.md#min_class) -### persistentLocalCache(settings) {:#persistentlocalcache_d312f71} +### replaceAll(value, find, replace) {:#replaceall_f06d323} -Creates an instance of `PersistentLocalCache`. The instance can be set to `FirestoreSettings.cache` to tell the SDK which cache layer to use. +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Persistent cache cannot be used in a Node.js environment. +Creates an expression that replaces all occurrences of a substring within a string with another substring. + +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field. +replaceAll(Field.of("message"), "hello", "hi"); + +``` Signature: ```typescript -export declare function persistentLocalCache(settings?: PersistentCacheSettings): PersistentLocalCache; +export declare function replaceAll(value: Constant, find: string, replace: string): ReplaceAll; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| settings | [PersistentCacheSettings](./firestore_.persistentcachesettings.md#persistentcachesettings_interface) | | +| value | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to perform the replacement on. | +| find | string | The substring to search for. | +| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | Returns: -[PersistentLocalCache](./firestore_.persistentlocalcache.md#persistentlocalcache_interface) +[ReplaceAll](./firestore_.replaceall.md#replaceall_class) -### persistentSingleTabManager(settings) {:#persistentsingletabmanager_c99c68d} +### replaceAll(value, find, replace) {:#replaceall_26a7926} -Creates an instance of `PersistentSingleTabManager`. +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within a string with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field. +replaceAll(Field.of("message"), Field.of("findField"), Field.of("replaceField")); + +``` Signature: ```typescript -export declare function persistentSingleTabManager(settings: PersistentSingleTabManagerSettings | undefined): PersistentSingleTabManager; +export declare function replaceAll(value: Constant, find: Constant, replace: Constant): ReplaceAll; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| settings | [PersistentSingleTabManagerSettings](./firestore_.persistentsingletabmanagersettings.md#persistentsingletabmanagersettings_interface) \| undefined | Configures the created tab manager. | +| value | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to perform the replacement on. | +| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | Returns: -[PersistentSingleTabManager](./firestore_.persistentsingletabmanager.md#persistentsingletabmanager_interface) +[ReplaceAll](./firestore_.replaceall.md#replaceall_class) -## function(snapshot, ...) +### replaceFirst(value, find, replace) {:#replacefirst_f06d323} -### endAt(snapshot) {:#endat_9a4477f} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided document (inclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. +Creates an expression that replaces the first occurrence of a substring within a string with another substring. + +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field. +replaceFirst(Field.of("message"), "hello", "hi"); + +``` Signature: ```typescript -export declare function endAt(snapshot: DocumentSnapshot): QueryEndAtConstraint; +export declare function replaceFirst(value: Constant, find: string, replace: string): ReplaceFirst; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| snapshot | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to end at. | +| value | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to perform the replacement on. | +| find | string | The substring to search for. | +| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | Returns: -[QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) +[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) -A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` +### replaceFirst(value, find, replace) {:#replacefirst_26a7926} -### endBefore(snapshot) {:#endbefore_9a4477f} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided document (exclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. +Creates an expression that replaces the first occurrence of a substring within a string with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field. +replaceFirst(Field.of("message"), Field.of("findField"), Field.of("replaceField")); + +``` Signature: ```typescript -export declare function endBefore(snapshot: DocumentSnapshot): QueryEndAtConstraint; +export declare function replaceFirst(value: Constant, find: Constant, replace: Constant): ReplaceFirst; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| snapshot | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to end before. | +| value | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to perform the replacement on. | +| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | Returns: -[QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) +[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) -A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` +### sumExpression(value) {:#sumexpression_f83680a} -### startAfter(snapshot) {:#startafter_9a4477f} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided document (exclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. +Creates an aggregation that calculates the sum of values from an expression across multiple stage inputs. + +```typescript +// Calculate the total revenue from a set of orders +sum(Field.of("orderAmount")).as("totalRevenue"); + +``` Signature: ```typescript -export declare function startAfter(snapshot: DocumentSnapshot): QueryStartAtConstraint; +export declare function sumExpression(value: Constant): Sum; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| snapshot | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to start after. | +| value | [Constant](./firestore_.constant.md#constant_class) | The expression to sum up. A new representing the 'sum' aggregation. | Returns: -[QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) +[Sum](./firestore_.sum.md#sum_class) -A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()` +### sumExpression(value) {:#sumexpression_7c807cd} -### startAt(snapshot) {:#startat_9a4477f} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided document (inclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the `orderBy` of this query. +Creates an aggregation that calculates the sum of a field's values across multiple stage inputs. + +```typescript +// Calculate the total revenue from a set of orders +sum("orderAmount").as("totalRevenue"); + +``` Signature: ```typescript -export declare function startAt(snapshot: DocumentSnapshot): QueryStartAtConstraint; +export declare function sumExpression(value: string): Sum; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| snapshot | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to start at. | +| value | string | The name of the field containing numeric values to sum up. A new representing the 'sum' aggregation. | Returns: -[QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) - -A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()`. +[Sum](./firestore_.sum.md#sum_class) ## function(values, ...) @@ -2489,6 +9511,19 @@ Constant used to indicate the LRU garbage collection should be disabled. Set thi CACHE_SIZE_UNLIMITED = -1 ``` +## AccumulatorTarget + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +An accumulator target, which is an expression with an alias that also implements the Accumulator interface. + +Signature: + +```typescript +export declare type AccumulatorTarget = ExprWithAlias; +``` + ## AddPrefixToKeys Returns a new map where every key is prefixed with the outer key appended to a dot. @@ -2557,6 +9592,32 @@ The type of a `DocumentChange` may be 'added', 'removed', or 'modified'. export declare type DocumentChangeType = 'added' | 'removed' | 'modified'; ``` +## ExprType + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +An enumeration of the different types of expressions. + +Signature: + +```typescript +export declare type ExprType = 'Field' | 'Constant' | 'Function' | 'ListOfExprs' | 'ExprWithAlias'; +``` + +## FilterExpr + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +A filter expression, which is an expression that also implements the FilterCondition interface. + +Signature: + +```typescript +export declare type FilterExpr = Constant & FilterCondition; +``` + ## FirestoreErrorCode The set of Firestore status codes. The codes are the same at the ones exposed by gRPC here: https://github.com/grpc/grpc/blob/master/doc/statuscodes.md @@ -2685,6 +9746,19 @@ export declare type QueryFilterConstraint = QueryFieldFilterConstraint | QueryCo export declare type QueryNonFilterConstraint = QueryOrderByConstraint | QueryLimitConstraint | QueryStartAtConstraint | QueryEndAtConstraint; ``` +## SelectableExpr + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +A selectable expression, which is an expression that also implements the Selectable interface. + +Signature: + +```typescript +export declare type SelectableExpr = Constant & Selectable; +``` + ## SetOptions An options object that configures the behavior of [setDoc()](./firestore_lite.md#setdoc_ee215ad), and calls. These calls can be configured to perform granular merges instead of overwriting the target documents in their entirety by providing a `SetOptions` with `merge: true`. diff --git a/docs-devsite/firestore_.min.md b/docs-devsite/firestore_.min.md new file mode 100644 index 00000000000..56f71586256 --- /dev/null +++ b/docs-devsite/firestore_.min.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Min class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Min extends FirestoreFunction implements Accumulator +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [Accumulator](./firestore_.accumulator.md#accumulator_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value, distinct)](./firestore_.min.md#minconstructor) | | (BETA) Constructs a new instance of the Min class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [accumulator](./firestore_.min.md#minaccumulator) | | true | (BETA) | + +## Min.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Min` class + +Signature: + +```typescript +constructor(value: Constant, distinct: boolean); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_.constant.md#constant_class) | | +| distinct | boolean | | + +## Min.accumulator + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +accumulator: true; +``` diff --git a/docs-devsite/firestore_.mod.md b/docs-devsite/firestore_.mod.md new file mode 100644 index 00000000000..205eba4f984 --- /dev/null +++ b/docs-devsite/firestore_.mod.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Mod class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Mod extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_.mod.md#modconstructor) | | (BETA) Constructs a new instance of the Mod class | + +## Mod.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Mod` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | | +| right | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.multiply.md b/docs-devsite/firestore_.multiply.md new file mode 100644 index 00000000000..add30cd9359 --- /dev/null +++ b/docs-devsite/firestore_.multiply.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Multiply class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Multiply extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_.multiply.md#multiplyconstructor) | | (BETA) Constructs a new instance of the Multiply class | + +## Multiply.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Multiply` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | | +| right | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.neq.md b/docs-devsite/firestore_.neq.md new file mode 100644 index 00000000000..fc44be2b9d7 --- /dev/null +++ b/docs-devsite/firestore_.neq.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Neq class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Neq extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_.neq.md#neqconstructor) | | (BETA) Constructs a new instance of the Neq class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_.neq.md#neqfilterable) | | true | (BETA) | + +## Neq.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Neq` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | | +| right | [Constant](./firestore_.constant.md#constant_class) | | + +## Neq.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_.not.md b/docs-devsite/firestore_.not.md new file mode 100644 index 00000000000..1b1823f75e6 --- /dev/null +++ b/docs-devsite/firestore_.not.md @@ -0,0 +1,66 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Not class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Not extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr)](./firestore_.not.md#notconstructor) | | (BETA) Constructs a new instance of the Not class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_.not.md#notfilterable) | | true | (BETA) | + +## Not.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Not` class + +Signature: + +```typescript +constructor(expr: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | | + +## Not.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_.offset.md b/docs-devsite/firestore_.offset.md new file mode 100644 index 00000000000..5d3431f382d --- /dev/null +++ b/docs-devsite/firestore_.offset.md @@ -0,0 +1,64 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Offset class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Offset implements Stage +``` +Implements: [Stage](./firestore_.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(offset)](./firestore_.offset.md#offsetconstructor) | | (BETA) Constructs a new instance of the Offset class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_.offset.md#offsetname) | | string | (BETA) | + +## Offset.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Offset` class + +Signature: + +```typescript +constructor(offset: number); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| offset | number | | + +## Offset.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_.or.md b/docs-devsite/firestore_.or.md new file mode 100644 index 00000000000..d2c506893a0 --- /dev/null +++ b/docs-devsite/firestore_.or.md @@ -0,0 +1,17 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# or namespace +Signature: + +```typescript +export declare namespace or +``` diff --git a/docs-devsite/firestore_.ordering.md b/docs-devsite/firestore_.ordering.md new file mode 100644 index 00000000000..ce673370b28 --- /dev/null +++ b/docs-devsite/firestore_.ordering.md @@ -0,0 +1,51 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Ordering class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Represents an ordering criterion for sorting documents in a Firestore pipeline. + +You create `Ordering` instances using the `ascending` and `descending` helper functions. + +Signature: + +```typescript +export declare class Ordering +``` + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr, direction)](./firestore_.ordering.md#orderingconstructor) | | (BETA) Constructs a new instance of the Ordering class | + +## Ordering.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Ordering` class + +Signature: + +```typescript +constructor(expr: Constant, direction: 'ascending' | 'descending'); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | | +| direction | 'ascending' \| 'descending' | | + diff --git a/docs-devsite/firestore_.pipeline.md b/docs-devsite/firestore_.pipeline.md new file mode 100644 index 00000000000..18c109d2c83 --- /dev/null +++ b/docs-devsite/firestore_.pipeline.md @@ -0,0 +1,609 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Pipeline class +Signature: + +```typescript +export declare class Pipeline +``` + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [converter](./firestore_.pipeline.md#pipelineconverter) | | any | | +| [readUserData](./firestore_.pipeline.md#pipelinereaduserdata) | | any | Reads user data for each expression in the expressionMap. | +| [selectablesToMap](./firestore_.pipeline.md#pipelineselectablestomap) | | any | | +| [stages](./firestore_.pipeline.md#pipelinestages) | | any | | +| [userDataReader](./firestore_.pipeline.md#pipelineuserdatareader) | | any | | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [addFields(fields)](./firestore_.pipeline.md#pipelineaddfields) | | Adds new fields to outputs from previous stages.This stage allows you to compute values on-the-fly based on existing data from previous stages or constants. You can use this to create new fields or overwrite existing ones (if there is name overlaps).The added fields are defined using [Selectable](./firestore_.selectable.md#selectable_interface)s, which can be:- [Field](./firestore_.field.md#field_class): References an existing document field. - : Performs a calculation using functions like add, multiply with assigned aliases using .Example: +```typescript +firestore.pipeline().collection("books") +.addFields( +Field.of("rating").as("bookRating"), // Rename 'rating' to 'bookRating' +add(5, Field.of("quantity")).as("totalCost") // Calculate 'totalCost' +); + +``` + | +| [aggregate(accumulators)](./firestore_.pipeline.md#pipelineaggregate) | | Performs aggregation operations on the documents from previous stages.

This stage allows you to calculate aggregate values over a set of documents. You define the aggregations to perform using [AccumulatorTarget](./firestore_.md#accumulatortarget) expressions which are typically results of calling on [Accumulator](./firestore_.accumulator.md#accumulator_interface) instances.

Example: +```typescript +// Calculate the average rating and the total number of books +firestore.pipeline().collection("books") +.aggregate( +Field.of("rating").avg().as("averageRating"), +countAll().as("totalBooks") +); + +``` + | +| [aggregate(options)](./firestore_.pipeline.md#pipelineaggregate) | | Performs optionally grouped aggregation operations on the documents from previous stages.

This stage allows you to calculate aggregate values over a set of documents, optionally grouped by one or more fields or functions. You can specify:

  • \*\*Grouping Fields or Functions:\*\* One or more fields or functions to group the documents by. For each distinct combination of values in these fields, a separate group is created. If no grouping fields are provided, a single group containing all documents is used. Not specifying groups is the same as putting the entire inputs into one group.
  • \*\*Accumulators:\*\* One or more accumulation operations to perform within each group. These are defined using [AccumulatorTarget](./firestore_.md#accumulatortarget) expressions, which are typically created by calling on [Accumulator](./firestore_.accumulator.md#accumulator_interface) instances. Each aggregation calculates a value (e.g., sum, average, count) based on the documents within its group.

Example: +```typescript +// Calculate the average rating for each genre. +firestore.pipeline().collection("books") +.aggregate({ +accumulators: [avg(Field.of("rating")).as("avg_rating")] +groups: ["genre"] +}); + +``` + | +| [distinct(groups)](./firestore_.pipeline.md#pipelinedistinct) | | Returns a set of distinct values from the inputs to this stage.

This stage run through the results from previous stages to include only results with unique combinations of values ([Field](./firestore_.field.md#field_class), , etc).

The parameters to this stage are defined using [Selectable](./firestore_.selectable.md#selectable_interface) expressions or s:

  • : Name of an existing field
  • [Field](./firestore_.field.md#field_class): References an existing document field.
  • : Represents the result of a function with an assigned alias name using

Example: +```typescript +// Get a list of unique author names in uppercase and genre combinations. +firestore.pipeline().collection("books") +.distinct(toUppercase(Field.of("author")).as("authorName"), Field.of("genre"), "publishedAt") +.select("authorName"); + +``` + | +| [execute()](./firestore_.pipeline.md#pipelineexecute) | | Executes this pipeline and returns a Promise to represent the asynchronous operation.

The returned Promise can be used to track the progress of the pipeline execution and retrieve the results (or handle any errors) asynchronously.

The pipeline results are returned as a list of [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) objects. Each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) typically represents a single key/value map that has passed through all the stages of the pipeline, however this might differ depending on the stages involved in the pipeline. For example:

  • If there are no stages or only transformation stages, each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) represents a single document.
  • If there is an aggregation, only a single [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) is returned, representing the aggregated results over the entire dataset .
  • If there is an aggregation stage with grouping, each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) represents a distinct group and its associated aggregated values.

Example: +```typescript +const futureResults = await firestore.pipeline().collection("books") + .where(gt(Field.of("rating"), 4.5)) + .select("title", "author", "rating") + .execute(); + +``` + A Promise representing the asynchronous pipeline execution. | +| [findNearest(options)](./firestore_.pipeline.md#pipelinefindnearest) | | | +| [genericStage(name, params)](./firestore_.pipeline.md#pipelinegenericstage) | | Adds a generic stage to the pipeline.

This method provides a flexible way to extend the pipeline's functionality by adding custom stages. Each generic stage is defined by a unique name and a set of params that control its behavior.

Example (Assuming there is no "where" stage available in SDK): +```typescript +// Assume we don't have a built-in "where" stage +firestore.pipeline().collection("books") +.genericStage("where", [Field.of("published").lt(1900)]) // Custom "where" stage +.select("title", "author"); + +``` + | +| [limit(limit)](./firestore_.pipeline.md#pipelinelimit) | | Limits the maximum number of documents returned by previous stages to limit.

This stage is particularly useful when you want to retrieve a controlled subset of data from a potentially large result set. It's often used for:

  • \*\*Pagination:\*\* In combination with to retrieve specific pages of results.
  • \*\*Limiting Data Retrieval:\*\* To prevent excessive data transfer and improve performance, especially when dealing with large collections.

Example: +```typescript +// Limit the results to the top 10 highest-rated books +firestore.pipeline().collection("books") +.sort(Field.of("rating").descending()) +.limit(10); + +``` + | +| [offset(offset)](./firestore_.pipeline.md#pipelineoffset) | | Skips the first offset number of documents from the results of previous stages.

This stage is useful for implementing pagination in your pipelines, allowing you to retrieve results in chunks. It is typically used in conjunction with to control the size of each page.

Example: +```typescript +// Retrieve the second page of 20 results +firestore.pipeline().collection("books") +.sort(Field.of("published").descending()) +.offset(20) // Skip the first 20 results +.limit(20); // Take the next 20 results + +``` + | +| [select(selections)](./firestore_.pipeline.md#pipelineselect) | | Selects or creates a set of fields from the outputs of previous stages.

The selected fields are defined using [Selectable](./firestore_.selectable.md#selectable_interface) expressions, which can be:

  • : Name of an existing field
  • [Field](./firestore_.field.md#field_class): References an existing field.
  • : Represents the result of a function with an assigned alias name using

If no selections are provided, the output of this stage is empty. Use instead if only additions are desired.

Example: +```typescript +firestore.pipeline().collection("books") +.select( +"firstName", +Field.of("lastName"), +Field.of("address").toUppercase().as("upperAddress"), +); + +``` + | +| [sort(orderings)](./firestore_.pipeline.md#pipelinesort) | | Sorts the documents from previous stages based on one or more [Ordering](./firestore_.ordering.md#ordering_class) criteria.

This stage allows you to order the results of your pipeline. You can specify multiple [Ordering](./firestore_.ordering.md#ordering_class) instances to sort by multiple fields in ascending or descending order. If documents have the same value for a field used for sorting, the next specified ordering will be used. If all orderings result in equal comparison, the documents are considered equal and the order is unspecified.

Example: +```typescript +// Sort books by rating in descending order, and then by title in ascending order for books +// with the same rating +firestore.pipeline().collection("books") +.sort( +Ordering.of(Field.of("rating")).descending(), +Ordering.of(Field.of("title")) // Ascending order is the default +); + +``` + | +| [sort(options)](./firestore_.pipeline.md#pipelinesort) | | | +| [where(condition)](./firestore_.pipeline.md#pipelinewhere) | | Filters the documents from previous stages to only include those matching the specified [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface).

This stage allows you to apply conditions to the data, similar to a "WHERE" clause in SQL. You can filter documents based on their field values, using implementations of [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface), typically including but not limited to:

  • field comparators: , (less than), (greater than), etc.
  • logical operators: , , , etc.
  • advanced functions: , , etc.

Example: +```typescript +firestore.pipeline().collection("books") +.where( +and( +gt(Field.of("rating"), 4.0), // Filter for ratings greater than 4.0 +Field.of("genre").eq("Science Fiction") // Equivalent to gt("genre", "Science Fiction") +) +); + +``` + | + +## Pipeline.converter + +Signature: + +```typescript +converter: any; +``` + +## Pipeline.readUserData + +Reads user data for each expression in the expressionMap. + +Signature: + +```typescript +readUserData: any; +``` + +## Pipeline.selectablesToMap + +Signature: + +```typescript +selectablesToMap: any; +``` + +## Pipeline.stages + +Signature: + +```typescript +stages: any; +``` + +## Pipeline.userDataReader + +Signature: + +```typescript +userDataReader: any; +``` + +## Pipeline.addFields() + +Adds new fields to outputs from previous stages. + +This stage allows you to compute values on-the-fly based on existing data from previous stages or constants. You can use this to create new fields or overwrite existing ones (if there is name overlaps). + +The added fields are defined using [Selectable](./firestore_.selectable.md#selectable_interface)s, which can be: + +- [Field](./firestore_.field.md#field_class): References an existing document field. - : Performs a calculation using functions like `add`, `multiply` with assigned aliases using . + +Example: + +```typescript +firestore.pipeline().collection("books") +.addFields( +Field.of("rating").as("bookRating"), // Rename 'rating' to 'bookRating' +add(5, Field.of("quantity")).as("totalCost") // Calculate 'totalCost' +); + +``` + +Signature: + +```typescript +addFields(...fields: Selectable[]): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| fields | [Selectable](./firestore_.selectable.md#selectable_interface)\[\] | The fields to add to the documents, specified as [Selectable](./firestore_.selectable.md#selectable_interface)s. A new Pipeline object with this stage appended to the stage list. | + +Returns: + +[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.aggregate() + +Performs aggregation operations on the documents from previous stages. + +

This stage allows you to calculate aggregate values over a set of documents. You define the aggregations to perform using [AccumulatorTarget](./firestore_.md#accumulatortarget) expressions which are typically results of calling on [Accumulator](./firestore_.accumulator.md#accumulator_interface) instances. + +

Example: + +```typescript +// Calculate the average rating and the total number of books +firestore.pipeline().collection("books") +.aggregate( +Field.of("rating").avg().as("averageRating"), +countAll().as("totalBooks") +); + +``` + +Signature: + +```typescript +aggregate(...accumulators: AccumulatorTarget[]): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| accumulators | [AccumulatorTarget](./firestore_.md#accumulatortarget)\[\] | The [AccumulatorTarget](./firestore_.md#accumulatortarget) expressions, each wrapping an [Accumulator](./firestore_.accumulator.md#accumulator_interface) and provide a name for the accumulated results. A new Pipeline object with this stage appended to the stage list. | + +Returns: + +[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.aggregate() + +Performs optionally grouped aggregation operations on the documents from previous stages. + +

This stage allows you to calculate aggregate values over a set of documents, optionally grouped by one or more fields or functions. You can specify: + +

  • \*\*Grouping Fields or Functions:\*\* One or more fields or functions to group the documents by. For each distinct combination of values in these fields, a separate group is created. If no grouping fields are provided, a single group containing all documents is used. Not specifying groups is the same as putting the entire inputs into one group.
  • \*\*Accumulators:\*\* One or more accumulation operations to perform within each group. These are defined using [AccumulatorTarget](./firestore_.md#accumulatortarget) expressions, which are typically created by calling on [Accumulator](./firestore_.accumulator.md#accumulator_interface) instances. Each aggregation calculates a value (e.g., sum, average, count) based on the documents within its group.
+ +

Example: + +```typescript +// Calculate the average rating for each genre. +firestore.pipeline().collection("books") +.aggregate({ +accumulators: [avg(Field.of("rating")).as("avg_rating")] +groups: ["genre"] +}); + +``` + +Signature: + +```typescript +aggregate(options: { accumulators: AccumulatorTarget[]; groups?: Array; }): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| options | { accumulators: [AccumulatorTarget](./firestore_.md#accumulatortarget)\[\]; groups?: Array<string \| [Selectable](./firestore_.selectable.md#selectable_interface)>; } | | + +Returns: + +[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.distinct() + +Returns a set of distinct values from the inputs to this stage. + +

This stage run through the results from previous stages to include only results with unique combinations of values ([Field](./firestore_.field.md#field_class), , etc). + +

The parameters to this stage are defined using [Selectable](./firestore_.selectable.md#selectable_interface) expressions or s: + +

  • : Name of an existing field
  • [Field](./firestore_.field.md#field_class): References an existing document field.
  • : Represents the result of a function with an assigned alias name using
+ +

Example: + +```typescript +// Get a list of unique author names in uppercase and genre combinations. +firestore.pipeline().collection("books") +.distinct(toUppercase(Field.of("author")).as("authorName"), Field.of("genre"), "publishedAt") +.select("authorName"); + +``` + +Signature: + +```typescript +distinct(...groups: Array): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| groups | Array<string \| [Selectable](./firestore_.selectable.md#selectable_interface)> | | + +Returns: + +[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.execute() + +Executes this pipeline and returns a Promise to represent the asynchronous operation. + +

The returned Promise can be used to track the progress of the pipeline execution and retrieve the results (or handle any errors) asynchronously. + +

The pipeline results are returned as a list of [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) objects. Each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) typically represents a single key/value map that has passed through all the stages of the pipeline, however this might differ depending on the stages involved in the pipeline. For example: + +

  • If there are no stages or only transformation stages, each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) represents a single document.
  • If there is an aggregation, only a single [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) is returned, representing the aggregated results over the entire dataset .
  • If there is an aggregation stage with grouping, each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) represents a distinct group and its associated aggregated values.
+ +

Example: + +```typescript +const futureResults = await firestore.pipeline().collection("books") + .where(gt(Field.of("rating"), 4.5)) + .select("title", "author", "rating") + .execute(); + +``` + A Promise representing the asynchronous pipeline execution. + +Signature: + +```typescript +execute(): Promise>>; +``` +Returns: + +Promise<Array<[PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class)<AppModelType>>> + +## Pipeline.findNearest() + +Signature: + +```typescript +findNearest(options: FindNearestOptions): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| options | [FindNearestOptions](./firestore_.findnearestoptions.md#findnearestoptions_interface) | | + +Returns: + +[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.genericStage() + +Adds a generic stage to the pipeline. + +

This method provides a flexible way to extend the pipeline's functionality by adding custom stages. Each generic stage is defined by a unique `name` and a set of `params` that control its behavior. + +

Example (Assuming there is no "where" stage available in SDK): + +```typescript +// Assume we don't have a built-in "where" stage +firestore.pipeline().collection("books") +.genericStage("where", [Field.of("published").lt(1900)]) // Custom "where" stage +.select("title", "author"); + +``` + +Signature: + +```typescript +genericStage(name: string, params: any[]): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | The unique name of the generic stage to add. | +| params | any\[\] | A list of parameters to configure the generic stage's behavior. A new object with this stage appended to the stage list. | + +Returns: + +[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.limit() + +Limits the maximum number of documents returned by previous stages to `limit`. + +

This stage is particularly useful when you want to retrieve a controlled subset of data from a potentially large result set. It's often used for: + +

  • \*\*Pagination:\*\* In combination with to retrieve specific pages of results.
  • \*\*Limiting Data Retrieval:\*\* To prevent excessive data transfer and improve performance, especially when dealing with large collections.
+ +

Example: + +```typescript +// Limit the results to the top 10 highest-rated books +firestore.pipeline().collection("books") +.sort(Field.of("rating").descending()) +.limit(10); + +``` + +Signature: + +```typescript +limit(limit: number): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| limit | number | The maximum number of documents to return. A new Pipeline object with this stage appended to the stage list. | + +Returns: + +[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.offset() + +Skips the first `offset` number of documents from the results of previous stages. + +

This stage is useful for implementing pagination in your pipelines, allowing you to retrieve results in chunks. It is typically used in conjunction with to control the size of each page. + +

Example: + +```typescript +// Retrieve the second page of 20 results +firestore.pipeline().collection("books") +.sort(Field.of("published").descending()) +.offset(20) // Skip the first 20 results +.limit(20); // Take the next 20 results + +``` + +Signature: + +```typescript +offset(offset: number): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| offset | number | The number of documents to skip. A new Pipeline object with this stage appended to the stage list. | + +Returns: + +[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.select() + +Selects or creates a set of fields from the outputs of previous stages. + +

The selected fields are defined using [Selectable](./firestore_.selectable.md#selectable_interface) expressions, which can be: + +

  • : Name of an existing field
  • [Field](./firestore_.field.md#field_class): References an existing field.
  • : Represents the result of a function with an assigned alias name using
+ +

If no selections are provided, the output of this stage is empty. Use instead if only additions are desired. + +

Example: + +```typescript +firestore.pipeline().collection("books") +.select( +"firstName", +Field.of("lastName"), +Field.of("address").toUppercase().as("upperAddress"), +); + +``` + +Signature: + +```typescript +select(...selections: Array): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| selections | Array<[Selectable](./firestore_.selectable.md#selectable_interface) \| string> | The fields to include in the output documents, specified as [Selectable](./firestore_.selectable.md#selectable_interface) expressions or values representing field names. A new Pipeline object with this stage appended to the stage list. | + +Returns: + +[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.sort() + +Sorts the documents from previous stages based on one or more [Ordering](./firestore_.ordering.md#ordering_class) criteria. + +

This stage allows you to order the results of your pipeline. You can specify multiple [Ordering](./firestore_.ordering.md#ordering_class) instances to sort by multiple fields in ascending or descending order. If documents have the same value for a field used for sorting, the next specified ordering will be used. If all orderings result in equal comparison, the documents are considered equal and the order is unspecified. + +

Example: + +```typescript +// Sort books by rating in descending order, and then by title in ascending order for books +// with the same rating +firestore.pipeline().collection("books") +.sort( +Ordering.of(Field.of("rating")).descending(), +Ordering.of(Field.of("title")) // Ascending order is the default +); + +``` + +Signature: + +```typescript +sort(...orderings: Ordering[]): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| orderings | [Ordering](./firestore_.ordering.md#ordering_class)\[\] | | + +Returns: + +[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.sort() + +Signature: + +```typescript +sort(options: { orderings: Ordering[]; }): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| options | { orderings: [Ordering](./firestore_.ordering.md#ordering_class)\[\]; } | | + +Returns: + +[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.where() + +Filters the documents from previous stages to only include those matching the specified [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface). + +

This stage allows you to apply conditions to the data, similar to a "WHERE" clause in SQL. You can filter documents based on their field values, using implementations of [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface), typically including but not limited to: + +

  • field comparators: , (less than), (greater than), etc.
  • logical operators: , , , etc.
  • advanced functions: , , etc.
+ +

Example: + +```typescript +firestore.pipeline().collection("books") +.where( +and( +gt(Field.of("rating"), 4.0), // Filter for ratings greater than 4.0 +Field.of("genre").eq("Science Fiction") // Equivalent to gt("genre", "Science Fiction") +) +); + +``` + +Signature: + +```typescript +where(condition: FilterCondition & Constant): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| condition | [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) & [Constant](./firestore_.constant.md#constant_class) | The [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) to apply. A new Pipeline object with this stage appended to the stage list. | + +Returns: + +[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> + diff --git a/docs-devsite/firestore_.pipelineresult.md b/docs-devsite/firestore_.pipelineresult.md new file mode 100644 index 00000000000..a035e4375ff --- /dev/null +++ b/docs-devsite/firestore_.pipelineresult.md @@ -0,0 +1,184 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# PipelineResult class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +A PipelineResult contains data read from a Firestore Pipeline. The data can be extracted with the or methods. + +

If the PipelineResult represents a non-document result, `ref` will return a undefined value. + +Signature: + +```typescript +export declare class PipelineResult +``` + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [createTime](./firestore_.pipelineresult.md#pipelineresultcreatetime) | | [Timestamp](./firestore_.timestamp.md#timestamp_class) \| undefined | (BETA) The time the document was created. Undefined if this result is not a document. {Timestamp\|undefined} | +| [executionTime](./firestore_.pipelineresult.md#pipelineresultexecutiontime) | | [Timestamp](./firestore_.timestamp.md#timestamp_class) | (BETA) The time at which the pipeline producing this result is executed. {Timestamp} | +| [id](./firestore_.pipelineresult.md#pipelineresultid) | | string \| undefined | (BETA) The ID of the document for which this PipelineResult contains data, if it is a document; otherwise undefined. {string} | +| [ref](./firestore_.pipelineresult.md#pipelineresultref) | | [DocumentReference](./firestore_.documentreference.md#documentreference_class) \| undefined | (BETA) The reference of the document, if it is a document; otherwise undefined. | +| [updateTime](./firestore_.pipelineresult.md#pipelineresultupdatetime) | | [Timestamp](./firestore_.timestamp.md#timestamp_class) \| undefined | (BETA) The time the document was last updated (at the time the snapshot was generated). Undefined if this result is not a document. {Timestamp\|undefined} | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [data()](./firestore_.pipelineresult.md#pipelineresultdata) | | (BETA) Retrieves all fields in the result as an object. Returns 'undefined' if the document doesn't exist. | +| [get(fieldPath)](./firestore_.pipelineresult.md#pipelineresultget) | | (BETA) Retrieves the field specified by field. | + +## PipelineResult.createTime + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +The time the document was created. Undefined if this result is not a document. + + {Timestamp\|undefined} + +Signature: + +```typescript +get createTime(): Timestamp | undefined; +``` + +## PipelineResult.executionTime + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +The time at which the pipeline producing this result is executed. + + {Timestamp} + +Signature: + +```typescript +get executionTime(): Timestamp; +``` + +## PipelineResult.id + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +The ID of the document for which this PipelineResult contains data, if it is a document; otherwise `undefined`. + + {string} + +Signature: + +```typescript +get id(): string | undefined; +``` + +## PipelineResult.ref + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +The reference of the document, if it is a document; otherwise `undefined`. + +Signature: + +```typescript +get ref(): DocumentReference | undefined; +``` + +## PipelineResult.updateTime + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +The time the document was last updated (at the time the snapshot was generated). Undefined if this result is not a document. + + {Timestamp\|undefined} + +Signature: + +```typescript +get updateTime(): Timestamp | undefined; +``` + +## PipelineResult.data() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Retrieves all fields in the result as an object. Returns 'undefined' if the document doesn't exist. + +Signature: + +```typescript +data(): AppModelType | undefined; +``` +Returns: + +AppModelType \| undefined + +{T\|undefined} An object containing all fields in the document or 'undefined' if the document doesn't exist. + +### Example + + +``` +let p = firestore.pipeline().collection('col'); + +p.execute().then(results => { + let data = results[0].data(); + console.log(`Retrieved data: ${JSON.stringify(data)}`); +}); + +``` + +## PipelineResult.get() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Retrieves the field specified by `field`. + +Signature: + +```typescript +get(fieldPath: string | FieldPath): any; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| fieldPath | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | | + +Returns: + +any + +{\*} The data at the specified field location or undefined if no such field exists. + +### Example + + +``` +let p = firestore.pipeline().collection('col'); + +p.execute().then(results => { + let field = results[0].get('a.b'); + console.log(`Retrieved field value: ${field}`); +}); + +``` + diff --git a/docs-devsite/firestore_.pipelinesource.md b/docs-devsite/firestore_.pipelinesource.md new file mode 100644 index 00000000000..cbe4150b1fe --- /dev/null +++ b/docs-devsite/firestore_.pipelinesource.md @@ -0,0 +1,109 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# PipelineSource class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Represents the source of a Firestore [Pipeline](./firestore_.pipeline.md#pipeline_class). + +Signature: + +```typescript +export declare class PipelineSource +``` + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [collection(collectionPath)](./firestore_.pipelinesource.md#pipelinesourcecollection) | | (BETA) | +| [collectionGroup(collectionId)](./firestore_.pipelinesource.md#pipelinesourcecollectiongroup) | | (BETA) | +| [database()](./firestore_.pipelinesource.md#pipelinesourcedatabase) | | (BETA) | +| [documents(docs)](./firestore_.pipelinesource.md#pipelinesourcedocuments) | | (BETA) | + +## PipelineSource.collection() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +collection(collectionPath: string): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| collectionPath | string | | + +Returns: + +[Pipeline](./firestore_.pipeline.md#pipeline_class) + +## PipelineSource.collectionGroup() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +collectionGroup(collectionId: string): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| collectionId | string | | + +Returns: + +[Pipeline](./firestore_.pipeline.md#pipeline_class) + +## PipelineSource.database() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +database(): Pipeline; +``` +Returns: + +[Pipeline](./firestore_.pipeline.md#pipeline_class) + +## PipelineSource.documents() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +documents(docs: DocumentReference[]): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| docs | [DocumentReference](./firestore_.documentreference.md#documentreference_class)\[\] | | + +Returns: + +[Pipeline](./firestore_.pipeline.md#pipeline_class) + diff --git a/docs-devsite/firestore_.query.md b/docs-devsite/firestore_.query.md index 086d117aa1e..f4d0c8d20e1 100644 --- a/docs-devsite/firestore_.query.md +++ b/docs-devsite/firestore_.query.md @@ -36,6 +36,7 @@ export declare class QueryNewDbModelType and your custom type NewAppModelType. | @@ -79,6 +80,19 @@ The type of this Firestore reference. readonly type: 'query' | 'collection'; ``` +## Query.pipeline() + +Pipeline query. + +Signature: + +```typescript +pipeline(): Pipeline; +``` +Returns: + +[Pipeline](./firestore_.pipeline.md#pipeline_class) + ## Query.withConverter() Removes the current converter. diff --git a/docs-devsite/firestore_.querycompositefilterconstraint.md b/docs-devsite/firestore_.querycompositefilterconstraint.md index bb00c3bf2b3..61afef2b6b7 100644 --- a/docs-devsite/firestore_.querycompositefilterconstraint.md +++ b/docs-devsite/firestore_.querycompositefilterconstraint.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # QueryCompositeFilterConstraint class -A `QueryCompositeFilterConstraint` is used to narrow the set of documents returned by a Firestore query by performing the logical OR or AND of multiple [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class)s or [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class)s. `QueryCompositeFilterConstraint`s are created by invoking [or()](./firestore_.md#or_e72c712) or [and()](./firestore_.md#and_e72c712) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the `QueryCompositeFilterConstraint`. +A `QueryCompositeFilterConstraint` is used to narrow the set of documents returned by a Firestore query by performing the logical OR or AND of multiple [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class)s or [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class)s. `QueryCompositeFilterConstraint`s are created by invoking or and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the `QueryCompositeFilterConstraint`. Signature: diff --git a/docs-devsite/firestore_.regexcontains.md b/docs-devsite/firestore_.regexcontains.md new file mode 100644 index 00000000000..b9be8441054 --- /dev/null +++ b/docs-devsite/firestore_.regexcontains.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# RegexContains class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class RegexContains extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr, pattern)](./firestore_.regexcontains.md#regexcontainsconstructor) | | (BETA) Constructs a new instance of the RegexContains class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_.regexcontains.md#regexcontainsfilterable) | | true | (BETA) | + +## RegexContains.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `RegexContains` class + +Signature: + +```typescript +constructor(expr: Constant, pattern: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | | +| pattern | [Constant](./firestore_.constant.md#constant_class) | | + +## RegexContains.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_.regexmatch.md b/docs-devsite/firestore_.regexmatch.md new file mode 100644 index 00000000000..5a8ccf289aa --- /dev/null +++ b/docs-devsite/firestore_.regexmatch.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# RegexMatch class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class RegexMatch extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr, pattern)](./firestore_.regexmatch.md#regexmatchconstructor) | | (BETA) Constructs a new instance of the RegexMatch class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_.regexmatch.md#regexmatchfilterable) | | true | (BETA) | + +## RegexMatch.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `RegexMatch` class + +Signature: + +```typescript +constructor(expr: Constant, pattern: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | | +| pattern | [Constant](./firestore_.constant.md#constant_class) | | + +## RegexMatch.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_.replaceall.md b/docs-devsite/firestore_.replaceall.md new file mode 100644 index 00000000000..592c709eac7 --- /dev/null +++ b/docs-devsite/firestore_.replaceall.md @@ -0,0 +1,50 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ReplaceAll class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ReplaceAll extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value, find, replace)](./firestore_.replaceall.md#replaceallconstructor) | | (BETA) Constructs a new instance of the ReplaceAll class | + +## ReplaceAll.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ReplaceAll` class + +Signature: + +```typescript +constructor(value: Constant, find: Constant, replace: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_.constant.md#constant_class) | | +| find | [Constant](./firestore_.constant.md#constant_class) | | +| replace | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.replacefirst.md b/docs-devsite/firestore_.replacefirst.md new file mode 100644 index 00000000000..d79957a1f6b --- /dev/null +++ b/docs-devsite/firestore_.replacefirst.md @@ -0,0 +1,50 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ReplaceFirst class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ReplaceFirst extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value, find, replace)](./firestore_.replacefirst.md#replacefirstconstructor) | | (BETA) Constructs a new instance of the ReplaceFirst class | + +## ReplaceFirst.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ReplaceFirst` class + +Signature: + +```typescript +constructor(value: Constant, find: Constant, replace: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_.constant.md#constant_class) | | +| find | [Constant](./firestore_.constant.md#constant_class) | | +| replace | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.reverse.md b/docs-devsite/firestore_.reverse.md new file mode 100644 index 00000000000..f6d8f61a312 --- /dev/null +++ b/docs-devsite/firestore_.reverse.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Reverse class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Reverse extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value)](./firestore_.reverse.md#reverseconstructor) | | (BETA) Constructs a new instance of the Reverse class | + +## Reverse.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Reverse` class + +Signature: + +```typescript +constructor(value: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.select.md b/docs-devsite/firestore_.select.md new file mode 100644 index 00000000000..42fe74ce7db --- /dev/null +++ b/docs-devsite/firestore_.select.md @@ -0,0 +1,64 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Select class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Select implements Stage +``` +Implements: [Stage](./firestore_.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(projections)](./firestore_.select.md#selectconstructor) | | (BETA) Constructs a new instance of the Select class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_.select.md#selectname) | | string | (BETA) | + +## Select.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Select` class + +Signature: + +```typescript +constructor(projections: Map); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| projections | Map<string, [Constant](./firestore_.constant.md#constant_class)> | | + +## Select.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_.selectable.md b/docs-devsite/firestore_.selectable.md new file mode 100644 index 00000000000..0fb32592d4a --- /dev/null +++ b/docs-devsite/firestore_.selectable.md @@ -0,0 +1,39 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Selectable interface +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +An interface that represents a selectable expression. + +Signature: + +```typescript +export declare interface Selectable +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [selectable](./firestore_.selectable.md#selectableselectable) | true | (BETA) | + +## Selectable.selectable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +selectable: true; +``` diff --git a/docs-devsite/firestore_.sort.md b/docs-devsite/firestore_.sort.md new file mode 100644 index 00000000000..fa7e1d119fc --- /dev/null +++ b/docs-devsite/firestore_.sort.md @@ -0,0 +1,64 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Sort class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Sort implements Stage +``` +Implements: [Stage](./firestore_.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(orders)](./firestore_.sort.md#sortconstructor) | | (BETA) Constructs a new instance of the Sort class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_.sort.md#sortname) | | string | (BETA) | + +## Sort.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Sort` class + +Signature: + +```typescript +constructor(orders: Ordering[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| orders | [Ordering](./firestore_.ordering.md#ordering_class)\[\] | | + +## Sort.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_.stage.md b/docs-devsite/firestore_.stage.md new file mode 100644 index 00000000000..34a94a3d4ba --- /dev/null +++ b/docs-devsite/firestore_.stage.md @@ -0,0 +1,38 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Stage interface +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare interface Stage +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [name](./firestore_.stage.md#stagename) | string | (BETA) | + +## Stage.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_.startswith.md b/docs-devsite/firestore_.startswith.md new file mode 100644 index 00000000000..e12aca31300 --- /dev/null +++ b/docs-devsite/firestore_.startswith.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# StartsWith class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class StartsWith extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr, prefix)](./firestore_.startswith.md#startswithconstructor) | | (BETA) Constructs a new instance of the StartsWith class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_.startswith.md#startswithfilterable) | | true | (BETA) | + +## StartsWith.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `StartsWith` class + +Signature: + +```typescript +constructor(expr: Constant, prefix: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | | +| prefix | [Constant](./firestore_.constant.md#constant_class) | | + +## StartsWith.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_.strconcat.md b/docs-devsite/firestore_.strconcat.md new file mode 100644 index 00000000000..5d044f31561 --- /dev/null +++ b/docs-devsite/firestore_.strconcat.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# StrConcat class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class StrConcat extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(first, rest)](./firestore_.strconcat.md#strconcatconstructor) | | (BETA) Constructs a new instance of the StrConcat class | + +## StrConcat.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `StrConcat` class + +Signature: + +```typescript +constructor(first: Constant, rest: Constant[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| first | [Constant](./firestore_.constant.md#constant_class) | | +| rest | [Constant](./firestore_.constant.md#constant_class)\[\] | | + diff --git a/docs-devsite/firestore_.strcontains.md b/docs-devsite/firestore_.strcontains.md new file mode 100644 index 00000000000..a704676ad7a --- /dev/null +++ b/docs-devsite/firestore_.strcontains.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# StrContains class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class StrContains extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr, substring)](./firestore_.strcontains.md#strcontainsconstructor) | | (BETA) Constructs a new instance of the StrContains class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_.strcontains.md#strcontainsfilterable) | | true | (BETA) | + +## StrContains.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `StrContains` class + +Signature: + +```typescript +constructor(expr: Constant, substring: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | | +| substring | [Constant](./firestore_.constant.md#constant_class) | | + +## StrContains.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_.subtract.md b/docs-devsite/firestore_.subtract.md new file mode 100644 index 00000000000..d72563e8471 --- /dev/null +++ b/docs-devsite/firestore_.subtract.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Subtract class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Subtract extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_.subtract.md#subtractconstructor) | | (BETA) Constructs a new instance of the Subtract class | + +## Subtract.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Subtract` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_.constant.md#constant_class) | | +| right | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.sum.md b/docs-devsite/firestore_.sum.md new file mode 100644 index 00000000000..41d11c83b0c --- /dev/null +++ b/docs-devsite/firestore_.sum.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Sum class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Sum extends FirestoreFunction implements Accumulator +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [Accumulator](./firestore_.accumulator.md#accumulator_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value, distinct)](./firestore_.sum.md#sumconstructor) | | (BETA) Constructs a new instance of the Sum class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [accumulator](./firestore_.sum.md#sumaccumulator) | | true | (BETA) | + +## Sum.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Sum` class + +Signature: + +```typescript +constructor(value: Constant, distinct: boolean); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_.constant.md#constant_class) | | +| distinct | boolean | | + +## Sum.accumulator + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +accumulator: true; +``` diff --git a/docs-devsite/firestore_.timestampadd.md b/docs-devsite/firestore_.timestampadd.md new file mode 100644 index 00000000000..9e563f5f364 --- /dev/null +++ b/docs-devsite/firestore_.timestampadd.md @@ -0,0 +1,50 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# TimestampAdd class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class TimestampAdd extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(timestamp, unit, amount)](./firestore_.timestampadd.md#timestampaddconstructor) | | (BETA) Constructs a new instance of the TimestampAdd class | + +## TimestampAdd.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `TimestampAdd` class + +Signature: + +```typescript +constructor(timestamp: Constant, unit: Constant, amount: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| timestamp | [Constant](./firestore_.constant.md#constant_class) | | +| unit | [Constant](./firestore_.constant.md#constant_class) | | +| amount | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.timestampsub.md b/docs-devsite/firestore_.timestampsub.md new file mode 100644 index 00000000000..a3a28e60c1b --- /dev/null +++ b/docs-devsite/firestore_.timestampsub.md @@ -0,0 +1,50 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# TimestampSub class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class TimestampSub extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(timestamp, unit, amount)](./firestore_.timestampsub.md#timestampsubconstructor) | | (BETA) Constructs a new instance of the TimestampSub class | + +## TimestampSub.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `TimestampSub` class + +Signature: + +```typescript +constructor(timestamp: Constant, unit: Constant, amount: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| timestamp | [Constant](./firestore_.constant.md#constant_class) | | +| unit | [Constant](./firestore_.constant.md#constant_class) | | +| amount | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.timestamptounixmicros.md b/docs-devsite/firestore_.timestamptounixmicros.md new file mode 100644 index 00000000000..3075048c254 --- /dev/null +++ b/docs-devsite/firestore_.timestamptounixmicros.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# TimestampToUnixMicros class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class TimestampToUnixMicros extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(input)](./firestore_.timestamptounixmicros.md#timestamptounixmicrosconstructor) | | (BETA) Constructs a new instance of the TimestampToUnixMicros class | + +## TimestampToUnixMicros.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `TimestampToUnixMicros` class + +Signature: + +```typescript +constructor(input: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| input | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.timestamptounixmillis.md b/docs-devsite/firestore_.timestamptounixmillis.md new file mode 100644 index 00000000000..0098c5932dd --- /dev/null +++ b/docs-devsite/firestore_.timestamptounixmillis.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# TimestampToUnixMillis class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class TimestampToUnixMillis extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(input)](./firestore_.timestamptounixmillis.md#timestamptounixmillisconstructor) | | (BETA) Constructs a new instance of the TimestampToUnixMillis class | + +## TimestampToUnixMillis.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `TimestampToUnixMillis` class + +Signature: + +```typescript +constructor(input: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| input | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.timestamptounixseconds.md b/docs-devsite/firestore_.timestamptounixseconds.md new file mode 100644 index 00000000000..49b2dd97664 --- /dev/null +++ b/docs-devsite/firestore_.timestamptounixseconds.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# TimestampToUnixSeconds class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class TimestampToUnixSeconds extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(input)](./firestore_.timestamptounixseconds.md#timestamptounixsecondsconstructor) | | (BETA) Constructs a new instance of the TimestampToUnixSeconds class | + +## TimestampToUnixSeconds.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `TimestampToUnixSeconds` class + +Signature: + +```typescript +constructor(input: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| input | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.tolower.md b/docs-devsite/firestore_.tolower.md new file mode 100644 index 00000000000..b5b29215bcd --- /dev/null +++ b/docs-devsite/firestore_.tolower.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ToLower class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ToLower extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr)](./firestore_.tolower.md#tolowerconstructor) | | (BETA) Constructs a new instance of the ToLower class | + +## ToLower.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ToLower` class + +Signature: + +```typescript +constructor(expr: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.toupper.md b/docs-devsite/firestore_.toupper.md new file mode 100644 index 00000000000..bfd5fb607b4 --- /dev/null +++ b/docs-devsite/firestore_.toupper.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ToUpper class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ToUpper extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr)](./firestore_.toupper.md#toupperconstructor) | | (BETA) Constructs a new instance of the ToUpper class | + +## ToUpper.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ToUpper` class + +Signature: + +```typescript +constructor(expr: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.trim.md b/docs-devsite/firestore_.trim.md new file mode 100644 index 00000000000..bfbce9afbed --- /dev/null +++ b/docs-devsite/firestore_.trim.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Trim class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Trim extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr)](./firestore_.trim.md#trimconstructor) | | (BETA) Constructs a new instance of the Trim class | + +## Trim.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Trim` class + +Signature: + +```typescript +constructor(expr: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.unixmicrostotimestamp.md b/docs-devsite/firestore_.unixmicrostotimestamp.md new file mode 100644 index 00000000000..cd40de9afb3 --- /dev/null +++ b/docs-devsite/firestore_.unixmicrostotimestamp.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# UnixMicrosToTimestamp class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class UnixMicrosToTimestamp extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(input)](./firestore_.unixmicrostotimestamp.md#unixmicrostotimestampconstructor) | | (BETA) Constructs a new instance of the UnixMicrosToTimestamp class | + +## UnixMicrosToTimestamp.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `UnixMicrosToTimestamp` class + +Signature: + +```typescript +constructor(input: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| input | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.unixmillistotimestamp.md b/docs-devsite/firestore_.unixmillistotimestamp.md new file mode 100644 index 00000000000..554deb16305 --- /dev/null +++ b/docs-devsite/firestore_.unixmillistotimestamp.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# UnixMillisToTimestamp class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class UnixMillisToTimestamp extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(input)](./firestore_.unixmillistotimestamp.md#unixmillistotimestampconstructor) | | (BETA) Constructs a new instance of the UnixMillisToTimestamp class | + +## UnixMillisToTimestamp.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `UnixMillisToTimestamp` class + +Signature: + +```typescript +constructor(input: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| input | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.unixsecondstotimestamp.md b/docs-devsite/firestore_.unixsecondstotimestamp.md new file mode 100644 index 00000000000..935b579ca0b --- /dev/null +++ b/docs-devsite/firestore_.unixsecondstotimestamp.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# UnixSecondsToTimestamp class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class UnixSecondsToTimestamp extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(input)](./firestore_.unixsecondstotimestamp.md#unixsecondstotimestampconstructor) | | (BETA) Constructs a new instance of the UnixSecondsToTimestamp class | + +## UnixSecondsToTimestamp.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `UnixSecondsToTimestamp` class + +Signature: + +```typescript +constructor(input: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| input | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.vectorlength.md b/docs-devsite/firestore_.vectorlength.md new file mode 100644 index 00000000000..0a7097bdbdd --- /dev/null +++ b/docs-devsite/firestore_.vectorlength.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# VectorLength class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class VectorLength extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value)](./firestore_.vectorlength.md#vectorlengthconstructor) | | (BETA) Constructs a new instance of the VectorLength class | + +## VectorLength.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `VectorLength` class + +Signature: + +```typescript +constructor(value: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_.where.md b/docs-devsite/firestore_.where.md new file mode 100644 index 00000000000..a6cca720fb8 --- /dev/null +++ b/docs-devsite/firestore_.where.md @@ -0,0 +1,64 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Where class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Where implements Stage +``` +Implements: [Stage](./firestore_.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(condition)](./firestore_.where.md#whereconstructor) | | (BETA) Constructs a new instance of the Where class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_.where.md#wherename) | | string | (BETA) | + +## Where.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Where` class + +Signature: + +```typescript +constructor(condition: FilterCondition & Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| condition | [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) & [Constant](./firestore_.constant.md#constant_class) | | + +## Where.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_.xor.md b/docs-devsite/firestore_.xor.md new file mode 100644 index 00000000000..b7a9269ed1b --- /dev/null +++ b/docs-devsite/firestore_.xor.md @@ -0,0 +1,66 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Xor class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Xor extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(conditions)](./firestore_.xor.md#xorconstructor) | | (BETA) Constructs a new instance of the Xor class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_.xor.md#xorfilterable) | | true | (BETA) | + +## Xor.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Xor` class + +Signature: + +```typescript +constructor(conditions: FilterExpr[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| conditions | [FilterExpr](./firestore_.md#filterexpr)\[\] | | + +## Xor.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.accumulator.md b/docs-devsite/firestore_lite.accumulator.md new file mode 100644 index 00000000000..0b26c43d241 --- /dev/null +++ b/docs-devsite/firestore_lite.accumulator.md @@ -0,0 +1,39 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Accumulator interface +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +An interface that represents an accumulator. + +Signature: + +```typescript +export declare interface Accumulator +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [accumulator](./firestore_lite.accumulator.md#accumulatoraccumulator) | true | (BETA) | + +## Accumulator.accumulator + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +accumulator: true; +``` diff --git a/docs-devsite/firestore_lite.add.md b/docs-devsite/firestore_lite.add.md new file mode 100644 index 00000000000..a01caad72ca --- /dev/null +++ b/docs-devsite/firestore_lite.add.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Add class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Add extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_lite.add.md#addconstructor) | | (BETA) Constructs a new instance of the Add class | + +## Add.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Add` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | | +| right | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.addfields.md b/docs-devsite/firestore_lite.addfields.md new file mode 100644 index 00000000000..7cef7ce90a3 --- /dev/null +++ b/docs-devsite/firestore_lite.addfields.md @@ -0,0 +1,64 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# AddFields class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class AddFields implements Stage +``` +Implements: [Stage](./firestore_lite.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(fields)](./firestore_lite.addfields.md#addfieldsconstructor) | | (BETA) Constructs a new instance of the AddFields class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_lite.addfields.md#addfieldsname) | | string | (BETA) | + +## AddFields.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `AddFields` class + +Signature: + +```typescript +constructor(fields: Map); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| fields | Map<string, [Constant](./firestore_lite.constant.md#constant_class)> | | + +## AddFields.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_lite.aggregate.md b/docs-devsite/firestore_lite.aggregate.md new file mode 100644 index 00000000000..b5df22e08ab --- /dev/null +++ b/docs-devsite/firestore_lite.aggregate.md @@ -0,0 +1,65 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Aggregate class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Aggregate implements Stage +``` +Implements: [Stage](./firestore_lite.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(accumulators, groups)](./firestore_lite.aggregate.md#aggregateconstructor) | | (BETA) Constructs a new instance of the Aggregate class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_lite.aggregate.md#aggregatename) | | string | (BETA) | + +## Aggregate.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Aggregate` class + +Signature: + +```typescript +constructor(accumulators: Map, groups: Map); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| accumulators | Map<string, [Accumulator](./firestore_lite.accumulator.md#accumulator_interface)> | | +| groups | Map<string, [Constant](./firestore_lite.constant.md#constant_class)> | | + +## Aggregate.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_lite.and.md b/docs-devsite/firestore_lite.and.md new file mode 100644 index 00000000000..59b0a32b25d --- /dev/null +++ b/docs-devsite/firestore_lite.and.md @@ -0,0 +1,17 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# and namespace +Signature: + +```typescript +export declare namespace and +``` diff --git a/docs-devsite/firestore_lite.arrayconcat.md b/docs-devsite/firestore_lite.arrayconcat.md new file mode 100644 index 00000000000..2c9bf6bd104 --- /dev/null +++ b/docs-devsite/firestore_lite.arrayconcat.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ArrayConcat class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ArrayConcat extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(array, elements)](./firestore_lite.arrayconcat.md#arrayconcatconstructor) | | (BETA) Constructs a new instance of the ArrayConcat class | + +## ArrayConcat.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ArrayConcat` class + +Signature: + +```typescript +constructor(array: Constant, elements: Constant[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_lite.constant.md#constant_class) | | +| elements | [Constant](./firestore_lite.constant.md#constant_class)\[\] | | + diff --git a/docs-devsite/firestore_lite.arraycontains.md b/docs-devsite/firestore_lite.arraycontains.md new file mode 100644 index 00000000000..9875702d3b9 --- /dev/null +++ b/docs-devsite/firestore_lite.arraycontains.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ArrayContains class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ArrayContains extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(array, element)](./firestore_lite.arraycontains.md#arraycontainsconstructor) | | (BETA) Constructs a new instance of the ArrayContains class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_lite.arraycontains.md#arraycontainsfilterable) | | true | (BETA) | + +## ArrayContains.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ArrayContains` class + +Signature: + +```typescript +constructor(array: Constant, element: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_lite.constant.md#constant_class) | | +| element | [Constant](./firestore_lite.constant.md#constant_class) | | + +## ArrayContains.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.arraycontainsall.md b/docs-devsite/firestore_lite.arraycontainsall.md new file mode 100644 index 00000000000..2d830641779 --- /dev/null +++ b/docs-devsite/firestore_lite.arraycontainsall.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ArrayContainsAll class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ArrayContainsAll extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(array, values)](./firestore_lite.arraycontainsall.md#arraycontainsallconstructor) | | (BETA) Constructs a new instance of the ArrayContainsAll class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_lite.arraycontainsall.md#arraycontainsallfilterable) | | true | (BETA) | + +## ArrayContainsAll.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ArrayContainsAll` class + +Signature: + +```typescript +constructor(array: Constant, values: Constant[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_lite.constant.md#constant_class) | | +| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | | + +## ArrayContainsAll.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.arraycontainsany.md b/docs-devsite/firestore_lite.arraycontainsany.md new file mode 100644 index 00000000000..6c87810c719 --- /dev/null +++ b/docs-devsite/firestore_lite.arraycontainsany.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ArrayContainsAny class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ArrayContainsAny extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(array, values)](./firestore_lite.arraycontainsany.md#arraycontainsanyconstructor) | | (BETA) Constructs a new instance of the ArrayContainsAny class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_lite.arraycontainsany.md#arraycontainsanyfilterable) | | true | (BETA) | + +## ArrayContainsAny.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ArrayContainsAny` class + +Signature: + +```typescript +constructor(array: Constant, values: Constant[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_lite.constant.md#constant_class) | | +| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | | + +## ArrayContainsAny.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.arrayelement.md b/docs-devsite/firestore_lite.arrayelement.md new file mode 100644 index 00000000000..768a623e6d9 --- /dev/null +++ b/docs-devsite/firestore_lite.arrayelement.md @@ -0,0 +1,41 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ArrayElement class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ArrayElement extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)()](./firestore_lite.arrayelement.md#arrayelementconstructor) | | (BETA) Constructs a new instance of the ArrayElement class | + +## ArrayElement.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ArrayElement` class + +Signature: + +```typescript +constructor(); +``` diff --git a/docs-devsite/firestore_lite.arraylength.md b/docs-devsite/firestore_lite.arraylength.md new file mode 100644 index 00000000000..d755e7b0e23 --- /dev/null +++ b/docs-devsite/firestore_lite.arraylength.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ArrayLength class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ArrayLength extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(array)](./firestore_lite.arraylength.md#arraylengthconstructor) | | (BETA) Constructs a new instance of the ArrayLength class | + +## ArrayLength.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ArrayLength` class + +Signature: + +```typescript +constructor(array: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.arrayreverse.md b/docs-devsite/firestore_lite.arrayreverse.md new file mode 100644 index 00000000000..0117a8e0971 --- /dev/null +++ b/docs-devsite/firestore_lite.arrayreverse.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ArrayReverse class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ArrayReverse extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(array)](./firestore_lite.arrayreverse.md#arrayreverseconstructor) | | (BETA) Constructs a new instance of the ArrayReverse class | + +## ArrayReverse.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ArrayReverse` class + +Signature: + +```typescript +constructor(array: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.avg.md b/docs-devsite/firestore_lite.avg.md new file mode 100644 index 00000000000..de139de6c28 --- /dev/null +++ b/docs-devsite/firestore_lite.avg.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Avg class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Avg extends FirestoreFunction implements Accumulator +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [Accumulator](./firestore_lite.accumulator.md#accumulator_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value, distinct)](./firestore_lite.avg.md#avgconstructor) | | (BETA) Constructs a new instance of the Avg class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [accumulator](./firestore_lite.avg.md#avgaccumulator) | | true | (BETA) | + +## Avg.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Avg` class + +Signature: + +```typescript +constructor(value: Constant, distinct: boolean); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_lite.constant.md#constant_class) | | +| distinct | boolean | | + +## Avg.accumulator + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +accumulator: true; +``` diff --git a/docs-devsite/firestore_lite.bytelength.md b/docs-devsite/firestore_lite.bytelength.md new file mode 100644 index 00000000000..2d8d42dea62 --- /dev/null +++ b/docs-devsite/firestore_lite.bytelength.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ByteLength class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ByteLength extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value)](./firestore_lite.bytelength.md#bytelengthconstructor) | | (BETA) Constructs a new instance of the ByteLength class | + +## ByteLength.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ByteLength` class + +Signature: + +```typescript +constructor(value: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.charlength.md b/docs-devsite/firestore_lite.charlength.md new file mode 100644 index 00000000000..c2889640765 --- /dev/null +++ b/docs-devsite/firestore_lite.charlength.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# CharLength class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class CharLength extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value)](./firestore_lite.charlength.md#charlengthconstructor) | | (BETA) Constructs a new instance of the CharLength class | + +## CharLength.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `CharLength` class + +Signature: + +```typescript +constructor(value: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.collectiongroupsource.md b/docs-devsite/firestore_lite.collectiongroupsource.md new file mode 100644 index 00000000000..0d650e6a9b7 --- /dev/null +++ b/docs-devsite/firestore_lite.collectiongroupsource.md @@ -0,0 +1,64 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# CollectionGroupSource class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class CollectionGroupSource implements Stage +``` +Implements: [Stage](./firestore_lite.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(collectionId)](./firestore_lite.collectiongroupsource.md#collectiongroupsourceconstructor) | | (BETA) Constructs a new instance of the CollectionGroupSource class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_lite.collectiongroupsource.md#collectiongroupsourcename) | | string | (BETA) | + +## CollectionGroupSource.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `CollectionGroupSource` class + +Signature: + +```typescript +constructor(collectionId: string); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| collectionId | string | | + +## CollectionGroupSource.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_lite.collectionsource.md b/docs-devsite/firestore_lite.collectionsource.md new file mode 100644 index 00000000000..a0c0a44d768 --- /dev/null +++ b/docs-devsite/firestore_lite.collectionsource.md @@ -0,0 +1,64 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# CollectionSource class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class CollectionSource implements Stage +``` +Implements: [Stage](./firestore_lite.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(collectionPath)](./firestore_lite.collectionsource.md#collectionsourceconstructor) | | (BETA) Constructs a new instance of the CollectionSource class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_lite.collectionsource.md#collectionsourcename) | | string | (BETA) | + +## CollectionSource.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `CollectionSource` class + +Signature: + +```typescript +constructor(collectionPath: string); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| collectionPath | string | | + +## CollectionSource.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_lite.constant.md b/docs-devsite/firestore_lite.constant.md new file mode 100644 index 00000000000..8a26c14416c --- /dev/null +++ b/docs-devsite/firestore_lite.constant.md @@ -0,0 +1,3504 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Constant class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Represents a constant value that can be used in a Firestore pipeline expression. + +You can create a `Constant` instance using the static method: + +```typescript +// Create a Constant instance for the number 10 +const ten = Constant.of(10); + +// Create a Constant instance for the string "hello" +const hello = Constant.of("hello"); + +``` + +Signature: + +```typescript +export declare class Constant +``` + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [exprType](./firestore_lite.constant.md#constantexprtype) | | [ExprType](./firestore_lite.md#exprtype) | (BETA) | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [add(other)](./firestore_lite.constant.md#constantadd) | | (BETA) Creates an expression that adds this expression to another expression. +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +Field.of("quantity").add(Field.of("reserve")); + +``` + | +| [add(other)](./firestore_lite.constant.md#constantadd) | | (BETA) Creates an expression that adds this expression to a constant value. +```typescript +// Add 5 to the value of the 'age' field +Field.of("age").add(5); + +``` + | +| [arrayConcat(arrays)](./firestore_lite.constant.md#constantarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. +```typescript +// Combine the 'items' array with another array field. +Field.of("items").arrayConcat(Field.of("otherItems")); + +``` + | +| [arrayConcat(arrays)](./firestore_lite.constant.md#constantarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. +```typescript +// Combine the 'tags' array with a new array and an array field +Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + +``` + | +| [arrayContains(element)](./firestore_lite.constant.md#constantarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific element. +```typescript +// Check if the 'sizes' array contains the value from the 'selectedSize' field +Field.of("sizes").arrayContains(Field.of("selectedSize")); + +``` + | +| [arrayContains(element)](./firestore_lite.constant.md#constantarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific value. +```typescript +// Check if the 'colors' array contains "red" +Field.of("colors").arrayContains("red"); + +``` + | +| [arrayContainsAll(values)](./firestore_lite.constant.md#constantarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. +```typescript +// Check if the 'tags' array contains both "news" and "sports" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + | +| [arrayContainsAll(values)](./firestore_lite.constant.md#constantarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + | +| [arrayContainsAny(values)](./firestore_lite.constant.md#constantarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "cate2" +Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + +``` + | +| [arrayContainsAny(values)](./firestore_lite.constant.md#constantarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + +``` + | +| [arrayLength()](./firestore_lite.constant.md#constantarraylength) | | (BETA) Creates an expression that calculates the length of an array. +```typescript +// Get the number of items in the 'cart' array +Field.of("cart").arrayLength(); + +``` + A new Expr representing the length of the array. | +| [as(name)](./firestore_lite.constant.md#constantas) | | (BETA) Assigns an alias to this expression.Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. +```typescript +// Calculate the total price and assign it the alias "totalPrice" and add it to the output. +firestore.pipeline().collection("items") +.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + +``` + | +| [ascending()](./firestore_lite.constant.md#constantascending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. +```typescript +// Sort documents by the 'name' field in ascending order +pipeline().collection("users") +.sort(Field.of("name").ascending()); + +``` + A new Ordering for ascending sorting. | +| [avg()](./firestore_lite.constant.md#constantavg) | | (BETA) Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. +```typescript +// Calculate the average age of users +Field.of("age").avg().as("averageAge"); + +``` + A new Accumulator representing the 'avg' aggregation. | +| [byteLength()](./firestore_lite.constant.md#constantbytelength) | | (BETA) Creates an expression that calculates the length of this string expression in bytes. +```typescript +// Calculate the length of the 'myString' field in bytes. +Field.of("myString").byteLength(); + +``` + A new representing the length of the string in bytes. | +| [charLength()](./firestore_lite.constant.md#constantcharlength) | | (BETA) Creates an expression that calculates the character length of a string in UTF-8. +```typescript +// Get the character length of the 'name' field in its UTF-8 form. +Field.of("name").charLength(); + +``` + A new Expr representing the length of the string. | +| [cosineDistance(other)](./firestore_lite.constant.md#constantcosinedistance) | | (BETA) Calculates the cosine distance between two vectors. +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +Field.of("userVector").cosineDistance(Field.of("itemVector")); + +``` + | +| [cosineDistance(other)](./firestore_lite.constant.md#constantcosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + +``` + | +| [cosineDistance(other)](./firestore_lite.constant.md#constantcosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance([37.7749, -122.4194]); + +``` + | +| [count()](./firestore_lite.constant.md#constantcount) | | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. +```typescript +// Count the total number of products +Field.of("productId").count().as("totalProducts"); + +``` + A new Accumulator representing the 'count' aggregation. | +| [descending()](./firestore_lite.constant.md#constantdescending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") +.sort(Field.of("createdAt").descending()); + +``` + A new Ordering for descending sorting. | +| [divide(other)](./firestore_lite.constant.md#constantdivide) | | (BETA) Creates an expression that divides this expression by another expression. +```typescript +// Divide the 'total' field by the 'count' field +Field.of("total").divide(Field.of("count")); + +``` + | +| [divide(other)](./firestore_lite.constant.md#constantdivide) | | (BETA) Creates an expression that divides this expression by a constant value. +```typescript +// Divide the 'value' field by 10 +Field.of("value").divide(10); + +``` + | +| [dotProduct(other)](./firestore_lite.constant.md#constantdotproduct) | | (BETA) Calculates the dot product between two vectors. +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct([0.5, 0.8, 0.2]); + +``` + | +| [dotProduct(other)](./firestore_lite.constant.md#constantdotproduct) | | (BETA) Calculates the dot product between two vectors. +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + +``` + | +| [dotProduct(other)](./firestore_lite.constant.md#constantdotproduct) | | (BETA) | +| [endsWith(suffix)](./firestore_lite.constant.md#constantendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix. +```typescript +// Check if the 'filename' field ends with ".txt" +Field.of("filename").endsWith(".txt"); + +``` + | +| [endsWith(suffix)](./firestore_lite.constant.md#constantendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix (represented as an expression). +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +Field.of("url").endsWith(Field.of("extension")); + +``` + | +| [eq(other)](./firestore_lite.constant.md#constanteq) | | (BETA) Creates an expression that checks if this expression is equal to another expression. +```typescript +// Check if the 'age' field is equal to 21 +Field.of("age").eq(21); + +``` + | +| [eq(other)](./firestore_lite.constant.md#constanteq) | | (BETA) Creates an expression that checks if this expression is equal to a constant value. +```typescript +// Check if the 'city' field is equal to "London" +Field.of("city").eq("London"); + +``` + | +| [euclideanDistance(other)](./firestore_lite.constant.md#constanteuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance([37.7749, -122.4194]); + +``` + | +| [euclideanDistance(other)](./firestore_lite.constant.md#constanteuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + +``` + | +| [euclideanDistance(other)](./firestore_lite.constant.md#constanteuclideandistance) | | (BETA) | +| [exists()](./firestore_lite.constant.md#constantexists) | | (BETA) Creates an expression that checks if a field exists in the document. +```typescript +// Check if the document has a field named "phoneNumber" +Field.of("phoneNumber").exists(); + +``` + A new Expr representing the 'exists' check. | +| [gt(other)](./firestore_lite.constant.md#constantgt) | | (BETA) Creates an expression that checks if this expression is greater than another expression. +```typescript +// Check if the 'age' field is greater than the 'limit' field +Field.of("age").gt(Field.of("limit")); + +``` + | +| [gt(other)](./firestore_lite.constant.md#constantgt) | | (BETA) Creates an expression that checks if this expression is greater than a constant value. +```typescript +// Check if the 'price' field is greater than 100 +Field.of("price").gt(100); + +``` + | +| [gte(other)](./firestore_lite.constant.md#constantgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to another expression. +```typescript +// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 +Field.of("quantity").gte(Field.of('requirement').add(1)); + +``` + | +| [gte(other)](./firestore_lite.constant.md#constantgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to a constant value. +```typescript +// Check if the 'score' field is greater than or equal to 80 +Field.of("score").gte(80); + +``` + | +| [in(others)](./firestore_lite.constant.md#constantin) | | (BETA) Creates an expression that checks if this expression is equal to any of the provided values or expressions. +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +Field.of("category").in("Electronics", Field.of("primaryType")); + +``` + | +| [in(others)](./firestore_lite.constant.md#constantin) | | (BETA) | +| [isNaN()](./firestore_lite.constant.md#constantisnan) | | (BETA) Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). +```typescript +// Check if the result of a calculation is NaN +Field.of("value").divide(0).isNaN(); + +``` + A new Expr representing the 'isNaN' check. | +| [like(pattern)](./firestore_lite.constant.md#constantlike) | | (BETA) Creates an expression that performs a case-sensitive string comparison. +```typescript +// Check if the 'title' field contains the word "guide" (case-sensitive) +Field.of("title").like("%guide%"); + +``` + | +| [like(pattern)](./firestore_lite.constant.md#constantlike) | | (BETA) | +| [logicalMax(other)](./firestore_lite.constant.md#constantlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMax(Function.currentTimestamp()); + +``` + | +| [logicalMax(other)](./firestore_lite.constant.md#constantlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'value' field and 10. +Field.of("value").logicalMax(10); + +``` + | +| [logicalMin(other)](./firestore_lite.constant.md#constantlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMin(Function.currentTimestamp()); + +``` + | +| [logicalMin(other)](./firestore_lite.constant.md#constantlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'value' field and 10. +Field.of("value").logicalMin(10); + +``` + | +| [lt(other)](./firestore_lite.constant.md#constantlt) | | (BETA) Creates an expression that checks if this expression is less than another expression. +```typescript +// Check if the 'age' field is less than 'limit' +Field.of("age").lt(Field.of('limit')); + +``` + | +| [lt(other)](./firestore_lite.constant.md#constantlt) | | (BETA) Creates an expression that checks if this expression is less than a constant value. +```typescript +// Check if the 'price' field is less than 50 +Field.of("price").lt(50); + +``` + | +| [lte(other)](./firestore_lite.constant.md#constantlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to another expression. +```typescript +// Check if the 'quantity' field is less than or equal to 20 +Field.of("quantity").lte(Constant.of(20)); + +``` + | +| [lte(other)](./firestore_lite.constant.md#constantlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to a constant value. +```typescript +// Check if the 'score' field is less than or equal to 70 +Field.of("score").lte(70); + +``` + | +| [mapGet(subfield)](./firestore_lite.constant.md#constantmapget) | | (BETA) Accesses a value from a map (object) field using the provided key. +```typescript +// Get the 'city' value from the 'address' map field +Field.of("address").mapGet("city"); + +``` + | +| [max()](./firestore_lite.constant.md#constantmax) | | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. +```typescript +// Find the highest score in a leaderboard +Field.of("score").max().as("highestScore"); + +``` + A new Accumulator representing the 'max' aggregation. | +| [min()](./firestore_lite.constant.md#constantmin) | | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. +```typescript +// Find the lowest price of all products +Field.of("price").min().as("lowestPrice"); + +``` + A new Accumulator representing the 'min' aggregation. | +| [mod(other)](./firestore_lite.constant.md#constantmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. +```typescript +// Calculate the remainder of dividing the 'value' field by the 'divisor' field +Field.of("value").mod(Field.of("divisor")); + +``` + | +| [mod(other)](./firestore_lite.constant.md#constantmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. +```typescript +// Calculate the remainder of dividing the 'value' field by 10 +Field.of("value").mod(10); + +``` + | +| [multiply(other)](./firestore_lite.constant.md#constantmultiply) | | (BETA) Creates an expression that multiplies this expression by another expression. +```typescript +// Multiply the 'quantity' field by the 'price' field +Field.of("quantity").multiply(Field.of("price")); + +``` + | +| [multiply(other)](./firestore_lite.constant.md#constantmultiply) | | (BETA) Creates an expression that multiplies this expression by a constant value. +```typescript +// Multiply the 'value' field by 2 +Field.of("value").multiply(2); + +``` + | +| [neq(other)](./firestore_lite.constant.md#constantneq) | | (BETA) Creates an expression that checks if this expression is not equal to another expression. +```typescript +// Check if the 'status' field is not equal to "completed" +Field.of("status").neq("completed"); + +``` + | +| [neq(other)](./firestore_lite.constant.md#constantneq) | | (BETA) Creates an expression that checks if this expression is not equal to a constant value. +```typescript +// Check if the 'country' field is not equal to "USA" +Field.of("country").neq("USA"); + +``` + | +| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a number value. | +| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a DocumentReference value. | +| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for an array value. | +| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a map value. | +| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a VectorValue value. | +| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a string value. | +| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a boolean value. | +| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a null value. | +| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for an undefined value. | +| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a GeoPoint value. | +| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a Timestamp value. | +| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a Date value. | +| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a Uint8Array value. | +| [regexContains(pattern)](./firestore_lite.constant.md#constantregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +Field.of("description").regexContains("(?i)example"); + +``` + | +| [regexContains(pattern)](./firestore_lite.constant.md#constantregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains the regular expression stored in field 'regex' +Field.of("description").regexContains(Field.of("regex")); + +``` + | +| [regexMatch(pattern)](./firestore_lite.constant.md#constantregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. +```typescript +// Check if the 'email' field matches a valid email pattern +Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + | +| [regexMatch(pattern)](./firestore_lite.constant.md#constantregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. +```typescript +// Check if the 'email' field matches a regular expression stored in field 'regex' +Field.of("email").regexMatch(Field.of("regex")); + +``` + | +| [replaceAll(find, replace)](./firestore_lite.constant.md#constantreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring. +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field +Field.of("message").replaceAll("hello", "hi"); + +``` + | +| [replaceAll(find, replace)](./firestore_lite.constant.md#constantreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + +``` + | +| [replaceFirst(find, replace)](./firestore_lite.constant.md#constantreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field +Field.of("message").replaceFirst("hello", "hi"); + +``` + | +| [replaceFirst(find, replace)](./firestore_lite.constant.md#constantreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + +``` + | +| [reverse()](./firestore_lite.constant.md#constantreverse) | | (BETA) Creates an expression that reverses this string expression. +```typescript +// Reverse the value of the 'myString' field. +Field.of("myString").reverse(); + +``` + A new representing the reversed string. | +| [startsWith(prefix)](./firestore_lite.constant.md#constantstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix. +```typescript +// Check if the 'name' field starts with "Mr." +Field.of("name").startsWith("Mr."); + +``` + | +| [startsWith(prefix)](./firestore_lite.constant.md#constantstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix (represented as an expression). +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +Field.of("fullName").startsWith(Field.of("firstName")); + +``` + | +| [strConcat(elements)](./firestore_lite.constant.md#constantstrconcat) | | (BETA) Creates an expression that concatenates string expressions together. +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + +``` + | +| [strContains(substring)](./firestore_lite.constant.md#constantstrcontains) | | (BETA) Creates an expression that checks if a string contains a specified substring. +```typescript +// Check if the 'description' field contains "example". +Field.of("description").strContains("example"); + +``` + | +| [strContains(expr)](./firestore_lite.constant.md#constantstrcontains) | | (BETA) Creates an expression that checks if a string contains the string represented by another expression. +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +Field.of("description").strContains(Field.of("keyword")); + +``` + | +| [subtract(other)](./firestore_lite.constant.md#constantsubtract) | | (BETA) Creates an expression that subtracts another expression from this expression. +```typescript +// Subtract the 'discount' field from the 'price' field +Field.of("price").subtract(Field.of("discount")); + +``` + | +| [subtract(other)](./firestore_lite.constant.md#constantsubtract) | | (BETA) Creates an expression that subtracts a constant value from this expression. +```typescript +// Subtract 20 from the value of the 'total' field +Field.of("total").subtract(20); + +``` + | +| [sum()](./firestore_lite.constant.md#constantsum) | | (BETA) Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. +```typescript +// Calculate the total revenue from a set of orders +Field.of("orderAmount").sum().as("totalRevenue"); + +``` + A new Accumulator representing the 'sum' aggregation. | +| [timestampAdd(unit, amount)](./firestore_lite.constant.md#constanttimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampAdd(unit, amount)](./firestore_lite.constant.md#constanttimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. +```typescript +// Add 1 day to the 'timestamp' field. +Field.of("timestamp").timestampAdd("day", 1); + +``` + | +| [timestampSub(unit, amount)](./firestore_lite.constant.md#constanttimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampSub(unit, amount)](./firestore_lite.constant.md#constanttimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. +```typescript +// Subtract 1 day from the 'timestamp' field. +Field.of("timestamp").timestampSub("day", 1); + +``` + | +| [timestampToUnixMicros()](./firestore_lite.constant.md#constanttimestamptounixmicros) | | (BETA) Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +Field.of("timestamp").timestampToUnixMicros(); + +``` + A new representing the number of microseconds since epoch. | +| [timestampToUnixMillis()](./firestore_lite.constant.md#constanttimestamptounixmillis) | | (BETA) Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +Field.of("timestamp").timestampToUnixMillis(); + +``` + A new representing the number of milliseconds since epoch. | +| [timestampToUnixSeconds()](./firestore_lite.constant.md#constanttimestamptounixseconds) | | (BETA) Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to seconds since epoch. +Field.of("timestamp").timestampToUnixSeconds(); + +``` + A new representing the number of seconds since epoch. | +| [toLower()](./firestore_lite.constant.md#constanttolower) | | (BETA) Creates an expression that converts a string to lowercase. +```typescript +// Convert the 'name' field to lowercase +Field.of("name").toLower(); + +``` + A new Expr representing the lowercase string. | +| [toUpper()](./firestore_lite.constant.md#constanttoupper) | | (BETA) Creates an expression that converts a string to uppercase. +```typescript +// Convert the 'title' field to uppercase +Field.of("title").toUpper(); + +``` + A new Expr representing the uppercase string. | +| [trim()](./firestore_lite.constant.md#constanttrim) | | (BETA) Creates an expression that removes leading and trailing whitespace from a string. +```typescript +// Trim whitespace from the 'userInput' field +Field.of("userInput").trim(); + +``` + A new Expr representing the trimmed string. | +| [unixMicrosToTimestamp()](./firestore_lite.constant.md#constantunixmicrostotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +Field.of("microseconds").unixMicrosToTimestamp(); + +``` + A new representing the timestamp. | +| [unixMillisToTimestamp()](./firestore_lite.constant.md#constantunixmillistotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +Field.of("milliseconds").unixMillisToTimestamp(); + +``` + A new representing the timestamp. | +| [unixSecondsToTimestamp()](./firestore_lite.constant.md#constantunixsecondstotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'seconds' field as seconds since epoch. +Field.of("seconds").unixSecondsToTimestamp(); + +``` + A new representing the timestamp. | +| [vector(value)](./firestore_lite.constant.md#constantvector) | static | (BETA) Creates a Constant instance for a VectorValue value. +```typescript +// Create a Constant instance for a vector value +const vectorConstant = Constant.ofVector([1, 2, 3]); + +``` + | +| [vectorLength()](./firestore_lite.constant.md#constantvectorlength) | | (BETA) Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. +```typescript +// Get the vector length (dimension) of the field 'embedding'. +Field.of("embedding").vectorLength(); + +``` + A new representing the length of the vector. | + +## Constant.exprType + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +exprType: ExprType; +``` + +## Constant.add() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds this expression to another expression. + +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +Field.of("quantity").add(Field.of("reserve")); + +``` + +Signature: + +```typescript +add(other: Constant): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to add to this expression. A new Expr representing the addition operation. | + +Returns: + +[Add](./firestore_lite.add.md#add_class) + +## Constant.add() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds this expression to a constant value. + +```typescript +// Add 5 to the value of the 'age' field +Field.of("age").add(5); + +``` + +Signature: + +```typescript +add(other: any): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to add. A new Expr representing the addition operation. | + +Returns: + +[Add](./firestore_lite.add.md#add_class) + +## Constant.arrayConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with one or more other arrays. + +```typescript +// Combine the 'items' array with another array field. +Field.of("items").arrayConcat(Field.of("otherItems")); + +``` + +Signature: + +```typescript +arrayConcat(arrays: Constant[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrays | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The array expressions to concatenate. A new Expr representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) + +## Constant.arrayConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with one or more other arrays. + +```typescript +// Combine the 'tags' array with a new array and an array field +Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + +``` + +Signature: + +```typescript +arrayConcat(arrays: any[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrays | any\[\] | The array expressions or values to concatenate. A new Expr representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) + +## Constant.arrayContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains a specific element. + +```typescript +// Check if the 'sizes' array contains the value from the 'selectedSize' field +Field.of("sizes").arrayContains(Field.of("selectedSize")); + +``` + +Signature: + +```typescript +arrayContains(element: Constant): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | [Constant](./firestore_lite.constant.md#constant_class) | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) + +## Constant.arrayContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains a specific value. + +```typescript +// Check if the 'colors' array contains "red" +Field.of("colors").arrayContains("red"); + +``` + +Signature: + +```typescript +arrayContains(element: any): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | any | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) + +## Constant.arrayContainsAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both "news" and "sports" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + +Signature: + +```typescript +arrayContainsAll(...values: Constant[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) + +## Constant.arrayContainsAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + +Signature: + +```typescript +arrayContainsAll(...values: any[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) + +## Constant.arrayContainsAny() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains any of the specified elements. + +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "cate2" +Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + +``` + +Signature: + +```typescript +arrayContainsAny(...values: Constant[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) + +## Constant.arrayContainsAny() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains any of the specified elements. + +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + +``` + +Signature: + +```typescript +arrayContainsAny(...values: any[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) + +## Constant.arrayLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of an array. + +```typescript +// Get the number of items in the 'cart' array +Field.of("cart").arrayLength(); + +``` + A new `Expr` representing the length of the array. + +Signature: + +```typescript +arrayLength(): ArrayLength; +``` +Returns: + +[ArrayLength](./firestore_lite.arraylength.md#arraylength_class) + +## Constant.as() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Assigns an alias to this expression. + +Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. + +```typescript +// Calculate the total price and assign it the alias "totalPrice" and add it to the output. +firestore.pipeline().collection("items") +.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + +``` + +Signature: + +```typescript +as(name: string): ExprWithAlias; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | The alias to assign to this expression. A new [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) that wraps this expression and associates it with the provided alias. | + +Returns: + +[ExprWithAlias](./firestore_lite.exprwithalias.md#exprwithalias_class)<this> + +## Constant.ascending() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. + +```typescript +// Sort documents by the 'name' field in ascending order +pipeline().collection("users") +.sort(Field.of("name").ascending()); + +``` + A new `Ordering` for ascending sorting. + +Signature: + +```typescript +ascending(): Ordering; +``` +Returns: + +[Ordering](./firestore_lite.ordering.md#ordering_class) + +## Constant.avg() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. + +```typescript +// Calculate the average age of users +Field.of("age").avg().as("averageAge"); + +``` + A new `Accumulator` representing the 'avg' aggregation. + +Signature: + +```typescript +avg(): Avg; +``` +Returns: + +[Avg](./firestore_lite.avg.md#avg_class) + +## Constant.byteLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of this string expression in bytes. + +```typescript +// Calculate the length of the 'myString' field in bytes. +Field.of("myString").byteLength(); + +``` + A new representing the length of the string in bytes. + +Signature: + +```typescript +byteLength(): ByteLength; +``` +Returns: + +[ByteLength](./firestore_lite.bytelength.md#bytelength_class) + +## Constant.charLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the character length of a string in UTF-8. + +```typescript +// Get the character length of the 'name' field in its UTF-8 form. +Field.of("name").charLength(); + +``` + A new `Expr` representing the length of the string. + +Signature: + +```typescript +charLength(): CharLength; +``` +Returns: + +[CharLength](./firestore_lite.charlength.md#charlength_class) + +## Constant.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the cosine distance between two vectors. + +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +Field.of("userVector").cosineDistance(Field.of("itemVector")); + +``` + +Signature: + +```typescript +cosineDistance(other: Constant): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new Expr representing the cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) + +## Constant.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vectors. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +cosineDistance(other: VectorValue): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) + +## Constant.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vectors. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance([37.7749, -122.4194]); + +``` + +Signature: + +```typescript +cosineDistance(other: number[]): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | The other vector (as an array of numbers) to compare against. A new Expr representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) + +## Constant.count() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. + +```typescript +// Count the total number of products +Field.of("productId").count().as("totalProducts"); + +``` + A new `Accumulator` representing the 'count' aggregation. + +Signature: + +```typescript +count(): Count; +``` +Returns: + +[Count](./firestore_lite.count.md#count_class) + +## Constant.descending() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. + +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") +.sort(Field.of("createdAt").descending()); + +``` + A new `Ordering` for descending sorting. + +Signature: + +```typescript +descending(): Ordering; +``` +Returns: + +[Ordering](./firestore_lite.ordering.md#ordering_class) + +## Constant.divide() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides this expression by another expression. + +```typescript +// Divide the 'total' field by the 'count' field +Field.of("total").divide(Field.of("count")); + +``` + +Signature: + +```typescript +divide(other: Constant): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new Expr representing the division operation. | + +Returns: + +[Divide](./firestore_lite.divide.md#divide_class) + +## Constant.divide() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides this expression by a constant value. + +```typescript +// Divide the 'value' field by 10 +Field.of("value").divide(10); + +``` + +Signature: + +```typescript +divide(other: any): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to divide by. A new Expr representing the division operation. | + +Returns: + +[Divide](./firestore_lite.divide.md#divide_class) + +## Constant.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vectors. + +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct([0.5, 0.8, 0.2]); + +``` + +Signature: + +```typescript +dotProduct(other: Constant): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) + +## Constant.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vectors. + +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + +``` + +Signature: + +```typescript +dotProduct(other: VectorValue): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) + +## Constant.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +dotProduct(other: number[]): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | | + +Returns: + +[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) + +## Constant.endsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string ends with a given postfix. + +```typescript +// Check if the 'filename' field ends with ".txt" +Field.of("filename").endsWith(".txt"); + +``` + +Signature: + +```typescript +endsWith(suffix: string): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| suffix | string | The postfix to check for. A new Expr representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_lite.endswith.md#endswith_class) + +## Constant.endsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string ends with a given postfix (represented as an expression). + +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +Field.of("url").endsWith(Field.of("extension")); + +``` + +Signature: + +```typescript +endsWith(suffix: Constant): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| suffix | [Constant](./firestore_lite.constant.md#constant_class) | The postfix expression to check for. A new Expr representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_lite.endswith.md#endswith_class) + +## Constant.eq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to another expression. + +```typescript +// Check if the 'age' field is equal to 21 +Field.of("age").eq(21); + +``` + +Signature: + +```typescript +eq(other: Constant): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for equality. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_lite.eq.md#eq_class) + +## Constant.eq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to a constant value. + +```typescript +// Check if the 'city' field is equal to "London" +Field.of("city").eq("London"); + +``` + +Signature: + +```typescript +eq(other: any): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for equality. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_lite.eq.md#eq_class) + +## Constant.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vectors. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance([37.7749, -122.4194]); + +``` + +Signature: + +```typescript +euclideanDistance(other: Constant): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) + +## Constant.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vectors. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +euclideanDistance(other: VectorValue): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) + +## Constant.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +euclideanDistance(other: number[]): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | | + +Returns: + +[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) + +## Constant.exists() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field exists in the document. + +```typescript +// Check if the document has a field named "phoneNumber" +Field.of("phoneNumber").exists(); + +``` + A new `Expr` representing the 'exists' check. + +Signature: + +```typescript +exists(): Exists; +``` +Returns: + +[Exists](./firestore_lite.exists.md#exists_class) + +## Constant.gt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than another expression. + +```typescript +// Check if the 'age' field is greater than the 'limit' field +Field.of("age").gt(Field.of("limit")); + +``` + +Signature: + +```typescript +gt(other: Constant): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for greater than. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_lite.gt.md#gt_class) + +## Constant.gt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than a constant value. + +```typescript +// Check if the 'price' field is greater than 100 +Field.of("price").gt(100); + +``` + +Signature: + +```typescript +gt(other: any): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for greater than. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_lite.gt.md#gt_class) + +## Constant.gte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than or equal to another expression. + +```typescript +// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 +Field.of("quantity").gte(Field.of('requirement').add(1)); + +``` + +Signature: + +```typescript +gte(other: Constant): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_lite.gte.md#gte_class) + +## Constant.gte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than or equal to a constant value. + +```typescript +// Check if the 'score' field is greater than or equal to 80 +Field.of("score").gte(80); + +``` + +Signature: + +```typescript +gte(other: any): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_lite.gte.md#gte_class) + +## Constant.in() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to any of the provided values or expressions. + +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +Field.of("category").in("Electronics", Field.of("primaryType")); + +``` + +Signature: + +```typescript +in(...others: Constant[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| others | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The values or expressions to check against. A new Expr representing the 'IN' comparison. | + +Returns: + +[In](./firestore_lite.in.md#in_class) + +## Constant.in() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +in(...others: any[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| others | any\[\] | | + +Returns: + +[In](./firestore_lite.in.md#in_class) + +## Constant.isNaN() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). + +```typescript +// Check if the result of a calculation is NaN +Field.of("value").divide(0).isNaN(); + +``` + A new `Expr` representing the 'isNaN' check. + +Signature: + +```typescript +isNaN(): IsNan; +``` +Returns: + +[IsNan](./firestore_lite.isnan.md#isnan_class) + +## Constant.like() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that performs a case-sensitive string comparison. + +```typescript +// Check if the 'title' field contains the word "guide" (case-sensitive) +Field.of("title").like("%guide%"); + +``` + +Signature: + +```typescript +like(pattern: string): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new Expr representing the 'like' comparison. | + +Returns: + +[Like](./firestore_lite.like.md#like_class) + +## Constant.like() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +like(pattern: Constant): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | | + +Returns: + +[Like](./firestore_lite.like.md#like_class) + +## Constant.logicalMax() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMax(Function.currentTimestamp()); + +``` + +Signature: + +```typescript +logicalMax(other: Constant): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare with. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) + +## Constant.logicalMax() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'value' field and 10. +Field.of("value").logicalMax(10); + +``` + +Signature: + +```typescript +logicalMax(other: any): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare with. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) + +## Constant.logicalMin() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMin(Function.currentTimestamp()); + +``` + +Signature: + +```typescript +logicalMin(other: Constant): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare with. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) + +## Constant.logicalMin() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'value' field and 10. +Field.of("value").logicalMin(10); + +``` + +Signature: + +```typescript +logicalMin(other: any): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare with. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) + +## Constant.lt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than another expression. + +```typescript +// Check if the 'age' field is less than 'limit' +Field.of("age").lt(Field.of('limit')); + +``` + +Signature: + +```typescript +lt(other: Constant): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for less than. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_lite.lt.md#lt_class) + +## Constant.lt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than a constant value. + +```typescript +// Check if the 'price' field is less than 50 +Field.of("price").lt(50); + +``` + +Signature: + +```typescript +lt(other: any): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for less than. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_lite.lt.md#lt_class) + +## Constant.lte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than or equal to another expression. + +```typescript +// Check if the 'quantity' field is less than or equal to 20 +Field.of("quantity").lte(Constant.of(20)); + +``` + +Signature: + +```typescript +lte(other: Constant): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_lite.lte.md#lte_class) + +## Constant.lte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than or equal to a constant value. + +```typescript +// Check if the 'score' field is less than or equal to 70 +Field.of("score").lte(70); + +``` + +Signature: + +```typescript +lte(other: any): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_lite.lte.md#lte_class) + +## Constant.mapGet() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Accesses a value from a map (object) field using the provided key. + +```typescript +// Get the 'city' value from the 'address' map field +Field.of("address").mapGet("city"); + +``` + +Signature: + +```typescript +mapGet(subfield: string): MapGet; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| subfield | string | The key to access in the map. A new Expr representing the value associated with the given key in the map. | + +Returns: + +[MapGet](./firestore_lite.mapget.md#mapget_class) + +## Constant.max() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that finds the maximum value of a field across multiple stage inputs. + +```typescript +// Find the highest score in a leaderboard +Field.of("score").max().as("highestScore"); + +``` + A new `Accumulator` representing the 'max' aggregation. + +Signature: + +```typescript +max(): Max; +``` +Returns: + +[Max](./firestore_lite.max.md#max_class) + +## Constant.min() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that finds the minimum value of a field across multiple stage inputs. + +```typescript +// Find the lowest price of all products +Field.of("price").min().as("lowestPrice"); + +``` + A new `Accumulator` representing the 'min' aggregation. + +Signature: + +```typescript +min(): Min; +``` +Returns: + +[Min](./firestore_lite.min.md#min_class) + +## Constant.mod() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. + +```typescript +// Calculate the remainder of dividing the 'value' field by the 'divisor' field +Field.of("value").mod(Field.of("divisor")); + +``` + +Signature: + +```typescript +mod(other: Constant): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new Expr representing the modulo operation. | + +Returns: + +[Mod](./firestore_lite.mod.md#mod_class) + +## Constant.mod() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. + +```typescript +// Calculate the remainder of dividing the 'value' field by 10 +Field.of("value").mod(10); + +``` + +Signature: + +```typescript +mod(other: any): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to divide by. A new Expr representing the modulo operation. | + +Returns: + +[Mod](./firestore_lite.mod.md#mod_class) + +## Constant.multiply() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies this expression by another expression. + +```typescript +// Multiply the 'quantity' field by the 'price' field +Field.of("quantity").multiply(Field.of("price")); + +``` + +Signature: + +```typescript +multiply(other: Constant): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to multiply by. A new Expr representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_lite.multiply.md#multiply_class) + +## Constant.multiply() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies this expression by a constant value. + +```typescript +// Multiply the 'value' field by 2 +Field.of("value").multiply(2); + +``` + +Signature: + +```typescript +multiply(other: any): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to multiply by. A new Expr representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_lite.multiply.md#multiply_class) + +## Constant.neq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is not equal to another expression. + +```typescript +// Check if the 'status' field is not equal to "completed" +Field.of("status").neq("completed"); + +``` + +Signature: + +```typescript +neq(other: Constant): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for inequality. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_lite.neq.md#neq_class) + +## Constant.neq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is not equal to a constant value. + +```typescript +// Check if the 'country' field is not equal to "USA" +Field.of("country").neq("USA"); + +``` + +Signature: + +```typescript +neq(other: any): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for inequality. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_lite.neq.md#neq_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a number value. + +Signature: + +```typescript +static of(value: number): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | number | The number value. A new Constant instance. | + +Returns: + +[Constant](./firestore_lite.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a DocumentReference value. + +Signature: + +```typescript +static of(value: DocumentReference): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class) | The DocumentReference value. A new Constant instance. | + +Returns: + +[Constant](./firestore_lite.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for an array value. + +Signature: + +```typescript +static of(value: any[]): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | any\[\] | The array value. A new Constant instance. | + +Returns: + +[Constant](./firestore_lite.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a map value. + +Signature: + +```typescript +static of(value: Map): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | Map<string, any> | The map value. A new Constant instance. | + +Returns: + +[Constant](./firestore_lite.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a VectorValue value. + +Signature: + +```typescript +static of(value: VectorValue): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The VectorValue value. A new Constant instance. | + +Returns: + +[Constant](./firestore_lite.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a string value. + +Signature: + +```typescript +static of(value: string): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | string | The string value. A new Constant instance. | + +Returns: + +[Constant](./firestore_lite.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a boolean value. + +Signature: + +```typescript +static of(value: boolean): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | boolean | The boolean value. A new Constant instance. | + +Returns: + +[Constant](./firestore_lite.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a null value. + +Signature: + +```typescript +static of(value: null): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | null | The null value. A new Constant instance. | + +Returns: + +[Constant](./firestore_lite.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for an undefined value. + +Signature: + +```typescript +static of(value: undefined): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | undefined | The undefined value. A new Constant instance. | + +Returns: + +[Constant](./firestore_lite.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a GeoPoint value. + +Signature: + +```typescript +static of(value: GeoPoint): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [GeoPoint](./firestore_lite.geopoint.md#geopoint_class) | The GeoPoint value. A new Constant instance. | + +Returns: + +[Constant](./firestore_lite.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a Timestamp value. + +Signature: + +```typescript +static of(value: Timestamp): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Timestamp](./firestore_lite.timestamp.md#timestamp_class) | The Timestamp value. A new Constant instance. | + +Returns: + +[Constant](./firestore_lite.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a Date value. + +Signature: + +```typescript +static of(value: Date): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | Date | The Date value. A new Constant instance. | + +Returns: + +[Constant](./firestore_lite.constant.md#constant_class) + +## Constant.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a Uint8Array value. + +Signature: + +```typescript +static of(value: Uint8Array): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | Uint8Array | The Uint8Array value. A new Constant instance. | + +Returns: + +[Constant](./firestore_lite.constant.md#constant_class) + +## Constant.regexContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +Field.of("description").regexContains("(?i)example"); + +``` + +Signature: + +```typescript +regexContains(pattern: string): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) + +## Constant.regexContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains the regular expression stored in field 'regex' +Field.of("description").regexContains(Field.of("regex")); + +``` + +Signature: + +```typescript +regexContains(pattern: Constant): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) + +## Constant.regexMatch() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a valid email pattern +Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + +Signature: + +```typescript +regexMatch(pattern: string): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The regular expression to use for the match. A new Expr representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) + +## Constant.regexMatch() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a regular expression stored in field 'regex' +Field.of("email").regexMatch(Field.of("regex")); + +``` + +Signature: + +```typescript +regexMatch(pattern: Constant): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the match. A new Expr representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) + +## Constant.replaceAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within this string expression with another substring. + +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field +Field.of("message").replaceAll("hello", "hi"); + +``` + +Signature: + +```typescript +replaceAll(find: string, replace: string): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | string | The substring to search for. | +| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) + +## Constant.replaceAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + +``` + +Signature: + +```typescript +replaceAll(find: Constant, replace: Constant): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) + +## Constant.replaceFirst() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. + +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field +Field.of("message").replaceFirst("hello", "hi"); + +``` + +Signature: + +```typescript +replaceFirst(find: string, replace: string): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | string | The substring to search for. | +| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) + +## Constant.replaceFirst() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + +``` + +Signature: + +```typescript +replaceFirst(find: Constant, replace: Constant): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) + +## Constant.reverse() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that reverses this string expression. + +```typescript +// Reverse the value of the 'myString' field. +Field.of("myString").reverse(); + +``` + A new representing the reversed string. + +Signature: + +```typescript +reverse(): Reverse; +``` +Returns: + +[Reverse](./firestore_lite.reverse.md#reverse_class) + +## Constant.startsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string starts with a given prefix. + +```typescript +// Check if the 'name' field starts with "Mr." +Field.of("name").startsWith("Mr."); + +``` + +Signature: + +```typescript +startsWith(prefix: string): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| prefix | string | The prefix to check for. A new Expr representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_lite.startswith.md#startswith_class) + +## Constant.startsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string starts with a given prefix (represented as an expression). + +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +Field.of("fullName").startsWith(Field.of("firstName")); + +``` + +Signature: + +```typescript +startsWith(prefix: Constant): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| prefix | [Constant](./firestore_lite.constant.md#constant_class) | The prefix expression to check for. A new Expr representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_lite.startswith.md#startswith_class) + +## Constant.strConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates string expressions together. + +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + +``` + +Signature: + +```typescript +strConcat(...elements: Array): StrConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| elements | Array<string \| [Constant](./firestore_lite.constant.md#constant_class)> | The expressions (typically strings) to concatenate. A new Expr representing the concatenated string. | + +Returns: + +[StrConcat](./firestore_lite.strconcat.md#strconcat_class) + +## Constant.strContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified substring. + +```typescript +// Check if the 'description' field contains "example". +Field.of("description").strContains("example"); + +``` + +Signature: + +```typescript +strContains(substring: string): StrContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| substring | string | The substring to search for. A new Expr representing the 'contains' comparison. | + +Returns: + +[StrContains](./firestore_lite.strcontains.md#strcontains_class) + +## Constant.strContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains the string represented by another expression. + +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +Field.of("description").strContains(Field.of("keyword")); + +``` + +Signature: + +```typescript +strContains(expr: Constant): StrContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. A new Expr representing the 'contains' comparison. | + +Returns: + +[StrContains](./firestore_lite.strcontains.md#strcontains_class) + +## Constant.subtract() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts another expression from this expression. + +```typescript +// Subtract the 'discount' field from the 'price' field +Field.of("price").subtract(Field.of("discount")); + +``` + +Signature: + +```typescript +subtract(other: Constant): Subtract; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to subtract from this expression. A new Expr representing the subtraction operation. | + +Returns: + +[Subtract](./firestore_lite.subtract.md#subtract_class) + +## Constant.subtract() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a constant value from this expression. + +```typescript +// Subtract 20 from the value of the 'total' field +Field.of("total").subtract(20); + +``` + +Signature: + +```typescript +subtract(other: any): Subtract; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to subtract. A new Expr representing the subtraction operation. | + +Returns: + +[Subtract](./firestore_lite.subtract.md#subtract_class) + +## Constant.sum() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. + +```typescript +// Calculate the total revenue from a set of orders +Field.of("orderAmount").sum().as("totalRevenue"); + +``` + A new `Accumulator` representing the 'sum' aggregation. + +Signature: + +```typescript +sum(): Sum; +``` +Returns: + +[Sum](./firestore_lite.sum.md#sum_class) + +## Constant.timestampAdd() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to this timestamp expression. + +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + +``` + +Signature: + +```typescript +timestampAdd(unit: Constant, amount: Constant): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) + +## Constant.timestampAdd() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to this timestamp expression. + +```typescript +// Add 1 day to the 'timestamp' field. +Field.of("timestamp").timestampAdd("day", 1); + +``` + +Signature: + +```typescript +timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | +| amount | number | The amount of time to add. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) + +## Constant.timestampSub() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from this timestamp expression. + +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + +``` + +Signature: + +```typescript +timestampSub(unit: Constant, amount: Constant): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) + +## Constant.timestampSub() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from this timestamp expression. + +```typescript +// Subtract 1 day from the 'timestamp' field. +Field.of("timestamp").timestampSub("day", 1); + +``` + +Signature: + +```typescript +timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | +| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) + +## Constant.timestampToUnixMicros() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +Field.of("timestamp").timestampToUnixMicros(); + +``` + A new representing the number of microseconds since epoch. + +Signature: + +```typescript +timestampToUnixMicros(): TimestampToUnixMicros; +``` +Returns: + +[TimestampToUnixMicros](./firestore_lite.timestamptounixmicros.md#timestamptounixmicros_class) + +## Constant.timestampToUnixMillis() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +Field.of("timestamp").timestampToUnixMillis(); + +``` + A new representing the number of milliseconds since epoch. + +Signature: + +```typescript +timestampToUnixMillis(): TimestampToUnixMillis; +``` +Returns: + +[TimestampToUnixMillis](./firestore_lite.timestamptounixmillis.md#timestamptounixmillis_class) + +## Constant.timestampToUnixSeconds() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to seconds since epoch. +Field.of("timestamp").timestampToUnixSeconds(); + +``` + A new representing the number of seconds since epoch. + +Signature: + +```typescript +timestampToUnixSeconds(): TimestampToUnixSeconds; +``` +Returns: + +[TimestampToUnixSeconds](./firestore_lite.timestamptounixseconds.md#timestamptounixseconds_class) + +## Constant.toLower() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string to lowercase. + +```typescript +// Convert the 'name' field to lowercase +Field.of("name").toLower(); + +``` + A new `Expr` representing the lowercase string. + +Signature: + +```typescript +toLower(): ToLower; +``` +Returns: + +[ToLower](./firestore_lite.tolower.md#tolower_class) + +## Constant.toUpper() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string to uppercase. + +```typescript +// Convert the 'title' field to uppercase +Field.of("title").toUpper(); + +``` + A new `Expr` representing the uppercase string. + +Signature: + +```typescript +toUpper(): ToUpper; +``` +Returns: + +[ToUpper](./firestore_lite.toupper.md#toupper_class) + +## Constant.trim() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that removes leading and trailing whitespace from a string. + +```typescript +// Trim whitespace from the 'userInput' field +Field.of("userInput").trim(); + +``` + A new `Expr` representing the trimmed string. + +Signature: + +```typescript +trim(): Trim; +``` +Returns: + +[Trim](./firestore_lite.trim.md#trim_class) + +## Constant.unixMicrosToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +Field.of("microseconds").unixMicrosToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixMicrosToTimestamp(): UnixMicrosToTimestamp; +``` +Returns: + +[UnixMicrosToTimestamp](./firestore_lite.unixmicrostotimestamp.md#unixmicrostotimestamp_class) + +## Constant.unixMillisToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +Field.of("milliseconds").unixMillisToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixMillisToTimestamp(): UnixMillisToTimestamp; +``` +Returns: + +[UnixMillisToTimestamp](./firestore_lite.unixmillistotimestamp.md#unixmillistotimestamp_class) + +## Constant.unixSecondsToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'seconds' field as seconds since epoch. +Field.of("seconds").unixSecondsToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixSecondsToTimestamp(): UnixSecondsToTimestamp; +``` +Returns: + +[UnixSecondsToTimestamp](./firestore_lite.unixsecondstotimestamp.md#unixsecondstotimestamp_class) + +## Constant.vector() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a `Constant` instance for a VectorValue value. + +```typescript +// Create a Constant instance for a vector value +const vectorConstant = Constant.ofVector([1, 2, 3]); + +``` + +Signature: + +```typescript +static vector(value: number[] | VectorValue): Constant; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | number\[\] \| [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The VectorValue value. A new Constant instance. | + +Returns: + +[Constant](./firestore_lite.constant.md#constant_class) + +## Constant.vectorLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. + +```typescript +// Get the vector length (dimension) of the field 'embedding'. +Field.of("embedding").vectorLength(); + +``` + A new representing the length of the vector. + +Signature: + +```typescript +vectorLength(): VectorLength; +``` +Returns: + +[VectorLength](./firestore_lite.vectorlength.md#vectorlength_class) + diff --git a/docs-devsite/firestore_lite.cosinedistance.md b/docs-devsite/firestore_lite.cosinedistance.md new file mode 100644 index 00000000000..d8642f784ee --- /dev/null +++ b/docs-devsite/firestore_lite.cosinedistance.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# CosineDistance class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class CosineDistance extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(vector1, vector2)](./firestore_lite.cosinedistance.md#cosinedistanceconstructor) | | (BETA) Constructs a new instance of the CosineDistance class | + +## CosineDistance.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `CosineDistance` class + +Signature: + +```typescript +constructor(vector1: Constant, vector2: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| vector1 | [Constant](./firestore_lite.constant.md#constant_class) | | +| vector2 | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.count.md b/docs-devsite/firestore_lite.count.md new file mode 100644 index 00000000000..3de2d0585a7 --- /dev/null +++ b/docs-devsite/firestore_lite.count.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Count class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Count extends FirestoreFunction implements Accumulator +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [Accumulator](./firestore_lite.accumulator.md#accumulator_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value, distinct)](./firestore_lite.count.md#countconstructor) | | (BETA) Constructs a new instance of the Count class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [accumulator](./firestore_lite.count.md#countaccumulator) | | true | (BETA) | + +## Count.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Count` class + +Signature: + +```typescript +constructor(value: Constant | undefined, distinct: boolean); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_lite.constant.md#constant_class) \| undefined | | +| distinct | boolean | | + +## Count.accumulator + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +accumulator: true; +``` diff --git a/docs-devsite/firestore_lite.databasesource.md b/docs-devsite/firestore_lite.databasesource.md new file mode 100644 index 00000000000..c837f93ba36 --- /dev/null +++ b/docs-devsite/firestore_lite.databasesource.md @@ -0,0 +1,39 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# DatabaseSource class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class DatabaseSource implements Stage +``` +Implements: [Stage](./firestore_lite.stage.md#stage_interface) + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_lite.databasesource.md#databasesourcename) | | string | (BETA) | + +## DatabaseSource.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_lite.distinct.md b/docs-devsite/firestore_lite.distinct.md new file mode 100644 index 00000000000..37d2385de22 --- /dev/null +++ b/docs-devsite/firestore_lite.distinct.md @@ -0,0 +1,64 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Distinct class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Distinct implements Stage +``` +Implements: [Stage](./firestore_lite.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(groups)](./firestore_lite.distinct.md#distinctconstructor) | | (BETA) Constructs a new instance of the Distinct class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_lite.distinct.md#distinctname) | | string | (BETA) | + +## Distinct.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Distinct` class + +Signature: + +```typescript +constructor(groups: Map); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| groups | Map<string, [Constant](./firestore_lite.constant.md#constant_class)> | | + +## Distinct.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_lite.divide.md b/docs-devsite/firestore_lite.divide.md new file mode 100644 index 00000000000..ae2ed8410a4 --- /dev/null +++ b/docs-devsite/firestore_lite.divide.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Divide class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Divide extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_lite.divide.md#divideconstructor) | | (BETA) Constructs a new instance of the Divide class | + +## Divide.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Divide` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | | +| right | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.documentssource.md b/docs-devsite/firestore_lite.documentssource.md new file mode 100644 index 00000000000..5444a06ee6a --- /dev/null +++ b/docs-devsite/firestore_lite.documentssource.md @@ -0,0 +1,92 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# DocumentsSource class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class DocumentsSource implements Stage +``` +Implements: [Stage](./firestore_lite.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(docPaths)](./firestore_lite.documentssource.md#documentssourceconstructor) | | (BETA) Constructs a new instance of the DocumentsSource class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_lite.documentssource.md#documentssourcename) | | string | (BETA) | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [of(refs)](./firestore_lite.documentssource.md#documentssourceof) | static | (BETA) | + +## DocumentsSource.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `DocumentsSource` class + +Signature: + +```typescript +constructor(docPaths: string[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| docPaths | string\[\] | | + +## DocumentsSource.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` + +## DocumentsSource.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +static of(refs: DocumentReference[]): DocumentsSource; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| refs | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)\[\] | | + +Returns: + +[DocumentsSource](./firestore_lite.documentssource.md#documentssource_class) + diff --git a/docs-devsite/firestore_lite.dotproduct.md b/docs-devsite/firestore_lite.dotproduct.md new file mode 100644 index 00000000000..ad91f78f92d --- /dev/null +++ b/docs-devsite/firestore_lite.dotproduct.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# DotProduct class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class DotProduct extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(vector1, vector2)](./firestore_lite.dotproduct.md#dotproductconstructor) | | (BETA) Constructs a new instance of the DotProduct class | + +## DotProduct.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `DotProduct` class + +Signature: + +```typescript +constructor(vector1: Constant, vector2: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| vector1 | [Constant](./firestore_lite.constant.md#constant_class) | | +| vector2 | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.endswith.md b/docs-devsite/firestore_lite.endswith.md new file mode 100644 index 00000000000..d34c4f3dc83 --- /dev/null +++ b/docs-devsite/firestore_lite.endswith.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# EndsWith class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class EndsWith extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr, suffix)](./firestore_lite.endswith.md#endswithconstructor) | | (BETA) Constructs a new instance of the EndsWith class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_lite.endswith.md#endswithfilterable) | | true | (BETA) | + +## EndsWith.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `EndsWith` class + +Signature: + +```typescript +constructor(expr: Constant, suffix: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | | +| suffix | [Constant](./firestore_lite.constant.md#constant_class) | | + +## EndsWith.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.eq.md b/docs-devsite/firestore_lite.eq.md new file mode 100644 index 00000000000..02fa728f481 --- /dev/null +++ b/docs-devsite/firestore_lite.eq.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Eq class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Eq extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_lite.eq.md#eqconstructor) | | (BETA) Constructs a new instance of the Eq class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_lite.eq.md#eqfilterable) | | true | (BETA) | + +## Eq.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Eq` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | | +| right | [Constant](./firestore_lite.constant.md#constant_class) | | + +## Eq.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.euclideandistance.md b/docs-devsite/firestore_lite.euclideandistance.md new file mode 100644 index 00000000000..860057fc9d7 --- /dev/null +++ b/docs-devsite/firestore_lite.euclideandistance.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# EuclideanDistance class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class EuclideanDistance extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(vector1, vector2)](./firestore_lite.euclideandistance.md#euclideandistanceconstructor) | | (BETA) Constructs a new instance of the EuclideanDistance class | + +## EuclideanDistance.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `EuclideanDistance` class + +Signature: + +```typescript +constructor(vector1: Constant, vector2: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| vector1 | [Constant](./firestore_lite.constant.md#constant_class) | | +| vector2 | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.exists.md b/docs-devsite/firestore_lite.exists.md new file mode 100644 index 00000000000..50ef86f9fec --- /dev/null +++ b/docs-devsite/firestore_lite.exists.md @@ -0,0 +1,66 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Exists class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Exists extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr)](./firestore_lite.exists.md#existsconstructor) | | (BETA) Constructs a new instance of the Exists class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_lite.exists.md#existsfilterable) | | true | (BETA) | + +## Exists.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Exists` class + +Signature: + +```typescript +constructor(expr: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | | + +## Exists.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.exprwithalias.md b/docs-devsite/firestore_lite.exprwithalias.md new file mode 100644 index 00000000000..a7c47c19b4f --- /dev/null +++ b/docs-devsite/firestore_lite.exprwithalias.md @@ -0,0 +1,3207 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ExprWithAlias class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ExprWithAlias implements Selectable +``` +Implements: [Selectable](./firestore_lite.selectable.md#selectable_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr, alias)](./firestore_lite.exprwithalias.md#exprwithaliasconstructor) | | (BETA) Constructs a new instance of the ExprWithAlias class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [alias](./firestore_lite.exprwithalias.md#exprwithaliasalias) | | string | (BETA) | +| [expr](./firestore_lite.exprwithalias.md#exprwithaliasexpr) | | T | (BETA) | +| [exprType](./firestore_lite.exprwithalias.md#exprwithaliasexprtype) | | [ExprType](./firestore_lite.md#exprtype) | (BETA) | +| [selectable](./firestore_lite.exprwithalias.md#exprwithaliasselectable) | | true | (BETA) | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [add(other)](./firestore_lite.exprwithalias.md#exprwithaliasadd) | | (BETA) Creates an expression that adds this expression to another expression. +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +Field.of("quantity").add(Field.of("reserve")); + +``` + | +| [add(other)](./firestore_lite.exprwithalias.md#exprwithaliasadd) | | (BETA) Creates an expression that adds this expression to a constant value. +```typescript +// Add 5 to the value of the 'age' field +Field.of("age").add(5); + +``` + | +| [arrayConcat(arrays)](./firestore_lite.exprwithalias.md#exprwithaliasarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. +```typescript +// Combine the 'items' array with another array field. +Field.of("items").arrayConcat(Field.of("otherItems")); + +``` + | +| [arrayConcat(arrays)](./firestore_lite.exprwithalias.md#exprwithaliasarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. +```typescript +// Combine the 'tags' array with a new array and an array field +Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + +``` + | +| [arrayContains(element)](./firestore_lite.exprwithalias.md#exprwithaliasarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific element. +```typescript +// Check if the 'sizes' array contains the value from the 'selectedSize' field +Field.of("sizes").arrayContains(Field.of("selectedSize")); + +``` + | +| [arrayContains(element)](./firestore_lite.exprwithalias.md#exprwithaliasarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific value. +```typescript +// Check if the 'colors' array contains "red" +Field.of("colors").arrayContains("red"); + +``` + | +| [arrayContainsAll(values)](./firestore_lite.exprwithalias.md#exprwithaliasarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. +```typescript +// Check if the 'tags' array contains both "news" and "sports" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + | +| [arrayContainsAll(values)](./firestore_lite.exprwithalias.md#exprwithaliasarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + | +| [arrayContainsAny(values)](./firestore_lite.exprwithalias.md#exprwithaliasarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "cate2" +Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + +``` + | +| [arrayContainsAny(values)](./firestore_lite.exprwithalias.md#exprwithaliasarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + +``` + | +| [arrayLength()](./firestore_lite.exprwithalias.md#exprwithaliasarraylength) | | (BETA) Creates an expression that calculates the length of an array. +```typescript +// Get the number of items in the 'cart' array +Field.of("cart").arrayLength(); + +``` + A new Expr representing the length of the array. | +| [as(name)](./firestore_lite.exprwithalias.md#exprwithaliasas) | | (BETA) Assigns an alias to this expression.Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. +```typescript +// Calculate the total price and assign it the alias "totalPrice" and add it to the output. +firestore.pipeline().collection("items") +.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + +``` + | +| [ascending()](./firestore_lite.exprwithalias.md#exprwithaliasascending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. +```typescript +// Sort documents by the 'name' field in ascending order +pipeline().collection("users") +.sort(Field.of("name").ascending()); + +``` + A new Ordering for ascending sorting. | +| [avg()](./firestore_lite.exprwithalias.md#exprwithaliasavg) | | (BETA) Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. +```typescript +// Calculate the average age of users +Field.of("age").avg().as("averageAge"); + +``` + A new Accumulator representing the 'avg' aggregation. | +| [byteLength()](./firestore_lite.exprwithalias.md#exprwithaliasbytelength) | | (BETA) Creates an expression that calculates the length of this string expression in bytes. +```typescript +// Calculate the length of the 'myString' field in bytes. +Field.of("myString").byteLength(); + +``` + A new representing the length of the string in bytes. | +| [charLength()](./firestore_lite.exprwithalias.md#exprwithaliascharlength) | | (BETA) Creates an expression that calculates the character length of a string in UTF-8. +```typescript +// Get the character length of the 'name' field in its UTF-8 form. +Field.of("name").charLength(); + +``` + A new Expr representing the length of the string. | +| [cosineDistance(other)](./firestore_lite.exprwithalias.md#exprwithaliascosinedistance) | | (BETA) Calculates the cosine distance between two vectors. +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +Field.of("userVector").cosineDistance(Field.of("itemVector")); + +``` + | +| [cosineDistance(other)](./firestore_lite.exprwithalias.md#exprwithaliascosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + +``` + | +| [cosineDistance(other)](./firestore_lite.exprwithalias.md#exprwithaliascosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance([37.7749, -122.4194]); + +``` + | +| [count()](./firestore_lite.exprwithalias.md#exprwithaliascount) | | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. +```typescript +// Count the total number of products +Field.of("productId").count().as("totalProducts"); + +``` + A new Accumulator representing the 'count' aggregation. | +| [descending()](./firestore_lite.exprwithalias.md#exprwithaliasdescending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") +.sort(Field.of("createdAt").descending()); + +``` + A new Ordering for descending sorting. | +| [divide(other)](./firestore_lite.exprwithalias.md#exprwithaliasdivide) | | (BETA) Creates an expression that divides this expression by another expression. +```typescript +// Divide the 'total' field by the 'count' field +Field.of("total").divide(Field.of("count")); + +``` + | +| [divide(other)](./firestore_lite.exprwithalias.md#exprwithaliasdivide) | | (BETA) Creates an expression that divides this expression by a constant value. +```typescript +// Divide the 'value' field by 10 +Field.of("value").divide(10); + +``` + | +| [dotProduct(other)](./firestore_lite.exprwithalias.md#exprwithaliasdotproduct) | | (BETA) Calculates the dot product between two vectors. +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct([0.5, 0.8, 0.2]); + +``` + | +| [dotProduct(other)](./firestore_lite.exprwithalias.md#exprwithaliasdotproduct) | | (BETA) Calculates the dot product between two vectors. +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + +``` + | +| [dotProduct(other)](./firestore_lite.exprwithalias.md#exprwithaliasdotproduct) | | (BETA) | +| [endsWith(suffix)](./firestore_lite.exprwithalias.md#exprwithaliasendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix. +```typescript +// Check if the 'filename' field ends with ".txt" +Field.of("filename").endsWith(".txt"); + +``` + | +| [endsWith(suffix)](./firestore_lite.exprwithalias.md#exprwithaliasendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix (represented as an expression). +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +Field.of("url").endsWith(Field.of("extension")); + +``` + | +| [eq(other)](./firestore_lite.exprwithalias.md#exprwithaliaseq) | | (BETA) Creates an expression that checks if this expression is equal to another expression. +```typescript +// Check if the 'age' field is equal to 21 +Field.of("age").eq(21); + +``` + | +| [eq(other)](./firestore_lite.exprwithalias.md#exprwithaliaseq) | | (BETA) Creates an expression that checks if this expression is equal to a constant value. +```typescript +// Check if the 'city' field is equal to "London" +Field.of("city").eq("London"); + +``` + | +| [euclideanDistance(other)](./firestore_lite.exprwithalias.md#exprwithaliaseuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance([37.7749, -122.4194]); + +``` + | +| [euclideanDistance(other)](./firestore_lite.exprwithalias.md#exprwithaliaseuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + +``` + | +| [euclideanDistance(other)](./firestore_lite.exprwithalias.md#exprwithaliaseuclideandistance) | | (BETA) | +| [exists()](./firestore_lite.exprwithalias.md#exprwithaliasexists) | | (BETA) Creates an expression that checks if a field exists in the document. +```typescript +// Check if the document has a field named "phoneNumber" +Field.of("phoneNumber").exists(); + +``` + A new Expr representing the 'exists' check. | +| [gt(other)](./firestore_lite.exprwithalias.md#exprwithaliasgt) | | (BETA) Creates an expression that checks if this expression is greater than another expression. +```typescript +// Check if the 'age' field is greater than the 'limit' field +Field.of("age").gt(Field.of("limit")); + +``` + | +| [gt(other)](./firestore_lite.exprwithalias.md#exprwithaliasgt) | | (BETA) Creates an expression that checks if this expression is greater than a constant value. +```typescript +// Check if the 'price' field is greater than 100 +Field.of("price").gt(100); + +``` + | +| [gte(other)](./firestore_lite.exprwithalias.md#exprwithaliasgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to another expression. +```typescript +// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 +Field.of("quantity").gte(Field.of('requirement').add(1)); + +``` + | +| [gte(other)](./firestore_lite.exprwithalias.md#exprwithaliasgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to a constant value. +```typescript +// Check if the 'score' field is greater than or equal to 80 +Field.of("score").gte(80); + +``` + | +| [in(others)](./firestore_lite.exprwithalias.md#exprwithaliasin) | | (BETA) Creates an expression that checks if this expression is equal to any of the provided values or expressions. +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +Field.of("category").in("Electronics", Field.of("primaryType")); + +``` + | +| [in(others)](./firestore_lite.exprwithalias.md#exprwithaliasin) | | (BETA) | +| [isNaN()](./firestore_lite.exprwithalias.md#exprwithaliasisnan) | | (BETA) Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). +```typescript +// Check if the result of a calculation is NaN +Field.of("value").divide(0).isNaN(); + +``` + A new Expr representing the 'isNaN' check. | +| [like(pattern)](./firestore_lite.exprwithalias.md#exprwithaliaslike) | | (BETA) Creates an expression that performs a case-sensitive string comparison. +```typescript +// Check if the 'title' field contains the word "guide" (case-sensitive) +Field.of("title").like("%guide%"); + +``` + | +| [like(pattern)](./firestore_lite.exprwithalias.md#exprwithaliaslike) | | (BETA) | +| [logicalMax(other)](./firestore_lite.exprwithalias.md#exprwithaliaslogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMax(Function.currentTimestamp()); + +``` + | +| [logicalMax(other)](./firestore_lite.exprwithalias.md#exprwithaliaslogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'value' field and 10. +Field.of("value").logicalMax(10); + +``` + | +| [logicalMin(other)](./firestore_lite.exprwithalias.md#exprwithaliaslogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMin(Function.currentTimestamp()); + +``` + | +| [logicalMin(other)](./firestore_lite.exprwithalias.md#exprwithaliaslogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'value' field and 10. +Field.of("value").logicalMin(10); + +``` + | +| [lt(other)](./firestore_lite.exprwithalias.md#exprwithaliaslt) | | (BETA) Creates an expression that checks if this expression is less than another expression. +```typescript +// Check if the 'age' field is less than 'limit' +Field.of("age").lt(Field.of('limit')); + +``` + | +| [lt(other)](./firestore_lite.exprwithalias.md#exprwithaliaslt) | | (BETA) Creates an expression that checks if this expression is less than a constant value. +```typescript +// Check if the 'price' field is less than 50 +Field.of("price").lt(50); + +``` + | +| [lte(other)](./firestore_lite.exprwithalias.md#exprwithaliaslte) | | (BETA) Creates an expression that checks if this expression is less than or equal to another expression. +```typescript +// Check if the 'quantity' field is less than or equal to 20 +Field.of("quantity").lte(Constant.of(20)); + +``` + | +| [lte(other)](./firestore_lite.exprwithalias.md#exprwithaliaslte) | | (BETA) Creates an expression that checks if this expression is less than or equal to a constant value. +```typescript +// Check if the 'score' field is less than or equal to 70 +Field.of("score").lte(70); + +``` + | +| [mapGet(subfield)](./firestore_lite.exprwithalias.md#exprwithaliasmapget) | | (BETA) Accesses a value from a map (object) field using the provided key. +```typescript +// Get the 'city' value from the 'address' map field +Field.of("address").mapGet("city"); + +``` + | +| [max()](./firestore_lite.exprwithalias.md#exprwithaliasmax) | | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. +```typescript +// Find the highest score in a leaderboard +Field.of("score").max().as("highestScore"); + +``` + A new Accumulator representing the 'max' aggregation. | +| [min()](./firestore_lite.exprwithalias.md#exprwithaliasmin) | | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. +```typescript +// Find the lowest price of all products +Field.of("price").min().as("lowestPrice"); + +``` + A new Accumulator representing the 'min' aggregation. | +| [mod(other)](./firestore_lite.exprwithalias.md#exprwithaliasmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. +```typescript +// Calculate the remainder of dividing the 'value' field by the 'divisor' field +Field.of("value").mod(Field.of("divisor")); + +``` + | +| [mod(other)](./firestore_lite.exprwithalias.md#exprwithaliasmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. +```typescript +// Calculate the remainder of dividing the 'value' field by 10 +Field.of("value").mod(10); + +``` + | +| [multiply(other)](./firestore_lite.exprwithalias.md#exprwithaliasmultiply) | | (BETA) Creates an expression that multiplies this expression by another expression. +```typescript +// Multiply the 'quantity' field by the 'price' field +Field.of("quantity").multiply(Field.of("price")); + +``` + | +| [multiply(other)](./firestore_lite.exprwithalias.md#exprwithaliasmultiply) | | (BETA) Creates an expression that multiplies this expression by a constant value. +```typescript +// Multiply the 'value' field by 2 +Field.of("value").multiply(2); + +``` + | +| [neq(other)](./firestore_lite.exprwithalias.md#exprwithaliasneq) | | (BETA) Creates an expression that checks if this expression is not equal to another expression. +```typescript +// Check if the 'status' field is not equal to "completed" +Field.of("status").neq("completed"); + +``` + | +| [neq(other)](./firestore_lite.exprwithalias.md#exprwithaliasneq) | | (BETA) Creates an expression that checks if this expression is not equal to a constant value. +```typescript +// Check if the 'country' field is not equal to "USA" +Field.of("country").neq("USA"); + +``` + | +| [regexContains(pattern)](./firestore_lite.exprwithalias.md#exprwithaliasregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +Field.of("description").regexContains("(?i)example"); + +``` + | +| [regexContains(pattern)](./firestore_lite.exprwithalias.md#exprwithaliasregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains the regular expression stored in field 'regex' +Field.of("description").regexContains(Field.of("regex")); + +``` + | +| [regexMatch(pattern)](./firestore_lite.exprwithalias.md#exprwithaliasregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. +```typescript +// Check if the 'email' field matches a valid email pattern +Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + | +| [regexMatch(pattern)](./firestore_lite.exprwithalias.md#exprwithaliasregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. +```typescript +// Check if the 'email' field matches a regular expression stored in field 'regex' +Field.of("email").regexMatch(Field.of("regex")); + +``` + | +| [replaceAll(find, replace)](./firestore_lite.exprwithalias.md#exprwithaliasreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring. +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field +Field.of("message").replaceAll("hello", "hi"); + +``` + | +| [replaceAll(find, replace)](./firestore_lite.exprwithalias.md#exprwithaliasreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + +``` + | +| [replaceFirst(find, replace)](./firestore_lite.exprwithalias.md#exprwithaliasreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field +Field.of("message").replaceFirst("hello", "hi"); + +``` + | +| [replaceFirst(find, replace)](./firestore_lite.exprwithalias.md#exprwithaliasreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + +``` + | +| [reverse()](./firestore_lite.exprwithalias.md#exprwithaliasreverse) | | (BETA) Creates an expression that reverses this string expression. +```typescript +// Reverse the value of the 'myString' field. +Field.of("myString").reverse(); + +``` + A new representing the reversed string. | +| [startsWith(prefix)](./firestore_lite.exprwithalias.md#exprwithaliasstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix. +```typescript +// Check if the 'name' field starts with "Mr." +Field.of("name").startsWith("Mr."); + +``` + | +| [startsWith(prefix)](./firestore_lite.exprwithalias.md#exprwithaliasstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix (represented as an expression). +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +Field.of("fullName").startsWith(Field.of("firstName")); + +``` + | +| [strConcat(elements)](./firestore_lite.exprwithalias.md#exprwithaliasstrconcat) | | (BETA) Creates an expression that concatenates string expressions together. +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + +``` + | +| [strContains(substring)](./firestore_lite.exprwithalias.md#exprwithaliasstrcontains) | | (BETA) Creates an expression that checks if a string contains a specified substring. +```typescript +// Check if the 'description' field contains "example". +Field.of("description").strContains("example"); + +``` + | +| [strContains(expr)](./firestore_lite.exprwithalias.md#exprwithaliasstrcontains) | | (BETA) Creates an expression that checks if a string contains the string represented by another expression. +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +Field.of("description").strContains(Field.of("keyword")); + +``` + | +| [subtract(other)](./firestore_lite.exprwithalias.md#exprwithaliassubtract) | | (BETA) Creates an expression that subtracts another expression from this expression. +```typescript +// Subtract the 'discount' field from the 'price' field +Field.of("price").subtract(Field.of("discount")); + +``` + | +| [subtract(other)](./firestore_lite.exprwithalias.md#exprwithaliassubtract) | | (BETA) Creates an expression that subtracts a constant value from this expression. +```typescript +// Subtract 20 from the value of the 'total' field +Field.of("total").subtract(20); + +``` + | +| [sum()](./firestore_lite.exprwithalias.md#exprwithaliassum) | | (BETA) Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. +```typescript +// Calculate the total revenue from a set of orders +Field.of("orderAmount").sum().as("totalRevenue"); + +``` + A new Accumulator representing the 'sum' aggregation. | +| [timestampAdd(unit, amount)](./firestore_lite.exprwithalias.md#exprwithaliastimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampAdd(unit, amount)](./firestore_lite.exprwithalias.md#exprwithaliastimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. +```typescript +// Add 1 day to the 'timestamp' field. +Field.of("timestamp").timestampAdd("day", 1); + +``` + | +| [timestampSub(unit, amount)](./firestore_lite.exprwithalias.md#exprwithaliastimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampSub(unit, amount)](./firestore_lite.exprwithalias.md#exprwithaliastimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. +```typescript +// Subtract 1 day from the 'timestamp' field. +Field.of("timestamp").timestampSub("day", 1); + +``` + | +| [timestampToUnixMicros()](./firestore_lite.exprwithalias.md#exprwithaliastimestamptounixmicros) | | (BETA) Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +Field.of("timestamp").timestampToUnixMicros(); + +``` + A new representing the number of microseconds since epoch. | +| [timestampToUnixMillis()](./firestore_lite.exprwithalias.md#exprwithaliastimestamptounixmillis) | | (BETA) Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +Field.of("timestamp").timestampToUnixMillis(); + +``` + A new representing the number of milliseconds since epoch. | +| [timestampToUnixSeconds()](./firestore_lite.exprwithalias.md#exprwithaliastimestamptounixseconds) | | (BETA) Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to seconds since epoch. +Field.of("timestamp").timestampToUnixSeconds(); + +``` + A new representing the number of seconds since epoch. | +| [toLower()](./firestore_lite.exprwithalias.md#exprwithaliastolower) | | (BETA) Creates an expression that converts a string to lowercase. +```typescript +// Convert the 'name' field to lowercase +Field.of("name").toLower(); + +``` + A new Expr representing the lowercase string. | +| [toUpper()](./firestore_lite.exprwithalias.md#exprwithaliastoupper) | | (BETA) Creates an expression that converts a string to uppercase. +```typescript +// Convert the 'title' field to uppercase +Field.of("title").toUpper(); + +``` + A new Expr representing the uppercase string. | +| [trim()](./firestore_lite.exprwithalias.md#exprwithaliastrim) | | (BETA) Creates an expression that removes leading and trailing whitespace from a string. +```typescript +// Trim whitespace from the 'userInput' field +Field.of("userInput").trim(); + +``` + A new Expr representing the trimmed string. | +| [unixMicrosToTimestamp()](./firestore_lite.exprwithalias.md#exprwithaliasunixmicrostotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +Field.of("microseconds").unixMicrosToTimestamp(); + +``` + A new representing the timestamp. | +| [unixMillisToTimestamp()](./firestore_lite.exprwithalias.md#exprwithaliasunixmillistotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +Field.of("milliseconds").unixMillisToTimestamp(); + +``` + A new representing the timestamp. | +| [unixSecondsToTimestamp()](./firestore_lite.exprwithalias.md#exprwithaliasunixsecondstotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'seconds' field as seconds since epoch. +Field.of("seconds").unixSecondsToTimestamp(); + +``` + A new representing the timestamp. | +| [vectorLength()](./firestore_lite.exprwithalias.md#exprwithaliasvectorlength) | | (BETA) Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. +```typescript +// Get the vector length (dimension) of the field 'embedding'. +Field.of("embedding").vectorLength(); + +``` + A new representing the length of the vector. | + +## ExprWithAlias.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ExprWithAlias` class + +Signature: + +```typescript +constructor(expr: T, alias: string); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | T | | +| alias | string | | + +## ExprWithAlias.alias + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +alias: string; +``` + +## ExprWithAlias.expr + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +expr: T; +``` + +## ExprWithAlias.exprType + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +exprType: ExprType; +``` + +## ExprWithAlias.selectable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +selectable: true; +``` + +## ExprWithAlias.add() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds this expression to another expression. + +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +Field.of("quantity").add(Field.of("reserve")); + +``` + +Signature: + +```typescript +add(other: Constant): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to add to this expression. A new Expr representing the addition operation. | + +Returns: + +[Add](./firestore_lite.add.md#add_class) + +## ExprWithAlias.add() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds this expression to a constant value. + +```typescript +// Add 5 to the value of the 'age' field +Field.of("age").add(5); + +``` + +Signature: + +```typescript +add(other: any): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to add. A new Expr representing the addition operation. | + +Returns: + +[Add](./firestore_lite.add.md#add_class) + +## ExprWithAlias.arrayConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with one or more other arrays. + +```typescript +// Combine the 'items' array with another array field. +Field.of("items").arrayConcat(Field.of("otherItems")); + +``` + +Signature: + +```typescript +arrayConcat(arrays: Constant[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrays | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The array expressions to concatenate. A new Expr representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) + +## ExprWithAlias.arrayConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with one or more other arrays. + +```typescript +// Combine the 'tags' array with a new array and an array field +Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + +``` + +Signature: + +```typescript +arrayConcat(arrays: any[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrays | any\[\] | The array expressions or values to concatenate. A new Expr representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) + +## ExprWithAlias.arrayContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains a specific element. + +```typescript +// Check if the 'sizes' array contains the value from the 'selectedSize' field +Field.of("sizes").arrayContains(Field.of("selectedSize")); + +``` + +Signature: + +```typescript +arrayContains(element: Constant): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | [Constant](./firestore_lite.constant.md#constant_class) | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) + +## ExprWithAlias.arrayContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains a specific value. + +```typescript +// Check if the 'colors' array contains "red" +Field.of("colors").arrayContains("red"); + +``` + +Signature: + +```typescript +arrayContains(element: any): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | any | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) + +## ExprWithAlias.arrayContainsAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both "news" and "sports" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + +Signature: + +```typescript +arrayContainsAll(...values: Constant[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) + +## ExprWithAlias.arrayContainsAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + +Signature: + +```typescript +arrayContainsAll(...values: any[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) + +## ExprWithAlias.arrayContainsAny() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains any of the specified elements. + +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "cate2" +Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + +``` + +Signature: + +```typescript +arrayContainsAny(...values: Constant[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) + +## ExprWithAlias.arrayContainsAny() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains any of the specified elements. + +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + +``` + +Signature: + +```typescript +arrayContainsAny(...values: any[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) + +## ExprWithAlias.arrayLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of an array. + +```typescript +// Get the number of items in the 'cart' array +Field.of("cart").arrayLength(); + +``` + A new `Expr` representing the length of the array. + +Signature: + +```typescript +arrayLength(): ArrayLength; +``` +Returns: + +[ArrayLength](./firestore_lite.arraylength.md#arraylength_class) + +## ExprWithAlias.as() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Assigns an alias to this expression. + +Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. + +```typescript +// Calculate the total price and assign it the alias "totalPrice" and add it to the output. +firestore.pipeline().collection("items") +.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + +``` + +Signature: + +```typescript +as(name: string): ExprWithAlias; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | The alias to assign to this expression. A new [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) that wraps this expression and associates it with the provided alias. | + +Returns: + +[ExprWithAlias](./firestore_lite.exprwithalias.md#exprwithalias_class)<this> + +## ExprWithAlias.ascending() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. + +```typescript +// Sort documents by the 'name' field in ascending order +pipeline().collection("users") +.sort(Field.of("name").ascending()); + +``` + A new `Ordering` for ascending sorting. + +Signature: + +```typescript +ascending(): Ordering; +``` +Returns: + +[Ordering](./firestore_lite.ordering.md#ordering_class) + +## ExprWithAlias.avg() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. + +```typescript +// Calculate the average age of users +Field.of("age").avg().as("averageAge"); + +``` + A new `Accumulator` representing the 'avg' aggregation. + +Signature: + +```typescript +avg(): Avg; +``` +Returns: + +[Avg](./firestore_lite.avg.md#avg_class) + +## ExprWithAlias.byteLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of this string expression in bytes. + +```typescript +// Calculate the length of the 'myString' field in bytes. +Field.of("myString").byteLength(); + +``` + A new representing the length of the string in bytes. + +Signature: + +```typescript +byteLength(): ByteLength; +``` +Returns: + +[ByteLength](./firestore_lite.bytelength.md#bytelength_class) + +## ExprWithAlias.charLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the character length of a string in UTF-8. + +```typescript +// Get the character length of the 'name' field in its UTF-8 form. +Field.of("name").charLength(); + +``` + A new `Expr` representing the length of the string. + +Signature: + +```typescript +charLength(): CharLength; +``` +Returns: + +[CharLength](./firestore_lite.charlength.md#charlength_class) + +## ExprWithAlias.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the cosine distance between two vectors. + +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +Field.of("userVector").cosineDistance(Field.of("itemVector")); + +``` + +Signature: + +```typescript +cosineDistance(other: Constant): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new Expr representing the cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) + +## ExprWithAlias.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vectors. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +cosineDistance(other: VectorValue): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) + +## ExprWithAlias.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vectors. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance([37.7749, -122.4194]); + +``` + +Signature: + +```typescript +cosineDistance(other: number[]): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | The other vector (as an array of numbers) to compare against. A new Expr representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) + +## ExprWithAlias.count() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. + +```typescript +// Count the total number of products +Field.of("productId").count().as("totalProducts"); + +``` + A new `Accumulator` representing the 'count' aggregation. + +Signature: + +```typescript +count(): Count; +``` +Returns: + +[Count](./firestore_lite.count.md#count_class) + +## ExprWithAlias.descending() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. + +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") +.sort(Field.of("createdAt").descending()); + +``` + A new `Ordering` for descending sorting. + +Signature: + +```typescript +descending(): Ordering; +``` +Returns: + +[Ordering](./firestore_lite.ordering.md#ordering_class) + +## ExprWithAlias.divide() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides this expression by another expression. + +```typescript +// Divide the 'total' field by the 'count' field +Field.of("total").divide(Field.of("count")); + +``` + +Signature: + +```typescript +divide(other: Constant): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new Expr representing the division operation. | + +Returns: + +[Divide](./firestore_lite.divide.md#divide_class) + +## ExprWithAlias.divide() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides this expression by a constant value. + +```typescript +// Divide the 'value' field by 10 +Field.of("value").divide(10); + +``` + +Signature: + +```typescript +divide(other: any): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to divide by. A new Expr representing the division operation. | + +Returns: + +[Divide](./firestore_lite.divide.md#divide_class) + +## ExprWithAlias.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vectors. + +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct([0.5, 0.8, 0.2]); + +``` + +Signature: + +```typescript +dotProduct(other: Constant): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) + +## ExprWithAlias.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vectors. + +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + +``` + +Signature: + +```typescript +dotProduct(other: VectorValue): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) + +## ExprWithAlias.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +dotProduct(other: number[]): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | | + +Returns: + +[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) + +## ExprWithAlias.endsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string ends with a given postfix. + +```typescript +// Check if the 'filename' field ends with ".txt" +Field.of("filename").endsWith(".txt"); + +``` + +Signature: + +```typescript +endsWith(suffix: string): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| suffix | string | The postfix to check for. A new Expr representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_lite.endswith.md#endswith_class) + +## ExprWithAlias.endsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string ends with a given postfix (represented as an expression). + +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +Field.of("url").endsWith(Field.of("extension")); + +``` + +Signature: + +```typescript +endsWith(suffix: Constant): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| suffix | [Constant](./firestore_lite.constant.md#constant_class) | The postfix expression to check for. A new Expr representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_lite.endswith.md#endswith_class) + +## ExprWithAlias.eq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to another expression. + +```typescript +// Check if the 'age' field is equal to 21 +Field.of("age").eq(21); + +``` + +Signature: + +```typescript +eq(other: Constant): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for equality. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_lite.eq.md#eq_class) + +## ExprWithAlias.eq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to a constant value. + +```typescript +// Check if the 'city' field is equal to "London" +Field.of("city").eq("London"); + +``` + +Signature: + +```typescript +eq(other: any): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for equality. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_lite.eq.md#eq_class) + +## ExprWithAlias.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vectors. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance([37.7749, -122.4194]); + +``` + +Signature: + +```typescript +euclideanDistance(other: Constant): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) + +## ExprWithAlias.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vectors. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +euclideanDistance(other: VectorValue): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) + +## ExprWithAlias.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +euclideanDistance(other: number[]): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | | + +Returns: + +[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) + +## ExprWithAlias.exists() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field exists in the document. + +```typescript +// Check if the document has a field named "phoneNumber" +Field.of("phoneNumber").exists(); + +``` + A new `Expr` representing the 'exists' check. + +Signature: + +```typescript +exists(): Exists; +``` +Returns: + +[Exists](./firestore_lite.exists.md#exists_class) + +## ExprWithAlias.gt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than another expression. + +```typescript +// Check if the 'age' field is greater than the 'limit' field +Field.of("age").gt(Field.of("limit")); + +``` + +Signature: + +```typescript +gt(other: Constant): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for greater than. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_lite.gt.md#gt_class) + +## ExprWithAlias.gt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than a constant value. + +```typescript +// Check if the 'price' field is greater than 100 +Field.of("price").gt(100); + +``` + +Signature: + +```typescript +gt(other: any): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for greater than. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_lite.gt.md#gt_class) + +## ExprWithAlias.gte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than or equal to another expression. + +```typescript +// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 +Field.of("quantity").gte(Field.of('requirement').add(1)); + +``` + +Signature: + +```typescript +gte(other: Constant): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_lite.gte.md#gte_class) + +## ExprWithAlias.gte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than or equal to a constant value. + +```typescript +// Check if the 'score' field is greater than or equal to 80 +Field.of("score").gte(80); + +``` + +Signature: + +```typescript +gte(other: any): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_lite.gte.md#gte_class) + +## ExprWithAlias.in() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to any of the provided values or expressions. + +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +Field.of("category").in("Electronics", Field.of("primaryType")); + +``` + +Signature: + +```typescript +in(...others: Constant[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| others | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The values or expressions to check against. A new Expr representing the 'IN' comparison. | + +Returns: + +[In](./firestore_lite.in.md#in_class) + +## ExprWithAlias.in() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +in(...others: any[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| others | any\[\] | | + +Returns: + +[In](./firestore_lite.in.md#in_class) + +## ExprWithAlias.isNaN() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). + +```typescript +// Check if the result of a calculation is NaN +Field.of("value").divide(0).isNaN(); + +``` + A new `Expr` representing the 'isNaN' check. + +Signature: + +```typescript +isNaN(): IsNan; +``` +Returns: + +[IsNan](./firestore_lite.isnan.md#isnan_class) + +## ExprWithAlias.like() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that performs a case-sensitive string comparison. + +```typescript +// Check if the 'title' field contains the word "guide" (case-sensitive) +Field.of("title").like("%guide%"); + +``` + +Signature: + +```typescript +like(pattern: string): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new Expr representing the 'like' comparison. | + +Returns: + +[Like](./firestore_lite.like.md#like_class) + +## ExprWithAlias.like() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +like(pattern: Constant): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | | + +Returns: + +[Like](./firestore_lite.like.md#like_class) + +## ExprWithAlias.logicalMax() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMax(Function.currentTimestamp()); + +``` + +Signature: + +```typescript +logicalMax(other: Constant): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare with. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) + +## ExprWithAlias.logicalMax() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'value' field and 10. +Field.of("value").logicalMax(10); + +``` + +Signature: + +```typescript +logicalMax(other: any): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare with. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) + +## ExprWithAlias.logicalMin() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMin(Function.currentTimestamp()); + +``` + +Signature: + +```typescript +logicalMin(other: Constant): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare with. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) + +## ExprWithAlias.logicalMin() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'value' field and 10. +Field.of("value").logicalMin(10); + +``` + +Signature: + +```typescript +logicalMin(other: any): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare with. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) + +## ExprWithAlias.lt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than another expression. + +```typescript +// Check if the 'age' field is less than 'limit' +Field.of("age").lt(Field.of('limit')); + +``` + +Signature: + +```typescript +lt(other: Constant): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for less than. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_lite.lt.md#lt_class) + +## ExprWithAlias.lt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than a constant value. + +```typescript +// Check if the 'price' field is less than 50 +Field.of("price").lt(50); + +``` + +Signature: + +```typescript +lt(other: any): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for less than. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_lite.lt.md#lt_class) + +## ExprWithAlias.lte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than or equal to another expression. + +```typescript +// Check if the 'quantity' field is less than or equal to 20 +Field.of("quantity").lte(Constant.of(20)); + +``` + +Signature: + +```typescript +lte(other: Constant): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_lite.lte.md#lte_class) + +## ExprWithAlias.lte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than or equal to a constant value. + +```typescript +// Check if the 'score' field is less than or equal to 70 +Field.of("score").lte(70); + +``` + +Signature: + +```typescript +lte(other: any): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_lite.lte.md#lte_class) + +## ExprWithAlias.mapGet() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Accesses a value from a map (object) field using the provided key. + +```typescript +// Get the 'city' value from the 'address' map field +Field.of("address").mapGet("city"); + +``` + +Signature: + +```typescript +mapGet(subfield: string): MapGet; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| subfield | string | The key to access in the map. A new Expr representing the value associated with the given key in the map. | + +Returns: + +[MapGet](./firestore_lite.mapget.md#mapget_class) + +## ExprWithAlias.max() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that finds the maximum value of a field across multiple stage inputs. + +```typescript +// Find the highest score in a leaderboard +Field.of("score").max().as("highestScore"); + +``` + A new `Accumulator` representing the 'max' aggregation. + +Signature: + +```typescript +max(): Max; +``` +Returns: + +[Max](./firestore_lite.max.md#max_class) + +## ExprWithAlias.min() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that finds the minimum value of a field across multiple stage inputs. + +```typescript +// Find the lowest price of all products +Field.of("price").min().as("lowestPrice"); + +``` + A new `Accumulator` representing the 'min' aggregation. + +Signature: + +```typescript +min(): Min; +``` +Returns: + +[Min](./firestore_lite.min.md#min_class) + +## ExprWithAlias.mod() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. + +```typescript +// Calculate the remainder of dividing the 'value' field by the 'divisor' field +Field.of("value").mod(Field.of("divisor")); + +``` + +Signature: + +```typescript +mod(other: Constant): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new Expr representing the modulo operation. | + +Returns: + +[Mod](./firestore_lite.mod.md#mod_class) + +## ExprWithAlias.mod() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. + +```typescript +// Calculate the remainder of dividing the 'value' field by 10 +Field.of("value").mod(10); + +``` + +Signature: + +```typescript +mod(other: any): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to divide by. A new Expr representing the modulo operation. | + +Returns: + +[Mod](./firestore_lite.mod.md#mod_class) + +## ExprWithAlias.multiply() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies this expression by another expression. + +```typescript +// Multiply the 'quantity' field by the 'price' field +Field.of("quantity").multiply(Field.of("price")); + +``` + +Signature: + +```typescript +multiply(other: Constant): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to multiply by. A new Expr representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_lite.multiply.md#multiply_class) + +## ExprWithAlias.multiply() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies this expression by a constant value. + +```typescript +// Multiply the 'value' field by 2 +Field.of("value").multiply(2); + +``` + +Signature: + +```typescript +multiply(other: any): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to multiply by. A new Expr representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_lite.multiply.md#multiply_class) + +## ExprWithAlias.neq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is not equal to another expression. + +```typescript +// Check if the 'status' field is not equal to "completed" +Field.of("status").neq("completed"); + +``` + +Signature: + +```typescript +neq(other: Constant): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for inequality. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_lite.neq.md#neq_class) + +## ExprWithAlias.neq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is not equal to a constant value. + +```typescript +// Check if the 'country' field is not equal to "USA" +Field.of("country").neq("USA"); + +``` + +Signature: + +```typescript +neq(other: any): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for inequality. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_lite.neq.md#neq_class) + +## ExprWithAlias.regexContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +Field.of("description").regexContains("(?i)example"); + +``` + +Signature: + +```typescript +regexContains(pattern: string): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) + +## ExprWithAlias.regexContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains the regular expression stored in field 'regex' +Field.of("description").regexContains(Field.of("regex")); + +``` + +Signature: + +```typescript +regexContains(pattern: Constant): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) + +## ExprWithAlias.regexMatch() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a valid email pattern +Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + +Signature: + +```typescript +regexMatch(pattern: string): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The regular expression to use for the match. A new Expr representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) + +## ExprWithAlias.regexMatch() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a regular expression stored in field 'regex' +Field.of("email").regexMatch(Field.of("regex")); + +``` + +Signature: + +```typescript +regexMatch(pattern: Constant): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the match. A new Expr representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) + +## ExprWithAlias.replaceAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within this string expression with another substring. + +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field +Field.of("message").replaceAll("hello", "hi"); + +``` + +Signature: + +```typescript +replaceAll(find: string, replace: string): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | string | The substring to search for. | +| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) + +## ExprWithAlias.replaceAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + +``` + +Signature: + +```typescript +replaceAll(find: Constant, replace: Constant): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) + +## ExprWithAlias.replaceFirst() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. + +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field +Field.of("message").replaceFirst("hello", "hi"); + +``` + +Signature: + +```typescript +replaceFirst(find: string, replace: string): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | string | The substring to search for. | +| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) + +## ExprWithAlias.replaceFirst() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + +``` + +Signature: + +```typescript +replaceFirst(find: Constant, replace: Constant): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) + +## ExprWithAlias.reverse() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that reverses this string expression. + +```typescript +// Reverse the value of the 'myString' field. +Field.of("myString").reverse(); + +``` + A new representing the reversed string. + +Signature: + +```typescript +reverse(): Reverse; +``` +Returns: + +[Reverse](./firestore_lite.reverse.md#reverse_class) + +## ExprWithAlias.startsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string starts with a given prefix. + +```typescript +// Check if the 'name' field starts with "Mr." +Field.of("name").startsWith("Mr."); + +``` + +Signature: + +```typescript +startsWith(prefix: string): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| prefix | string | The prefix to check for. A new Expr representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_lite.startswith.md#startswith_class) + +## ExprWithAlias.startsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string starts with a given prefix (represented as an expression). + +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +Field.of("fullName").startsWith(Field.of("firstName")); + +``` + +Signature: + +```typescript +startsWith(prefix: Constant): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| prefix | [Constant](./firestore_lite.constant.md#constant_class) | The prefix expression to check for. A new Expr representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_lite.startswith.md#startswith_class) + +## ExprWithAlias.strConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates string expressions together. + +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + +``` + +Signature: + +```typescript +strConcat(...elements: Array): StrConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| elements | Array<string \| [Constant](./firestore_lite.constant.md#constant_class)> | The expressions (typically strings) to concatenate. A new Expr representing the concatenated string. | + +Returns: + +[StrConcat](./firestore_lite.strconcat.md#strconcat_class) + +## ExprWithAlias.strContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified substring. + +```typescript +// Check if the 'description' field contains "example". +Field.of("description").strContains("example"); + +``` + +Signature: + +```typescript +strContains(substring: string): StrContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| substring | string | The substring to search for. A new Expr representing the 'contains' comparison. | + +Returns: + +[StrContains](./firestore_lite.strcontains.md#strcontains_class) + +## ExprWithAlias.strContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains the string represented by another expression. + +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +Field.of("description").strContains(Field.of("keyword")); + +``` + +Signature: + +```typescript +strContains(expr: Constant): StrContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. A new Expr representing the 'contains' comparison. | + +Returns: + +[StrContains](./firestore_lite.strcontains.md#strcontains_class) + +## ExprWithAlias.subtract() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts another expression from this expression. + +```typescript +// Subtract the 'discount' field from the 'price' field +Field.of("price").subtract(Field.of("discount")); + +``` + +Signature: + +```typescript +subtract(other: Constant): Subtract; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to subtract from this expression. A new Expr representing the subtraction operation. | + +Returns: + +[Subtract](./firestore_lite.subtract.md#subtract_class) + +## ExprWithAlias.subtract() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a constant value from this expression. + +```typescript +// Subtract 20 from the value of the 'total' field +Field.of("total").subtract(20); + +``` + +Signature: + +```typescript +subtract(other: any): Subtract; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to subtract. A new Expr representing the subtraction operation. | + +Returns: + +[Subtract](./firestore_lite.subtract.md#subtract_class) + +## ExprWithAlias.sum() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. + +```typescript +// Calculate the total revenue from a set of orders +Field.of("orderAmount").sum().as("totalRevenue"); + +``` + A new `Accumulator` representing the 'sum' aggregation. + +Signature: + +```typescript +sum(): Sum; +``` +Returns: + +[Sum](./firestore_lite.sum.md#sum_class) + +## ExprWithAlias.timestampAdd() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to this timestamp expression. + +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + +``` + +Signature: + +```typescript +timestampAdd(unit: Constant, amount: Constant): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) + +## ExprWithAlias.timestampAdd() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to this timestamp expression. + +```typescript +// Add 1 day to the 'timestamp' field. +Field.of("timestamp").timestampAdd("day", 1); + +``` + +Signature: + +```typescript +timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | +| amount | number | The amount of time to add. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) + +## ExprWithAlias.timestampSub() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from this timestamp expression. + +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + +``` + +Signature: + +```typescript +timestampSub(unit: Constant, amount: Constant): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) + +## ExprWithAlias.timestampSub() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from this timestamp expression. + +```typescript +// Subtract 1 day from the 'timestamp' field. +Field.of("timestamp").timestampSub("day", 1); + +``` + +Signature: + +```typescript +timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | +| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) + +## ExprWithAlias.timestampToUnixMicros() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +Field.of("timestamp").timestampToUnixMicros(); + +``` + A new representing the number of microseconds since epoch. + +Signature: + +```typescript +timestampToUnixMicros(): TimestampToUnixMicros; +``` +Returns: + +[TimestampToUnixMicros](./firestore_lite.timestamptounixmicros.md#timestamptounixmicros_class) + +## ExprWithAlias.timestampToUnixMillis() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +Field.of("timestamp").timestampToUnixMillis(); + +``` + A new representing the number of milliseconds since epoch. + +Signature: + +```typescript +timestampToUnixMillis(): TimestampToUnixMillis; +``` +Returns: + +[TimestampToUnixMillis](./firestore_lite.timestamptounixmillis.md#timestamptounixmillis_class) + +## ExprWithAlias.timestampToUnixSeconds() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to seconds since epoch. +Field.of("timestamp").timestampToUnixSeconds(); + +``` + A new representing the number of seconds since epoch. + +Signature: + +```typescript +timestampToUnixSeconds(): TimestampToUnixSeconds; +``` +Returns: + +[TimestampToUnixSeconds](./firestore_lite.timestamptounixseconds.md#timestamptounixseconds_class) + +## ExprWithAlias.toLower() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string to lowercase. + +```typescript +// Convert the 'name' field to lowercase +Field.of("name").toLower(); + +``` + A new `Expr` representing the lowercase string. + +Signature: + +```typescript +toLower(): ToLower; +``` +Returns: + +[ToLower](./firestore_lite.tolower.md#tolower_class) + +## ExprWithAlias.toUpper() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string to uppercase. + +```typescript +// Convert the 'title' field to uppercase +Field.of("title").toUpper(); + +``` + A new `Expr` representing the uppercase string. + +Signature: + +```typescript +toUpper(): ToUpper; +``` +Returns: + +[ToUpper](./firestore_lite.toupper.md#toupper_class) + +## ExprWithAlias.trim() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that removes leading and trailing whitespace from a string. + +```typescript +// Trim whitespace from the 'userInput' field +Field.of("userInput").trim(); + +``` + A new `Expr` representing the trimmed string. + +Signature: + +```typescript +trim(): Trim; +``` +Returns: + +[Trim](./firestore_lite.trim.md#trim_class) + +## ExprWithAlias.unixMicrosToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +Field.of("microseconds").unixMicrosToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixMicrosToTimestamp(): UnixMicrosToTimestamp; +``` +Returns: + +[UnixMicrosToTimestamp](./firestore_lite.unixmicrostotimestamp.md#unixmicrostotimestamp_class) + +## ExprWithAlias.unixMillisToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +Field.of("milliseconds").unixMillisToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixMillisToTimestamp(): UnixMillisToTimestamp; +``` +Returns: + +[UnixMillisToTimestamp](./firestore_lite.unixmillistotimestamp.md#unixmillistotimestamp_class) + +## ExprWithAlias.unixSecondsToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'seconds' field as seconds since epoch. +Field.of("seconds").unixSecondsToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixSecondsToTimestamp(): UnixSecondsToTimestamp; +``` +Returns: + +[UnixSecondsToTimestamp](./firestore_lite.unixsecondstotimestamp.md#unixsecondstotimestamp_class) + +## ExprWithAlias.vectorLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. + +```typescript +// Get the vector length (dimension) of the field 'embedding'. +Field.of("embedding").vectorLength(); + +``` + A new representing the length of the vector. + +Signature: + +```typescript +vectorLength(): VectorLength; +``` +Returns: + +[VectorLength](./firestore_lite.vectorlength.md#vectorlength_class) + diff --git a/docs-devsite/firestore_lite.field.md b/docs-devsite/firestore_lite.field.md new file mode 100644 index 00000000000..0619a19d6bb --- /dev/null +++ b/docs-devsite/firestore_lite.field.md @@ -0,0 +1,3275 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Field class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Represents a reference to a field in a Firestore document, or outputs of a [Pipeline](./firestore_.pipeline.md#pipeline_class) stage. + +

Field references are used to access document field values in expressions and to specify fields for sorting, filtering, and projecting data in Firestore pipelines. + +

You can create a `Field` instance using the static method: + +```typescript +// Create a Field instance for the 'name' field +const nameField = Field.of("name"); + +// Create a Field instance for a nested field 'address.city' +const cityField = Field.of("address.city"); + +``` + +Signature: + +```typescript +export declare class Field implements Selectable +``` +Implements: [Selectable](./firestore_lite.selectable.md#selectable_interface) + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [exprType](./firestore_lite.field.md#fieldexprtype) | | [ExprType](./firestore_lite.md#exprtype) | (BETA) | +| [selectable](./firestore_lite.field.md#fieldselectable) | | true | (BETA) | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [add(other)](./firestore_lite.field.md#fieldadd) | | (BETA) Creates an expression that adds this expression to another expression. +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +Field.of("quantity").add(Field.of("reserve")); + +``` + | +| [add(other)](./firestore_lite.field.md#fieldadd) | | (BETA) Creates an expression that adds this expression to a constant value. +```typescript +// Add 5 to the value of the 'age' field +Field.of("age").add(5); + +``` + | +| [arrayConcat(arrays)](./firestore_lite.field.md#fieldarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. +```typescript +// Combine the 'items' array with another array field. +Field.of("items").arrayConcat(Field.of("otherItems")); + +``` + | +| [arrayConcat(arrays)](./firestore_lite.field.md#fieldarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. +```typescript +// Combine the 'tags' array with a new array and an array field +Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + +``` + | +| [arrayContains(element)](./firestore_lite.field.md#fieldarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific element. +```typescript +// Check if the 'sizes' array contains the value from the 'selectedSize' field +Field.of("sizes").arrayContains(Field.of("selectedSize")); + +``` + | +| [arrayContains(element)](./firestore_lite.field.md#fieldarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific value. +```typescript +// Check if the 'colors' array contains "red" +Field.of("colors").arrayContains("red"); + +``` + | +| [arrayContainsAll(values)](./firestore_lite.field.md#fieldarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. +```typescript +// Check if the 'tags' array contains both "news" and "sports" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + | +| [arrayContainsAll(values)](./firestore_lite.field.md#fieldarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + | +| [arrayContainsAny(values)](./firestore_lite.field.md#fieldarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "cate2" +Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + +``` + | +| [arrayContainsAny(values)](./firestore_lite.field.md#fieldarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + +``` + | +| [arrayLength()](./firestore_lite.field.md#fieldarraylength) | | (BETA) Creates an expression that calculates the length of an array. +```typescript +// Get the number of items in the 'cart' array +Field.of("cart").arrayLength(); + +``` + A new Expr representing the length of the array. | +| [as(name)](./firestore_lite.field.md#fieldas) | | (BETA) Assigns an alias to this expression.Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. +```typescript +// Calculate the total price and assign it the alias "totalPrice" and add it to the output. +firestore.pipeline().collection("items") +.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + +``` + | +| [ascending()](./firestore_lite.field.md#fieldascending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. +```typescript +// Sort documents by the 'name' field in ascending order +pipeline().collection("users") +.sort(Field.of("name").ascending()); + +``` + A new Ordering for ascending sorting. | +| [avg()](./firestore_lite.field.md#fieldavg) | | (BETA) Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. +```typescript +// Calculate the average age of users +Field.of("age").avg().as("averageAge"); + +``` + A new Accumulator representing the 'avg' aggregation. | +| [byteLength()](./firestore_lite.field.md#fieldbytelength) | | (BETA) Creates an expression that calculates the length of this string expression in bytes. +```typescript +// Calculate the length of the 'myString' field in bytes. +Field.of("myString").byteLength(); + +``` + A new representing the length of the string in bytes. | +| [charLength()](./firestore_lite.field.md#fieldcharlength) | | (BETA) Creates an expression that calculates the character length of a string in UTF-8. +```typescript +// Get the character length of the 'name' field in its UTF-8 form. +Field.of("name").charLength(); + +``` + A new Expr representing the length of the string. | +| [cosineDistance(other)](./firestore_lite.field.md#fieldcosinedistance) | | (BETA) Calculates the cosine distance between two vectors. +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +Field.of("userVector").cosineDistance(Field.of("itemVector")); + +``` + | +| [cosineDistance(other)](./firestore_lite.field.md#fieldcosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + +``` + | +| [cosineDistance(other)](./firestore_lite.field.md#fieldcosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance([37.7749, -122.4194]); + +``` + | +| [count()](./firestore_lite.field.md#fieldcount) | | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. +```typescript +// Count the total number of products +Field.of("productId").count().as("totalProducts"); + +``` + A new Accumulator representing the 'count' aggregation. | +| [descending()](./firestore_lite.field.md#fielddescending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") +.sort(Field.of("createdAt").descending()); + +``` + A new Ordering for descending sorting. | +| [divide(other)](./firestore_lite.field.md#fielddivide) | | (BETA) Creates an expression that divides this expression by another expression. +```typescript +// Divide the 'total' field by the 'count' field +Field.of("total").divide(Field.of("count")); + +``` + | +| [divide(other)](./firestore_lite.field.md#fielddivide) | | (BETA) Creates an expression that divides this expression by a constant value. +```typescript +// Divide the 'value' field by 10 +Field.of("value").divide(10); + +``` + | +| [dotProduct(other)](./firestore_lite.field.md#fielddotproduct) | | (BETA) Calculates the dot product between two vectors. +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct([0.5, 0.8, 0.2]); + +``` + | +| [dotProduct(other)](./firestore_lite.field.md#fielddotproduct) | | (BETA) Calculates the dot product between two vectors. +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + +``` + | +| [dotProduct(other)](./firestore_lite.field.md#fielddotproduct) | | (BETA) | +| [endsWith(suffix)](./firestore_lite.field.md#fieldendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix. +```typescript +// Check if the 'filename' field ends with ".txt" +Field.of("filename").endsWith(".txt"); + +``` + | +| [endsWith(suffix)](./firestore_lite.field.md#fieldendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix (represented as an expression). +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +Field.of("url").endsWith(Field.of("extension")); + +``` + | +| [eq(other)](./firestore_lite.field.md#fieldeq) | | (BETA) Creates an expression that checks if this expression is equal to another expression. +```typescript +// Check if the 'age' field is equal to 21 +Field.of("age").eq(21); + +``` + | +| [eq(other)](./firestore_lite.field.md#fieldeq) | | (BETA) Creates an expression that checks if this expression is equal to a constant value. +```typescript +// Check if the 'city' field is equal to "London" +Field.of("city").eq("London"); + +``` + | +| [euclideanDistance(other)](./firestore_lite.field.md#fieldeuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance([37.7749, -122.4194]); + +``` + | +| [euclideanDistance(other)](./firestore_lite.field.md#fieldeuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + +``` + | +| [euclideanDistance(other)](./firestore_lite.field.md#fieldeuclideandistance) | | (BETA) | +| [exists()](./firestore_lite.field.md#fieldexists) | | (BETA) Creates an expression that checks if a field exists in the document. +```typescript +// Check if the document has a field named "phoneNumber" +Field.of("phoneNumber").exists(); + +``` + A new Expr representing the 'exists' check. | +| [fieldName()](./firestore_lite.field.md#fieldfieldname) | | (BETA) | +| [gt(other)](./firestore_lite.field.md#fieldgt) | | (BETA) Creates an expression that checks if this expression is greater than another expression. +```typescript +// Check if the 'age' field is greater than the 'limit' field +Field.of("age").gt(Field.of("limit")); + +``` + | +| [gt(other)](./firestore_lite.field.md#fieldgt) | | (BETA) Creates an expression that checks if this expression is greater than a constant value. +```typescript +// Check if the 'price' field is greater than 100 +Field.of("price").gt(100); + +``` + | +| [gte(other)](./firestore_lite.field.md#fieldgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to another expression. +```typescript +// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 +Field.of("quantity").gte(Field.of('requirement').add(1)); + +``` + | +| [gte(other)](./firestore_lite.field.md#fieldgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to a constant value. +```typescript +// Check if the 'score' field is greater than or equal to 80 +Field.of("score").gte(80); + +``` + | +| [in(others)](./firestore_lite.field.md#fieldin) | | (BETA) Creates an expression that checks if this expression is equal to any of the provided values or expressions. +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +Field.of("category").in("Electronics", Field.of("primaryType")); + +``` + | +| [in(others)](./firestore_lite.field.md#fieldin) | | (BETA) | +| [isNaN()](./firestore_lite.field.md#fieldisnan) | | (BETA) Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). +```typescript +// Check if the result of a calculation is NaN +Field.of("value").divide(0).isNaN(); + +``` + A new Expr representing the 'isNaN' check. | +| [like(pattern)](./firestore_lite.field.md#fieldlike) | | (BETA) Creates an expression that performs a case-sensitive string comparison. +```typescript +// Check if the 'title' field contains the word "guide" (case-sensitive) +Field.of("title").like("%guide%"); + +``` + | +| [like(pattern)](./firestore_lite.field.md#fieldlike) | | (BETA) | +| [logicalMax(other)](./firestore_lite.field.md#fieldlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMax(Function.currentTimestamp()); + +``` + | +| [logicalMax(other)](./firestore_lite.field.md#fieldlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'value' field and 10. +Field.of("value").logicalMax(10); + +``` + | +| [logicalMin(other)](./firestore_lite.field.md#fieldlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMin(Function.currentTimestamp()); + +``` + | +| [logicalMin(other)](./firestore_lite.field.md#fieldlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'value' field and 10. +Field.of("value").logicalMin(10); + +``` + | +| [lt(other)](./firestore_lite.field.md#fieldlt) | | (BETA) Creates an expression that checks if this expression is less than another expression. +```typescript +// Check if the 'age' field is less than 'limit' +Field.of("age").lt(Field.of('limit')); + +``` + | +| [lt(other)](./firestore_lite.field.md#fieldlt) | | (BETA) Creates an expression that checks if this expression is less than a constant value. +```typescript +// Check if the 'price' field is less than 50 +Field.of("price").lt(50); + +``` + | +| [lte(other)](./firestore_lite.field.md#fieldlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to another expression. +```typescript +// Check if the 'quantity' field is less than or equal to 20 +Field.of("quantity").lte(Constant.of(20)); + +``` + | +| [lte(other)](./firestore_lite.field.md#fieldlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to a constant value. +```typescript +// Check if the 'score' field is less than or equal to 70 +Field.of("score").lte(70); + +``` + | +| [mapGet(subfield)](./firestore_lite.field.md#fieldmapget) | | (BETA) Accesses a value from a map (object) field using the provided key. +```typescript +// Get the 'city' value from the 'address' map field +Field.of("address").mapGet("city"); + +``` + | +| [max()](./firestore_lite.field.md#fieldmax) | | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. +```typescript +// Find the highest score in a leaderboard +Field.of("score").max().as("highestScore"); + +``` + A new Accumulator representing the 'max' aggregation. | +| [min()](./firestore_lite.field.md#fieldmin) | | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. +```typescript +// Find the lowest price of all products +Field.of("price").min().as("lowestPrice"); + +``` + A new Accumulator representing the 'min' aggregation. | +| [mod(other)](./firestore_lite.field.md#fieldmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. +```typescript +// Calculate the remainder of dividing the 'value' field by the 'divisor' field +Field.of("value").mod(Field.of("divisor")); + +``` + | +| [mod(other)](./firestore_lite.field.md#fieldmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. +```typescript +// Calculate the remainder of dividing the 'value' field by 10 +Field.of("value").mod(10); + +``` + | +| [multiply(other)](./firestore_lite.field.md#fieldmultiply) | | (BETA) Creates an expression that multiplies this expression by another expression. +```typescript +// Multiply the 'quantity' field by the 'price' field +Field.of("quantity").multiply(Field.of("price")); + +``` + | +| [multiply(other)](./firestore_lite.field.md#fieldmultiply) | | (BETA) Creates an expression that multiplies this expression by a constant value. +```typescript +// Multiply the 'value' field by 2 +Field.of("value").multiply(2); + +``` + | +| [neq(other)](./firestore_lite.field.md#fieldneq) | | (BETA) Creates an expression that checks if this expression is not equal to another expression. +```typescript +// Check if the 'status' field is not equal to "completed" +Field.of("status").neq("completed"); + +``` + | +| [neq(other)](./firestore_lite.field.md#fieldneq) | | (BETA) Creates an expression that checks if this expression is not equal to a constant value. +```typescript +// Check if the 'country' field is not equal to "USA" +Field.of("country").neq("USA"); + +``` + | +| [of(name)](./firestore_lite.field.md#fieldof) | static | (BETA) Creates a instance representing the field at the given path.The path can be a simple field name (e.g., "name") or a dot-separated path to a nested field (e.g., "address.city"). +```typescript +// Create a Field instance for the 'title' field +const titleField = Field.of("title"); + +// Create a Field instance for a nested field 'author.firstName' +const authorFirstNameField = Field.of("author.firstName"); + +``` + | +| [of(path)](./firestore_lite.field.md#fieldof) | static | (BETA) | +| [of(pipeline, name)](./firestore_lite.field.md#fieldof) | static | (BETA) | +| [regexContains(pattern)](./firestore_lite.field.md#fieldregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +Field.of("description").regexContains("(?i)example"); + +``` + | +| [regexContains(pattern)](./firestore_lite.field.md#fieldregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains the regular expression stored in field 'regex' +Field.of("description").regexContains(Field.of("regex")); + +``` + | +| [regexMatch(pattern)](./firestore_lite.field.md#fieldregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. +```typescript +// Check if the 'email' field matches a valid email pattern +Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + | +| [regexMatch(pattern)](./firestore_lite.field.md#fieldregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. +```typescript +// Check if the 'email' field matches a regular expression stored in field 'regex' +Field.of("email").regexMatch(Field.of("regex")); + +``` + | +| [replaceAll(find, replace)](./firestore_lite.field.md#fieldreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring. +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field +Field.of("message").replaceAll("hello", "hi"); + +``` + | +| [replaceAll(find, replace)](./firestore_lite.field.md#fieldreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + +``` + | +| [replaceFirst(find, replace)](./firestore_lite.field.md#fieldreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field +Field.of("message").replaceFirst("hello", "hi"); + +``` + | +| [replaceFirst(find, replace)](./firestore_lite.field.md#fieldreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + +``` + | +| [reverse()](./firestore_lite.field.md#fieldreverse) | | (BETA) Creates an expression that reverses this string expression. +```typescript +// Reverse the value of the 'myString' field. +Field.of("myString").reverse(); + +``` + A new representing the reversed string. | +| [startsWith(prefix)](./firestore_lite.field.md#fieldstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix. +```typescript +// Check if the 'name' field starts with "Mr." +Field.of("name").startsWith("Mr."); + +``` + | +| [startsWith(prefix)](./firestore_lite.field.md#fieldstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix (represented as an expression). +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +Field.of("fullName").startsWith(Field.of("firstName")); + +``` + | +| [strConcat(elements)](./firestore_lite.field.md#fieldstrconcat) | | (BETA) Creates an expression that concatenates string expressions together. +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + +``` + | +| [strContains(substring)](./firestore_lite.field.md#fieldstrcontains) | | (BETA) Creates an expression that checks if a string contains a specified substring. +```typescript +// Check if the 'description' field contains "example". +Field.of("description").strContains("example"); + +``` + | +| [strContains(expr)](./firestore_lite.field.md#fieldstrcontains) | | (BETA) Creates an expression that checks if a string contains the string represented by another expression. +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +Field.of("description").strContains(Field.of("keyword")); + +``` + | +| [subtract(other)](./firestore_lite.field.md#fieldsubtract) | | (BETA) Creates an expression that subtracts another expression from this expression. +```typescript +// Subtract the 'discount' field from the 'price' field +Field.of("price").subtract(Field.of("discount")); + +``` + | +| [subtract(other)](./firestore_lite.field.md#fieldsubtract) | | (BETA) Creates an expression that subtracts a constant value from this expression. +```typescript +// Subtract 20 from the value of the 'total' field +Field.of("total").subtract(20); + +``` + | +| [sum()](./firestore_lite.field.md#fieldsum) | | (BETA) Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. +```typescript +// Calculate the total revenue from a set of orders +Field.of("orderAmount").sum().as("totalRevenue"); + +``` + A new Accumulator representing the 'sum' aggregation. | +| [timestampAdd(unit, amount)](./firestore_lite.field.md#fieldtimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampAdd(unit, amount)](./firestore_lite.field.md#fieldtimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. +```typescript +// Add 1 day to the 'timestamp' field. +Field.of("timestamp").timestampAdd("day", 1); + +``` + | +| [timestampSub(unit, amount)](./firestore_lite.field.md#fieldtimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampSub(unit, amount)](./firestore_lite.field.md#fieldtimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. +```typescript +// Subtract 1 day from the 'timestamp' field. +Field.of("timestamp").timestampSub("day", 1); + +``` + | +| [timestampToUnixMicros()](./firestore_lite.field.md#fieldtimestamptounixmicros) | | (BETA) Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +Field.of("timestamp").timestampToUnixMicros(); + +``` + A new representing the number of microseconds since epoch. | +| [timestampToUnixMillis()](./firestore_lite.field.md#fieldtimestamptounixmillis) | | (BETA) Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +Field.of("timestamp").timestampToUnixMillis(); + +``` + A new representing the number of milliseconds since epoch. | +| [timestampToUnixSeconds()](./firestore_lite.field.md#fieldtimestamptounixseconds) | | (BETA) Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to seconds since epoch. +Field.of("timestamp").timestampToUnixSeconds(); + +``` + A new representing the number of seconds since epoch. | +| [toLower()](./firestore_lite.field.md#fieldtolower) | | (BETA) Creates an expression that converts a string to lowercase. +```typescript +// Convert the 'name' field to lowercase +Field.of("name").toLower(); + +``` + A new Expr representing the lowercase string. | +| [toUpper()](./firestore_lite.field.md#fieldtoupper) | | (BETA) Creates an expression that converts a string to uppercase. +```typescript +// Convert the 'title' field to uppercase +Field.of("title").toUpper(); + +``` + A new Expr representing the uppercase string. | +| [trim()](./firestore_lite.field.md#fieldtrim) | | (BETA) Creates an expression that removes leading and trailing whitespace from a string. +```typescript +// Trim whitespace from the 'userInput' field +Field.of("userInput").trim(); + +``` + A new Expr representing the trimmed string. | +| [unixMicrosToTimestamp()](./firestore_lite.field.md#fieldunixmicrostotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +Field.of("microseconds").unixMicrosToTimestamp(); + +``` + A new representing the timestamp. | +| [unixMillisToTimestamp()](./firestore_lite.field.md#fieldunixmillistotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +Field.of("milliseconds").unixMillisToTimestamp(); + +``` + A new representing the timestamp. | +| [unixSecondsToTimestamp()](./firestore_lite.field.md#fieldunixsecondstotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'seconds' field as seconds since epoch. +Field.of("seconds").unixSecondsToTimestamp(); + +``` + A new representing the timestamp. | +| [vectorLength()](./firestore_lite.field.md#fieldvectorlength) | | (BETA) Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. +```typescript +// Get the vector length (dimension) of the field 'embedding'. +Field.of("embedding").vectorLength(); + +``` + A new representing the length of the vector. | + +## Field.exprType + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +exprType: ExprType; +``` + +## Field.selectable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +selectable: true; +``` + +## Field.add() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds this expression to another expression. + +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +Field.of("quantity").add(Field.of("reserve")); + +``` + +Signature: + +```typescript +add(other: Constant): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to add to this expression. A new Expr representing the addition operation. | + +Returns: + +[Add](./firestore_lite.add.md#add_class) + +## Field.add() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds this expression to a constant value. + +```typescript +// Add 5 to the value of the 'age' field +Field.of("age").add(5); + +``` + +Signature: + +```typescript +add(other: any): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to add. A new Expr representing the addition operation. | + +Returns: + +[Add](./firestore_lite.add.md#add_class) + +## Field.arrayConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with one or more other arrays. + +```typescript +// Combine the 'items' array with another array field. +Field.of("items").arrayConcat(Field.of("otherItems")); + +``` + +Signature: + +```typescript +arrayConcat(arrays: Constant[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrays | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The array expressions to concatenate. A new Expr representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) + +## Field.arrayConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with one or more other arrays. + +```typescript +// Combine the 'tags' array with a new array and an array field +Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + +``` + +Signature: + +```typescript +arrayConcat(arrays: any[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrays | any\[\] | The array expressions or values to concatenate. A new Expr representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) + +## Field.arrayContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains a specific element. + +```typescript +// Check if the 'sizes' array contains the value from the 'selectedSize' field +Field.of("sizes").arrayContains(Field.of("selectedSize")); + +``` + +Signature: + +```typescript +arrayContains(element: Constant): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | [Constant](./firestore_lite.constant.md#constant_class) | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) + +## Field.arrayContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains a specific value. + +```typescript +// Check if the 'colors' array contains "red" +Field.of("colors").arrayContains("red"); + +``` + +Signature: + +```typescript +arrayContains(element: any): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | any | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) + +## Field.arrayContainsAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both "news" and "sports" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + +Signature: + +```typescript +arrayContainsAll(...values: Constant[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) + +## Field.arrayContainsAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + +Signature: + +```typescript +arrayContainsAll(...values: any[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) + +## Field.arrayContainsAny() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains any of the specified elements. + +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "cate2" +Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + +``` + +Signature: + +```typescript +arrayContainsAny(...values: Constant[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) + +## Field.arrayContainsAny() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains any of the specified elements. + +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + +``` + +Signature: + +```typescript +arrayContainsAny(...values: any[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) + +## Field.arrayLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of an array. + +```typescript +// Get the number of items in the 'cart' array +Field.of("cart").arrayLength(); + +``` + A new `Expr` representing the length of the array. + +Signature: + +```typescript +arrayLength(): ArrayLength; +``` +Returns: + +[ArrayLength](./firestore_lite.arraylength.md#arraylength_class) + +## Field.as() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Assigns an alias to this expression. + +Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. + +```typescript +// Calculate the total price and assign it the alias "totalPrice" and add it to the output. +firestore.pipeline().collection("items") +.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + +``` + +Signature: + +```typescript +as(name: string): ExprWithAlias; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | The alias to assign to this expression. A new [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) that wraps this expression and associates it with the provided alias. | + +Returns: + +[ExprWithAlias](./firestore_lite.exprwithalias.md#exprwithalias_class)<this> + +## Field.ascending() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. + +```typescript +// Sort documents by the 'name' field in ascending order +pipeline().collection("users") +.sort(Field.of("name").ascending()); + +``` + A new `Ordering` for ascending sorting. + +Signature: + +```typescript +ascending(): Ordering; +``` +Returns: + +[Ordering](./firestore_lite.ordering.md#ordering_class) + +## Field.avg() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. + +```typescript +// Calculate the average age of users +Field.of("age").avg().as("averageAge"); + +``` + A new `Accumulator` representing the 'avg' aggregation. + +Signature: + +```typescript +avg(): Avg; +``` +Returns: + +[Avg](./firestore_lite.avg.md#avg_class) + +## Field.byteLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of this string expression in bytes. + +```typescript +// Calculate the length of the 'myString' field in bytes. +Field.of("myString").byteLength(); + +``` + A new representing the length of the string in bytes. + +Signature: + +```typescript +byteLength(): ByteLength; +``` +Returns: + +[ByteLength](./firestore_lite.bytelength.md#bytelength_class) + +## Field.charLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the character length of a string in UTF-8. + +```typescript +// Get the character length of the 'name' field in its UTF-8 form. +Field.of("name").charLength(); + +``` + A new `Expr` representing the length of the string. + +Signature: + +```typescript +charLength(): CharLength; +``` +Returns: + +[CharLength](./firestore_lite.charlength.md#charlength_class) + +## Field.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the cosine distance between two vectors. + +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +Field.of("userVector").cosineDistance(Field.of("itemVector")); + +``` + +Signature: + +```typescript +cosineDistance(other: Constant): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new Expr representing the cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) + +## Field.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vectors. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +cosineDistance(other: VectorValue): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) + +## Field.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vectors. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance([37.7749, -122.4194]); + +``` + +Signature: + +```typescript +cosineDistance(other: number[]): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | The other vector (as an array of numbers) to compare against. A new Expr representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) + +## Field.count() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. + +```typescript +// Count the total number of products +Field.of("productId").count().as("totalProducts"); + +``` + A new `Accumulator` representing the 'count' aggregation. + +Signature: + +```typescript +count(): Count; +``` +Returns: + +[Count](./firestore_lite.count.md#count_class) + +## Field.descending() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. + +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") +.sort(Field.of("createdAt").descending()); + +``` + A new `Ordering` for descending sorting. + +Signature: + +```typescript +descending(): Ordering; +``` +Returns: + +[Ordering](./firestore_lite.ordering.md#ordering_class) + +## Field.divide() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides this expression by another expression. + +```typescript +// Divide the 'total' field by the 'count' field +Field.of("total").divide(Field.of("count")); + +``` + +Signature: + +```typescript +divide(other: Constant): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new Expr representing the division operation. | + +Returns: + +[Divide](./firestore_lite.divide.md#divide_class) + +## Field.divide() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides this expression by a constant value. + +```typescript +// Divide the 'value' field by 10 +Field.of("value").divide(10); + +``` + +Signature: + +```typescript +divide(other: any): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to divide by. A new Expr representing the division operation. | + +Returns: + +[Divide](./firestore_lite.divide.md#divide_class) + +## Field.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vectors. + +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct([0.5, 0.8, 0.2]); + +``` + +Signature: + +```typescript +dotProduct(other: Constant): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) + +## Field.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vectors. + +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + +``` + +Signature: + +```typescript +dotProduct(other: VectorValue): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) + +## Field.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +dotProduct(other: number[]): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | | + +Returns: + +[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) + +## Field.endsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string ends with a given postfix. + +```typescript +// Check if the 'filename' field ends with ".txt" +Field.of("filename").endsWith(".txt"); + +``` + +Signature: + +```typescript +endsWith(suffix: string): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| suffix | string | The postfix to check for. A new Expr representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_lite.endswith.md#endswith_class) + +## Field.endsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string ends with a given postfix (represented as an expression). + +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +Field.of("url").endsWith(Field.of("extension")); + +``` + +Signature: + +```typescript +endsWith(suffix: Constant): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| suffix | [Constant](./firestore_lite.constant.md#constant_class) | The postfix expression to check for. A new Expr representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_lite.endswith.md#endswith_class) + +## Field.eq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to another expression. + +```typescript +// Check if the 'age' field is equal to 21 +Field.of("age").eq(21); + +``` + +Signature: + +```typescript +eq(other: Constant): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for equality. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_lite.eq.md#eq_class) + +## Field.eq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to a constant value. + +```typescript +// Check if the 'city' field is equal to "London" +Field.of("city").eq("London"); + +``` + +Signature: + +```typescript +eq(other: any): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for equality. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_lite.eq.md#eq_class) + +## Field.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vectors. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance([37.7749, -122.4194]); + +``` + +Signature: + +```typescript +euclideanDistance(other: Constant): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) + +## Field.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vectors. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +euclideanDistance(other: VectorValue): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) + +## Field.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +euclideanDistance(other: number[]): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | | + +Returns: + +[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) + +## Field.exists() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field exists in the document. + +```typescript +// Check if the document has a field named "phoneNumber" +Field.of("phoneNumber").exists(); + +``` + A new `Expr` representing the 'exists' check. + +Signature: + +```typescript +exists(): Exists; +``` +Returns: + +[Exists](./firestore_lite.exists.md#exists_class) + +## Field.fieldName() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +fieldName(): string; +``` +Returns: + +string + +## Field.gt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than another expression. + +```typescript +// Check if the 'age' field is greater than the 'limit' field +Field.of("age").gt(Field.of("limit")); + +``` + +Signature: + +```typescript +gt(other: Constant): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for greater than. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_lite.gt.md#gt_class) + +## Field.gt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than a constant value. + +```typescript +// Check if the 'price' field is greater than 100 +Field.of("price").gt(100); + +``` + +Signature: + +```typescript +gt(other: any): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for greater than. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_lite.gt.md#gt_class) + +## Field.gte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than or equal to another expression. + +```typescript +// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 +Field.of("quantity").gte(Field.of('requirement').add(1)); + +``` + +Signature: + +```typescript +gte(other: Constant): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_lite.gte.md#gte_class) + +## Field.gte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than or equal to a constant value. + +```typescript +// Check if the 'score' field is greater than or equal to 80 +Field.of("score").gte(80); + +``` + +Signature: + +```typescript +gte(other: any): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_lite.gte.md#gte_class) + +## Field.in() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to any of the provided values or expressions. + +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +Field.of("category").in("Electronics", Field.of("primaryType")); + +``` + +Signature: + +```typescript +in(...others: Constant[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| others | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The values or expressions to check against. A new Expr representing the 'IN' comparison. | + +Returns: + +[In](./firestore_lite.in.md#in_class) + +## Field.in() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +in(...others: any[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| others | any\[\] | | + +Returns: + +[In](./firestore_lite.in.md#in_class) + +## Field.isNaN() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). + +```typescript +// Check if the result of a calculation is NaN +Field.of("value").divide(0).isNaN(); + +``` + A new `Expr` representing the 'isNaN' check. + +Signature: + +```typescript +isNaN(): IsNan; +``` +Returns: + +[IsNan](./firestore_lite.isnan.md#isnan_class) + +## Field.like() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that performs a case-sensitive string comparison. + +```typescript +// Check if the 'title' field contains the word "guide" (case-sensitive) +Field.of("title").like("%guide%"); + +``` + +Signature: + +```typescript +like(pattern: string): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new Expr representing the 'like' comparison. | + +Returns: + +[Like](./firestore_lite.like.md#like_class) + +## Field.like() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +like(pattern: Constant): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | | + +Returns: + +[Like](./firestore_lite.like.md#like_class) + +## Field.logicalMax() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMax(Function.currentTimestamp()); + +``` + +Signature: + +```typescript +logicalMax(other: Constant): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare with. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) + +## Field.logicalMax() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'value' field and 10. +Field.of("value").logicalMax(10); + +``` + +Signature: + +```typescript +logicalMax(other: any): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare with. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) + +## Field.logicalMin() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMin(Function.currentTimestamp()); + +``` + +Signature: + +```typescript +logicalMin(other: Constant): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare with. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) + +## Field.logicalMin() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'value' field and 10. +Field.of("value").logicalMin(10); + +``` + +Signature: + +```typescript +logicalMin(other: any): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare with. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) + +## Field.lt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than another expression. + +```typescript +// Check if the 'age' field is less than 'limit' +Field.of("age").lt(Field.of('limit')); + +``` + +Signature: + +```typescript +lt(other: Constant): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for less than. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_lite.lt.md#lt_class) + +## Field.lt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than a constant value. + +```typescript +// Check if the 'price' field is less than 50 +Field.of("price").lt(50); + +``` + +Signature: + +```typescript +lt(other: any): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for less than. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_lite.lt.md#lt_class) + +## Field.lte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than or equal to another expression. + +```typescript +// Check if the 'quantity' field is less than or equal to 20 +Field.of("quantity").lte(Constant.of(20)); + +``` + +Signature: + +```typescript +lte(other: Constant): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_lite.lte.md#lte_class) + +## Field.lte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than or equal to a constant value. + +```typescript +// Check if the 'score' field is less than or equal to 70 +Field.of("score").lte(70); + +``` + +Signature: + +```typescript +lte(other: any): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_lite.lte.md#lte_class) + +## Field.mapGet() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Accesses a value from a map (object) field using the provided key. + +```typescript +// Get the 'city' value from the 'address' map field +Field.of("address").mapGet("city"); + +``` + +Signature: + +```typescript +mapGet(subfield: string): MapGet; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| subfield | string | The key to access in the map. A new Expr representing the value associated with the given key in the map. | + +Returns: + +[MapGet](./firestore_lite.mapget.md#mapget_class) + +## Field.max() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that finds the maximum value of a field across multiple stage inputs. + +```typescript +// Find the highest score in a leaderboard +Field.of("score").max().as("highestScore"); + +``` + A new `Accumulator` representing the 'max' aggregation. + +Signature: + +```typescript +max(): Max; +``` +Returns: + +[Max](./firestore_lite.max.md#max_class) + +## Field.min() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that finds the minimum value of a field across multiple stage inputs. + +```typescript +// Find the lowest price of all products +Field.of("price").min().as("lowestPrice"); + +``` + A new `Accumulator` representing the 'min' aggregation. + +Signature: + +```typescript +min(): Min; +``` +Returns: + +[Min](./firestore_lite.min.md#min_class) + +## Field.mod() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. + +```typescript +// Calculate the remainder of dividing the 'value' field by the 'divisor' field +Field.of("value").mod(Field.of("divisor")); + +``` + +Signature: + +```typescript +mod(other: Constant): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new Expr representing the modulo operation. | + +Returns: + +[Mod](./firestore_lite.mod.md#mod_class) + +## Field.mod() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. + +```typescript +// Calculate the remainder of dividing the 'value' field by 10 +Field.of("value").mod(10); + +``` + +Signature: + +```typescript +mod(other: any): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to divide by. A new Expr representing the modulo operation. | + +Returns: + +[Mod](./firestore_lite.mod.md#mod_class) + +## Field.multiply() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies this expression by another expression. + +```typescript +// Multiply the 'quantity' field by the 'price' field +Field.of("quantity").multiply(Field.of("price")); + +``` + +Signature: + +```typescript +multiply(other: Constant): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to multiply by. A new Expr representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_lite.multiply.md#multiply_class) + +## Field.multiply() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies this expression by a constant value. + +```typescript +// Multiply the 'value' field by 2 +Field.of("value").multiply(2); + +``` + +Signature: + +```typescript +multiply(other: any): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to multiply by. A new Expr representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_lite.multiply.md#multiply_class) + +## Field.neq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is not equal to another expression. + +```typescript +// Check if the 'status' field is not equal to "completed" +Field.of("status").neq("completed"); + +``` + +Signature: + +```typescript +neq(other: Constant): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for inequality. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_lite.neq.md#neq_class) + +## Field.neq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is not equal to a constant value. + +```typescript +// Check if the 'country' field is not equal to "USA" +Field.of("country").neq("USA"); + +``` + +Signature: + +```typescript +neq(other: any): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for inequality. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_lite.neq.md#neq_class) + +## Field.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a instance representing the field at the given path. + +The path can be a simple field name (e.g., "name") or a dot-separated path to a nested field (e.g., "address.city"). + +```typescript +// Create a Field instance for the 'title' field +const titleField = Field.of("title"); + +// Create a Field instance for a nested field 'author.firstName' +const authorFirstNameField = Field.of("author.firstName"); + +``` + +Signature: + +```typescript +static of(name: string): Field; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | The path to the field. A new instance representing the specified field. | + +Returns: + +[Field](./firestore_lite.field.md#field_class) + +## Field.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +static of(path: FieldPath): Field; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| path | [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | | + +Returns: + +[Field](./firestore_lite.field.md#field_class) + +## Field.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +static of(pipeline: Pipeline, name: string): Field; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pipeline | [Pipeline](./firestore_lite.pipeline.md#pipeline_class) | | +| name | string | | + +Returns: + +[Field](./firestore_lite.field.md#field_class) + +## Field.regexContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +Field.of("description").regexContains("(?i)example"); + +``` + +Signature: + +```typescript +regexContains(pattern: string): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) + +## Field.regexContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains the regular expression stored in field 'regex' +Field.of("description").regexContains(Field.of("regex")); + +``` + +Signature: + +```typescript +regexContains(pattern: Constant): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) + +## Field.regexMatch() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a valid email pattern +Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + +Signature: + +```typescript +regexMatch(pattern: string): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The regular expression to use for the match. A new Expr representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) + +## Field.regexMatch() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a regular expression stored in field 'regex' +Field.of("email").regexMatch(Field.of("regex")); + +``` + +Signature: + +```typescript +regexMatch(pattern: Constant): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the match. A new Expr representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) + +## Field.replaceAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within this string expression with another substring. + +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field +Field.of("message").replaceAll("hello", "hi"); + +``` + +Signature: + +```typescript +replaceAll(find: string, replace: string): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | string | The substring to search for. | +| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) + +## Field.replaceAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + +``` + +Signature: + +```typescript +replaceAll(find: Constant, replace: Constant): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) + +## Field.replaceFirst() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. + +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field +Field.of("message").replaceFirst("hello", "hi"); + +``` + +Signature: + +```typescript +replaceFirst(find: string, replace: string): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | string | The substring to search for. | +| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) + +## Field.replaceFirst() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + +``` + +Signature: + +```typescript +replaceFirst(find: Constant, replace: Constant): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) + +## Field.reverse() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that reverses this string expression. + +```typescript +// Reverse the value of the 'myString' field. +Field.of("myString").reverse(); + +``` + A new representing the reversed string. + +Signature: + +```typescript +reverse(): Reverse; +``` +Returns: + +[Reverse](./firestore_lite.reverse.md#reverse_class) + +## Field.startsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string starts with a given prefix. + +```typescript +// Check if the 'name' field starts with "Mr." +Field.of("name").startsWith("Mr."); + +``` + +Signature: + +```typescript +startsWith(prefix: string): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| prefix | string | The prefix to check for. A new Expr representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_lite.startswith.md#startswith_class) + +## Field.startsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string starts with a given prefix (represented as an expression). + +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +Field.of("fullName").startsWith(Field.of("firstName")); + +``` + +Signature: + +```typescript +startsWith(prefix: Constant): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| prefix | [Constant](./firestore_lite.constant.md#constant_class) | The prefix expression to check for. A new Expr representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_lite.startswith.md#startswith_class) + +## Field.strConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates string expressions together. + +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + +``` + +Signature: + +```typescript +strConcat(...elements: Array): StrConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| elements | Array<string \| [Constant](./firestore_lite.constant.md#constant_class)> | The expressions (typically strings) to concatenate. A new Expr representing the concatenated string. | + +Returns: + +[StrConcat](./firestore_lite.strconcat.md#strconcat_class) + +## Field.strContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified substring. + +```typescript +// Check if the 'description' field contains "example". +Field.of("description").strContains("example"); + +``` + +Signature: + +```typescript +strContains(substring: string): StrContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| substring | string | The substring to search for. A new Expr representing the 'contains' comparison. | + +Returns: + +[StrContains](./firestore_lite.strcontains.md#strcontains_class) + +## Field.strContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains the string represented by another expression. + +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +Field.of("description").strContains(Field.of("keyword")); + +``` + +Signature: + +```typescript +strContains(expr: Constant): StrContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. A new Expr representing the 'contains' comparison. | + +Returns: + +[StrContains](./firestore_lite.strcontains.md#strcontains_class) + +## Field.subtract() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts another expression from this expression. + +```typescript +// Subtract the 'discount' field from the 'price' field +Field.of("price").subtract(Field.of("discount")); + +``` + +Signature: + +```typescript +subtract(other: Constant): Subtract; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to subtract from this expression. A new Expr representing the subtraction operation. | + +Returns: + +[Subtract](./firestore_lite.subtract.md#subtract_class) + +## Field.subtract() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a constant value from this expression. + +```typescript +// Subtract 20 from the value of the 'total' field +Field.of("total").subtract(20); + +``` + +Signature: + +```typescript +subtract(other: any): Subtract; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to subtract. A new Expr representing the subtraction operation. | + +Returns: + +[Subtract](./firestore_lite.subtract.md#subtract_class) + +## Field.sum() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. + +```typescript +// Calculate the total revenue from a set of orders +Field.of("orderAmount").sum().as("totalRevenue"); + +``` + A new `Accumulator` representing the 'sum' aggregation. + +Signature: + +```typescript +sum(): Sum; +``` +Returns: + +[Sum](./firestore_lite.sum.md#sum_class) + +## Field.timestampAdd() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to this timestamp expression. + +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + +``` + +Signature: + +```typescript +timestampAdd(unit: Constant, amount: Constant): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) + +## Field.timestampAdd() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to this timestamp expression. + +```typescript +// Add 1 day to the 'timestamp' field. +Field.of("timestamp").timestampAdd("day", 1); + +``` + +Signature: + +```typescript +timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | +| amount | number | The amount of time to add. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) + +## Field.timestampSub() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from this timestamp expression. + +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + +``` + +Signature: + +```typescript +timestampSub(unit: Constant, amount: Constant): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) + +## Field.timestampSub() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from this timestamp expression. + +```typescript +// Subtract 1 day from the 'timestamp' field. +Field.of("timestamp").timestampSub("day", 1); + +``` + +Signature: + +```typescript +timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | +| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) + +## Field.timestampToUnixMicros() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +Field.of("timestamp").timestampToUnixMicros(); + +``` + A new representing the number of microseconds since epoch. + +Signature: + +```typescript +timestampToUnixMicros(): TimestampToUnixMicros; +``` +Returns: + +[TimestampToUnixMicros](./firestore_lite.timestamptounixmicros.md#timestamptounixmicros_class) + +## Field.timestampToUnixMillis() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +Field.of("timestamp").timestampToUnixMillis(); + +``` + A new representing the number of milliseconds since epoch. + +Signature: + +```typescript +timestampToUnixMillis(): TimestampToUnixMillis; +``` +Returns: + +[TimestampToUnixMillis](./firestore_lite.timestamptounixmillis.md#timestamptounixmillis_class) + +## Field.timestampToUnixSeconds() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to seconds since epoch. +Field.of("timestamp").timestampToUnixSeconds(); + +``` + A new representing the number of seconds since epoch. + +Signature: + +```typescript +timestampToUnixSeconds(): TimestampToUnixSeconds; +``` +Returns: + +[TimestampToUnixSeconds](./firestore_lite.timestamptounixseconds.md#timestamptounixseconds_class) + +## Field.toLower() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string to lowercase. + +```typescript +// Convert the 'name' field to lowercase +Field.of("name").toLower(); + +``` + A new `Expr` representing the lowercase string. + +Signature: + +```typescript +toLower(): ToLower; +``` +Returns: + +[ToLower](./firestore_lite.tolower.md#tolower_class) + +## Field.toUpper() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string to uppercase. + +```typescript +// Convert the 'title' field to uppercase +Field.of("title").toUpper(); + +``` + A new `Expr` representing the uppercase string. + +Signature: + +```typescript +toUpper(): ToUpper; +``` +Returns: + +[ToUpper](./firestore_lite.toupper.md#toupper_class) + +## Field.trim() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that removes leading and trailing whitespace from a string. + +```typescript +// Trim whitespace from the 'userInput' field +Field.of("userInput").trim(); + +``` + A new `Expr` representing the trimmed string. + +Signature: + +```typescript +trim(): Trim; +``` +Returns: + +[Trim](./firestore_lite.trim.md#trim_class) + +## Field.unixMicrosToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +Field.of("microseconds").unixMicrosToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixMicrosToTimestamp(): UnixMicrosToTimestamp; +``` +Returns: + +[UnixMicrosToTimestamp](./firestore_lite.unixmicrostotimestamp.md#unixmicrostotimestamp_class) + +## Field.unixMillisToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +Field.of("milliseconds").unixMillisToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixMillisToTimestamp(): UnixMillisToTimestamp; +``` +Returns: + +[UnixMillisToTimestamp](./firestore_lite.unixmillistotimestamp.md#unixmillistotimestamp_class) + +## Field.unixSecondsToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'seconds' field as seconds since epoch. +Field.of("seconds").unixSecondsToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixSecondsToTimestamp(): UnixSecondsToTimestamp; +``` +Returns: + +[UnixSecondsToTimestamp](./firestore_lite.unixsecondstotimestamp.md#unixsecondstotimestamp_class) + +## Field.vectorLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. + +```typescript +// Get the vector length (dimension) of the field 'embedding'. +Field.of("embedding").vectorLength(); + +``` + A new representing the length of the vector. + +Signature: + +```typescript +vectorLength(): VectorLength; +``` +Returns: + +[VectorLength](./firestore_lite.vectorlength.md#vectorlength_class) + diff --git a/docs-devsite/firestore_lite.fields.md b/docs-devsite/firestore_lite.fields.md new file mode 100644 index 00000000000..469b9b6b651 --- /dev/null +++ b/docs-devsite/firestore_lite.fields.md @@ -0,0 +1,3210 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Fields class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Fields implements Selectable +``` +Implements: [Selectable](./firestore_lite.selectable.md#selectable_interface) + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [exprType](./firestore_lite.fields.md#fieldsexprtype) | | [ExprType](./firestore_lite.md#exprtype) | (BETA) | +| [selectable](./firestore_lite.fields.md#fieldsselectable) | | true | (BETA) | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [add(other)](./firestore_lite.fields.md#fieldsadd) | | (BETA) Creates an expression that adds this expression to another expression. +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +Field.of("quantity").add(Field.of("reserve")); + +``` + | +| [add(other)](./firestore_lite.fields.md#fieldsadd) | | (BETA) Creates an expression that adds this expression to a constant value. +```typescript +// Add 5 to the value of the 'age' field +Field.of("age").add(5); + +``` + | +| [arrayConcat(arrays)](./firestore_lite.fields.md#fieldsarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. +```typescript +// Combine the 'items' array with another array field. +Field.of("items").arrayConcat(Field.of("otherItems")); + +``` + | +| [arrayConcat(arrays)](./firestore_lite.fields.md#fieldsarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. +```typescript +// Combine the 'tags' array with a new array and an array field +Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + +``` + | +| [arrayContains(element)](./firestore_lite.fields.md#fieldsarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific element. +```typescript +// Check if the 'sizes' array contains the value from the 'selectedSize' field +Field.of("sizes").arrayContains(Field.of("selectedSize")); + +``` + | +| [arrayContains(element)](./firestore_lite.fields.md#fieldsarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific value. +```typescript +// Check if the 'colors' array contains "red" +Field.of("colors").arrayContains("red"); + +``` + | +| [arrayContainsAll(values)](./firestore_lite.fields.md#fieldsarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. +```typescript +// Check if the 'tags' array contains both "news" and "sports" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + | +| [arrayContainsAll(values)](./firestore_lite.fields.md#fieldsarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + | +| [arrayContainsAny(values)](./firestore_lite.fields.md#fieldsarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "cate2" +Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + +``` + | +| [arrayContainsAny(values)](./firestore_lite.fields.md#fieldsarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + +``` + | +| [arrayLength()](./firestore_lite.fields.md#fieldsarraylength) | | (BETA) Creates an expression that calculates the length of an array. +```typescript +// Get the number of items in the 'cart' array +Field.of("cart").arrayLength(); + +``` + A new Expr representing the length of the array. | +| [as(name)](./firestore_lite.fields.md#fieldsas) | | (BETA) Assigns an alias to this expression.Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. +```typescript +// Calculate the total price and assign it the alias "totalPrice" and add it to the output. +firestore.pipeline().collection("items") +.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + +``` + | +| [ascending()](./firestore_lite.fields.md#fieldsascending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. +```typescript +// Sort documents by the 'name' field in ascending order +pipeline().collection("users") +.sort(Field.of("name").ascending()); + +``` + A new Ordering for ascending sorting. | +| [avg()](./firestore_lite.fields.md#fieldsavg) | | (BETA) Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. +```typescript +// Calculate the average age of users +Field.of("age").avg().as("averageAge"); + +``` + A new Accumulator representing the 'avg' aggregation. | +| [byteLength()](./firestore_lite.fields.md#fieldsbytelength) | | (BETA) Creates an expression that calculates the length of this string expression in bytes. +```typescript +// Calculate the length of the 'myString' field in bytes. +Field.of("myString").byteLength(); + +``` + A new representing the length of the string in bytes. | +| [charLength()](./firestore_lite.fields.md#fieldscharlength) | | (BETA) Creates an expression that calculates the character length of a string in UTF-8. +```typescript +// Get the character length of the 'name' field in its UTF-8 form. +Field.of("name").charLength(); + +``` + A new Expr representing the length of the string. | +| [cosineDistance(other)](./firestore_lite.fields.md#fieldscosinedistance) | | (BETA) Calculates the cosine distance between two vectors. +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +Field.of("userVector").cosineDistance(Field.of("itemVector")); + +``` + | +| [cosineDistance(other)](./firestore_lite.fields.md#fieldscosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + +``` + | +| [cosineDistance(other)](./firestore_lite.fields.md#fieldscosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance([37.7749, -122.4194]); + +``` + | +| [count()](./firestore_lite.fields.md#fieldscount) | | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. +```typescript +// Count the total number of products +Field.of("productId").count().as("totalProducts"); + +``` + A new Accumulator representing the 'count' aggregation. | +| [descending()](./firestore_lite.fields.md#fieldsdescending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") +.sort(Field.of("createdAt").descending()); + +``` + A new Ordering for descending sorting. | +| [divide(other)](./firestore_lite.fields.md#fieldsdivide) | | (BETA) Creates an expression that divides this expression by another expression. +```typescript +// Divide the 'total' field by the 'count' field +Field.of("total").divide(Field.of("count")); + +``` + | +| [divide(other)](./firestore_lite.fields.md#fieldsdivide) | | (BETA) Creates an expression that divides this expression by a constant value. +```typescript +// Divide the 'value' field by 10 +Field.of("value").divide(10); + +``` + | +| [dotProduct(other)](./firestore_lite.fields.md#fieldsdotproduct) | | (BETA) Calculates the dot product between two vectors. +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct([0.5, 0.8, 0.2]); + +``` + | +| [dotProduct(other)](./firestore_lite.fields.md#fieldsdotproduct) | | (BETA) Calculates the dot product between two vectors. +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + +``` + | +| [dotProduct(other)](./firestore_lite.fields.md#fieldsdotproduct) | | (BETA) | +| [endsWith(suffix)](./firestore_lite.fields.md#fieldsendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix. +```typescript +// Check if the 'filename' field ends with ".txt" +Field.of("filename").endsWith(".txt"); + +``` + | +| [endsWith(suffix)](./firestore_lite.fields.md#fieldsendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix (represented as an expression). +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +Field.of("url").endsWith(Field.of("extension")); + +``` + | +| [eq(other)](./firestore_lite.fields.md#fieldseq) | | (BETA) Creates an expression that checks if this expression is equal to another expression. +```typescript +// Check if the 'age' field is equal to 21 +Field.of("age").eq(21); + +``` + | +| [eq(other)](./firestore_lite.fields.md#fieldseq) | | (BETA) Creates an expression that checks if this expression is equal to a constant value. +```typescript +// Check if the 'city' field is equal to "London" +Field.of("city").eq("London"); + +``` + | +| [euclideanDistance(other)](./firestore_lite.fields.md#fieldseuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance([37.7749, -122.4194]); + +``` + | +| [euclideanDistance(other)](./firestore_lite.fields.md#fieldseuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + +``` + | +| [euclideanDistance(other)](./firestore_lite.fields.md#fieldseuclideandistance) | | (BETA) | +| [exists()](./firestore_lite.fields.md#fieldsexists) | | (BETA) Creates an expression that checks if a field exists in the document. +```typescript +// Check if the document has a field named "phoneNumber" +Field.of("phoneNumber").exists(); + +``` + A new Expr representing the 'exists' check. | +| [fieldList()](./firestore_lite.fields.md#fieldsfieldlist) | | (BETA) | +| [gt(other)](./firestore_lite.fields.md#fieldsgt) | | (BETA) Creates an expression that checks if this expression is greater than another expression. +```typescript +// Check if the 'age' field is greater than the 'limit' field +Field.of("age").gt(Field.of("limit")); + +``` + | +| [gt(other)](./firestore_lite.fields.md#fieldsgt) | | (BETA) Creates an expression that checks if this expression is greater than a constant value. +```typescript +// Check if the 'price' field is greater than 100 +Field.of("price").gt(100); + +``` + | +| [gte(other)](./firestore_lite.fields.md#fieldsgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to another expression. +```typescript +// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 +Field.of("quantity").gte(Field.of('requirement').add(1)); + +``` + | +| [gte(other)](./firestore_lite.fields.md#fieldsgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to a constant value. +```typescript +// Check if the 'score' field is greater than or equal to 80 +Field.of("score").gte(80); + +``` + | +| [in(others)](./firestore_lite.fields.md#fieldsin) | | (BETA) Creates an expression that checks if this expression is equal to any of the provided values or expressions. +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +Field.of("category").in("Electronics", Field.of("primaryType")); + +``` + | +| [in(others)](./firestore_lite.fields.md#fieldsin) | | (BETA) | +| [isNaN()](./firestore_lite.fields.md#fieldsisnan) | | (BETA) Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). +```typescript +// Check if the result of a calculation is NaN +Field.of("value").divide(0).isNaN(); + +``` + A new Expr representing the 'isNaN' check. | +| [like(pattern)](./firestore_lite.fields.md#fieldslike) | | (BETA) Creates an expression that performs a case-sensitive string comparison. +```typescript +// Check if the 'title' field contains the word "guide" (case-sensitive) +Field.of("title").like("%guide%"); + +``` + | +| [like(pattern)](./firestore_lite.fields.md#fieldslike) | | (BETA) | +| [logicalMax(other)](./firestore_lite.fields.md#fieldslogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMax(Function.currentTimestamp()); + +``` + | +| [logicalMax(other)](./firestore_lite.fields.md#fieldslogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'value' field and 10. +Field.of("value").logicalMax(10); + +``` + | +| [logicalMin(other)](./firestore_lite.fields.md#fieldslogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMin(Function.currentTimestamp()); + +``` + | +| [logicalMin(other)](./firestore_lite.fields.md#fieldslogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'value' field and 10. +Field.of("value").logicalMin(10); + +``` + | +| [lt(other)](./firestore_lite.fields.md#fieldslt) | | (BETA) Creates an expression that checks if this expression is less than another expression. +```typescript +// Check if the 'age' field is less than 'limit' +Field.of("age").lt(Field.of('limit')); + +``` + | +| [lt(other)](./firestore_lite.fields.md#fieldslt) | | (BETA) Creates an expression that checks if this expression is less than a constant value. +```typescript +// Check if the 'price' field is less than 50 +Field.of("price").lt(50); + +``` + | +| [lte(other)](./firestore_lite.fields.md#fieldslte) | | (BETA) Creates an expression that checks if this expression is less than or equal to another expression. +```typescript +// Check if the 'quantity' field is less than or equal to 20 +Field.of("quantity").lte(Constant.of(20)); + +``` + | +| [lte(other)](./firestore_lite.fields.md#fieldslte) | | (BETA) Creates an expression that checks if this expression is less than or equal to a constant value. +```typescript +// Check if the 'score' field is less than or equal to 70 +Field.of("score").lte(70); + +``` + | +| [mapGet(subfield)](./firestore_lite.fields.md#fieldsmapget) | | (BETA) Accesses a value from a map (object) field using the provided key. +```typescript +// Get the 'city' value from the 'address' map field +Field.of("address").mapGet("city"); + +``` + | +| [max()](./firestore_lite.fields.md#fieldsmax) | | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. +```typescript +// Find the highest score in a leaderboard +Field.of("score").max().as("highestScore"); + +``` + A new Accumulator representing the 'max' aggregation. | +| [min()](./firestore_lite.fields.md#fieldsmin) | | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. +```typescript +// Find the lowest price of all products +Field.of("price").min().as("lowestPrice"); + +``` + A new Accumulator representing the 'min' aggregation. | +| [mod(other)](./firestore_lite.fields.md#fieldsmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. +```typescript +// Calculate the remainder of dividing the 'value' field by the 'divisor' field +Field.of("value").mod(Field.of("divisor")); + +``` + | +| [mod(other)](./firestore_lite.fields.md#fieldsmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. +```typescript +// Calculate the remainder of dividing the 'value' field by 10 +Field.of("value").mod(10); + +``` + | +| [multiply(other)](./firestore_lite.fields.md#fieldsmultiply) | | (BETA) Creates an expression that multiplies this expression by another expression. +```typescript +// Multiply the 'quantity' field by the 'price' field +Field.of("quantity").multiply(Field.of("price")); + +``` + | +| [multiply(other)](./firestore_lite.fields.md#fieldsmultiply) | | (BETA) Creates an expression that multiplies this expression by a constant value. +```typescript +// Multiply the 'value' field by 2 +Field.of("value").multiply(2); + +``` + | +| [neq(other)](./firestore_lite.fields.md#fieldsneq) | | (BETA) Creates an expression that checks if this expression is not equal to another expression. +```typescript +// Check if the 'status' field is not equal to "completed" +Field.of("status").neq("completed"); + +``` + | +| [neq(other)](./firestore_lite.fields.md#fieldsneq) | | (BETA) Creates an expression that checks if this expression is not equal to a constant value. +```typescript +// Check if the 'country' field is not equal to "USA" +Field.of("country").neq("USA"); + +``` + | +| [of(name, others)](./firestore_lite.fields.md#fieldsof) | static | (BETA) | +| [ofAll()](./firestore_lite.fields.md#fieldsofall) | static | (BETA) | +| [regexContains(pattern)](./firestore_lite.fields.md#fieldsregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +Field.of("description").regexContains("(?i)example"); + +``` + | +| [regexContains(pattern)](./firestore_lite.fields.md#fieldsregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains the regular expression stored in field 'regex' +Field.of("description").regexContains(Field.of("regex")); + +``` + | +| [regexMatch(pattern)](./firestore_lite.fields.md#fieldsregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. +```typescript +// Check if the 'email' field matches a valid email pattern +Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + | +| [regexMatch(pattern)](./firestore_lite.fields.md#fieldsregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. +```typescript +// Check if the 'email' field matches a regular expression stored in field 'regex' +Field.of("email").regexMatch(Field.of("regex")); + +``` + | +| [replaceAll(find, replace)](./firestore_lite.fields.md#fieldsreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring. +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field +Field.of("message").replaceAll("hello", "hi"); + +``` + | +| [replaceAll(find, replace)](./firestore_lite.fields.md#fieldsreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + +``` + | +| [replaceFirst(find, replace)](./firestore_lite.fields.md#fieldsreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field +Field.of("message").replaceFirst("hello", "hi"); + +``` + | +| [replaceFirst(find, replace)](./firestore_lite.fields.md#fieldsreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + +``` + | +| [reverse()](./firestore_lite.fields.md#fieldsreverse) | | (BETA) Creates an expression that reverses this string expression. +```typescript +// Reverse the value of the 'myString' field. +Field.of("myString").reverse(); + +``` + A new representing the reversed string. | +| [startsWith(prefix)](./firestore_lite.fields.md#fieldsstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix. +```typescript +// Check if the 'name' field starts with "Mr." +Field.of("name").startsWith("Mr."); + +``` + | +| [startsWith(prefix)](./firestore_lite.fields.md#fieldsstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix (represented as an expression). +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +Field.of("fullName").startsWith(Field.of("firstName")); + +``` + | +| [strConcat(elements)](./firestore_lite.fields.md#fieldsstrconcat) | | (BETA) Creates an expression that concatenates string expressions together. +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + +``` + | +| [strContains(substring)](./firestore_lite.fields.md#fieldsstrcontains) | | (BETA) Creates an expression that checks if a string contains a specified substring. +```typescript +// Check if the 'description' field contains "example". +Field.of("description").strContains("example"); + +``` + | +| [strContains(expr)](./firestore_lite.fields.md#fieldsstrcontains) | | (BETA) Creates an expression that checks if a string contains the string represented by another expression. +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +Field.of("description").strContains(Field.of("keyword")); + +``` + | +| [subtract(other)](./firestore_lite.fields.md#fieldssubtract) | | (BETA) Creates an expression that subtracts another expression from this expression. +```typescript +// Subtract the 'discount' field from the 'price' field +Field.of("price").subtract(Field.of("discount")); + +``` + | +| [subtract(other)](./firestore_lite.fields.md#fieldssubtract) | | (BETA) Creates an expression that subtracts a constant value from this expression. +```typescript +// Subtract 20 from the value of the 'total' field +Field.of("total").subtract(20); + +``` + | +| [sum()](./firestore_lite.fields.md#fieldssum) | | (BETA) Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. +```typescript +// Calculate the total revenue from a set of orders +Field.of("orderAmount").sum().as("totalRevenue"); + +``` + A new Accumulator representing the 'sum' aggregation. | +| [timestampAdd(unit, amount)](./firestore_lite.fields.md#fieldstimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampAdd(unit, amount)](./firestore_lite.fields.md#fieldstimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. +```typescript +// Add 1 day to the 'timestamp' field. +Field.of("timestamp").timestampAdd("day", 1); + +``` + | +| [timestampSub(unit, amount)](./firestore_lite.fields.md#fieldstimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampSub(unit, amount)](./firestore_lite.fields.md#fieldstimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. +```typescript +// Subtract 1 day from the 'timestamp' field. +Field.of("timestamp").timestampSub("day", 1); + +``` + | +| [timestampToUnixMicros()](./firestore_lite.fields.md#fieldstimestamptounixmicros) | | (BETA) Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +Field.of("timestamp").timestampToUnixMicros(); + +``` + A new representing the number of microseconds since epoch. | +| [timestampToUnixMillis()](./firestore_lite.fields.md#fieldstimestamptounixmillis) | | (BETA) Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +Field.of("timestamp").timestampToUnixMillis(); + +``` + A new representing the number of milliseconds since epoch. | +| [timestampToUnixSeconds()](./firestore_lite.fields.md#fieldstimestamptounixseconds) | | (BETA) Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to seconds since epoch. +Field.of("timestamp").timestampToUnixSeconds(); + +``` + A new representing the number of seconds since epoch. | +| [toLower()](./firestore_lite.fields.md#fieldstolower) | | (BETA) Creates an expression that converts a string to lowercase. +```typescript +// Convert the 'name' field to lowercase +Field.of("name").toLower(); + +``` + A new Expr representing the lowercase string. | +| [toUpper()](./firestore_lite.fields.md#fieldstoupper) | | (BETA) Creates an expression that converts a string to uppercase. +```typescript +// Convert the 'title' field to uppercase +Field.of("title").toUpper(); + +``` + A new Expr representing the uppercase string. | +| [trim()](./firestore_lite.fields.md#fieldstrim) | | (BETA) Creates an expression that removes leading and trailing whitespace from a string. +```typescript +// Trim whitespace from the 'userInput' field +Field.of("userInput").trim(); + +``` + A new Expr representing the trimmed string. | +| [unixMicrosToTimestamp()](./firestore_lite.fields.md#fieldsunixmicrostotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +Field.of("microseconds").unixMicrosToTimestamp(); + +``` + A new representing the timestamp. | +| [unixMillisToTimestamp()](./firestore_lite.fields.md#fieldsunixmillistotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +Field.of("milliseconds").unixMillisToTimestamp(); + +``` + A new representing the timestamp. | +| [unixSecondsToTimestamp()](./firestore_lite.fields.md#fieldsunixsecondstotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'seconds' field as seconds since epoch. +Field.of("seconds").unixSecondsToTimestamp(); + +``` + A new representing the timestamp. | +| [vectorLength()](./firestore_lite.fields.md#fieldsvectorlength) | | (BETA) Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. +```typescript +// Get the vector length (dimension) of the field 'embedding'. +Field.of("embedding").vectorLength(); + +``` + A new representing the length of the vector. | + +## Fields.exprType + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +exprType: ExprType; +``` + +## Fields.selectable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +selectable: true; +``` + +## Fields.add() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds this expression to another expression. + +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +Field.of("quantity").add(Field.of("reserve")); + +``` + +Signature: + +```typescript +add(other: Constant): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to add to this expression. A new Expr representing the addition operation. | + +Returns: + +[Add](./firestore_lite.add.md#add_class) + +## Fields.add() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds this expression to a constant value. + +```typescript +// Add 5 to the value of the 'age' field +Field.of("age").add(5); + +``` + +Signature: + +```typescript +add(other: any): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to add. A new Expr representing the addition operation. | + +Returns: + +[Add](./firestore_lite.add.md#add_class) + +## Fields.arrayConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with one or more other arrays. + +```typescript +// Combine the 'items' array with another array field. +Field.of("items").arrayConcat(Field.of("otherItems")); + +``` + +Signature: + +```typescript +arrayConcat(arrays: Constant[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrays | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The array expressions to concatenate. A new Expr representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) + +## Fields.arrayConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with one or more other arrays. + +```typescript +// Combine the 'tags' array with a new array and an array field +Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + +``` + +Signature: + +```typescript +arrayConcat(arrays: any[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrays | any\[\] | The array expressions or values to concatenate. A new Expr representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) + +## Fields.arrayContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains a specific element. + +```typescript +// Check if the 'sizes' array contains the value from the 'selectedSize' field +Field.of("sizes").arrayContains(Field.of("selectedSize")); + +``` + +Signature: + +```typescript +arrayContains(element: Constant): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | [Constant](./firestore_lite.constant.md#constant_class) | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) + +## Fields.arrayContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains a specific value. + +```typescript +// Check if the 'colors' array contains "red" +Field.of("colors").arrayContains("red"); + +``` + +Signature: + +```typescript +arrayContains(element: any): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | any | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) + +## Fields.arrayContainsAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both "news" and "sports" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + +Signature: + +```typescript +arrayContainsAll(...values: Constant[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) + +## Fields.arrayContainsAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + +Signature: + +```typescript +arrayContainsAll(...values: any[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) + +## Fields.arrayContainsAny() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains any of the specified elements. + +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "cate2" +Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + +``` + +Signature: + +```typescript +arrayContainsAny(...values: Constant[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) + +## Fields.arrayContainsAny() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains any of the specified elements. + +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + +``` + +Signature: + +```typescript +arrayContainsAny(...values: any[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) + +## Fields.arrayLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of an array. + +```typescript +// Get the number of items in the 'cart' array +Field.of("cart").arrayLength(); + +``` + A new `Expr` representing the length of the array. + +Signature: + +```typescript +arrayLength(): ArrayLength; +``` +Returns: + +[ArrayLength](./firestore_lite.arraylength.md#arraylength_class) + +## Fields.as() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Assigns an alias to this expression. + +Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. + +```typescript +// Calculate the total price and assign it the alias "totalPrice" and add it to the output. +firestore.pipeline().collection("items") +.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + +``` + +Signature: + +```typescript +as(name: string): ExprWithAlias; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | The alias to assign to this expression. A new [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) that wraps this expression and associates it with the provided alias. | + +Returns: + +[ExprWithAlias](./firestore_lite.exprwithalias.md#exprwithalias_class)<this> + +## Fields.ascending() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. + +```typescript +// Sort documents by the 'name' field in ascending order +pipeline().collection("users") +.sort(Field.of("name").ascending()); + +``` + A new `Ordering` for ascending sorting. + +Signature: + +```typescript +ascending(): Ordering; +``` +Returns: + +[Ordering](./firestore_lite.ordering.md#ordering_class) + +## Fields.avg() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. + +```typescript +// Calculate the average age of users +Field.of("age").avg().as("averageAge"); + +``` + A new `Accumulator` representing the 'avg' aggregation. + +Signature: + +```typescript +avg(): Avg; +``` +Returns: + +[Avg](./firestore_lite.avg.md#avg_class) + +## Fields.byteLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of this string expression in bytes. + +```typescript +// Calculate the length of the 'myString' field in bytes. +Field.of("myString").byteLength(); + +``` + A new representing the length of the string in bytes. + +Signature: + +```typescript +byteLength(): ByteLength; +``` +Returns: + +[ByteLength](./firestore_lite.bytelength.md#bytelength_class) + +## Fields.charLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the character length of a string in UTF-8. + +```typescript +// Get the character length of the 'name' field in its UTF-8 form. +Field.of("name").charLength(); + +``` + A new `Expr` representing the length of the string. + +Signature: + +```typescript +charLength(): CharLength; +``` +Returns: + +[CharLength](./firestore_lite.charlength.md#charlength_class) + +## Fields.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the cosine distance between two vectors. + +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +Field.of("userVector").cosineDistance(Field.of("itemVector")); + +``` + +Signature: + +```typescript +cosineDistance(other: Constant): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new Expr representing the cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) + +## Fields.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vectors. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +cosineDistance(other: VectorValue): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) + +## Fields.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vectors. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance([37.7749, -122.4194]); + +``` + +Signature: + +```typescript +cosineDistance(other: number[]): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | The other vector (as an array of numbers) to compare against. A new Expr representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) + +## Fields.count() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. + +```typescript +// Count the total number of products +Field.of("productId").count().as("totalProducts"); + +``` + A new `Accumulator` representing the 'count' aggregation. + +Signature: + +```typescript +count(): Count; +``` +Returns: + +[Count](./firestore_lite.count.md#count_class) + +## Fields.descending() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. + +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") +.sort(Field.of("createdAt").descending()); + +``` + A new `Ordering` for descending sorting. + +Signature: + +```typescript +descending(): Ordering; +``` +Returns: + +[Ordering](./firestore_lite.ordering.md#ordering_class) + +## Fields.divide() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides this expression by another expression. + +```typescript +// Divide the 'total' field by the 'count' field +Field.of("total").divide(Field.of("count")); + +``` + +Signature: + +```typescript +divide(other: Constant): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new Expr representing the division operation. | + +Returns: + +[Divide](./firestore_lite.divide.md#divide_class) + +## Fields.divide() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides this expression by a constant value. + +```typescript +// Divide the 'value' field by 10 +Field.of("value").divide(10); + +``` + +Signature: + +```typescript +divide(other: any): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to divide by. A new Expr representing the division operation. | + +Returns: + +[Divide](./firestore_lite.divide.md#divide_class) + +## Fields.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vectors. + +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct([0.5, 0.8, 0.2]); + +``` + +Signature: + +```typescript +dotProduct(other: Constant): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) + +## Fields.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vectors. + +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + +``` + +Signature: + +```typescript +dotProduct(other: VectorValue): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) + +## Fields.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +dotProduct(other: number[]): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | | + +Returns: + +[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) + +## Fields.endsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string ends with a given postfix. + +```typescript +// Check if the 'filename' field ends with ".txt" +Field.of("filename").endsWith(".txt"); + +``` + +Signature: + +```typescript +endsWith(suffix: string): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| suffix | string | The postfix to check for. A new Expr representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_lite.endswith.md#endswith_class) + +## Fields.endsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string ends with a given postfix (represented as an expression). + +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +Field.of("url").endsWith(Field.of("extension")); + +``` + +Signature: + +```typescript +endsWith(suffix: Constant): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| suffix | [Constant](./firestore_lite.constant.md#constant_class) | The postfix expression to check for. A new Expr representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_lite.endswith.md#endswith_class) + +## Fields.eq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to another expression. + +```typescript +// Check if the 'age' field is equal to 21 +Field.of("age").eq(21); + +``` + +Signature: + +```typescript +eq(other: Constant): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for equality. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_lite.eq.md#eq_class) + +## Fields.eq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to a constant value. + +```typescript +// Check if the 'city' field is equal to "London" +Field.of("city").eq("London"); + +``` + +Signature: + +```typescript +eq(other: any): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for equality. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_lite.eq.md#eq_class) + +## Fields.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vectors. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance([37.7749, -122.4194]); + +``` + +Signature: + +```typescript +euclideanDistance(other: Constant): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) + +## Fields.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vectors. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +euclideanDistance(other: VectorValue): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) + +## Fields.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +euclideanDistance(other: number[]): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | | + +Returns: + +[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) + +## Fields.exists() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field exists in the document. + +```typescript +// Check if the document has a field named "phoneNumber" +Field.of("phoneNumber").exists(); + +``` + A new `Expr` representing the 'exists' check. + +Signature: + +```typescript +exists(): Exists; +``` +Returns: + +[Exists](./firestore_lite.exists.md#exists_class) + +## Fields.fieldList() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +fieldList(): Field[]; +``` +Returns: + +[Field](./firestore_lite.field.md#field_class)\[\] + +## Fields.gt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than another expression. + +```typescript +// Check if the 'age' field is greater than the 'limit' field +Field.of("age").gt(Field.of("limit")); + +``` + +Signature: + +```typescript +gt(other: Constant): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for greater than. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_lite.gt.md#gt_class) + +## Fields.gt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than a constant value. + +```typescript +// Check if the 'price' field is greater than 100 +Field.of("price").gt(100); + +``` + +Signature: + +```typescript +gt(other: any): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for greater than. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_lite.gt.md#gt_class) + +## Fields.gte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than or equal to another expression. + +```typescript +// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 +Field.of("quantity").gte(Field.of('requirement').add(1)); + +``` + +Signature: + +```typescript +gte(other: Constant): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_lite.gte.md#gte_class) + +## Fields.gte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than or equal to a constant value. + +```typescript +// Check if the 'score' field is greater than or equal to 80 +Field.of("score").gte(80); + +``` + +Signature: + +```typescript +gte(other: any): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_lite.gte.md#gte_class) + +## Fields.in() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to any of the provided values or expressions. + +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +Field.of("category").in("Electronics", Field.of("primaryType")); + +``` + +Signature: + +```typescript +in(...others: Constant[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| others | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The values or expressions to check against. A new Expr representing the 'IN' comparison. | + +Returns: + +[In](./firestore_lite.in.md#in_class) + +## Fields.in() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +in(...others: any[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| others | any\[\] | | + +Returns: + +[In](./firestore_lite.in.md#in_class) + +## Fields.isNaN() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). + +```typescript +// Check if the result of a calculation is NaN +Field.of("value").divide(0).isNaN(); + +``` + A new `Expr` representing the 'isNaN' check. + +Signature: + +```typescript +isNaN(): IsNan; +``` +Returns: + +[IsNan](./firestore_lite.isnan.md#isnan_class) + +## Fields.like() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that performs a case-sensitive string comparison. + +```typescript +// Check if the 'title' field contains the word "guide" (case-sensitive) +Field.of("title").like("%guide%"); + +``` + +Signature: + +```typescript +like(pattern: string): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new Expr representing the 'like' comparison. | + +Returns: + +[Like](./firestore_lite.like.md#like_class) + +## Fields.like() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +like(pattern: Constant): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | | + +Returns: + +[Like](./firestore_lite.like.md#like_class) + +## Fields.logicalMax() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMax(Function.currentTimestamp()); + +``` + +Signature: + +```typescript +logicalMax(other: Constant): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare with. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) + +## Fields.logicalMax() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'value' field and 10. +Field.of("value").logicalMax(10); + +``` + +Signature: + +```typescript +logicalMax(other: any): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare with. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) + +## Fields.logicalMin() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMin(Function.currentTimestamp()); + +``` + +Signature: + +```typescript +logicalMin(other: Constant): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare with. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) + +## Fields.logicalMin() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'value' field and 10. +Field.of("value").logicalMin(10); + +``` + +Signature: + +```typescript +logicalMin(other: any): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare with. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) + +## Fields.lt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than another expression. + +```typescript +// Check if the 'age' field is less than 'limit' +Field.of("age").lt(Field.of('limit')); + +``` + +Signature: + +```typescript +lt(other: Constant): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for less than. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_lite.lt.md#lt_class) + +## Fields.lt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than a constant value. + +```typescript +// Check if the 'price' field is less than 50 +Field.of("price").lt(50); + +``` + +Signature: + +```typescript +lt(other: any): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for less than. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_lite.lt.md#lt_class) + +## Fields.lte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than or equal to another expression. + +```typescript +// Check if the 'quantity' field is less than or equal to 20 +Field.of("quantity").lte(Constant.of(20)); + +``` + +Signature: + +```typescript +lte(other: Constant): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_lite.lte.md#lte_class) + +## Fields.lte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than or equal to a constant value. + +```typescript +// Check if the 'score' field is less than or equal to 70 +Field.of("score").lte(70); + +``` + +Signature: + +```typescript +lte(other: any): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_lite.lte.md#lte_class) + +## Fields.mapGet() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Accesses a value from a map (object) field using the provided key. + +```typescript +// Get the 'city' value from the 'address' map field +Field.of("address").mapGet("city"); + +``` + +Signature: + +```typescript +mapGet(subfield: string): MapGet; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| subfield | string | The key to access in the map. A new Expr representing the value associated with the given key in the map. | + +Returns: + +[MapGet](./firestore_lite.mapget.md#mapget_class) + +## Fields.max() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that finds the maximum value of a field across multiple stage inputs. + +```typescript +// Find the highest score in a leaderboard +Field.of("score").max().as("highestScore"); + +``` + A new `Accumulator` representing the 'max' aggregation. + +Signature: + +```typescript +max(): Max; +``` +Returns: + +[Max](./firestore_lite.max.md#max_class) + +## Fields.min() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that finds the minimum value of a field across multiple stage inputs. + +```typescript +// Find the lowest price of all products +Field.of("price").min().as("lowestPrice"); + +``` + A new `Accumulator` representing the 'min' aggregation. + +Signature: + +```typescript +min(): Min; +``` +Returns: + +[Min](./firestore_lite.min.md#min_class) + +## Fields.mod() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. + +```typescript +// Calculate the remainder of dividing the 'value' field by the 'divisor' field +Field.of("value").mod(Field.of("divisor")); + +``` + +Signature: + +```typescript +mod(other: Constant): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new Expr representing the modulo operation. | + +Returns: + +[Mod](./firestore_lite.mod.md#mod_class) + +## Fields.mod() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. + +```typescript +// Calculate the remainder of dividing the 'value' field by 10 +Field.of("value").mod(10); + +``` + +Signature: + +```typescript +mod(other: any): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to divide by. A new Expr representing the modulo operation. | + +Returns: + +[Mod](./firestore_lite.mod.md#mod_class) + +## Fields.multiply() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies this expression by another expression. + +```typescript +// Multiply the 'quantity' field by the 'price' field +Field.of("quantity").multiply(Field.of("price")); + +``` + +Signature: + +```typescript +multiply(other: Constant): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to multiply by. A new Expr representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_lite.multiply.md#multiply_class) + +## Fields.multiply() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies this expression by a constant value. + +```typescript +// Multiply the 'value' field by 2 +Field.of("value").multiply(2); + +``` + +Signature: + +```typescript +multiply(other: any): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to multiply by. A new Expr representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_lite.multiply.md#multiply_class) + +## Fields.neq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is not equal to another expression. + +```typescript +// Check if the 'status' field is not equal to "completed" +Field.of("status").neq("completed"); + +``` + +Signature: + +```typescript +neq(other: Constant): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for inequality. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_lite.neq.md#neq_class) + +## Fields.neq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is not equal to a constant value. + +```typescript +// Check if the 'country' field is not equal to "USA" +Field.of("country").neq("USA"); + +``` + +Signature: + +```typescript +neq(other: any): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for inequality. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_lite.neq.md#neq_class) + +## Fields.of() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +static of(name: string, ...others: string[]): Fields; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | | +| others | string\[\] | | + +Returns: + +[Fields](./firestore_lite.fields.md#fields_class) + +## Fields.ofAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +static ofAll(): Fields; +``` +Returns: + +[Fields](./firestore_lite.fields.md#fields_class) + +## Fields.regexContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +Field.of("description").regexContains("(?i)example"); + +``` + +Signature: + +```typescript +regexContains(pattern: string): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) + +## Fields.regexContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains the regular expression stored in field 'regex' +Field.of("description").regexContains(Field.of("regex")); + +``` + +Signature: + +```typescript +regexContains(pattern: Constant): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) + +## Fields.regexMatch() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a valid email pattern +Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + +Signature: + +```typescript +regexMatch(pattern: string): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The regular expression to use for the match. A new Expr representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) + +## Fields.regexMatch() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a regular expression stored in field 'regex' +Field.of("email").regexMatch(Field.of("regex")); + +``` + +Signature: + +```typescript +regexMatch(pattern: Constant): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the match. A new Expr representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) + +## Fields.replaceAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within this string expression with another substring. + +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field +Field.of("message").replaceAll("hello", "hi"); + +``` + +Signature: + +```typescript +replaceAll(find: string, replace: string): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | string | The substring to search for. | +| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) + +## Fields.replaceAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + +``` + +Signature: + +```typescript +replaceAll(find: Constant, replace: Constant): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) + +## Fields.replaceFirst() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. + +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field +Field.of("message").replaceFirst("hello", "hi"); + +``` + +Signature: + +```typescript +replaceFirst(find: string, replace: string): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | string | The substring to search for. | +| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) + +## Fields.replaceFirst() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + +``` + +Signature: + +```typescript +replaceFirst(find: Constant, replace: Constant): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) + +## Fields.reverse() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that reverses this string expression. + +```typescript +// Reverse the value of the 'myString' field. +Field.of("myString").reverse(); + +``` + A new representing the reversed string. + +Signature: + +```typescript +reverse(): Reverse; +``` +Returns: + +[Reverse](./firestore_lite.reverse.md#reverse_class) + +## Fields.startsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string starts with a given prefix. + +```typescript +// Check if the 'name' field starts with "Mr." +Field.of("name").startsWith("Mr."); + +``` + +Signature: + +```typescript +startsWith(prefix: string): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| prefix | string | The prefix to check for. A new Expr representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_lite.startswith.md#startswith_class) + +## Fields.startsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string starts with a given prefix (represented as an expression). + +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +Field.of("fullName").startsWith(Field.of("firstName")); + +``` + +Signature: + +```typescript +startsWith(prefix: Constant): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| prefix | [Constant](./firestore_lite.constant.md#constant_class) | The prefix expression to check for. A new Expr representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_lite.startswith.md#startswith_class) + +## Fields.strConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates string expressions together. + +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + +``` + +Signature: + +```typescript +strConcat(...elements: Array): StrConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| elements | Array<string \| [Constant](./firestore_lite.constant.md#constant_class)> | The expressions (typically strings) to concatenate. A new Expr representing the concatenated string. | + +Returns: + +[StrConcat](./firestore_lite.strconcat.md#strconcat_class) + +## Fields.strContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified substring. + +```typescript +// Check if the 'description' field contains "example". +Field.of("description").strContains("example"); + +``` + +Signature: + +```typescript +strContains(substring: string): StrContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| substring | string | The substring to search for. A new Expr representing the 'contains' comparison. | + +Returns: + +[StrContains](./firestore_lite.strcontains.md#strcontains_class) + +## Fields.strContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains the string represented by another expression. + +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +Field.of("description").strContains(Field.of("keyword")); + +``` + +Signature: + +```typescript +strContains(expr: Constant): StrContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. A new Expr representing the 'contains' comparison. | + +Returns: + +[StrContains](./firestore_lite.strcontains.md#strcontains_class) + +## Fields.subtract() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts another expression from this expression. + +```typescript +// Subtract the 'discount' field from the 'price' field +Field.of("price").subtract(Field.of("discount")); + +``` + +Signature: + +```typescript +subtract(other: Constant): Subtract; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to subtract from this expression. A new Expr representing the subtraction operation. | + +Returns: + +[Subtract](./firestore_lite.subtract.md#subtract_class) + +## Fields.subtract() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a constant value from this expression. + +```typescript +// Subtract 20 from the value of the 'total' field +Field.of("total").subtract(20); + +``` + +Signature: + +```typescript +subtract(other: any): Subtract; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to subtract. A new Expr representing the subtraction operation. | + +Returns: + +[Subtract](./firestore_lite.subtract.md#subtract_class) + +## Fields.sum() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. + +```typescript +// Calculate the total revenue from a set of orders +Field.of("orderAmount").sum().as("totalRevenue"); + +``` + A new `Accumulator` representing the 'sum' aggregation. + +Signature: + +```typescript +sum(): Sum; +``` +Returns: + +[Sum](./firestore_lite.sum.md#sum_class) + +## Fields.timestampAdd() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to this timestamp expression. + +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + +``` + +Signature: + +```typescript +timestampAdd(unit: Constant, amount: Constant): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) + +## Fields.timestampAdd() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to this timestamp expression. + +```typescript +// Add 1 day to the 'timestamp' field. +Field.of("timestamp").timestampAdd("day", 1); + +``` + +Signature: + +```typescript +timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | +| amount | number | The amount of time to add. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) + +## Fields.timestampSub() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from this timestamp expression. + +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + +``` + +Signature: + +```typescript +timestampSub(unit: Constant, amount: Constant): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) + +## Fields.timestampSub() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from this timestamp expression. + +```typescript +// Subtract 1 day from the 'timestamp' field. +Field.of("timestamp").timestampSub("day", 1); + +``` + +Signature: + +```typescript +timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | +| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) + +## Fields.timestampToUnixMicros() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +Field.of("timestamp").timestampToUnixMicros(); + +``` + A new representing the number of microseconds since epoch. + +Signature: + +```typescript +timestampToUnixMicros(): TimestampToUnixMicros; +``` +Returns: + +[TimestampToUnixMicros](./firestore_lite.timestamptounixmicros.md#timestamptounixmicros_class) + +## Fields.timestampToUnixMillis() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +Field.of("timestamp").timestampToUnixMillis(); + +``` + A new representing the number of milliseconds since epoch. + +Signature: + +```typescript +timestampToUnixMillis(): TimestampToUnixMillis; +``` +Returns: + +[TimestampToUnixMillis](./firestore_lite.timestamptounixmillis.md#timestamptounixmillis_class) + +## Fields.timestampToUnixSeconds() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to seconds since epoch. +Field.of("timestamp").timestampToUnixSeconds(); + +``` + A new representing the number of seconds since epoch. + +Signature: + +```typescript +timestampToUnixSeconds(): TimestampToUnixSeconds; +``` +Returns: + +[TimestampToUnixSeconds](./firestore_lite.timestamptounixseconds.md#timestamptounixseconds_class) + +## Fields.toLower() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string to lowercase. + +```typescript +// Convert the 'name' field to lowercase +Field.of("name").toLower(); + +``` + A new `Expr` representing the lowercase string. + +Signature: + +```typescript +toLower(): ToLower; +``` +Returns: + +[ToLower](./firestore_lite.tolower.md#tolower_class) + +## Fields.toUpper() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string to uppercase. + +```typescript +// Convert the 'title' field to uppercase +Field.of("title").toUpper(); + +``` + A new `Expr` representing the uppercase string. + +Signature: + +```typescript +toUpper(): ToUpper; +``` +Returns: + +[ToUpper](./firestore_lite.toupper.md#toupper_class) + +## Fields.trim() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that removes leading and trailing whitespace from a string. + +```typescript +// Trim whitespace from the 'userInput' field +Field.of("userInput").trim(); + +``` + A new `Expr` representing the trimmed string. + +Signature: + +```typescript +trim(): Trim; +``` +Returns: + +[Trim](./firestore_lite.trim.md#trim_class) + +## Fields.unixMicrosToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +Field.of("microseconds").unixMicrosToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixMicrosToTimestamp(): UnixMicrosToTimestamp; +``` +Returns: + +[UnixMicrosToTimestamp](./firestore_lite.unixmicrostotimestamp.md#unixmicrostotimestamp_class) + +## Fields.unixMillisToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +Field.of("milliseconds").unixMillisToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixMillisToTimestamp(): UnixMillisToTimestamp; +``` +Returns: + +[UnixMillisToTimestamp](./firestore_lite.unixmillistotimestamp.md#unixmillistotimestamp_class) + +## Fields.unixSecondsToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'seconds' field as seconds since epoch. +Field.of("seconds").unixSecondsToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixSecondsToTimestamp(): UnixSecondsToTimestamp; +``` +Returns: + +[UnixSecondsToTimestamp](./firestore_lite.unixsecondstotimestamp.md#unixsecondstotimestamp_class) + +## Fields.vectorLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. + +```typescript +// Get the vector length (dimension) of the field 'embedding'. +Field.of("embedding").vectorLength(); + +``` + A new representing the length of the vector. + +Signature: + +```typescript +vectorLength(): VectorLength; +``` +Returns: + +[VectorLength](./firestore_lite.vectorlength.md#vectorlength_class) + diff --git a/docs-devsite/firestore_lite.filtercondition.md b/docs-devsite/firestore_lite.filtercondition.md new file mode 100644 index 00000000000..3f638859319 --- /dev/null +++ b/docs-devsite/firestore_lite.filtercondition.md @@ -0,0 +1,39 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# FilterCondition interface +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +An interface that represents a filter condition. + +Signature: + +```typescript +export declare interface FilterCondition +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [filterable](./firestore_lite.filtercondition.md#filterconditionfilterable) | true | (BETA) | + +## FilterCondition.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.findnearest.md b/docs-devsite/firestore_lite.findnearest.md new file mode 100644 index 00000000000..a0fe60cb31e --- /dev/null +++ b/docs-devsite/firestore_lite.findnearest.md @@ -0,0 +1,39 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# FindNearest class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class FindNearest implements Stage +``` +Implements: [Stage](./firestore_lite.stage.md#stage_interface) + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_lite.findnearest.md#findnearestname) | | string | (BETA) | + +## FindNearest.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_lite.findnearestoptions.md b/docs-devsite/firestore_lite.findnearestoptions.md new file mode 100644 index 00000000000..fe142b4a8d4 --- /dev/null +++ b/docs-devsite/firestore_lite.findnearestoptions.md @@ -0,0 +1,86 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# FindNearestOptions interface +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare interface FindNearestOptions +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [distanceField](./firestore_lite.findnearestoptions.md#findnearestoptionsdistancefield) | string | (BETA) | +| [distanceMeasure](./firestore_lite.findnearestoptions.md#findnearestoptionsdistancemeasure) | 'euclidean' \| 'cosine' \| 'dot\_product' | (BETA) | +| [field](./firestore_lite.findnearestoptions.md#findnearestoptionsfield) | [Field](./firestore_lite.field.md#field_class) | (BETA) | +| [limit](./firestore_lite.findnearestoptions.md#findnearestoptionslimit) | number | (BETA) | +| [vectorValue](./firestore_lite.findnearestoptions.md#findnearestoptionsvectorvalue) | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) \| number\[\] | (BETA) | + +## FindNearestOptions.distanceField + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +distanceField?: string; +``` + +## FindNearestOptions.distanceMeasure + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +distanceMeasure: 'euclidean' | 'cosine' | 'dot_product'; +``` + +## FindNearestOptions.field + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +field: Field; +``` + +## FindNearestOptions.limit + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +limit?: number; +``` + +## FindNearestOptions.vectorValue + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +vectorValue: VectorValue | number[]; +``` diff --git a/docs-devsite/firestore_lite.firestore.md b/docs-devsite/firestore_lite.firestore.md index 2edac7aa130..cfbb412ed25 100644 --- a/docs-devsite/firestore_lite.firestore.md +++ b/docs-devsite/firestore_lite.firestore.md @@ -31,6 +31,7 @@ export declare class Firestore | Method | Modifiers | Description | | --- | --- | --- | +| [pipeline()](./firestore_lite.firestore.md#firestorepipeline) | | Pipeline query. | | [toJSON()](./firestore_lite.firestore.md#firestoretojson) | | Returns a JSON-serializable representation of this Firestore instance. | ## Firestore.app @@ -53,6 +54,19 @@ Whether it's a Firestore or Firestore Lite instance. type: 'firestore-lite' | 'firestore'; ``` +## Firestore.pipeline() + +Pipeline query. + +Signature: + +```typescript +pipeline(): PipelineSource; +``` +Returns: + +[PipelineSource](./firestore_lite.pipelinesource.md#pipelinesource_class) + ## Firestore.toJSON() Returns a JSON-serializable representation of this `Firestore` instance. diff --git a/docs-devsite/firestore_lite.firestorefunction.md b/docs-devsite/firestore_lite.firestorefunction.md new file mode 100644 index 00000000000..04bf9e874f8 --- /dev/null +++ b/docs-devsite/firestore_lite.firestorefunction.md @@ -0,0 +1,3173 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# FirestoreFunction class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +This class defines the base class for Firestore [Pipeline](./firestore_.pipeline.md#pipeline_class) functions, which can be evaluated within pipeline execution. + +Typically, you would not use this class or its children directly. Use either the functions like , , or the methods on (, , etc) to construct new Function instances. + +Signature: + +```typescript +export declare class FirestoreFunction +``` + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(name, params)](./firestore_lite.firestorefunction.md#firestorefunctionconstructor) | | (BETA) Constructs a new instance of the FirestoreFunction class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [exprType](./firestore_lite.firestorefunction.md#firestorefunctionexprtype) | | [ExprType](./firestore_lite.md#exprtype) | (BETA) | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [add(other)](./firestore_lite.firestorefunction.md#firestorefunctionadd) | | (BETA) Creates an expression that adds this expression to another expression. +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +Field.of("quantity").add(Field.of("reserve")); + +``` + | +| [add(other)](./firestore_lite.firestorefunction.md#firestorefunctionadd) | | (BETA) Creates an expression that adds this expression to a constant value. +```typescript +// Add 5 to the value of the 'age' field +Field.of("age").add(5); + +``` + | +| [arrayConcat(arrays)](./firestore_lite.firestorefunction.md#firestorefunctionarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. +```typescript +// Combine the 'items' array with another array field. +Field.of("items").arrayConcat(Field.of("otherItems")); + +``` + | +| [arrayConcat(arrays)](./firestore_lite.firestorefunction.md#firestorefunctionarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. +```typescript +// Combine the 'tags' array with a new array and an array field +Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + +``` + | +| [arrayContains(element)](./firestore_lite.firestorefunction.md#firestorefunctionarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific element. +```typescript +// Check if the 'sizes' array contains the value from the 'selectedSize' field +Field.of("sizes").arrayContains(Field.of("selectedSize")); + +``` + | +| [arrayContains(element)](./firestore_lite.firestorefunction.md#firestorefunctionarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific value. +```typescript +// Check if the 'colors' array contains "red" +Field.of("colors").arrayContains("red"); + +``` + | +| [arrayContainsAll(values)](./firestore_lite.firestorefunction.md#firestorefunctionarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. +```typescript +// Check if the 'tags' array contains both "news" and "sports" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + | +| [arrayContainsAll(values)](./firestore_lite.firestorefunction.md#firestorefunctionarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + | +| [arrayContainsAny(values)](./firestore_lite.firestorefunction.md#firestorefunctionarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "cate2" +Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + +``` + | +| [arrayContainsAny(values)](./firestore_lite.firestorefunction.md#firestorefunctionarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + +``` + | +| [arrayLength()](./firestore_lite.firestorefunction.md#firestorefunctionarraylength) | | (BETA) Creates an expression that calculates the length of an array. +```typescript +// Get the number of items in the 'cart' array +Field.of("cart").arrayLength(); + +``` + A new Expr representing the length of the array. | +| [as(name)](./firestore_lite.firestorefunction.md#firestorefunctionas) | | (BETA) Assigns an alias to this expression.Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. +```typescript +// Calculate the total price and assign it the alias "totalPrice" and add it to the output. +firestore.pipeline().collection("items") +.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + +``` + | +| [ascending()](./firestore_lite.firestorefunction.md#firestorefunctionascending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. +```typescript +// Sort documents by the 'name' field in ascending order +pipeline().collection("users") +.sort(Field.of("name").ascending()); + +``` + A new Ordering for ascending sorting. | +| [avg()](./firestore_lite.firestorefunction.md#firestorefunctionavg) | | (BETA) Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. +```typescript +// Calculate the average age of users +Field.of("age").avg().as("averageAge"); + +``` + A new Accumulator representing the 'avg' aggregation. | +| [byteLength()](./firestore_lite.firestorefunction.md#firestorefunctionbytelength) | | (BETA) Creates an expression that calculates the length of this string expression in bytes. +```typescript +// Calculate the length of the 'myString' field in bytes. +Field.of("myString").byteLength(); + +``` + A new representing the length of the string in bytes. | +| [charLength()](./firestore_lite.firestorefunction.md#firestorefunctioncharlength) | | (BETA) Creates an expression that calculates the character length of a string in UTF-8. +```typescript +// Get the character length of the 'name' field in its UTF-8 form. +Field.of("name").charLength(); + +``` + A new Expr representing the length of the string. | +| [cosineDistance(other)](./firestore_lite.firestorefunction.md#firestorefunctioncosinedistance) | | (BETA) Calculates the cosine distance between two vectors. +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +Field.of("userVector").cosineDistance(Field.of("itemVector")); + +``` + | +| [cosineDistance(other)](./firestore_lite.firestorefunction.md#firestorefunctioncosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + +``` + | +| [cosineDistance(other)](./firestore_lite.firestorefunction.md#firestorefunctioncosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance([37.7749, -122.4194]); + +``` + | +| [count()](./firestore_lite.firestorefunction.md#firestorefunctioncount) | | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. +```typescript +// Count the total number of products +Field.of("productId").count().as("totalProducts"); + +``` + A new Accumulator representing the 'count' aggregation. | +| [descending()](./firestore_lite.firestorefunction.md#firestorefunctiondescending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") +.sort(Field.of("createdAt").descending()); + +``` + A new Ordering for descending sorting. | +| [divide(other)](./firestore_lite.firestorefunction.md#firestorefunctiondivide) | | (BETA) Creates an expression that divides this expression by another expression. +```typescript +// Divide the 'total' field by the 'count' field +Field.of("total").divide(Field.of("count")); + +``` + | +| [divide(other)](./firestore_lite.firestorefunction.md#firestorefunctiondivide) | | (BETA) Creates an expression that divides this expression by a constant value. +```typescript +// Divide the 'value' field by 10 +Field.of("value").divide(10); + +``` + | +| [dotProduct(other)](./firestore_lite.firestorefunction.md#firestorefunctiondotproduct) | | (BETA) Calculates the dot product between two vectors. +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct([0.5, 0.8, 0.2]); + +``` + | +| [dotProduct(other)](./firestore_lite.firestorefunction.md#firestorefunctiondotproduct) | | (BETA) Calculates the dot product between two vectors. +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + +``` + | +| [dotProduct(other)](./firestore_lite.firestorefunction.md#firestorefunctiondotproduct) | | (BETA) | +| [endsWith(suffix)](./firestore_lite.firestorefunction.md#firestorefunctionendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix. +```typescript +// Check if the 'filename' field ends with ".txt" +Field.of("filename").endsWith(".txt"); + +``` + | +| [endsWith(suffix)](./firestore_lite.firestorefunction.md#firestorefunctionendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix (represented as an expression). +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +Field.of("url").endsWith(Field.of("extension")); + +``` + | +| [eq(other)](./firestore_lite.firestorefunction.md#firestorefunctioneq) | | (BETA) Creates an expression that checks if this expression is equal to another expression. +```typescript +// Check if the 'age' field is equal to 21 +Field.of("age").eq(21); + +``` + | +| [eq(other)](./firestore_lite.firestorefunction.md#firestorefunctioneq) | | (BETA) Creates an expression that checks if this expression is equal to a constant value. +```typescript +// Check if the 'city' field is equal to "London" +Field.of("city").eq("London"); + +``` + | +| [euclideanDistance(other)](./firestore_lite.firestorefunction.md#firestorefunctioneuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance([37.7749, -122.4194]); + +``` + | +| [euclideanDistance(other)](./firestore_lite.firestorefunction.md#firestorefunctioneuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + +``` + | +| [euclideanDistance(other)](./firestore_lite.firestorefunction.md#firestorefunctioneuclideandistance) | | (BETA) | +| [exists()](./firestore_lite.firestorefunction.md#firestorefunctionexists) | | (BETA) Creates an expression that checks if a field exists in the document. +```typescript +// Check if the document has a field named "phoneNumber" +Field.of("phoneNumber").exists(); + +``` + A new Expr representing the 'exists' check. | +| [gt(other)](./firestore_lite.firestorefunction.md#firestorefunctiongt) | | (BETA) Creates an expression that checks if this expression is greater than another expression. +```typescript +// Check if the 'age' field is greater than the 'limit' field +Field.of("age").gt(Field.of("limit")); + +``` + | +| [gt(other)](./firestore_lite.firestorefunction.md#firestorefunctiongt) | | (BETA) Creates an expression that checks if this expression is greater than a constant value. +```typescript +// Check if the 'price' field is greater than 100 +Field.of("price").gt(100); + +``` + | +| [gte(other)](./firestore_lite.firestorefunction.md#firestorefunctiongte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to another expression. +```typescript +// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 +Field.of("quantity").gte(Field.of('requirement').add(1)); + +``` + | +| [gte(other)](./firestore_lite.firestorefunction.md#firestorefunctiongte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to a constant value. +```typescript +// Check if the 'score' field is greater than or equal to 80 +Field.of("score").gte(80); + +``` + | +| [in(others)](./firestore_lite.firestorefunction.md#firestorefunctionin) | | (BETA) Creates an expression that checks if this expression is equal to any of the provided values or expressions. +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +Field.of("category").in("Electronics", Field.of("primaryType")); + +``` + | +| [in(others)](./firestore_lite.firestorefunction.md#firestorefunctionin) | | (BETA) | +| [isNaN()](./firestore_lite.firestorefunction.md#firestorefunctionisnan) | | (BETA) Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). +```typescript +// Check if the result of a calculation is NaN +Field.of("value").divide(0).isNaN(); + +``` + A new Expr representing the 'isNaN' check. | +| [like(pattern)](./firestore_lite.firestorefunction.md#firestorefunctionlike) | | (BETA) Creates an expression that performs a case-sensitive string comparison. +```typescript +// Check if the 'title' field contains the word "guide" (case-sensitive) +Field.of("title").like("%guide%"); + +``` + | +| [like(pattern)](./firestore_lite.firestorefunction.md#firestorefunctionlike) | | (BETA) | +| [logicalMax(other)](./firestore_lite.firestorefunction.md#firestorefunctionlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMax(Function.currentTimestamp()); + +``` + | +| [logicalMax(other)](./firestore_lite.firestorefunction.md#firestorefunctionlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'value' field and 10. +Field.of("value").logicalMax(10); + +``` + | +| [logicalMin(other)](./firestore_lite.firestorefunction.md#firestorefunctionlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMin(Function.currentTimestamp()); + +``` + | +| [logicalMin(other)](./firestore_lite.firestorefunction.md#firestorefunctionlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'value' field and 10. +Field.of("value").logicalMin(10); + +``` + | +| [lt(other)](./firestore_lite.firestorefunction.md#firestorefunctionlt) | | (BETA) Creates an expression that checks if this expression is less than another expression. +```typescript +// Check if the 'age' field is less than 'limit' +Field.of("age").lt(Field.of('limit')); + +``` + | +| [lt(other)](./firestore_lite.firestorefunction.md#firestorefunctionlt) | | (BETA) Creates an expression that checks if this expression is less than a constant value. +```typescript +// Check if the 'price' field is less than 50 +Field.of("price").lt(50); + +``` + | +| [lte(other)](./firestore_lite.firestorefunction.md#firestorefunctionlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to another expression. +```typescript +// Check if the 'quantity' field is less than or equal to 20 +Field.of("quantity").lte(Constant.of(20)); + +``` + | +| [lte(other)](./firestore_lite.firestorefunction.md#firestorefunctionlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to a constant value. +```typescript +// Check if the 'score' field is less than or equal to 70 +Field.of("score").lte(70); + +``` + | +| [mapGet(subfield)](./firestore_lite.firestorefunction.md#firestorefunctionmapget) | | (BETA) Accesses a value from a map (object) field using the provided key. +```typescript +// Get the 'city' value from the 'address' map field +Field.of("address").mapGet("city"); + +``` + | +| [max()](./firestore_lite.firestorefunction.md#firestorefunctionmax) | | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. +```typescript +// Find the highest score in a leaderboard +Field.of("score").max().as("highestScore"); + +``` + A new Accumulator representing the 'max' aggregation. | +| [min()](./firestore_lite.firestorefunction.md#firestorefunctionmin) | | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. +```typescript +// Find the lowest price of all products +Field.of("price").min().as("lowestPrice"); + +``` + A new Accumulator representing the 'min' aggregation. | +| [mod(other)](./firestore_lite.firestorefunction.md#firestorefunctionmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. +```typescript +// Calculate the remainder of dividing the 'value' field by the 'divisor' field +Field.of("value").mod(Field.of("divisor")); + +``` + | +| [mod(other)](./firestore_lite.firestorefunction.md#firestorefunctionmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. +```typescript +// Calculate the remainder of dividing the 'value' field by 10 +Field.of("value").mod(10); + +``` + | +| [multiply(other)](./firestore_lite.firestorefunction.md#firestorefunctionmultiply) | | (BETA) Creates an expression that multiplies this expression by another expression. +```typescript +// Multiply the 'quantity' field by the 'price' field +Field.of("quantity").multiply(Field.of("price")); + +``` + | +| [multiply(other)](./firestore_lite.firestorefunction.md#firestorefunctionmultiply) | | (BETA) Creates an expression that multiplies this expression by a constant value. +```typescript +// Multiply the 'value' field by 2 +Field.of("value").multiply(2); + +``` + | +| [neq(other)](./firestore_lite.firestorefunction.md#firestorefunctionneq) | | (BETA) Creates an expression that checks if this expression is not equal to another expression. +```typescript +// Check if the 'status' field is not equal to "completed" +Field.of("status").neq("completed"); + +``` + | +| [neq(other)](./firestore_lite.firestorefunction.md#firestorefunctionneq) | | (BETA) Creates an expression that checks if this expression is not equal to a constant value. +```typescript +// Check if the 'country' field is not equal to "USA" +Field.of("country").neq("USA"); + +``` + | +| [regexContains(pattern)](./firestore_lite.firestorefunction.md#firestorefunctionregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +Field.of("description").regexContains("(?i)example"); + +``` + | +| [regexContains(pattern)](./firestore_lite.firestorefunction.md#firestorefunctionregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains the regular expression stored in field 'regex' +Field.of("description").regexContains(Field.of("regex")); + +``` + | +| [regexMatch(pattern)](./firestore_lite.firestorefunction.md#firestorefunctionregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. +```typescript +// Check if the 'email' field matches a valid email pattern +Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + | +| [regexMatch(pattern)](./firestore_lite.firestorefunction.md#firestorefunctionregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. +```typescript +// Check if the 'email' field matches a regular expression stored in field 'regex' +Field.of("email").regexMatch(Field.of("regex")); + +``` + | +| [replaceAll(find, replace)](./firestore_lite.firestorefunction.md#firestorefunctionreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring. +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field +Field.of("message").replaceAll("hello", "hi"); + +``` + | +| [replaceAll(find, replace)](./firestore_lite.firestorefunction.md#firestorefunctionreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + +``` + | +| [replaceFirst(find, replace)](./firestore_lite.firestorefunction.md#firestorefunctionreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field +Field.of("message").replaceFirst("hello", "hi"); + +``` + | +| [replaceFirst(find, replace)](./firestore_lite.firestorefunction.md#firestorefunctionreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + +``` + | +| [reverse()](./firestore_lite.firestorefunction.md#firestorefunctionreverse) | | (BETA) Creates an expression that reverses this string expression. +```typescript +// Reverse the value of the 'myString' field. +Field.of("myString").reverse(); + +``` + A new representing the reversed string. | +| [startsWith(prefix)](./firestore_lite.firestorefunction.md#firestorefunctionstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix. +```typescript +// Check if the 'name' field starts with "Mr." +Field.of("name").startsWith("Mr."); + +``` + | +| [startsWith(prefix)](./firestore_lite.firestorefunction.md#firestorefunctionstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix (represented as an expression). +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +Field.of("fullName").startsWith(Field.of("firstName")); + +``` + | +| [strConcat(elements)](./firestore_lite.firestorefunction.md#firestorefunctionstrconcat) | | (BETA) Creates an expression that concatenates string expressions together. +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + +``` + | +| [strContains(substring)](./firestore_lite.firestorefunction.md#firestorefunctionstrcontains) | | (BETA) Creates an expression that checks if a string contains a specified substring. +```typescript +// Check if the 'description' field contains "example". +Field.of("description").strContains("example"); + +``` + | +| [strContains(expr)](./firestore_lite.firestorefunction.md#firestorefunctionstrcontains) | | (BETA) Creates an expression that checks if a string contains the string represented by another expression. +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +Field.of("description").strContains(Field.of("keyword")); + +``` + | +| [subtract(other)](./firestore_lite.firestorefunction.md#firestorefunctionsubtract) | | (BETA) Creates an expression that subtracts another expression from this expression. +```typescript +// Subtract the 'discount' field from the 'price' field +Field.of("price").subtract(Field.of("discount")); + +``` + | +| [subtract(other)](./firestore_lite.firestorefunction.md#firestorefunctionsubtract) | | (BETA) Creates an expression that subtracts a constant value from this expression. +```typescript +// Subtract 20 from the value of the 'total' field +Field.of("total").subtract(20); + +``` + | +| [sum()](./firestore_lite.firestorefunction.md#firestorefunctionsum) | | (BETA) Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. +```typescript +// Calculate the total revenue from a set of orders +Field.of("orderAmount").sum().as("totalRevenue"); + +``` + A new Accumulator representing the 'sum' aggregation. | +| [timestampAdd(unit, amount)](./firestore_lite.firestorefunction.md#firestorefunctiontimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampAdd(unit, amount)](./firestore_lite.firestorefunction.md#firestorefunctiontimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. +```typescript +// Add 1 day to the 'timestamp' field. +Field.of("timestamp").timestampAdd("day", 1); + +``` + | +| [timestampSub(unit, amount)](./firestore_lite.firestorefunction.md#firestorefunctiontimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampSub(unit, amount)](./firestore_lite.firestorefunction.md#firestorefunctiontimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. +```typescript +// Subtract 1 day from the 'timestamp' field. +Field.of("timestamp").timestampSub("day", 1); + +``` + | +| [timestampToUnixMicros()](./firestore_lite.firestorefunction.md#firestorefunctiontimestamptounixmicros) | | (BETA) Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +Field.of("timestamp").timestampToUnixMicros(); + +``` + A new representing the number of microseconds since epoch. | +| [timestampToUnixMillis()](./firestore_lite.firestorefunction.md#firestorefunctiontimestamptounixmillis) | | (BETA) Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +Field.of("timestamp").timestampToUnixMillis(); + +``` + A new representing the number of milliseconds since epoch. | +| [timestampToUnixSeconds()](./firestore_lite.firestorefunction.md#firestorefunctiontimestamptounixseconds) | | (BETA) Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to seconds since epoch. +Field.of("timestamp").timestampToUnixSeconds(); + +``` + A new representing the number of seconds since epoch. | +| [toLower()](./firestore_lite.firestorefunction.md#firestorefunctiontolower) | | (BETA) Creates an expression that converts a string to lowercase. +```typescript +// Convert the 'name' field to lowercase +Field.of("name").toLower(); + +``` + A new Expr representing the lowercase string. | +| [toUpper()](./firestore_lite.firestorefunction.md#firestorefunctiontoupper) | | (BETA) Creates an expression that converts a string to uppercase. +```typescript +// Convert the 'title' field to uppercase +Field.of("title").toUpper(); + +``` + A new Expr representing the uppercase string. | +| [trim()](./firestore_lite.firestorefunction.md#firestorefunctiontrim) | | (BETA) Creates an expression that removes leading and trailing whitespace from a string. +```typescript +// Trim whitespace from the 'userInput' field +Field.of("userInput").trim(); + +``` + A new Expr representing the trimmed string. | +| [unixMicrosToTimestamp()](./firestore_lite.firestorefunction.md#firestorefunctionunixmicrostotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +Field.of("microseconds").unixMicrosToTimestamp(); + +``` + A new representing the timestamp. | +| [unixMillisToTimestamp()](./firestore_lite.firestorefunction.md#firestorefunctionunixmillistotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +Field.of("milliseconds").unixMillisToTimestamp(); + +``` + A new representing the timestamp. | +| [unixSecondsToTimestamp()](./firestore_lite.firestorefunction.md#firestorefunctionunixsecondstotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'seconds' field as seconds since epoch. +Field.of("seconds").unixSecondsToTimestamp(); + +``` + A new representing the timestamp. | +| [vectorLength()](./firestore_lite.firestorefunction.md#firestorefunctionvectorlength) | | (BETA) Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. +```typescript +// Get the vector length (dimension) of the field 'embedding'. +Field.of("embedding").vectorLength(); + +``` + A new representing the length of the vector. | + +## FirestoreFunction.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `FirestoreFunction` class + +Signature: + +```typescript +constructor(name: string, params: Constant[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | | +| params | [Constant](./firestore_lite.constant.md#constant_class)\[\] | | + +## FirestoreFunction.exprType + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +exprType: ExprType; +``` + +## FirestoreFunction.add() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds this expression to another expression. + +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +Field.of("quantity").add(Field.of("reserve")); + +``` + +Signature: + +```typescript +add(other: Constant): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to add to this expression. A new Expr representing the addition operation. | + +Returns: + +[Add](./firestore_lite.add.md#add_class) + +## FirestoreFunction.add() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds this expression to a constant value. + +```typescript +// Add 5 to the value of the 'age' field +Field.of("age").add(5); + +``` + +Signature: + +```typescript +add(other: any): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to add. A new Expr representing the addition operation. | + +Returns: + +[Add](./firestore_lite.add.md#add_class) + +## FirestoreFunction.arrayConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with one or more other arrays. + +```typescript +// Combine the 'items' array with another array field. +Field.of("items").arrayConcat(Field.of("otherItems")); + +``` + +Signature: + +```typescript +arrayConcat(arrays: Constant[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrays | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The array expressions to concatenate. A new Expr representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) + +## FirestoreFunction.arrayConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with one or more other arrays. + +```typescript +// Combine the 'tags' array with a new array and an array field +Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + +``` + +Signature: + +```typescript +arrayConcat(arrays: any[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrays | any\[\] | The array expressions or values to concatenate. A new Expr representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) + +## FirestoreFunction.arrayContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains a specific element. + +```typescript +// Check if the 'sizes' array contains the value from the 'selectedSize' field +Field.of("sizes").arrayContains(Field.of("selectedSize")); + +``` + +Signature: + +```typescript +arrayContains(element: Constant): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | [Constant](./firestore_lite.constant.md#constant_class) | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) + +## FirestoreFunction.arrayContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains a specific value. + +```typescript +// Check if the 'colors' array contains "red" +Field.of("colors").arrayContains("red"); + +``` + +Signature: + +```typescript +arrayContains(element: any): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | any | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) + +## FirestoreFunction.arrayContainsAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both "news" and "sports" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + +Signature: + +```typescript +arrayContainsAll(...values: Constant[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) + +## FirestoreFunction.arrayContainsAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + +``` + +Signature: + +```typescript +arrayContainsAll(...values: any[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) + +## FirestoreFunction.arrayContainsAny() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains any of the specified elements. + +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "cate2" +Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + +``` + +Signature: + +```typescript +arrayContainsAny(...values: Constant[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) + +## FirestoreFunction.arrayContainsAny() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array contains any of the specified elements. + +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + +``` + +Signature: + +```typescript +arrayContainsAny(...values: any[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) + +## FirestoreFunction.arrayLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of an array. + +```typescript +// Get the number of items in the 'cart' array +Field.of("cart").arrayLength(); + +``` + A new `Expr` representing the length of the array. + +Signature: + +```typescript +arrayLength(): ArrayLength; +``` +Returns: + +[ArrayLength](./firestore_lite.arraylength.md#arraylength_class) + +## FirestoreFunction.as() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Assigns an alias to this expression. + +Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. + +```typescript +// Calculate the total price and assign it the alias "totalPrice" and add it to the output. +firestore.pipeline().collection("items") +.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + +``` + +Signature: + +```typescript +as(name: string): ExprWithAlias; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | The alias to assign to this expression. A new [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) that wraps this expression and associates it with the provided alias. | + +Returns: + +[ExprWithAlias](./firestore_lite.exprwithalias.md#exprwithalias_class)<this> + +## FirestoreFunction.ascending() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. + +```typescript +// Sort documents by the 'name' field in ascending order +pipeline().collection("users") +.sort(Field.of("name").ascending()); + +``` + A new `Ordering` for ascending sorting. + +Signature: + +```typescript +ascending(): Ordering; +``` +Returns: + +[Ordering](./firestore_lite.ordering.md#ordering_class) + +## FirestoreFunction.avg() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. + +```typescript +// Calculate the average age of users +Field.of("age").avg().as("averageAge"); + +``` + A new `Accumulator` representing the 'avg' aggregation. + +Signature: + +```typescript +avg(): Avg; +``` +Returns: + +[Avg](./firestore_lite.avg.md#avg_class) + +## FirestoreFunction.byteLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of this string expression in bytes. + +```typescript +// Calculate the length of the 'myString' field in bytes. +Field.of("myString").byteLength(); + +``` + A new representing the length of the string in bytes. + +Signature: + +```typescript +byteLength(): ByteLength; +``` +Returns: + +[ByteLength](./firestore_lite.bytelength.md#bytelength_class) + +## FirestoreFunction.charLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the character length of a string in UTF-8. + +```typescript +// Get the character length of the 'name' field in its UTF-8 form. +Field.of("name").charLength(); + +``` + A new `Expr` representing the length of the string. + +Signature: + +```typescript +charLength(): CharLength; +``` +Returns: + +[CharLength](./firestore_lite.charlength.md#charlength_class) + +## FirestoreFunction.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the cosine distance between two vectors. + +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +Field.of("userVector").cosineDistance(Field.of("itemVector")); + +``` + +Signature: + +```typescript +cosineDistance(other: Constant): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new Expr representing the cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) + +## FirestoreFunction.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vectors. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +cosineDistance(other: VectorValue): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) + +## FirestoreFunction.cosineDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vectors. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +Field.of("location").cosineDistance([37.7749, -122.4194]); + +``` + +Signature: + +```typescript +cosineDistance(other: number[]): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | The other vector (as an array of numbers) to compare against. A new Expr representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) + +## FirestoreFunction.count() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. + +```typescript +// Count the total number of products +Field.of("productId").count().as("totalProducts"); + +``` + A new `Accumulator` representing the 'count' aggregation. + +Signature: + +```typescript +count(): Count; +``` +Returns: + +[Count](./firestore_lite.count.md#count_class) + +## FirestoreFunction.descending() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. + +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") +.sort(Field.of("createdAt").descending()); + +``` + A new `Ordering` for descending sorting. + +Signature: + +```typescript +descending(): Ordering; +``` +Returns: + +[Ordering](./firestore_lite.ordering.md#ordering_class) + +## FirestoreFunction.divide() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides this expression by another expression. + +```typescript +// Divide the 'total' field by the 'count' field +Field.of("total").divide(Field.of("count")); + +``` + +Signature: + +```typescript +divide(other: Constant): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new Expr representing the division operation. | + +Returns: + +[Divide](./firestore_lite.divide.md#divide_class) + +## FirestoreFunction.divide() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides this expression by a constant value. + +```typescript +// Divide the 'value' field by 10 +Field.of("value").divide(10); + +``` + +Signature: + +```typescript +divide(other: any): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to divide by. A new Expr representing the division operation. | + +Returns: + +[Divide](./firestore_lite.divide.md#divide_class) + +## FirestoreFunction.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vectors. + +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct([0.5, 0.8, 0.2]); + +``` + +Signature: + +```typescript +dotProduct(other: Constant): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) + +## FirestoreFunction.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vectors. + +```typescript +// Calculate the dot product between a feature vector and a target vector +Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + +``` + +Signature: + +```typescript +dotProduct(other: VectorValue): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) + +## FirestoreFunction.dotProduct() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +dotProduct(other: number[]): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | | + +Returns: + +[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) + +## FirestoreFunction.endsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string ends with a given postfix. + +```typescript +// Check if the 'filename' field ends with ".txt" +Field.of("filename").endsWith(".txt"); + +``` + +Signature: + +```typescript +endsWith(suffix: string): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| suffix | string | The postfix to check for. A new Expr representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_lite.endswith.md#endswith_class) + +## FirestoreFunction.endsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string ends with a given postfix (represented as an expression). + +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +Field.of("url").endsWith(Field.of("extension")); + +``` + +Signature: + +```typescript +endsWith(suffix: Constant): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| suffix | [Constant](./firestore_lite.constant.md#constant_class) | The postfix expression to check for. A new Expr representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_lite.endswith.md#endswith_class) + +## FirestoreFunction.eq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to another expression. + +```typescript +// Check if the 'age' field is equal to 21 +Field.of("age").eq(21); + +``` + +Signature: + +```typescript +eq(other: Constant): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for equality. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_lite.eq.md#eq_class) + +## FirestoreFunction.eq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to a constant value. + +```typescript +// Check if the 'city' field is equal to "London" +Field.of("city").eq("London"); + +``` + +Signature: + +```typescript +eq(other: any): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for equality. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_lite.eq.md#eq_class) + +## FirestoreFunction.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vectors. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance([37.7749, -122.4194]); + +``` + +Signature: + +```typescript +euclideanDistance(other: Constant): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) + +## FirestoreFunction.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vectors. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +euclideanDistance(other: VectorValue): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) + +## FirestoreFunction.euclideanDistance() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +euclideanDistance(other: number[]): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | number\[\] | | + +Returns: + +[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) + +## FirestoreFunction.exists() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field exists in the document. + +```typescript +// Check if the document has a field named "phoneNumber" +Field.of("phoneNumber").exists(); + +``` + A new `Expr` representing the 'exists' check. + +Signature: + +```typescript +exists(): Exists; +``` +Returns: + +[Exists](./firestore_lite.exists.md#exists_class) + +## FirestoreFunction.gt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than another expression. + +```typescript +// Check if the 'age' field is greater than the 'limit' field +Field.of("age").gt(Field.of("limit")); + +``` + +Signature: + +```typescript +gt(other: Constant): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for greater than. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_lite.gt.md#gt_class) + +## FirestoreFunction.gt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than a constant value. + +```typescript +// Check if the 'price' field is greater than 100 +Field.of("price").gt(100); + +``` + +Signature: + +```typescript +gt(other: any): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for greater than. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_lite.gt.md#gt_class) + +## FirestoreFunction.gte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than or equal to another expression. + +```typescript +// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 +Field.of("quantity").gte(Field.of('requirement').add(1)); + +``` + +Signature: + +```typescript +gte(other: Constant): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_lite.gte.md#gte_class) + +## FirestoreFunction.gte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is greater than or equal to a constant value. + +```typescript +// Check if the 'score' field is greater than or equal to 80 +Field.of("score").gte(80); + +``` + +Signature: + +```typescript +gte(other: any): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_lite.gte.md#gte_class) + +## FirestoreFunction.in() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is equal to any of the provided values or expressions. + +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +Field.of("category").in("Electronics", Field.of("primaryType")); + +``` + +Signature: + +```typescript +in(...others: Constant[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| others | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The values or expressions to check against. A new Expr representing the 'IN' comparison. | + +Returns: + +[In](./firestore_lite.in.md#in_class) + +## FirestoreFunction.in() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +in(...others: any[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| others | any\[\] | | + +Returns: + +[In](./firestore_lite.in.md#in_class) + +## FirestoreFunction.isNaN() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). + +```typescript +// Check if the result of a calculation is NaN +Field.of("value").divide(0).isNaN(); + +``` + A new `Expr` representing the 'isNaN' check. + +Signature: + +```typescript +isNaN(): IsNan; +``` +Returns: + +[IsNan](./firestore_lite.isnan.md#isnan_class) + +## FirestoreFunction.like() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that performs a case-sensitive string comparison. + +```typescript +// Check if the 'title' field contains the word "guide" (case-sensitive) +Field.of("title").like("%guide%"); + +``` + +Signature: + +```typescript +like(pattern: string): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new Expr representing the 'like' comparison. | + +Returns: + +[Like](./firestore_lite.like.md#like_class) + +## FirestoreFunction.like() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +like(pattern: Constant): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | | + +Returns: + +[Like](./firestore_lite.like.md#like_class) + +## FirestoreFunction.logicalMax() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMax(Function.currentTimestamp()); + +``` + +Signature: + +```typescript +logicalMax(other: Constant): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare with. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) + +## FirestoreFunction.logicalMax() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'value' field and 10. +Field.of("value").logicalMax(10); + +``` + +Signature: + +```typescript +logicalMax(other: any): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare with. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) + +## FirestoreFunction.logicalMin() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'timestamp' field and the current timestamp. +Field.of("timestamp").logicalMin(Function.currentTimestamp()); + +``` + +Signature: + +```typescript +logicalMin(other: Constant): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare with. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) + +## FirestoreFunction.logicalMin() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'value' field and 10. +Field.of("value").logicalMin(10); + +``` + +Signature: + +```typescript +logicalMin(other: any): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare with. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) + +## FirestoreFunction.lt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than another expression. + +```typescript +// Check if the 'age' field is less than 'limit' +Field.of("age").lt(Field.of('limit')); + +``` + +Signature: + +```typescript +lt(other: Constant): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for less than. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_lite.lt.md#lt_class) + +## FirestoreFunction.lt() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than a constant value. + +```typescript +// Check if the 'price' field is less than 50 +Field.of("price").lt(50); + +``` + +Signature: + +```typescript +lt(other: any): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for less than. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_lite.lt.md#lt_class) + +## FirestoreFunction.lte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than or equal to another expression. + +```typescript +// Check if the 'quantity' field is less than or equal to 20 +Field.of("quantity").lte(Constant.of(20)); + +``` + +Signature: + +```typescript +lte(other: Constant): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_lite.lte.md#lte_class) + +## FirestoreFunction.lte() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is less than or equal to a constant value. + +```typescript +// Check if the 'score' field is less than or equal to 70 +Field.of("score").lte(70); + +``` + +Signature: + +```typescript +lte(other: any): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_lite.lte.md#lte_class) + +## FirestoreFunction.mapGet() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Accesses a value from a map (object) field using the provided key. + +```typescript +// Get the 'city' value from the 'address' map field +Field.of("address").mapGet("city"); + +``` + +Signature: + +```typescript +mapGet(subfield: string): MapGet; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| subfield | string | The key to access in the map. A new Expr representing the value associated with the given key in the map. | + +Returns: + +[MapGet](./firestore_lite.mapget.md#mapget_class) + +## FirestoreFunction.max() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that finds the maximum value of a field across multiple stage inputs. + +```typescript +// Find the highest score in a leaderboard +Field.of("score").max().as("highestScore"); + +``` + A new `Accumulator` representing the 'max' aggregation. + +Signature: + +```typescript +max(): Max; +``` +Returns: + +[Max](./firestore_lite.max.md#max_class) + +## FirestoreFunction.min() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that finds the minimum value of a field across multiple stage inputs. + +```typescript +// Find the lowest price of all products +Field.of("price").min().as("lowestPrice"); + +``` + A new `Accumulator` representing the 'min' aggregation. + +Signature: + +```typescript +min(): Min; +``` +Returns: + +[Min](./firestore_lite.min.md#min_class) + +## FirestoreFunction.mod() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. + +```typescript +// Calculate the remainder of dividing the 'value' field by the 'divisor' field +Field.of("value").mod(Field.of("divisor")); + +``` + +Signature: + +```typescript +mod(other: Constant): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new Expr representing the modulo operation. | + +Returns: + +[Mod](./firestore_lite.mod.md#mod_class) + +## FirestoreFunction.mod() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. + +```typescript +// Calculate the remainder of dividing the 'value' field by 10 +Field.of("value").mod(10); + +``` + +Signature: + +```typescript +mod(other: any): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to divide by. A new Expr representing the modulo operation. | + +Returns: + +[Mod](./firestore_lite.mod.md#mod_class) + +## FirestoreFunction.multiply() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies this expression by another expression. + +```typescript +// Multiply the 'quantity' field by the 'price' field +Field.of("quantity").multiply(Field.of("price")); + +``` + +Signature: + +```typescript +multiply(other: Constant): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to multiply by. A new Expr representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_lite.multiply.md#multiply_class) + +## FirestoreFunction.multiply() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies this expression by a constant value. + +```typescript +// Multiply the 'value' field by 2 +Field.of("value").multiply(2); + +``` + +Signature: + +```typescript +multiply(other: any): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to multiply by. A new Expr representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_lite.multiply.md#multiply_class) + +## FirestoreFunction.neq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is not equal to another expression. + +```typescript +// Check if the 'status' field is not equal to "completed" +Field.of("status").neq("completed"); + +``` + +Signature: + +```typescript +neq(other: Constant): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for inequality. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_lite.neq.md#neq_class) + +## FirestoreFunction.neq() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if this expression is not equal to a constant value. + +```typescript +// Check if the 'country' field is not equal to "USA" +Field.of("country").neq("USA"); + +``` + +Signature: + +```typescript +neq(other: any): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to compare for inequality. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_lite.neq.md#neq_class) + +## FirestoreFunction.regexContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +Field.of("description").regexContains("(?i)example"); + +``` + +Signature: + +```typescript +regexContains(pattern: string): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) + +## FirestoreFunction.regexContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains the regular expression stored in field 'regex' +Field.of("description").regexContains(Field.of("regex")); + +``` + +Signature: + +```typescript +regexContains(pattern: Constant): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) + +## FirestoreFunction.regexMatch() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a valid email pattern +Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + +Signature: + +```typescript +regexMatch(pattern: string): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | string | The regular expression to use for the match. A new Expr representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) + +## FirestoreFunction.regexMatch() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a regular expression stored in field 'regex' +Field.of("email").regexMatch(Field.of("regex")); + +``` + +Signature: + +```typescript +regexMatch(pattern: Constant): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the match. A new Expr representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) + +## FirestoreFunction.replaceAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within this string expression with another substring. + +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field +Field.of("message").replaceAll("hello", "hi"); + +``` + +Signature: + +```typescript +replaceAll(find: string, replace: string): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | string | The substring to search for. | +| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) + +## FirestoreFunction.replaceAll() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + +``` + +Signature: + +```typescript +replaceAll(find: Constant, replace: Constant): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) + +## FirestoreFunction.replaceFirst() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. + +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field +Field.of("message").replaceFirst("hello", "hi"); + +``` + +Signature: + +```typescript +replaceFirst(find: string, replace: string): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | string | The substring to search for. | +| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) + +## FirestoreFunction.replaceFirst() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field +Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + +``` + +Signature: + +```typescript +replaceFirst(find: Constant, replace: Constant): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) + +## FirestoreFunction.reverse() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that reverses this string expression. + +```typescript +// Reverse the value of the 'myString' field. +Field.of("myString").reverse(); + +``` + A new representing the reversed string. + +Signature: + +```typescript +reverse(): Reverse; +``` +Returns: + +[Reverse](./firestore_lite.reverse.md#reverse_class) + +## FirestoreFunction.startsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string starts with a given prefix. + +```typescript +// Check if the 'name' field starts with "Mr." +Field.of("name").startsWith("Mr."); + +``` + +Signature: + +```typescript +startsWith(prefix: string): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| prefix | string | The prefix to check for. A new Expr representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_lite.startswith.md#startswith_class) + +## FirestoreFunction.startsWith() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string starts with a given prefix (represented as an expression). + +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +Field.of("fullName").startsWith(Field.of("firstName")); + +``` + +Signature: + +```typescript +startsWith(prefix: Constant): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| prefix | [Constant](./firestore_lite.constant.md#constant_class) | The prefix expression to check for. A new Expr representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_lite.startswith.md#startswith_class) + +## FirestoreFunction.strConcat() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates string expressions together. + +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + +``` + +Signature: + +```typescript +strConcat(...elements: Array): StrConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| elements | Array<string \| [Constant](./firestore_lite.constant.md#constant_class)> | The expressions (typically strings) to concatenate. A new Expr representing the concatenated string. | + +Returns: + +[StrConcat](./firestore_lite.strconcat.md#strconcat_class) + +## FirestoreFunction.strContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains a specified substring. + +```typescript +// Check if the 'description' field contains "example". +Field.of("description").strContains("example"); + +``` + +Signature: + +```typescript +strContains(substring: string): StrContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| substring | string | The substring to search for. A new Expr representing the 'contains' comparison. | + +Returns: + +[StrContains](./firestore_lite.strcontains.md#strcontains_class) + +## FirestoreFunction.strContains() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string contains the string represented by another expression. + +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +Field.of("description").strContains(Field.of("keyword")); + +``` + +Signature: + +```typescript +strContains(expr: Constant): StrContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. A new Expr representing the 'contains' comparison. | + +Returns: + +[StrContains](./firestore_lite.strcontains.md#strcontains_class) + +## FirestoreFunction.subtract() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts another expression from this expression. + +```typescript +// Subtract the 'discount' field from the 'price' field +Field.of("price").subtract(Field.of("discount")); + +``` + +Signature: + +```typescript +subtract(other: Constant): Subtract; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to subtract from this expression. A new Expr representing the subtraction operation. | + +Returns: + +[Subtract](./firestore_lite.subtract.md#subtract_class) + +## FirestoreFunction.subtract() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a constant value from this expression. + +```typescript +// Subtract 20 from the value of the 'total' field +Field.of("total").subtract(20); + +``` + +Signature: + +```typescript +subtract(other: any): Subtract; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| other | any | The constant value to subtract. A new Expr representing the subtraction operation. | + +Returns: + +[Subtract](./firestore_lite.subtract.md#subtract_class) + +## FirestoreFunction.sum() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. + +```typescript +// Calculate the total revenue from a set of orders +Field.of("orderAmount").sum().as("totalRevenue"); + +``` + A new `Accumulator` representing the 'sum' aggregation. + +Signature: + +```typescript +sum(): Sum; +``` +Returns: + +[Sum](./firestore_lite.sum.md#sum_class) + +## FirestoreFunction.timestampAdd() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to this timestamp expression. + +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + +``` + +Signature: + +```typescript +timestampAdd(unit: Constant, amount: Constant): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) + +## FirestoreFunction.timestampAdd() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to this timestamp expression. + +```typescript +// Add 1 day to the 'timestamp' field. +Field.of("timestamp").timestampAdd("day", 1); + +``` + +Signature: + +```typescript +timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | +| amount | number | The amount of time to add. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) + +## FirestoreFunction.timestampSub() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from this timestamp expression. + +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + +``` + +Signature: + +```typescript +timestampSub(unit: Constant, amount: Constant): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) + +## FirestoreFunction.timestampSub() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from this timestamp expression. + +```typescript +// Subtract 1 day from the 'timestamp' field. +Field.of("timestamp").timestampSub("day", 1); + +``` + +Signature: + +```typescript +timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | +| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) + +## FirestoreFunction.timestampToUnixMicros() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +Field.of("timestamp").timestampToUnixMicros(); + +``` + A new representing the number of microseconds since epoch. + +Signature: + +```typescript +timestampToUnixMicros(): TimestampToUnixMicros; +``` +Returns: + +[TimestampToUnixMicros](./firestore_lite.timestamptounixmicros.md#timestamptounixmicros_class) + +## FirestoreFunction.timestampToUnixMillis() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +Field.of("timestamp").timestampToUnixMillis(); + +``` + A new representing the number of milliseconds since epoch. + +Signature: + +```typescript +timestampToUnixMillis(): TimestampToUnixMillis; +``` +Returns: + +[TimestampToUnixMillis](./firestore_lite.timestamptounixmillis.md#timestamptounixmillis_class) + +## FirestoreFunction.timestampToUnixSeconds() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to seconds since epoch. +Field.of("timestamp").timestampToUnixSeconds(); + +``` + A new representing the number of seconds since epoch. + +Signature: + +```typescript +timestampToUnixSeconds(): TimestampToUnixSeconds; +``` +Returns: + +[TimestampToUnixSeconds](./firestore_lite.timestamptounixseconds.md#timestamptounixseconds_class) + +## FirestoreFunction.toLower() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string to lowercase. + +```typescript +// Convert the 'name' field to lowercase +Field.of("name").toLower(); + +``` + A new `Expr` representing the lowercase string. + +Signature: + +```typescript +toLower(): ToLower; +``` +Returns: + +[ToLower](./firestore_lite.tolower.md#tolower_class) + +## FirestoreFunction.toUpper() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string to uppercase. + +```typescript +// Convert the 'title' field to uppercase +Field.of("title").toUpper(); + +``` + A new `Expr` representing the uppercase string. + +Signature: + +```typescript +toUpper(): ToUpper; +``` +Returns: + +[ToUpper](./firestore_lite.toupper.md#toupper_class) + +## FirestoreFunction.trim() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that removes leading and trailing whitespace from a string. + +```typescript +// Trim whitespace from the 'userInput' field +Field.of("userInput").trim(); + +``` + A new `Expr` representing the trimmed string. + +Signature: + +```typescript +trim(): Trim; +``` +Returns: + +[Trim](./firestore_lite.trim.md#trim_class) + +## FirestoreFunction.unixMicrosToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +Field.of("microseconds").unixMicrosToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixMicrosToTimestamp(): UnixMicrosToTimestamp; +``` +Returns: + +[UnixMicrosToTimestamp](./firestore_lite.unixmicrostotimestamp.md#unixmicrostotimestamp_class) + +## FirestoreFunction.unixMillisToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +Field.of("milliseconds").unixMillisToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixMillisToTimestamp(): UnixMillisToTimestamp; +``` +Returns: + +[UnixMillisToTimestamp](./firestore_lite.unixmillistotimestamp.md#unixmillistotimestamp_class) + +## FirestoreFunction.unixSecondsToTimestamp() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'seconds' field as seconds since epoch. +Field.of("seconds").unixSecondsToTimestamp(); + +``` + A new representing the timestamp. + +Signature: + +```typescript +unixSecondsToTimestamp(): UnixSecondsToTimestamp; +``` +Returns: + +[UnixSecondsToTimestamp](./firestore_lite.unixsecondstotimestamp.md#unixsecondstotimestamp_class) + +## FirestoreFunction.vectorLength() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. + +```typescript +// Get the vector length (dimension) of the field 'embedding'. +Field.of("embedding").vectorLength(); + +``` + A new representing the length of the vector. + +Signature: + +```typescript +vectorLength(): VectorLength; +``` +Returns: + +[VectorLength](./firestore_lite.vectorlength.md#vectorlength_class) + diff --git a/docs-devsite/firestore_lite.genericstage.md b/docs-devsite/firestore_lite.genericstage.md new file mode 100644 index 00000000000..c2f723c8f50 --- /dev/null +++ b/docs-devsite/firestore_lite.genericstage.md @@ -0,0 +1,65 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# GenericStage class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class GenericStage implements Stage +``` +Implements: [Stage](./firestore_lite.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(name, params)](./firestore_lite.genericstage.md#genericstageconstructor) | | (BETA) Constructs a new instance of the GenericStage class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_lite.genericstage.md#genericstagename) | | string | (BETA) | + +## GenericStage.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `GenericStage` class + +Signature: + +```typescript +constructor(name: string, params: unknown[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | | +| params | unknown\[\] | | + +## GenericStage.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_lite.gt.md b/docs-devsite/firestore_lite.gt.md new file mode 100644 index 00000000000..61c217f58ce --- /dev/null +++ b/docs-devsite/firestore_lite.gt.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Gt class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Gt extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_lite.gt.md#gtconstructor) | | (BETA) Constructs a new instance of the Gt class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_lite.gt.md#gtfilterable) | | true | (BETA) | + +## Gt.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Gt` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | | +| right | [Constant](./firestore_lite.constant.md#constant_class) | | + +## Gt.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.gte.md b/docs-devsite/firestore_lite.gte.md new file mode 100644 index 00000000000..1550dd8daec --- /dev/null +++ b/docs-devsite/firestore_lite.gte.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Gte class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Gte extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_lite.gte.md#gteconstructor) | | (BETA) Constructs a new instance of the Gte class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_lite.gte.md#gtefilterable) | | true | (BETA) | + +## Gte.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Gte` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | | +| right | [Constant](./firestore_lite.constant.md#constant_class) | | + +## Gte.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.if.md b/docs-devsite/firestore_lite.if.md new file mode 100644 index 00000000000..c587b2f1f01 --- /dev/null +++ b/docs-devsite/firestore_lite.if.md @@ -0,0 +1,68 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# If class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class If extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(condition, thenExpr, elseExpr)](./firestore_lite.if.md#ifconstructor) | | (BETA) Constructs a new instance of the If class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_lite.if.md#iffilterable) | | true | (BETA) | + +## If.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `If` class + +Signature: + +```typescript +constructor(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| condition | [FilterExpr](./firestore_lite.md#filterexpr) | | +| thenExpr | [Constant](./firestore_lite.constant.md#constant_class) | | +| elseExpr | [Constant](./firestore_lite.constant.md#constant_class) | | + +## If.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.in.md b/docs-devsite/firestore_lite.in.md new file mode 100644 index 00000000000..83bd0e57107 --- /dev/null +++ b/docs-devsite/firestore_lite.in.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# In class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class In extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, others)](./firestore_lite.in.md#inconstructor) | | (BETA) Constructs a new instance of the In class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_lite.in.md#infilterable) | | true | (BETA) | + +## In.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `In` class + +Signature: + +```typescript +constructor(left: Constant, others: Constant[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | | +| others | [Constant](./firestore_lite.constant.md#constant_class)\[\] | | + +## In.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.isnan.md b/docs-devsite/firestore_lite.isnan.md new file mode 100644 index 00000000000..f3be87e7eb8 --- /dev/null +++ b/docs-devsite/firestore_lite.isnan.md @@ -0,0 +1,66 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# IsNan class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class IsNan extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr)](./firestore_lite.isnan.md#isnanconstructor) | | (BETA) Constructs a new instance of the IsNan class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_lite.isnan.md#isnanfilterable) | | true | (BETA) | + +## IsNan.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `IsNan` class + +Signature: + +```typescript +constructor(expr: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | | + +## IsNan.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.like.md b/docs-devsite/firestore_lite.like.md new file mode 100644 index 00000000000..67b00346b88 --- /dev/null +++ b/docs-devsite/firestore_lite.like.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Like class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Like extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr, pattern)](./firestore_lite.like.md#likeconstructor) | | (BETA) Constructs a new instance of the Like class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_lite.like.md#likefilterable) | | true | (BETA) | + +## Like.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Like` class + +Signature: + +```typescript +constructor(expr: Constant, pattern: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | | + +## Like.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.limit.md b/docs-devsite/firestore_lite.limit.md new file mode 100644 index 00000000000..4e559293f2a --- /dev/null +++ b/docs-devsite/firestore_lite.limit.md @@ -0,0 +1,64 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Limit class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Limit implements Stage +``` +Implements: [Stage](./firestore_lite.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(limit)](./firestore_lite.limit.md#limitconstructor) | | (BETA) Constructs a new instance of the Limit class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_lite.limit.md#limitname) | | string | (BETA) | + +## Limit.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Limit` class + +Signature: + +```typescript +constructor(limit: number); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| limit | number | | + +## Limit.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_lite.logicalmax.md b/docs-devsite/firestore_lite.logicalmax.md new file mode 100644 index 00000000000..f992776b068 --- /dev/null +++ b/docs-devsite/firestore_lite.logicalmax.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# LogicalMax class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class LogicalMax extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_lite.logicalmax.md#logicalmaxconstructor) | | (BETA) Constructs a new instance of the LogicalMax class | + +## LogicalMax.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `LogicalMax` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | | +| right | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.logicalmin.md b/docs-devsite/firestore_lite.logicalmin.md new file mode 100644 index 00000000000..686378b7f56 --- /dev/null +++ b/docs-devsite/firestore_lite.logicalmin.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# LogicalMin class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class LogicalMin extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_lite.logicalmin.md#logicalminconstructor) | | (BETA) Constructs a new instance of the LogicalMin class | + +## LogicalMin.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `LogicalMin` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | | +| right | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.lt.md b/docs-devsite/firestore_lite.lt.md new file mode 100644 index 00000000000..b44d2f656d0 --- /dev/null +++ b/docs-devsite/firestore_lite.lt.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Lt class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Lt extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_lite.lt.md#ltconstructor) | | (BETA) Constructs a new instance of the Lt class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_lite.lt.md#ltfilterable) | | true | (BETA) | + +## Lt.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Lt` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | | +| right | [Constant](./firestore_lite.constant.md#constant_class) | | + +## Lt.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.lte.md b/docs-devsite/firestore_lite.lte.md new file mode 100644 index 00000000000..ddde6a08d93 --- /dev/null +++ b/docs-devsite/firestore_lite.lte.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Lte class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Lte extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_lite.lte.md#lteconstructor) | | (BETA) Constructs a new instance of the Lte class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_lite.lte.md#ltefilterable) | | true | (BETA) | + +## Lte.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Lte` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | | +| right | [Constant](./firestore_lite.constant.md#constant_class) | | + +## Lte.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.mapget.md b/docs-devsite/firestore_lite.mapget.md new file mode 100644 index 00000000000..617b92d4d5a --- /dev/null +++ b/docs-devsite/firestore_lite.mapget.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# MapGet class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class MapGet extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(map, name)](./firestore_lite.mapget.md#mapgetconstructor) | | (BETA) Constructs a new instance of the MapGet class | + +## MapGet.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `MapGet` class + +Signature: + +```typescript +constructor(map: Constant, name: string); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| map | [Constant](./firestore_lite.constant.md#constant_class) | | +| name | string | | + diff --git a/docs-devsite/firestore_lite.max.md b/docs-devsite/firestore_lite.max.md new file mode 100644 index 00000000000..185fa011d0a --- /dev/null +++ b/docs-devsite/firestore_lite.max.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Max class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Max extends FirestoreFunction implements Accumulator +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [Accumulator](./firestore_lite.accumulator.md#accumulator_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value, distinct)](./firestore_lite.max.md#maxconstructor) | | (BETA) Constructs a new instance of the Max class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [accumulator](./firestore_lite.max.md#maxaccumulator) | | true | (BETA) | + +## Max.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Max` class + +Signature: + +```typescript +constructor(value: Constant, distinct: boolean); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_lite.constant.md#constant_class) | | +| distinct | boolean | | + +## Max.accumulator + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +accumulator: true; +``` diff --git a/docs-devsite/firestore_lite.md b/docs-devsite/firestore_lite.md index da7d304e3d5..59abff098db 100644 --- a/docs-devsite/firestore_lite.md +++ b/docs-devsite/firestore_lite.md @@ -25,48 +25,1216 @@ https://github.com/firebase/firebase-js-sdk | [collectionGroup(firestore, collectionId)](./firestore_lite.md#collectiongroup_1838fc3) | Creates and returns a new Query instance that includes all documents in the database that are contained in a collection or subcollection with the given collectionId. | | [connectFirestoreEmulator(firestore, host, port, options)](./firestore_lite.md#connectfirestoreemulator_7c247cd) | Modify this instance to communicate with the Cloud Firestore emulator.Note: This must be called before this instance has been used to do any operations. | | [doc(firestore, path, pathSegments)](./firestore_lite.md#doc_1eb4c23) | Gets a DocumentReference instance that refers to the document at the specified absolute path. | +| [pipeline(firestore)](./firestore_lite.md#pipeline_231a8e0) | Experimental Modular API for console testing. | | [runTransaction(firestore, updateFunction, options)](./firestore_lite.md#runtransaction_6f03ec4) | Executes the given updateFunction and then attempts to commit the changes applied within the transaction. If any document read within the transaction has changed, Cloud Firestore retries the updateFunction. If it fails to commit after 5 attempts, the transaction fails.The maximum number of writes allowed in a single transaction is 500. | | [terminate(firestore)](./firestore_lite.md#terminate_231a8e0) | Terminates the provided Firestore instance.After calling terminate() only the clearIndexedDbPersistence() functions may be used. Any other function will throw a FirestoreError. Termination does not cancel any pending writes, and any promises that are awaiting a response from the server will not be resolved.To restart after termination, create a new instance of Firestore with [getFirestore()](./firestore_.md#getfirestore).Note: Under normal circumstances, calling terminate() is not required. This function is useful only when you want to force this instance to release all of its resources or in combination with [clearIndexedDbPersistence()](./firestore_.md#clearindexeddbpersistence_231a8e0) to ensure that all local state is destroyed between test runs. | | [writeBatch(firestore)](./firestore_lite.md#writebatch_231a8e0) | Creates a write batch, used for performing multiple writes as a single atomic operation. The maximum number of writes allowed in a single WriteBatch is 500.The result of these writes will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the write fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. | | function() | | [count()](./firestore_lite.md#count) | Create an AggregateField object that can be used to compute the count of documents in the result set of a query. | +| [countAll()](./firestore_lite.md#countall) | (BETA) Creates an aggregation that counts the total number of stage inputs. +```typescript +// Count the total number of users +countAll().as("totalUsers"); + +``` + A new representing the 'countAll' aggregation. | | [deleteField()](./firestore_lite.md#deletefield) | Returns a sentinel for use with [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) or [setDoc()](./firestore_lite.md#setdoc_ee215ad) with {merge: true} to mark a field for deletion. | | [documentId()](./firestore_lite.md#documentid) | Returns a special sentinel FieldPath to refer to the ID of a document. It can be used in queries to sort or filter by the document ID. | | [getFirestore()](./firestore_lite.md#getfirestore) | Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. | | [serverTimestamp()](./firestore_lite.md#servertimestamp) | Returns a sentinel used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) to include a server-generated timestamp in the written data. | +| [useFirestorePipelines()](./firestore_lite.md#usefirestorepipelines) | | +| function(array, ...) | +| [arrayConcat(array, elements)](./firestore_lite.md#arrayconcat_0b3ddb9) | (BETA) Creates an expression that concatenates an array expression with other arrays. +```typescript +// Combine the 'items' array with two new item arrays +arrayConcat(Field.of("items"), [Field.of("newItems"), Field.of("otherItems")]); + +``` + | +| [arrayConcat(array, elements)](./firestore_lite.md#arrayconcat_21991c1) | (BETA) Creates an expression that concatenates an array expression with other arrays and/or values. +```typescript +// Combine the 'tags' array with a new array +arrayConcat(Field.of("tags"), ["newTag1", "newTag2"]); + +``` + | +| [arrayConcat(array, elements)](./firestore_lite.md#arrayconcat_f8d5d5e) | (BETA) Creates an expression that concatenates a field's array value with other arrays. +```typescript +// Combine the 'items' array with two new item arrays +arrayConcat("items", [Field.of("newItems"), Field.of("otherItems")]); + +``` + | +| [arrayConcat(array, elements)](./firestore_lite.md#arrayconcat_5a66d99) | (BETA) Creates an expression that concatenates a field's array value with other arrays and/or values. +```typescript +// Combine the 'tags' array with a new array +arrayConcat("tags", ["newTag1", "newTag2"]); + +``` + | +| [arrayContains(array, element)](./firestore_lite.md#arraycontains_01ea7c0) | (BETA) Creates an expression that checks if an array expression contains a specific element. +```typescript +// Check if the 'colors' array contains the value of field 'selectedColor' +arrayContains(Field.of("colors"), Field.of("selectedColor")); + +``` + | +| [arrayContains(array, element)](./firestore_lite.md#arraycontains_60f8f2f) | (BETA) Creates an expression that checks if an array expression contains a specific element. +```typescript +// Check if the 'colors' array contains "red" +arrayContains(Field.of("colors"), "red"); + +``` + | +| [arrayContains(array, element)](./firestore_lite.md#arraycontains_0ebdbfe) | (BETA) Creates an expression that checks if a field's array value contains a specific element. +```typescript +// Check if the 'colors' array contains the value of field 'selectedColor' +arrayContains("colors", Field.of("selectedColor")); + +``` + | +| [arrayContains(array, element)](./firestore_lite.md#arraycontains_8f718df) | (BETA) Creates an expression that checks if a field's array value contains a specific value. +```typescript +// Check if the 'colors' array contains "red" +arrayContains("colors", "red"); + +``` + | +| [arrayContainsAll(array, values)](./firestore_lite.md#arraycontainsall_7b7433a) | (BETA) Creates an expression that checks if an array expression contains all the specified elements. +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" +arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); + +``` + | +| [arrayContainsAll(array, values)](./firestore_lite.md#arraycontainsall_d919466) | (BETA) Creates an expression that checks if an array expression contains all the specified elements. +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" +arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); + +``` + | +| [arrayContainsAll(array, values)](./firestore_lite.md#arraycontainsall_b40e2df) | (BETA) Creates an expression that checks if a field's array value contains all the specified values or expressions. +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); + +``` + | +| [arrayContainsAll(array, values)](./firestore_lite.md#arraycontainsall_b08efbb) | (BETA) Creates an expression that checks if a field's array value contains all the specified values or expressions. +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); + +``` + | +| [arrayContainsAny(array, values)](./firestore_lite.md#arraycontainsany_7b7433a) | (BETA) Creates an expression that checks if an array expression contains any of the specified elements. +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "Science" +arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); + +``` + | +| [arrayContainsAny(array, values)](./firestore_lite.md#arraycontainsany_d919466) | (BETA) Creates an expression that checks if an array expression contains any of the specified elements. +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "Science" +arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); + +``` + | +| [arrayContainsAny(array, values)](./firestore_lite.md#arraycontainsany_b40e2df) | (BETA) Creates an expression that checks if a field's array value contains any of the specified elements. +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +arrayContainsAny("categories", [Field.of("cate1"), "Science"]); + +``` + | +| [arrayContainsAny(array, values)](./firestore_lite.md#arraycontainsany_b08efbb) | (BETA) Creates an expression that checks if a field's array value contains any of the specified elements. +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +arrayContainsAny("categories", [Field.of("cate1"), "Science"]); + +``` + | +| [arrayLength(array)](./firestore_lite.md#arraylength_0bb5dbb) | (BETA) Creates an expression that calculates the length of an array expression. +```typescript +// Get the number of items in the 'cart' array +arrayLength(Field.of("cart")); + +``` + | +| function(condition, ...) | +| [ifFunction(condition, thenExpr, elseExpr)](./firestore_lite.md#iffunction_f7b2404) | (BETA) Creates a conditional expression that evaluates to a 'then' expression if a condition is true and an 'else' expression if the condition is false. +```typescript +// If 'age' is greater than 18, return "Adult"; otherwise, return "Minor". +ifFunction( + gt("age", 18), Constant.of("Adult"), Constant.of("Minor")); + +``` + | | function(databaseId, ...) | | [getFirestore(databaseId)](./firestore_lite.md#getfirestore_53dc891) | (BETA) Returns the existing [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. | +| function(element, ...) | +| [inAny(element, others)](./firestore_lite.md#inany_a73b259) | (BETA) Creates an expression that checks if an expression is equal to any of the provided values or expressions. +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +inAny(Field.of("category"), [Constant.of("Electronics"), Field.of("primaryType")]); + +``` + | +| [inAny(element, others)](./firestore_lite.md#inany_f5721c6) | (BETA) Creates an expression that checks if an expression is equal to any of the provided values or expressions. +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +inAny(Field.of("category"), ["Electronics", Field.of("primaryType")]); + +``` + | +| [inAny(element, others)](./firestore_lite.md#inany_c6646ea) | (BETA) Creates an expression that checks if a field's value is equal to any of the provided values or expressions. +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +inAny("category", [Constant.of("Electronics"), Field.of("primaryType")]); + +``` + | +| [inAny(element, others)](./firestore_lite.md#inany_e6877aa) | (BETA) Creates an expression that checks if a field's value is equal to any of the provided values or expressions. +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +inAny("category", ["Electronics", Field.of("primaryType")]); + +``` + | +| [notInAny(element, others)](./firestore_lite.md#notinany_a73b259) | (BETA) Creates an expression that checks if an expression is not equal to any of the provided values or expressions. +```typescript +// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' +notInAny(Field.of("status"), [Constant.of("pending"), Field.of("rejectedStatus")]); + +``` + | +| [notInAny(element, others)](./firestore_lite.md#notinany_f5721c6) | (BETA) Creates an expression that checks if an expression is not equal to any of the provided values or expressions. +```typescript +// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' +notInAny(Field.of("status"), ["pending", Field.of("rejectedStatus")]); + +``` + | +| [notInAny(element, others)](./firestore_lite.md#notinany_c6646ea) | (BETA) Creates an expression that checks if a field's value is not equal to any of the provided values or expressions. +```typescript +// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' +notInAny("status", [Constant.of("pending"), Field.of("rejectedStatus")]); + +``` + | +| [notInAny(element, others)](./firestore_lite.md#notinany_e6877aa) | (BETA) Creates an expression that checks if a field's value is not equal to any of the provided values or expressions. +```typescript +// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' +notInAny("status", ["pending", Field.of("rejectedStatus")]); + +``` + | | function(elements, ...) | | [arrayRemove(elements)](./firestore_lite.md#arrayremove_7d853aa) | Returns a special value that can be used with [setDoc()](./firestore_.md#setdoc_ee215ad) or that tells the server to remove the given elements from any array value that already exists on the server. All instances of each element specified will be removed from the array. If the field being modified is not already an array it will be overwritten with an empty array. | | [arrayUnion(elements)](./firestore_lite.md#arrayunion_7d853aa) | Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to union the given elements with any array value that already exists on the server. Each specified element that doesn't already exist in the array will be added to the end. If the field being modified is not already an array it will be overwritten with an array containing exactly the specified elements. | +| function(expr, ...) | +| [ascending(expr)](./firestore_lite.md#ascending_f3fb767) | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. +```typescript +// Sort documents by the 'name' field in ascending order +firestore.pipeline().collection("users") + .sort(ascending(Field.of("name"))); + +``` + | +| [byteLength(expr)](./firestore_lite.md#bytelength_f3fb767) | (BETA) Creates an expression that calculates the byte length of a string in UTF-8, or just the length of a Blob. +```typescript +// Calculate the length of the 'myString' field in bytes. +byteLength(Field.of("myString")); + +``` + | +| [charLength(expr)](./firestore_lite.md#charlength_f3fb767) | (BETA) Creates an expression that calculates the character length of a string expression in UTF-8. +```typescript +// Get the character length of the 'name' field in UTF-8. +strLength(Field.of("name")); + +``` + | +| [cosineDistance(expr, other)](./firestore_lite.md#cosinedistance_b4c7dc2) | (BETA) Calculates the Cosine distance between a field's vector value and a double array. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +cosineDistance("location", [37.7749, -122.4194]); + +``` + | +| [cosineDistance(expr, other)](./firestore_lite.md#cosinedistance_8d2bd9d) | (BETA) Calculates the Cosine distance between a field's vector value and a VectorValue. +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +cosineDistance("location", new VectorValue([37.7749, -122.4194])); + +``` + | +| [cosineDistance(expr, other)](./firestore_lite.md#cosinedistance_c9ae0bc) | (BETA) Calculates the Cosine distance between a field's vector value and a vector expression. +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +cosineDistance("userVector", Field.of("itemVector")); + +``` + | +| [cosineDistance(expr, other)](./firestore_lite.md#cosinedistance_e701952) | (BETA) Calculates the Cosine distance between a vector expression and a double array. +```typescript +// Calculate the cosine distance between the 'location' field and a target location +cosineDistance(Field.of("location"), [37.7749, -122.4194]); + +``` + | +| [cosineDistance(expr, other)](./firestore_lite.md#cosinedistance_cc2e83e) | (BETA) Calculates the Cosine distance between a vector expression and a VectorValue. +```typescript +// Calculate the cosine distance between the 'location' field and a target location +cosineDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); + +``` + | +| [cosineDistance(expr, other)](./firestore_lite.md#cosinedistance_0896fbd) | (BETA) Calculates the Cosine distance between two vector expressions. +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +cosineDistance(Field.of("userVector"), Field.of("itemVector")); + +``` + | +| [descending(expr)](./firestore_lite.md#descending_f3fb767) | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") + .sort(descending(Field.of("createdAt"))); + +``` + | +| [dotProduct(expr, other)](./firestore_lite.md#dotproduct_b4c7dc2) | (BETA) Calculates the dot product between a field's vector value and a double array. +```typescript +// Calculate the dot product distance between a feature vector and a target vector +dotProduct("features", [0.5, 0.8, 0.2]); + +``` + | +| [dotProduct(expr, other)](./firestore_lite.md#dotproduct_8d2bd9d) | (BETA) Calculates the dot product between a field's vector value and a VectorValue. +```typescript +// Calculate the dot product distance between a feature vector and a target vector +dotProduct("features", new VectorValue([0.5, 0.8, 0.2])); + +``` + | +| [dotProduct(expr, other)](./firestore_lite.md#dotproduct_c9ae0bc) | (BETA) Calculates the dot product between a field's vector value and a vector expression. +```typescript +// Calculate the dot product distance between two document vectors: 'docVector1' and 'docVector2' +dotProduct("docVector1", Field.of("docVector2")); + +``` + | +| [dotProduct(expr, other)](./firestore_lite.md#dotproduct_e701952) | (BETA) Calculates the dot product between a vector expression and a double array. +```typescript +// Calculate the dot product between a feature vector and a target vector +dotProduct(Field.of("features"), [0.5, 0.8, 0.2]); + +``` + | +| [dotProduct(expr, other)](./firestore_lite.md#dotproduct_cc2e83e) | (BETA) Calculates the dot product between a vector expression and a VectorValue. +```typescript +// Calculate the dot product between a feature vector and a target vector +dotProduct(Field.of("features"), new VectorValue([0.5, 0.8, 0.2])); + +``` + | +| [dotProduct(expr, other)](./firestore_lite.md#dotproduct_0896fbd) | (BETA) Calculates the dot product between two vector expressions. +```typescript +// Calculate the dot product between two document vectors: 'docVector1' and 'docVector2' +dotProduct(Field.of("docVector1"), Field.of("docVector2")); + +``` + | +| [endsWith(expr, suffix)](./firestore_lite.md#endswith_88569cd) | (BETA) Creates an expression that checks if a field's value ends with a given postfix. +```typescript +// Check if the 'filename' field ends with ".txt" +endsWith("filename", ".txt"); + +``` + | +| [endsWith(expr, suffix)](./firestore_lite.md#endswith_e2e794e) | (BETA) Creates an expression that checks if a field's value ends with a given postfix. +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +endsWith("url", Field.of("extension")); + +``` + | +| [endsWith(expr, suffix)](./firestore_lite.md#endswith_6308b81) | (BETA) Creates an expression that checks if a string expression ends with a given postfix. +```typescript +// Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." +endsWith(Field.of("fullName"), "Jr."); + +``` + | +| [endsWith(expr, suffix)](./firestore_lite.md#endswith_ab1cc39) | (BETA) Creates an expression that checks if a string expression ends with a given postfix. +```typescript +// Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." +endsWith(Field.of("fullName"), Constant.of("Jr.")); + +``` + | +| [euclideanDistance(expr, other)](./firestore_lite.md#euclideandistance_b4c7dc2) | (BETA) Calculates the Euclidean distance between a field's vector value and a double array. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +euclideanDistance("location", [37.7749, -122.4194]); + +``` + | +| [euclideanDistance(expr, other)](./firestore_lite.md#euclideandistance_8d2bd9d) | (BETA) Calculates the Euclidean distance between a field's vector value and a VectorValue. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +euclideanDistance("location", new VectorValue([37.7749, -122.4194])); + +``` + | +| [euclideanDistance(expr, other)](./firestore_lite.md#euclideandistance_c9ae0bc) | (BETA) Calculates the Euclidean distance between a field's vector value and a vector expression. +```typescript +// Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' +euclideanDistance("pointA", Field.of("pointB")); + +``` + | +| [euclideanDistance(expr, other)](./firestore_lite.md#euclideandistance_e701952) | (BETA) Calculates the Euclidean distance between a vector expression and a double array. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location + +euclideanDistance(Field.of("location"), [37.7749, -122.4194]); + +``` + | +| [euclideanDistance(expr, other)](./firestore_lite.md#euclideandistance_cc2e83e) | (BETA) Calculates the Euclidean distance between a vector expression and a VectorValue. +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +euclideanDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); + +``` + | +| [euclideanDistance(expr, other)](./firestore_lite.md#euclideandistance_0896fbd) | (BETA) Calculates the Euclidean distance between two vector expressions. +```typescript +// Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' +euclideanDistance(Field.of("pointA"), Field.of("pointB")); + +``` + | +| [reverse(expr)](./firestore_lite.md#reverse_f3fb767) | (BETA) Creates an expression that reverses a string. +```typescript +// Reverse the value of the 'myString' field. +reverse(Field.of("myString")); + +``` + | +| [startsWith(expr, prefix)](./firestore_lite.md#startswith_484d9f3) | (BETA) Creates an expression that checks if a field's value starts with a given prefix. +```typescript +// Check if the 'name' field starts with "Mr." +startsWith("name", "Mr."); + +``` + | +| [startsWith(expr, prefix)](./firestore_lite.md#startswith_7deb5c7) | (BETA) Creates an expression that checks if a field's value starts with a given prefix. +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +startsWith("fullName", Field.of("firstName")); + +``` + | +| [startsWith(expr, prefix)](./firestore_lite.md#startswith_68300d1) | (BETA) Creates an expression that checks if a string expression starts with a given prefix. +```typescript +// Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." +startsWith(Field.of("fullName"), "Mr."); + +``` + | +| [startsWith(expr, prefix)](./firestore_lite.md#startswith_5774b68) | (BETA) Creates an expression that checks if a string expression starts with a given prefix. +```typescript +// Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." +startsWith(Field.of("fullName"), Field.of("prefix")); + +``` + | +| [timestampToUnixMicros(expr)](./firestore_lite.md#timestamptounixmicros_f3fb767) | (BETA) Creates an expression that converts a timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +timestampToUnixMicros(Field.of("timestamp")); + +``` + | +| [timestampToUnixMillis(expr)](./firestore_lite.md#timestamptounixmillis_f3fb767) | (BETA) Creates an expression that converts a timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +timestampToUnixMillis(Field.of("timestamp")); + +``` + | +| [timestampToUnixSeconds(expr)](./firestore_lite.md#timestamptounixseconds_f3fb767) | (BETA) Creates an expression that converts a timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to seconds since epoch. +timestampToUnixSeconds(Field.of("timestamp")); + +``` + | +| [toLower(expr)](./firestore_lite.md#tolower_1e536ed) | (BETA) Creates an expression that converts a string field to lowercase. +```typescript +// Convert the 'name' field to lowercase +toLower("name"); + +``` + | +| [toLower(expr)](./firestore_lite.md#tolower_f3fb767) | (BETA) Creates an expression that converts a string expression to lowercase. +```typescript +// Convert the 'name' field to lowercase +toLower(Field.of("name")); + +``` + | +| [toUpper(expr)](./firestore_lite.md#toupper_1e536ed) | (BETA) Creates an expression that converts a string field to uppercase. +```typescript +// Convert the 'title' field to uppercase +toUpper("title"); + +``` + | +| [toUpper(expr)](./firestore_lite.md#toupper_f3fb767) | (BETA) Creates an expression that converts a string expression to uppercase. +```typescript +// Convert the 'title' field to uppercase +toUppercase(Field.of("title")); + +``` + | +| [trim(expr)](./firestore_lite.md#trim_1e536ed) | (BETA) Creates an expression that removes leading and trailing whitespace from a string field. +```typescript +// Trim whitespace from the 'userInput' field +trim("userInput"); + +``` + | +| [trim(expr)](./firestore_lite.md#trim_f3fb767) | (BETA) Creates an expression that removes leading and trailing whitespace from a string expression. +```typescript +// Trim whitespace from the 'userInput' field +trim(Field.of("userInput")); + +``` + | +| [unixMicrosToTimestamp(expr)](./firestore_lite.md#unixmicrostotimestamp_f3fb767) | (BETA) Creates an expression that interprets an expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +unixMicrosToTimestamp(Field.of("microseconds")); + +``` + | +| [unixMillisToTimestamp(expr)](./firestore_lite.md#unixmillistotimestamp_f3fb767) | (BETA) Creates an expression that interprets an expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +unixMillisToTimestamp(Field.of("milliseconds")); + +``` + | +| [unixSecondsToTimestamp(expr)](./firestore_lite.md#unixsecondstotimestamp_f3fb767) | (BETA) Creates an expression that interprets an expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'seconds' field as seconds since epoch. +unixSecondsToTimestamp(Field.of("seconds")); + +``` + | +| [vectorLength(expr)](./firestore_lite.md#vectorlength_f3fb767) | (BETA) Creates an expression that calculates the length of a Firestore Vector. +```typescript +// Get the vector length (dimension) of the field 'embedding'. +vectorLength(Field.of("embedding")); + +``` + | | function(field, ...) | | [average(field)](./firestore_lite.md#average_aacc3a9) | Create an AggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query. | +| [byteLength(field)](./firestore_lite.md#bytelength_0fb8cd4) | (BETA) Creates an expression that calculates the length of a string represented by a field in UTF-8 bytes, or just the length of a Blob. +```typescript +// Calculate the length of the 'myString' field in bytes. +byteLength("myString"); + +``` + | +| [charLength(field)](./firestore_lite.md#charlength_0fb8cd4) | (BETA) Creates an expression that calculates the character length of a string field in UTF8. +```typescript +// Get the character length of the 'name' field in UTF-8. +strLength("name"); + +``` + | +| [exists(field)](./firestore_lite.md#exists_0fb8cd4) | (BETA) Creates an expression that checks if a field exists. +```typescript +// Check if the document has a field named "phoneNumber" +exists("phoneNumber"); + +``` + | +| [replaceAll(field, find, replace)](./firestore_lite.md#replaceall_b257ab0) | (BETA) Creates an expression that replaces all occurrences of a substring within a string represented by a field with another substring. +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field. +replaceAll("message", "hello", "hi"); + +``` + | +| [replaceFirst(field, find, replace)](./firestore_lite.md#replacefirst_b257ab0) | (BETA) Creates an expression that replaces the first occurrence of a substring within a string represented by a field with another substring. +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field. +replaceFirst("message", "hello", "hi"); + +``` + | +| [reverse(field)](./firestore_lite.md#reverse_0fb8cd4) | (BETA) Creates an expression that reverses a string represented by a field. +```typescript +// Reverse the value of the 'myString' field. +reverse("myString"); + +``` + | | [sum(field)](./firestore_lite.md#sum_aacc3a9) | Create an AggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query. | -| function(fieldPath, ...) | -| [orderBy(fieldPath, directionStr)](./firestore_lite.md#orderby_006d61f) | Creates a [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) that sorts the query result by the specified field, optionally in descending order instead of ascending.Note: Documents that do not contain the specified field will not be present in the query result. | -| [where(fieldPath, opStr, value)](./firestore_lite.md#where_0fae4bf) | Creates a [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) that enforces that documents must contain the specified field and that the value should satisfy the relation constraint provided. | -| function(fieldValues, ...) | -| [endAt(fieldValues)](./firestore_lite.md#endat_8b2f2c8) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | -| [endBefore(fieldValues)](./firestore_lite.md#endbefore_8b2f2c8) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | -| [startAfter(fieldValues)](./firestore_lite.md#startafter_8b2f2c8) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | -| [startAt(fieldValues)](./firestore_lite.md#startat_8b2f2c8) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | -| function(left, ...) | -| [aggregateFieldEqual(left, right)](./firestore_lite.md#aggregatefieldequal_e80a2b2) | Compares two 'AggregateField\` instances for equality. | -| [aggregateQuerySnapshotEqual(left, right)](./firestore_lite.md#aggregatequerysnapshotequal_1529a20) | Compares two AggregateQuerySnapshot instances for equality.Two AggregateQuerySnapshot instances are considered "equal" if they have underlying queries that compare equal, and the same data. | -| [queryEqual(left, right)](./firestore_lite.md#queryequal_7a1f045) | Returns true if the provided queries point to the same collection and apply the same constraints. | -| [refEqual(left, right)](./firestore_lite.md#refequal_598b780) | Returns true if the provided references are equal. | -| [snapshotEqual(left, right)](./firestore_lite.md#snapshotequal_5109204) | Returns true if the provided snapshots are equal. | -| function(limit, ...) | -| [limit(limit)](./firestore_lite.md#limit_ec46c78) | Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the first matching documents. | -| [limitToLast(limit)](./firestore_lite.md#limittolast_ec46c78) | Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the last matching documents.You must specify at least one orderBy clause for limitToLast queries, otherwise an exception will be thrown during execution. | -| function(logLevel, ...) | -| [setLogLevel(logLevel)](./firestore_lite.md#setloglevel_d02fda2) | Sets the verbosity of Cloud Firestore logs (debug, error, or silent). | -| function(n, ...) | -| [increment(n)](./firestore_lite.md#increment_5685735) | Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to increment the field's current value by the given value.If either the operand or the current field value uses floating point precision, all arithmetic follows IEEE 754 semantics. If both values are integers, values outside of JavaScript's safe number range (Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER) are also subject to precision loss. Furthermore, once processed by the Firestore backend, all integer operations are capped between -2^63 and 2^63-1.If the current field value is not of type number, or if the field does not yet exist, the transformation sets the field to the given value. | -| function(query, ...) | -| [getAggregate(query, aggregateSpec)](./firestore_lite.md#getaggregate_2073a74) | Calculates the specified aggregations over the documents in the result set of the given query without actually downloading the documents.Using this function to perform aggregations is efficient because only the final aggregation values, not the documents' data, are downloaded. This function can perform aggregations of the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). | -| [getCount(query)](./firestore_lite.md#getcount_4e56953) | Calculates the number of documents in the result set of the given query without actually downloading the documents.Using this function to count the documents is efficient because only the final count, not the documents' data, is downloaded. This function can count the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). | +| [timestampAdd(field, unit, amount)](./firestore_lite.md#timestampadd_565792c) | (BETA) Creates an expression that adds a specified amount of time to a timestamp represented by a field. +```typescript +// Add 1 day to the 'timestamp' field. +timestampAdd("timestamp", "day", 1); + +``` + | +| [timestampSub(field, unit, amount)](./firestore_lite.md#timestampsub_565792c) | (BETA) Creates an expression that subtracts a specified amount of time from a timestamp represented by a field. +```typescript +// Subtract 1 day from the 'timestamp' field. +timestampSub("timestamp", "day", 1); + +``` + | +| [timestampToUnixMicros(field)](./firestore_lite.md#timestamptounixmicros_0fb8cd4) | (BETA) Creates an expression that converts a timestamp field to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +timestampToUnixMicros("timestamp"); + +``` + | +| [timestampToUnixMillis(field)](./firestore_lite.md#timestamptounixmillis_0fb8cd4) | (BETA) Creates an expression that converts a timestamp field to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +timestampToUnixMillis("timestamp"); + +``` + | +| [timestampToUnixSeconds(field)](./firestore_lite.md#timestamptounixseconds_0fb8cd4) | (BETA) Creates an expression that converts a timestamp field to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). +```typescript +// Convert the 'timestamp' field to seconds since epoch. +timestampToUnixSeconds("timestamp"); + +``` + | +| [unixMicrosToTimestamp(field)](./firestore_lite.md#unixmicrostotimestamp_0fb8cd4) | (BETA) Creates an expression that interprets a field's value as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +unixMicrosToTimestamp("microseconds"); + +``` + | +| [unixMillisToTimestamp(field)](./firestore_lite.md#unixmillistotimestamp_0fb8cd4) | (BETA) Creates an expression that interprets a field's value as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +unixMillisToTimestamp("milliseconds"); + +``` + | +| [unixSecondsToTimestamp(field)](./firestore_lite.md#unixsecondstotimestamp_0fb8cd4) | (BETA) Creates an expression that interprets a field's value as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. +```typescript +// Interpret the 'seconds' field as seconds since epoch. +unixSecondsToTimestamp("seconds"); + +``` + | +| [vectorLength(field)](./firestore_lite.md#vectorlength_0fb8cd4) | (BETA) Creates an expression that calculates the length of a Firestore Vector represented by a field. +```typescript +// Get the vector length (dimension) of the field 'embedding'. +vectorLength("embedding"); + +``` + | +| function(fieldPath, ...) | +| [orderBy(fieldPath, directionStr)](./firestore_lite.md#orderby_006d61f) | Creates a [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) that sorts the query result by the specified field, optionally in descending order instead of ascending.Note: Documents that do not contain the specified field will not be present in the query result. | +| [where(fieldPath, opStr, value)](./firestore_lite.md#where_0fae4bf) | Creates a [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) that enforces that documents must contain the specified field and that the value should satisfy the relation constraint provided. | +| function(fieldValues, ...) | +| [endAt(fieldValues)](./firestore_lite.md#endat_8b2f2c8) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | +| [endBefore(fieldValues)](./firestore_lite.md#endbefore_8b2f2c8) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | +| [startAfter(fieldValues)](./firestore_lite.md#startafter_8b2f2c8) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | +| [startAt(fieldValues)](./firestore_lite.md#startat_8b2f2c8) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | +| function(filter, ...) | +| [not(filter)](./firestore_lite.md#not_5520849) | (BETA) Creates an expression that negates a filter condition. +```typescript +// Find documents where the 'completed' field is NOT true +not(eq("completed", true)); + +``` + | +| function(first, ...) | +| [strConcat(first, elements)](./firestore_lite.md#strconcat_0f1bdbf) | (BETA) Creates an expression that concatenates string functions, fields or constants together. +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +strConcat("firstName", " ", Field.of("lastName")); + +``` + | +| [strConcat(first, elements)](./firestore_lite.md#strconcat_1eb0ac1) | (BETA) Creates an expression that concatenates string expressions together. +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +strConcat(Field.of("firstName"), " ", Field.of("lastName")); + +``` + | +| function(left, ...) | +| [add(left, right)](./firestore_lite.md#add_be96f75) | (BETA) Creates an expression that adds two expressions together. +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +add(Field.of("quantity"), Field.of("reserve")); + +``` + | +| [add(left, right)](./firestore_lite.md#add_010ba9e) | (BETA) Creates an expression that adds an expression to a constant value. +```typescript +// Add 5 to the value of the 'age' field +add(Field.of("age"), 5); + +``` + | +| [add(left, right)](./firestore_lite.md#add_674c63f) | (BETA) Creates an expression that adds a field's value to an expression. +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +add("quantity", Field.of("reserve")); + +``` + | +| [add(left, right)](./firestore_lite.md#add_1f46a76) | (BETA) Creates an expression that adds a field's value to a constant value. +```typescript +// Add 5 to the value of the 'age' field +add("age", 5); + +``` + | +| [aggregateFieldEqual(left, right)](./firestore_lite.md#aggregatefieldequal_e80a2b2) | Compares two 'AggregateField\` instances for equality. | +| [aggregateQuerySnapshotEqual(left, right)](./firestore_lite.md#aggregatequerysnapshotequal_1529a20) | Compares two AggregateQuerySnapshot instances for equality.Two AggregateQuerySnapshot instances are considered "equal" if they have underlying queries that compare equal, and the same data. | +| [and(left, right)](./firestore_lite.md#and_eba7e36) | (BETA) Creates an expression that performs a logical 'AND' operation on multiple filter conditions. +```typescript +// Check if the 'age' field is greater than 18 AND the 'city' field is "London" AND +// the 'status' field is "active" +const condition = and(gt("age", 18), eq("city", "London"), eq("status", "active")); + +``` + | +| [divide(left, right)](./firestore_lite.md#divide_be96f75) | (BETA) Creates an expression that divides two expressions. +```typescript +// Divide the 'total' field by the 'count' field +divide(Field.of("total"), Field.of("count")); + +``` + | +| [divide(left, right)](./firestore_lite.md#divide_010ba9e) | (BETA) Creates an expression that divides an expression by a constant value. +```typescript +// Divide the 'value' field by 10 +divide(Field.of("value"), 10); + +``` + | +| [divide(left, right)](./firestore_lite.md#divide_674c63f) | (BETA) Creates an expression that divides a field's value by an expression. +```typescript +// Divide the 'total' field by the 'count' field +divide("total", Field.of("count")); + +``` + | +| [divide(left, right)](./firestore_lite.md#divide_1f46a76) | (BETA) Creates an expression that divides a field's value by a constant value. +```typescript +// Divide the 'value' field by 10 +divide("value", 10); + +``` + | +| [eq(left, right)](./firestore_lite.md#eq_be96f75) | (BETA) Creates an expression that checks if two expressions are equal. +```typescript +// Check if the 'age' field is equal to an expression +eq(Field.of("age"), Field.of("minAge").add(10)); + +``` + | +| [eq(left, right)](./firestore_lite.md#eq_010ba9e) | (BETA) Creates an expression that checks if an expression is equal to a constant value. +```typescript +// Check if the 'age' field is equal to 21 +eq(Field.of("age"), 21); + +``` + | +| [eq(left, right)](./firestore_lite.md#eq_674c63f) | (BETA) Creates an expression that checks if a field's value is equal to an expression. +```typescript +// Check if the 'age' field is equal to the 'limit' field +eq("age", Field.of("limit")); + +``` + | +| [eq(left, right)](./firestore_lite.md#eq_1f46a76) | (BETA) Creates an expression that checks if a field's value is equal to a constant value. +```typescript +// Check if the 'city' field is equal to string constant "London" +eq("city", "London"); + +``` + | +| [gt(left, right)](./firestore_lite.md#gt_be96f75) | (BETA) Creates an expression that checks if the first expression is greater than the second expression. +```typescript +// Check if the 'age' field is greater than 18 +gt(Field.of("age"), Constant(9).add(9)); + +``` + | +| [gt(left, right)](./firestore_lite.md#gt_010ba9e) | (BETA) Creates an expression that checks if an expression is greater than a constant value. +```typescript +// Check if the 'age' field is greater than 18 +gt(Field.of("age"), 18); + +``` + | +| [gt(left, right)](./firestore_lite.md#gt_674c63f) | (BETA) Creates an expression that checks if a field's value is greater than an expression. +```typescript +// Check if the value of field 'age' is greater than the value of field 'limit' +gt("age", Field.of("limit")); + +``` + | +| [gt(left, right)](./firestore_lite.md#gt_1f46a76) | (BETA) Creates an expression that checks if a field's value is greater than a constant value. +```typescript +// Check if the 'price' field is greater than 100 +gt("price", 100); + +``` + | +| [gte(left, right)](./firestore_lite.md#gte_be96f75) | (BETA) Creates an expression that checks if the first expression is greater than or equal to the second expression. +```typescript +// Check if the 'quantity' field is greater than or equal to the field "threshold" +gte(Field.of("quantity"), Field.of("threshold")); + +``` + | +| [gte(left, right)](./firestore_lite.md#gte_010ba9e) | (BETA) Creates an expression that checks if an expression is greater than or equal to a constant value. +```typescript +// Check if the 'quantity' field is greater than or equal to 10 +gte(Field.of("quantity"), 10); + +``` + | +| [gte(left, right)](./firestore_lite.md#gte_674c63f) | (BETA) Creates an expression that checks if a field's value is greater than or equal to an expression. +```typescript +// Check if the value of field 'age' is greater than or equal to the value of field 'limit' +gte("age", Field.of("limit")); + +``` + | +| [gte(left, right)](./firestore_lite.md#gte_1f46a76) | (BETA) Creates an expression that checks if a field's value is greater than or equal to a constant value. +```typescript +// Check if the 'score' field is greater than or equal to 80 +gte("score", 80); + +``` + | +| [like(left, pattern)](./firestore_lite.md#like_33ec01b) | (BETA) Creates an expression that performs a case-sensitive wildcard string comparison against a field. +```typescript +// Check if the 'title' field contains the string "guide" +like("title", "%guide%"); + +``` + | +| [like(left, pattern)](./firestore_lite.md#like_dd84184) | (BETA) Creates an expression that performs a case-sensitive wildcard string comparison against a field. +```typescript +// Check if the 'title' field contains the string "guide" +like("title", Field.of("pattern")); + +``` + | +| [like(left, pattern)](./firestore_lite.md#like_3aaffe0) | (BETA) Creates an expression that performs a case-sensitive wildcard string comparison. +```typescript +// Check if the 'title' field contains the string "guide" +like(Field.of("title"), "%guide%"); + +``` + | +| [like(left, pattern)](./firestore_lite.md#like_a2c3e8b) | (BETA) Creates an expression that performs a case-sensitive wildcard string comparison. +```typescript +// Check if the 'title' field contains the string "guide" +like(Field.of("title"), Field.of("pattern")); + +``` + | +| [logicalMax(left, right)](./firestore_lite.md#logicalmax_be96f75) | (BETA) Creates an expression that returns the larger value between two expressions, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'field1' field and the 'field2' field. +logicalMax(Field.of("field1"), Field.of("field2")); + +``` + | +| [logicalMax(left, right)](./firestore_lite.md#logicalmax_010ba9e) | (BETA) Creates an expression that returns the larger value between an expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'value' field and 10. +logicalMax(Field.of("value"), 10); + +``` + | +| [logicalMax(left, right)](./firestore_lite.md#logicalmax_674c63f) | (BETA) Creates an expression that returns the larger value between a field and an expression, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'field1' field and the 'field2' field. +logicalMax("field1", Field.of('field2')); + +``` + | +| [logicalMax(left, right)](./firestore_lite.md#logicalmax_1f46a76) | (BETA) Creates an expression that returns the larger value between a field and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the larger value between the 'value' field and 10. +logicalMax("value", 10); + +``` + | +| [logicalMin(left, right)](./firestore_lite.md#logicalmin_be96f75) | (BETA) Creates an expression that returns the smaller value between two expressions, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'field1' field and the 'field2' field. +logicalMin(Field.of("field1"), Field.of("field2")); + +``` + | +| [logicalMin(left, right)](./firestore_lite.md#logicalmin_010ba9e) | (BETA) Creates an expression that returns the smaller value between an expression and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'value' field and 10. +logicalMin(Field.of("value"), 10); + +``` + | +| [logicalMin(left, right)](./firestore_lite.md#logicalmin_674c63f) | (BETA) Creates an expression that returns the smaller value between a field and an expression, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'field1' field and the 'field2' field. +logicalMin("field1", Field.of("field2")); + +``` + | +| [logicalMin(left, right)](./firestore_lite.md#logicalmin_1f46a76) | (BETA) Creates an expression that returns the smaller value between a field and a constant value, based on Firestore's value type ordering. +```typescript +// Returns the smaller value between the 'value' field and 10. +logicalMin("value", 10); + +``` + | +| [lt(left, right)](./firestore_lite.md#lt_be96f75) | (BETA) Creates an expression that checks if the first expression is less than the second expression. +```typescript +// Check if the 'age' field is less than 30 +lt(Field.of("age"), Field.of("limit")); + +``` + | +| [lt(left, right)](./firestore_lite.md#lt_010ba9e) | (BETA) Creates an expression that checks if an expression is less than a constant value. +```typescript +// Check if the 'age' field is less than 30 +lt(Field.of("age"), 30); + +``` + | +| [lt(left, right)](./firestore_lite.md#lt_674c63f) | (BETA) Creates an expression that checks if a field's value is less than an expression. +```typescript +// Check if the 'age' field is less than the 'limit' field +lt("age", Field.of("limit")); + +``` + | +| [lt(left, right)](./firestore_lite.md#lt_1f46a76) | (BETA) Creates an expression that checks if a field's value is less than a constant value. +```typescript +// Check if the 'price' field is less than 50 +lt("price", 50); + +``` + | +| [lte(left, right)](./firestore_lite.md#lte_be96f75) | (BETA) Creates an expression that checks if the first expression is less than or equal to the second expression. +```typescript +// Check if the 'quantity' field is less than or equal to 20 +lte(Field.of("quantity"), Field.of("limit")); + +``` + | +| [lte(left, right)](./firestore_lite.md#lte_010ba9e) | (BETA) Creates an expression that checks if an expression is less than or equal to a constant value. +```typescript +// Check if the 'quantity' field is less than or equal to 20 +lte(Field.of("quantity"), 20); + +``` + | +| [lte(left, right)](./firestore_lite.md#lte_674c63f) | Creates an expression that checks if a field's value is less than or equal to an expression. +```typescript +// Check if the 'quantity' field is less than or equal to the 'limit' field +lte("quantity", Field.of("limit")); + +``` + | +| [lte(left, right)](./firestore_lite.md#lte_1f46a76) | (BETA) Creates an expression that checks if a field's value is less than or equal to a constant value. +```typescript +// Check if the 'score' field is less than or equal to 70 +lte("score", 70); + +``` + | +| [mod(left, right)](./firestore_lite.md#mod_be96f75) | (BETA) Creates an expression that calculates the modulo (remainder) of dividing two expressions. +```typescript +// Calculate the remainder of dividing 'field1' by 'field2'. +mod(Field.of("field1"), Field.of("field2")); + +``` + | +| [mod(left, right)](./firestore_lite.md#mod_010ba9e) | (BETA) Creates an expression that calculates the modulo (remainder) of dividing an expression by a constant. +```typescript +// Calculate the remainder of dividing 'field1' by 5. +mod(Field.of("field1"), 5); + +``` + | +| [mod(left, right)](./firestore_lite.md#mod_674c63f) | (BETA) Creates an expression that calculates the modulo (remainder) of dividing a field's value by an expression. +```typescript +// Calculate the remainder of dividing 'field1' by 'field2'. +mod("field1", Field.of("field2")); + +``` + | +| [mod(left, right)](./firestore_lite.md#mod_1f46a76) | (BETA) Creates an expression that calculates the modulo (remainder) of dividing a field's value by a constant. +```typescript +// Calculate the remainder of dividing 'field1' by 5. +mod("field1", 5); + +``` + | +| [multiply(left, right)](./firestore_lite.md#multiply_be96f75) | (BETA) Creates an expression that multiplies two expressions together. +```typescript +// Multiply the 'quantity' field by the 'price' field +multiply(Field.of("quantity"), Field.of("price")); + +``` + | +| [multiply(left, right)](./firestore_lite.md#multiply_010ba9e) | (BETA) Creates an expression that multiplies an expression by a constant value. +```typescript +// Multiply the value of the 'price' field by 2 +multiply(Field.of("price"), 2); + +``` + | +| [multiply(left, right)](./firestore_lite.md#multiply_674c63f) | (BETA) Creates an expression that multiplies a field's value by an expression. +```typescript +// Multiply the 'quantity' field by the 'price' field +multiply("quantity", Field.of("price")); + +``` + | +| [multiply(left, right)](./firestore_lite.md#multiply_1f46a76) | (BETA) Creates an expression that multiplies a field's value by a constant value. +```typescript +// Multiply the 'value' field by 2 +multiply("value", 2); + +``` + | +| [neq(left, right)](./firestore_lite.md#neq_be96f75) | (BETA) Creates an expression that checks if two expressions are not equal. +```typescript +// Check if the 'status' field is not equal to field 'finalState' +neq(Field.of("status"), Field.of("finalState")); + +``` + | +| [neq(left, right)](./firestore_lite.md#neq_010ba9e) | (BETA) Creates an expression that checks if an expression is not equal to a constant value. +```typescript +// Check if the 'status' field is not equal to "completed" +neq(Field.of("status"), "completed"); + +``` + | +| [neq(left, right)](./firestore_lite.md#neq_674c63f) | (BETA) Creates an expression that checks if a field's value is not equal to an expression. +```typescript +// Check if the 'status' field is not equal to the value of 'expectedStatus' +neq("status", Field.of("expectedStatus")); + +``` + | +| [neq(left, right)](./firestore_lite.md#neq_1f46a76) | (BETA) Creates an expression that checks if a field's value is not equal to a constant value. +```typescript +// Check if the 'country' field is not equal to "USA" +neq("country", "USA"); + +``` + | +| [or(left, right)](./firestore_lite.md#or_eba7e36) | (BETA) Creates an expression that performs a logical 'OR' operation on multiple filter conditions. +```typescript +// Check if the 'age' field is greater than 18 OR the 'city' field is "London" OR +// the 'status' field is "active" +const condition = or(gt("age", 18), eq("city", "London"), eq("status", "active")); + +``` + | +| [queryEqual(left, right)](./firestore_lite.md#queryequal_7a1f045) | Returns true if the provided queries point to the same collection and apply the same constraints. | +| [refEqual(left, right)](./firestore_lite.md#refequal_598b780) | Returns true if the provided references are equal. | +| [regexContains(left, pattern)](./firestore_lite.md#regexcontains_33ec01b) | (BETA) Creates an expression that checks if a string field contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +regexContains("description", "(?i)example"); + +``` + | +| [regexContains(left, pattern)](./firestore_lite.md#regexcontains_dd84184) | (BETA) Creates an expression that checks if a string field contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +regexContains("description", Field.of("pattern")); + +``` + | +| [regexContains(left, pattern)](./firestore_lite.md#regexcontains_3aaffe0) | (BETA) Creates an expression that checks if a string expression contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +regexContains(Field.of("description"), "(?i)example"); + +``` + | +| [regexContains(left, pattern)](./firestore_lite.md#regexcontains_a2c3e8b) | (BETA) Creates an expression that checks if a string expression contains a specified regular expression as a substring. +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +regexContains(Field.of("description"), Field.of("pattern")); + +``` + | +| [regexMatch(left, pattern)](./firestore_lite.md#regexmatch_33ec01b) | (BETA) Creates an expression that checks if a string field matches a specified regular expression. +```typescript +// Check if the 'email' field matches a valid email pattern +regexMatch("email", "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + | +| [regexMatch(left, pattern)](./firestore_lite.md#regexmatch_dd84184) | (BETA) Creates an expression that checks if a string field matches a specified regular expression. +```typescript +// Check if the 'email' field matches a valid email pattern +regexMatch("email", Field.of("pattern")); + +``` + | +| [regexMatch(left, pattern)](./firestore_lite.md#regexmatch_3aaffe0) | (BETA) Creates an expression that checks if a string expression matches a specified regular expression. +```typescript +// Check if the 'email' field matches a valid email pattern +regexMatch(Field.of("email"), "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + | +| [regexMatch(left, pattern)](./firestore_lite.md#regexmatch_a2c3e8b) | (BETA) Creates an expression that checks if a string expression matches a specified regular expression. +```typescript +// Check if the 'email' field matches a valid email pattern +regexMatch(Field.of("email"), Field.of("pattern")); + +``` + | +| [snapshotEqual(left, right)](./firestore_lite.md#snapshotequal_5109204) | Returns true if the provided snapshots are equal. | +| [strContains(left, substring)](./firestore_lite.md#strcontains_18eaf5d) | (BETA) Creates an expression that checks if a string field contains a specified substring. +```typescript +// Check if the 'description' field contains "example". +strContains("description", "example"); + +``` + | +| [strContains(left, substring)](./firestore_lite.md#strcontains_f0f1f2f) | (BETA) Creates an expression that checks if a string field contains a substring specified by an expression. +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +strContains("description", Field.of("keyword")); + +``` + | +| [strContains(left, substring)](./firestore_lite.md#strcontains_5fdbd29) | (BETA) Creates an expression that checks if a string expression contains a specified substring. +```typescript +// Check if the 'description' field contains "example". +strContains(Field.of("description"), "example"); + +``` + | +| [strContains(left, substring)](./firestore_lite.md#strcontains_d9d749f) | (BETA) Creates an expression that checks if a string expression contains a substring specified by another expression. +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +strContains(Field.of("description"), Field.of("keyword")); + +``` + | +| [subtract(left, right)](./firestore_lite.md#subtract_be96f75) | (BETA) Creates an expression that subtracts two expressions. +```typescript +// Subtract the 'discount' field from the 'price' field +subtract(Field.of("price"), Field.of("discount")); + +``` + | +| [subtract(left, right)](./firestore_lite.md#subtract_010ba9e) | (BETA) Creates an expression that subtracts a constant value from an expression. +```typescript +// Subtract the constant value 2 from the 'value' field +subtract(Field.of("value"), 2); + +``` + | +| [subtract(left, right)](./firestore_lite.md#subtract_674c63f) | (BETA) Creates an expression that subtracts an expression from a field's value. +```typescript +// Subtract the 'discount' field from the 'price' field +subtract("price", Field.of("discount")); + +``` + | +| [subtract(left, right)](./firestore_lite.md#subtract_1f46a76) | (BETA) Creates an expression that subtracts a constant value from a field's value. +```typescript +// Subtract 20 from the value of the 'total' field +subtract("total", 20); + +``` + | +| [xor(left, right)](./firestore_lite.md#xor_eba7e36) | (BETA) Creates an expression that performs a logical 'XOR' (exclusive OR) operation on multiple filter conditions. +```typescript +// Check if only one of the conditions is true: 'age' greater than 18, 'city' is "London", +// or 'status' is "active". +const condition = xor( + gt("age", 18), + eq("city", "London"), + eq("status", "active")); + +``` + | +| function(limit, ...) | +| [limit(limit)](./firestore_lite.md#limit_ec46c78) | Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the first matching documents. | +| [limitToLast(limit)](./firestore_lite.md#limittolast_ec46c78) | Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the last matching documents.You must specify at least one orderBy clause for limitToLast queries, otherwise an exception will be thrown during execution. | +| function(logLevel, ...) | +| [setLogLevel(logLevel)](./firestore_lite.md#setloglevel_d02fda2) | Sets the verbosity of Cloud Firestore logs (debug, error, or silent). | +| function(mapExpr, ...) | +| [mapGet(mapExpr, subField)](./firestore_lite.md#mapget_9715f90) | (BETA) Accesses a value from a map (object) expression using the provided key. +```typescript +// Get the 'city' value from the 'address' map field +mapGet(Field.of("address"), "city"); + +``` + | +| function(mapField, ...) | +| [mapGet(mapField, subField)](./firestore_lite.md#mapget_b37bbb6) | (BETA) Accesses a value from a map (object) field using the provided key. +```typescript +// Get the 'city' value from the 'address' map field +mapGet("address", "city"); + +``` + | +| function(n, ...) | +| [increment(n)](./firestore_lite.md#increment_5685735) | Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to increment the field's current value by the given value.If either the operand or the current field value uses floating point precision, all arithmetic follows IEEE 754 semantics. If both values are integers, values outside of JavaScript's safe number range (Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER) are also subject to precision loss. Furthermore, once processed by the Firestore backend, all integer operations are capped between -2^63 and 2^63-1.If the current field value is not of type number, or if the field does not yet exist, the transformation sets the field to the given value. | +| function(name, ...) | +| [genericFunction(name, params)](./firestore_lite.md#genericfunction_b886545) | (BETA) Creates functions that work on the backend but do not exist in the SDK yet. +```typescript +// Call a user defined function named "myFunc" with the arguments 10 and 20 +// This is the same of the 'sum(Field.of("price"))', if it did not exist +genericFunction("sum", [Field.of("price")]); + +``` + | +| function(pipeline, ...) | +| [execute(pipeline)](./firestore_lite.md#execute_86486e6) | (BETA) Modular API for console experimentation. | +| function(query, ...) | +| [getAggregate(query, aggregateSpec)](./firestore_lite.md#getaggregate_2073a74) | Calculates the specified aggregations over the documents in the result set of the given query without actually downloading the documents.Using this function to perform aggregations is efficient because only the final aggregation values, not the documents' data, are downloaded. This function can perform aggregations of the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). | +| [getCount(query)](./firestore_lite.md#getcount_4e56953) | Calculates the number of documents in the result set of the given query without actually downloading the documents.Using this function to count the documents is efficient because only the final count, not the documents' data, is downloaded. This function can count the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). | | [getDocs(query)](./firestore_lite.md#getdocs_4e56953) | Executes the query and returns the results as a [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class).All queries are executed directly by the server, even if the query was previously executed. Recent modifications are only reflected in the retrieved results if they have already been applied by the backend. If the client is offline, the operation fails. To see previously cached result and local modifications, use the full Firestore SDK. | +| [pipeline(query)](./firestore_lite.md#pipeline_20b2416) | Experimental Modular API for console testing. | | [query(query, compositeFilter, queryConstraints)](./firestore_lite.md#query_9f7b0f4) | Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. | | [query(query, queryConstraints)](./firestore_lite.md#query_0f46da1) | Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. | | function(queryConstraints, ...) | @@ -89,1487 +1257,7272 @@ https://github.com/firebase/firebase-js-sdk | [endBefore(snapshot)](./firestore_lite.md#endbefore_9a4477f) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided document (exclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. | | [startAfter(snapshot)](./firestore_lite.md#startafter_9a4477f) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided document (exclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. | | [startAt(snapshot)](./firestore_lite.md#startat_9a4477f) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided document (inclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of this query. | +| function(timestamp, ...) | +| [timestampAdd(timestamp, unit, amount)](./firestore_lite.md#timestampadd_87db576) | (BETA) Creates an expression that adds a specified amount of time to a timestamp. +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +timestampAdd(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampAdd(timestamp, unit, amount)](./firestore_lite.md#timestampadd_46a2d7e) | (BETA) Creates an expression that adds a specified amount of time to a timestamp. +```typescript +// Add 1 day to the 'timestamp' field. +timestampAdd(Field.of("timestamp"), "day", 1); + +``` + | +| [timestampSub(timestamp, unit, amount)](./firestore_lite.md#timestampsub_87db576) | (BETA) Creates an expression that subtracts a specified amount of time from a timestamp. +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +timestampSub(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); + +``` + | +| [timestampSub(timestamp, unit, amount)](./firestore_lite.md#timestampsub_46a2d7e) | (BETA) Creates an expression that subtracts a specified amount of time from a timestamp. +```typescript +// Subtract 1 day from the 'timestamp' field. +timestampSub(Field.of("timestamp"), "day", 1); + +``` + | +| function(value, ...) | +| [avgFunction(value)](./firestore_lite.md#avgfunction_f83680a) | (BETA) Creates an aggregation that calculates the average (mean) of values from an expression across multiple stage inputs. +```typescript +// Calculate the average age of users +avg(Field.of("age")).as("averageAge"); + +``` + | +| [avgFunction(value)](./firestore_lite.md#avgfunction_7c807cd) | (BETA) Creates an aggregation that calculates the average (mean) of a field's values across multiple stage inputs. +```typescript +// Calculate the average age of users +avg("age").as("averageAge"); + +``` + | +| [exists(value)](./firestore_lite.md#exists_f83680a) | (BETA) Creates an expression that checks if a field exists. +```typescript +// Check if the document has a field named "phoneNumber" +exists(Field.of("phoneNumber")); + +``` + | +| [isNan(value)](./firestore_lite.md#isnan_f83680a) | (BETA) Creates an expression that checks if an expression evaluates to 'NaN' (Not a Number). +```typescript +// Check if the result of a calculation is NaN +isNaN(Field.of("value").divide(0)); + +``` + | +| [isNan(value)](./firestore_lite.md#isnan_7c807cd) | (BETA) Creates an expression that checks if a field's value evaluates to 'NaN' (Not a Number). +```typescript +// Check if the result of a calculation is NaN +isNaN("value"); + +``` + | +| [max(value)](./firestore_lite.md#max_f83680a) | (BETA) Creates an aggregation that finds the maximum value of an expression across multiple stage inputs. +```typescript +// Find the highest score in a leaderboard +max(Field.of("score")).as("highestScore"); + +``` + | +| [max(value)](./firestore_lite.md#max_7c807cd) | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. +```typescript +// Find the highest score in a leaderboard +max("score").as("highestScore"); + +``` + | +| [min(value)](./firestore_lite.md#min_f83680a) | (BETA) Creates an aggregation that finds the minimum value of an expression across multiple stage inputs. +```typescript +// Find the lowest price of all products +min(Field.of("price")).as("lowestPrice"); + +``` + | +| [min(value)](./firestore_lite.md#min_7c807cd) | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. +```typescript +// Find the lowest price of all products +min("price").as("lowestPrice"); + +``` + | +| [replaceAll(value, find, replace)](./firestore_lite.md#replaceall_f06d323) | (BETA) Creates an expression that replaces all occurrences of a substring within a string with another substring. +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field. +replaceAll(Field.of("message"), "hello", "hi"); + +``` + | +| [replaceAll(value, find, replace)](./firestore_lite.md#replaceall_26a7926) | (BETA) Creates an expression that replaces all occurrences of a substring within a string with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field. +replaceAll(Field.of("message"), Field.of("findField"), Field.of("replaceField")); + +``` + | +| [replaceFirst(value, find, replace)](./firestore_lite.md#replacefirst_f06d323) | (BETA) Creates an expression that replaces the first occurrence of a substring within a string with another substring. +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field. +replaceFirst(Field.of("message"), "hello", "hi"); + +``` + | +| [replaceFirst(value, find, replace)](./firestore_lite.md#replacefirst_26a7926) | (BETA) Creates an expression that replaces the first occurrence of a substring within a string with another substring, where the substring to find and the replacement substring are specified by expressions. +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field. +replaceFirst(Field.of("message"), Field.of("findField"), Field.of("replaceField")); + +``` + | +| [sumFunction(value)](./firestore_lite.md#sumfunction_f83680a) | (BETA) Creates an aggregation that calculates the sum of values from an expression across multiple stage inputs. +```typescript +// Calculate the total revenue from a set of orders +sum(Field.of("orderAmount")).as("totalRevenue"); + +``` + | +| [sumFunction(value)](./firestore_lite.md#sumfunction_7c807cd) | (BETA) Creates an aggregation that calculates the sum of a field's values across multiple stage inputs. +```typescript +// Calculate the total revenue from a set of orders +sum("orderAmount").as("totalRevenue"); + +``` + | | function(values, ...) | | [vector(values)](./firestore_lite.md#vector_0dbdaf2) | Creates a new VectorValue constructed with a copy of the given array of numbers. | -## Classes +## Classes + +| Class | Description | +| --- | --- | +| [Add](./firestore_lite.add.md#add_class) | (BETA) | +| [AddFields](./firestore_lite.addfields.md#addfields_class) | (BETA) | +| [Aggregate](./firestore_lite.aggregate.md#aggregate_class) | (BETA) | +| [AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class) | Represents an aggregation that can be performed by Firestore. | +| [AggregateQuerySnapshot](./firestore_lite.aggregatequerysnapshot.md#aggregatequerysnapshot_class) | The results of executing an aggregation query. | +| [And](./firestore_lite.and.md#and_class) | (BETA) | +| [ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) | (BETA) | +| [ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) | (BETA) | +| [ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) | (BETA) | +| [ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) | (BETA) | +| [ArrayElement](./firestore_lite.arrayelement.md#arrayelement_class) | (BETA) | +| [ArrayLength](./firestore_lite.arraylength.md#arraylength_class) | (BETA) | +| [ArrayReverse](./firestore_lite.arrayreverse.md#arrayreverse_class) | (BETA) | +| [Avg](./firestore_lite.avg.md#avg_class) | (BETA) | +| [ByteLength](./firestore_lite.bytelength.md#bytelength_class) | (BETA) | +| [Bytes](./firestore_lite.bytes.md#bytes_class) | An immutable object representing an array of bytes. | +| [CharLength](./firestore_lite.charlength.md#charlength_class) | (BETA) | +| [CollectionGroupSource](./firestore_lite.collectiongroupsource.md#collectiongroupsource_class) | (BETA) | +| [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class) | A CollectionReference object can be used for adding documents, getting document references, and querying for documents (using [query()](./firestore_.md#query_9f7b0f4)). | +| [CollectionSource](./firestore_lite.collectionsource.md#collectionsource_class) | (BETA) | +| [Constant](./firestore_lite.constant.md#constant_class) | (BETA) Represents a constant value that can be used in a Firestore pipeline expression.You can create a Constant instance using the static method: +```typescript +// Create a Constant instance for the number 10 +const ten = Constant.of(10); + +// Create a Constant instance for the string "hello" +const hello = Constant.of("hello"); + +``` + | +| [CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) | (BETA) | +| [Count](./firestore_lite.count.md#count_class) | (BETA) | +| [DatabaseSource](./firestore_lite.databasesource.md#databasesource_class) | (BETA) | +| [Distinct](./firestore_lite.distinct.md#distinct_class) | (BETA) | +| [Divide](./firestore_lite.divide.md#divide_class) | (BETA) | +| [DocumentReference](./firestore_lite.documentreference.md#documentreference_class) | A DocumentReference refers to a document location in a Firestore database and can be used to write, read, or listen to the location. The document at the referenced location may or may not exist. | +| [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class) | A DocumentSnapshot contains data read from a document in your Firestore database. The data can be extracted with .data() or .get(<field>) to get a specific field.For a DocumentSnapshot that points to a non-existing document, any data access will return 'undefined'. You can use the exists() method to explicitly verify a document's existence. | +| [DocumentsSource](./firestore_lite.documentssource.md#documentssource_class) | (BETA) | +| [DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) | (BETA) | +| [EndsWith](./firestore_lite.endswith.md#endswith_class) | (BETA) | +| [Eq](./firestore_lite.eq.md#eq_class) | (BETA) | +| [EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) | (BETA) | +| [Exists](./firestore_lite.exists.md#exists_class) | (BETA) | +| [ExprWithAlias](./firestore_lite.exprwithalias.md#exprwithalias_class) | (BETA) | +| [Field](./firestore_lite.field.md#field_class) | (BETA) Represents a reference to a field in a Firestore document, or outputs of a [Pipeline](./firestore_.pipeline.md#pipeline_class) stage.

Field references are used to access document field values in expressions and to specify fields for sorting, filtering, and projecting data in Firestore pipelines.

You can create a Field instance using the static method: +```typescript +// Create a Field instance for the 'name' field +const nameField = Field.of("name"); + +// Create a Field instance for a nested field 'address.city' +const cityField = Field.of("address.city"); + +``` + | +| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | A FieldPath refers to a field in a document. The path may consist of a single field name (referring to a top-level field in the document), or a list of field names (referring to a nested field in the document).Create a FieldPath by providing field names. If more than one field name is provided, the path will point to a nested field in a document. | +| [Fields](./firestore_lite.fields.md#fields_class) | (BETA) | +| [FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) | Sentinel values that can be used when writing document fields with set() or update(). | +| [FindNearest](./firestore_lite.findnearest.md#findnearest_class) | (BETA) | +| [Firestore](./firestore_lite.firestore.md#firestore_class) | The Cloud Firestore service interface.Do not call this constructor directly. Instead, use [getFirestore()](./firestore_.md#getfirestore). | +| [FirestoreError](./firestore_lite.firestoreerror.md#firestoreerror_class) | An error returned by a Firestore operation. | +| [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) | (BETA) This class defines the base class for Firestore [Pipeline](./firestore_.pipeline.md#pipeline_class) functions, which can be evaluated within pipeline execution.Typically, you would not use this class or its children directly. Use either the functions like , , or the methods on (, , etc) to construct new Function instances. | +| [GenericStage](./firestore_lite.genericstage.md#genericstage_class) | (BETA) | +| [GeoPoint](./firestore_lite.geopoint.md#geopoint_class) | An immutable object representing a geographic location in Firestore. The location is represented as latitude/longitude pair.Latitude values are in the range of \[-90, 90\]. Longitude values are in the range of \[-180, 180\]. | +| [Gt](./firestore_lite.gt.md#gt_class) | (BETA) | +| [Gte](./firestore_lite.gte.md#gte_class) | (BETA) | +| [If](./firestore_lite.if.md#if_class) | (BETA) | +| [In](./firestore_lite.in.md#in_class) | (BETA) | +| [IsNan](./firestore_lite.isnan.md#isnan_class) | (BETA) | +| [Like](./firestore_lite.like.md#like_class) | (BETA) | +| [Limit](./firestore_lite.limit.md#limit_class) | (BETA) | +| [LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) | (BETA) | +| [LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) | (BETA) | +| [Lt](./firestore_lite.lt.md#lt_class) | (BETA) | +| [Lte](./firestore_lite.lte.md#lte_class) | (BETA) | +| [MapGet](./firestore_lite.mapget.md#mapget_class) | (BETA) | +| [Max](./firestore_lite.max.md#max_class) | (BETA) | +| [Min](./firestore_lite.min.md#min_class) | (BETA) | +| [Mod](./firestore_lite.mod.md#mod_class) | (BETA) | +| [Multiply](./firestore_lite.multiply.md#multiply_class) | (BETA) | +| [Neq](./firestore_lite.neq.md#neq_class) | (BETA) | +| [Not](./firestore_lite.not.md#not_class) | (BETA) | +| [Offset](./firestore_lite.offset.md#offset_class) | (BETA) | +| [Or](./firestore_lite.or.md#or_class) | (BETA) | +| [Ordering](./firestore_lite.ordering.md#ordering_class) | (BETA) Represents an ordering criterion for sorting documents in a Firestore pipeline.You create Ordering instances using the ascending and descending helper functions. | +| [Pipeline](./firestore_lite.pipeline.md#pipeline_class) | Base-class implementation | +| [PipelineResult](./firestore_lite.pipelineresult.md#pipelineresult_class) | (BETA) A PipelineResult contains data read from a Firestore Pipeline. The data can be extracted with the or methods.

If the PipelineResult represents a non-document result, ref will return a undefined value. | +| [PipelineSource](./firestore_lite.pipelinesource.md#pipelinesource_class) | (BETA) Represents the source of a Firestore [Pipeline](./firestore_.pipeline.md#pipeline_class). | +| [Query](./firestore_lite.query.md#query_class) | A Query refers to a query which you can read or listen to. You can also construct refined Query objects by adding filters and ordering. | +| [QueryCompositeFilterConstraint](./firestore_lite.querycompositefilterconstraint.md#querycompositefilterconstraint_class) | A QueryCompositeFilterConstraint is used to narrow the set of documents returned by a Firestore query by performing the logical OR or AND of multiple [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class)s or [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class)s. QueryCompositeFilterConstraints are created by invoking or and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the QueryCompositeFilterConstraint. | +| [QueryConstraint](./firestore_lite.queryconstraint.md#queryconstraint_class) | A QueryConstraint is used to narrow the set of documents returned by a Firestore query. QueryConstraints are created by invoking [where()](./firestore_.md#where_0fae4bf), [orderBy()](./firestore_.md#orderby_006d61f), [startAt()](./firestore_.md#startat_9a4477f), [startAfter()](./firestore_.md#startafter_9a4477f), [endBefore()](./firestore_.md#endbefore_9a4477f), [endAt()](./firestore_.md#endat_9a4477f), [limit()](./firestore_.md#limit_ec46c78), [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryConstraint. | +| [QueryDocumentSnapshot](./firestore_lite.querydocumentsnapshot.md#querydocumentsnapshot_class) | A QueryDocumentSnapshot contains data read from a document in your Firestore database as part of a query. The document is guaranteed to exist and its data can be extracted with .data() or .get(<field>) to get a specific field.A QueryDocumentSnapshot offers the same API surface as a DocumentSnapshot. Since query results contain only existing documents, the exists property will always be true and data() will never return 'undefined'. | +| [QueryEndAtConstraint](./firestore_lite.queryendatconstraint.md#queryendatconstraint_class) | A QueryEndAtConstraint is used to exclude documents from the end of a result set returned by a Firestore query. QueryEndAtConstraints are created by invoking [endAt()](./firestore_.md#endat_9a4477f) or [endBefore()](./firestore_.md#endbefore_9a4477f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryEndAtConstraint. | +| [QueryFieldFilterConstraint](./firestore_lite.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) | A QueryFieldFilterConstraint is used to narrow the set of documents returned by a Firestore query by filtering on one or more document fields. QueryFieldFilterConstraints are created by invoking [where()](./firestore_.md#where_0fae4bf) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryFieldFilterConstraint. | +| [QueryLimitConstraint](./firestore_lite.querylimitconstraint.md#querylimitconstraint_class) | A QueryLimitConstraint is used to limit the number of documents returned by a Firestore query. QueryLimitConstraints are created by invoking [limit()](./firestore_.md#limit_ec46c78) or [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryLimitConstraint. | +| [QueryOrderByConstraint](./firestore_lite.queryorderbyconstraint.md#queryorderbyconstraint_class) | A QueryOrderByConstraint is used to sort the set of documents returned by a Firestore query. QueryOrderByConstraints are created by invoking [orderBy()](./firestore_.md#orderby_006d61f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryOrderByConstraint.Note: Documents that do not contain the orderBy field will not be present in the query result. | +| [QuerySnapshot](./firestore_lite.querysnapshot.md#querysnapshot_class) | A QuerySnapshot contains zero or more DocumentSnapshot objects representing the results of a query. The documents can be accessed as an array via the docs property or enumerated using the forEach method. The number of documents can be determined via the empty and size properties. | +| [QueryStartAtConstraint](./firestore_lite.querystartatconstraint.md#querystartatconstraint_class) | A QueryStartAtConstraint is used to exclude documents from the start of a result set returned by a Firestore query. QueryStartAtConstraints are created by invoking [startAt()](./firestore_.md#startat_9a4477f) or [startAfter()](./firestore_.md#startafter_9a4477f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryStartAtConstraint. | +| [RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) | (BETA) | +| [RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) | (BETA) | +| [ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) | (BETA) | +| [ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) | (BETA) | +| [Reverse](./firestore_lite.reverse.md#reverse_class) | (BETA) | +| [Select](./firestore_lite.select.md#select_class) | (BETA) | +| [Sort](./firestore_lite.sort.md#sort_class) | (BETA) | +| [StartsWith](./firestore_lite.startswith.md#startswith_class) | (BETA) | +| [StrConcat](./firestore_lite.strconcat.md#strconcat_class) | (BETA) | +| [StrContains](./firestore_lite.strcontains.md#strcontains_class) | (BETA) | +| [Subtract](./firestore_lite.subtract.md#subtract_class) | (BETA) | +| [Sum](./firestore_lite.sum.md#sum_class) | (BETA) | +| [Timestamp](./firestore_lite.timestamp.md#timestamp_class) | A Timestamp represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time.It is encoded using the Proleptic Gregorian Calendar which extends the Gregorian calendar backwards to year one. It is encoded assuming all minutes are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.For examples and further specifications, refer to the [Timestamp definition](https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto). | +| [TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) | (BETA) | +| [TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) | (BETA) | +| [TimestampToUnixMicros](./firestore_lite.timestamptounixmicros.md#timestamptounixmicros_class) | (BETA) | +| [TimestampToUnixMillis](./firestore_lite.timestamptounixmillis.md#timestamptounixmillis_class) | (BETA) | +| [TimestampToUnixSeconds](./firestore_lite.timestamptounixseconds.md#timestamptounixseconds_class) | (BETA) | +| [ToLower](./firestore_lite.tolower.md#tolower_class) | (BETA) | +| [ToUpper](./firestore_lite.toupper.md#toupper_class) | (BETA) | +| [Transaction](./firestore_lite.transaction.md#transaction_class) | A reference to a transaction.The Transaction object passed to a transaction's updateFunction provides the methods to read and write data within the transaction context. See [runTransaction()](./firestore_.md#runtransaction_6f03ec4). | +| [Trim](./firestore_lite.trim.md#trim_class) | (BETA) | +| [UnixMicrosToTimestamp](./firestore_lite.unixmicrostotimestamp.md#unixmicrostotimestamp_class) | (BETA) | +| [UnixMillisToTimestamp](./firestore_lite.unixmillistotimestamp.md#unixmillistotimestamp_class) | (BETA) | +| [UnixSecondsToTimestamp](./firestore_lite.unixsecondstotimestamp.md#unixsecondstotimestamp_class) | (BETA) | +| [VectorLength](./firestore_lite.vectorlength.md#vectorlength_class) | (BETA) | +| [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | Represents a vector type in Firestore documents. Create an instance with . VectorValue | +| [Where](./firestore_lite.where.md#where_class) | (BETA) | +| [WriteBatch](./firestore_lite.writebatch.md#writebatch_class) | A write batch, used to perform multiple writes as a single atomic unit.A WriteBatch object can be acquired by calling [writeBatch()](./firestore_.md#writebatch_231a8e0). It provides methods for adding writes to the write batch. None of the writes will be committed (or visible locally) until [WriteBatch.commit()](./firestore_.writebatch.md#writebatchcommit) is called. | +| [Xor](./firestore_lite.xor.md#xor_class) | (BETA) | + +## Interfaces + +| Interface | Description | +| --- | --- | +| [Accumulator](./firestore_lite.accumulator.md#accumulator_interface) | (BETA) An interface that represents an accumulator. | +| [AggregateSpec](./firestore_lite.aggregatespec.md#aggregatespec_interface) | Specifies a set of aggregations and their aliases. | +| [DocumentData](./firestore_lite.documentdata.md#documentdata_interface) | Document data (for use with [setDoc()](./firestore_lite.md#setdoc_ee215ad)) consists of fields mapped to values. | +| [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) | (BETA) An interface that represents a filter condition. | +| [FindNearestOptions](./firestore_lite.findnearestoptions.md#findnearestoptions_interface) | (BETA) | +| [FirestoreDataConverter](./firestore_lite.firestoredataconverter.md#firestoredataconverter_interface) | Converter used by withConverter() to transform user objects of type AppModelType into Firestore data of type DbModelType.Using the converter allows you to specify generic type arguments when storing and retrieving objects from Firestore.In this context, an "AppModel" is a class that is used in an application to package together related information and functionality. Such a class could, for example, have properties with complex, nested data types, properties used for memoization, properties of types not supported by Firestore (such as symbol and bigint), and helper functions that perform compound operations. Such classes are not suitable and/or possible to store into a Firestore database. Instead, instances of such classes need to be converted to "plain old JavaScript objects" (POJOs) with exclusively primitive properties, potentially nested inside other POJOs or arrays of POJOs. In this context, this type is referred to as the "DbModel" and would be an object suitable for persisting into Firestore. For convenience, applications can implement FirestoreDataConverter and register the converter with Firestore objects, such as DocumentReference or Query, to automatically convert AppModel to DbModel when storing into Firestore, and convert DbModel to AppModel when retrieving from Firestore. | +| [Selectable](./firestore_lite.selectable.md#selectable_interface) | (BETA) An interface that represents a selectable expression. | +| [Settings](./firestore_lite.settings.md#settings_interface) | Specifies custom configurations for your Cloud Firestore instance. You must set these before invoking any other methods. | +| [Stage](./firestore_lite.stage.md#stage_interface) | (BETA) | +| [TransactionOptions](./firestore_lite.transactionoptions.md#transactionoptions_interface) | Options to customize transaction behavior. | + +## Namespaces + +| Namespace | Description | +| --- | --- | +| [and](./firestore_lite.and.md#and_namespace) | | +| [or](./firestore_lite.or.md#or_namespace) | | + +## Type Aliases + +| Type Alias | Description | +| --- | --- | +| [AccumulatorTarget](./firestore_lite.md#accumulatortarget) | (BETA) An accumulator target, which is an expression with an alias that also implements the Accumulator interface. | +| [AddPrefixToKeys](./firestore_lite.md#addprefixtokeys) | Returns a new map where every key is prefixed with the outer key appended to a dot. | +| [AggregateFieldType](./firestore_lite.md#aggregatefieldtype) | The union of all AggregateField types that are supported by Firestore. | +| [AggregateSpecData](./firestore_lite.md#aggregatespecdata) | A type whose keys are taken from an AggregateSpec, and whose values are the result of the aggregation performed by the corresponding AggregateField from the input AggregateSpec. | +| [AggregateType](./firestore_lite.md#aggregatetype) | Union type representing the aggregate type to be performed. | +| [ChildUpdateFields](./firestore_lite.md#childupdatefields) | Helper for calculating the nested fields for a given type T1. This is needed to distribute union types such as undefined | {...} (happens for optional props) or {a: A} | {b: B}.In this use case, V is used to distribute the union types of T[K] on Record, since T[K] is evaluated as an expression and not distributed.See https://www.typescriptlang.org/docs/handbook/advanced-types.html\#distributive-conditional-types | +| [ExprType](./firestore_lite.md#exprtype) | (BETA) An enumeration of the different types of expressions. | +| [FilterExpr](./firestore_lite.md#filterexpr) | (BETA) A filter expression, which is an expression that also implements the FilterCondition interface. | +| [FirestoreErrorCode](./firestore_lite.md#firestoreerrorcode) | The set of Firestore status codes. The codes are the same at the ones exposed by gRPC here: https://github.com/grpc/grpc/blob/master/doc/statuscodes.mdPossible values: - 'cancelled': The operation was cancelled (typically by the caller). - 'unknown': Unknown error or an error from a different error domain. - 'invalid-argument': Client specified an invalid argument. Note that this differs from 'failed-precondition'. 'invalid-argument' indicates arguments that are problematic regardless of the state of the system (e.g. an invalid field name). - 'deadline-exceeded': Deadline expired before operation could complete. For operations that change the state of the system, this error may be returned even if the operation has completed successfully. For example, a successful response from a server could have been delayed long enough for the deadline to expire. - 'not-found': Some requested document was not found. - 'already-exists': Some document that we attempted to create already exists. - 'permission-denied': The caller does not have permission to execute the specified operation. - 'resource-exhausted': Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space. - 'failed-precondition': Operation was rejected because the system is not in a state required for the operation's execution. - 'aborted': The operation was aborted, typically due to a concurrency issue like transaction aborts, etc. - 'out-of-range': Operation was attempted past the valid range. - 'unimplemented': Operation is not implemented or not supported/enabled. - 'internal': Internal errors. Means some invariants expected by underlying system has been broken. If you see one of these errors, something is very broken. - 'unavailable': The service is currently unavailable. This is most likely a transient condition and may be corrected by retrying with a backoff. - 'data-loss': Unrecoverable data loss or corruption. - 'unauthenticated': The request does not have valid authentication credentials for the operation. | +| [NestedUpdateFields](./firestore_lite.md#nestedupdatefields) | For each field (e.g. 'bar'), find all nested keys (e.g. {'bar.baz': T1, 'bar.qux': T2}). Intersect them together to make a single map containing all possible keys that are all marked as optional | +| [OrderByDirection](./firestore_lite.md#orderbydirection) | The direction of a [orderBy()](./firestore_.md#orderby_006d61f) clause is specified as 'desc' or 'asc' (descending or ascending). | +| [PartialWithFieldValue](./firestore_lite.md#partialwithfieldvalue) | Similar to TypeScript's Partial<T>, but allows nested fields to be omitted and FieldValues to be passed in as property values. | +| [Primitive](./firestore_lite.md#primitive) | Primitive types. | +| [QueryConstraintType](./firestore_lite.md#queryconstrainttype) | Describes the different query constraints available in this SDK. | +| [QueryFilterConstraint](./firestore_lite.md#queryfilterconstraint) | QueryFilterConstraint is a helper union type that represents [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) and [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). | +| [QueryNonFilterConstraint](./firestore_lite.md#querynonfilterconstraint) | QueryNonFilterConstraint is a helper union type that represents QueryConstraints which are used to narrow or order the set of documents, but that do not explicitly filter on a document field. QueryNonFilterConstraints are created by invoking [orderBy()](./firestore_.md#orderby_006d61f), [startAt()](./firestore_.md#startat_9a4477f), [startAfter()](./firestore_.md#startafter_9a4477f), [endBefore()](./firestore_.md#endbefore_9a4477f), [endAt()](./firestore_.md#endat_9a4477f), [limit()](./firestore_.md#limit_ec46c78) or [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the QueryConstraint. | +| [SelectableExpr](./firestore_lite.md#selectableexpr) | (BETA) A selectable expression, which is an expression that also implements the Selectable interface. | +| [SetOptions](./firestore_lite.md#setoptions) | An options object that configures the behavior of [setDoc()](./firestore_lite.md#setdoc_ee215ad), and calls. These calls can be configured to perform granular merges instead of overwriting the target documents in their entirety by providing a SetOptions with merge: true. | +| [UnionToIntersection](./firestore_lite.md#uniontointersection) | Given a union type U = T1 | T2 | ..., returns an intersected type (T1 & T2 & ...).Uses distributive conditional types and inference from conditional types. This works because multiple candidates for the same type variable in contra-variant positions causes an intersection type to be inferred. https://www.typescriptlang.org/docs/handbook/advanced-types.html\#type-inference-in-conditional-types https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type | +| [UpdateData](./firestore_lite.md#updatedata) | Update data (for use with [updateDoc()](./firestore_.md#updatedoc_51a65e3)) that consists of field paths (e.g. 'foo' or 'foo.baz') mapped to values. Fields that contain dots reference nested fields within the document. FieldValues can be passed in as property values. | +| [WhereFilterOp](./firestore_lite.md#wherefilterop) | Filter conditions in a [where()](./firestore_.md#where_0fae4bf) clause are specified using the strings '&lt;', '&lt;=', '==', '!=', '&gt;=', '&gt;', 'array-contains', 'in', 'array-contains-any', and 'not-in'. | +| [WithFieldValue](./firestore_lite.md#withfieldvalue) | Allows FieldValues to be passed in as a property value while maintaining type safety. | + +## function(app, ...) + +### getFirestore(app) {:#getfirestore_cf608e1} + +Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. + +Signature: + +```typescript +export declare function getFirestore(app: FirebaseApp): Firestore; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) instance that the returned [Firestore](./firestore_.firestore.md#firestore_class) instance is associated with. | + +Returns: + +[Firestore](./firestore_lite.firestore.md#firestore_class) + +The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. + +### getFirestore(app, databaseId) {:#getfirestore_48de6cb} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Returns the existing [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. + +Signature: + +```typescript +export declare function getFirestore(app: FirebaseApp, databaseId: string): Firestore; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) instance that the returned [Firestore](./firestore_.firestore.md#firestore_class) instance is associated with. | +| databaseId | string | The name of the database. | + +Returns: + +[Firestore](./firestore_lite.firestore.md#firestore_class) + +The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. + +### initializeFirestore(app, settings) {:#initializefirestore_87c6318} + +Initializes a new instance of Cloud Firestore with the provided settings. Can only be called before any other functions, including [getFirestore()](./firestore_.md#getfirestore). If the custom settings are empty, this function is equivalent to calling [getFirestore()](./firestore_.md#getfirestore). + +Signature: + +```typescript +export declare function initializeFirestore(app: FirebaseApp, settings: Settings): Firestore; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) with which the Firestore instance will be associated. | +| settings | [Settings](./firestore_lite.settings.md#settings_interface) | A settings object to configure the Firestore instance. | + +Returns: + +[Firestore](./firestore_lite.firestore.md#firestore_class) + +A newly initialized `Firestore` instance. + +### initializeFirestore(app, settings, databaseId) {:#initializefirestore_37baaaf} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Initializes a new instance of Cloud Firestore with the provided settings. Can only be called before any other functions, including [getFirestore()](./firestore_.md#getfirestore). If the custom settings are empty, this function is equivalent to calling [getFirestore()](./firestore_.md#getfirestore). + +Signature: + +```typescript +export declare function initializeFirestore(app: FirebaseApp, settings: Settings, databaseId?: string): Firestore; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) with which the Firestore instance will be associated. | +| settings | [Settings](./firestore_lite.settings.md#settings_interface) | A settings object to configure the Firestore instance. | +| databaseId | string | The name of the database. | + +Returns: + +[Firestore](./firestore_lite.firestore.md#firestore_class) + +A newly initialized `Firestore` instance. + +## function(firestore, ...) + +### collection(firestore, path, pathSegments) {:#collection_1eb4c23} + +Gets a `CollectionReference` instance that refers to the collection at the specified absolute path. + +Signature: + +```typescript +export declare function collection(firestore: Firestore, path: string, ...pathSegments: string[]): CollectionReference; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | A reference to the root Firestore instance. | +| path | string | A slash-separated path to a collection. | +| pathSegments | string\[\] | Additional path segments to apply relative to the first argument. | + +Returns: + +[CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> + +The `CollectionReference` instance. + +#### Exceptions + +If the final path has an even number of segments and does not point to a collection. + +### collectionGroup(firestore, collectionId) {:#collectiongroup_1838fc3} + +Creates and returns a new `Query` instance that includes all documents in the database that are contained in a collection or subcollection with the given `collectionId`. + +Signature: + +```typescript +export declare function collectionGroup(firestore: Firestore, collectionId: string): Query; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | A reference to the root Firestore instance. | +| collectionId | string | Identifies the collections to query over. Every collection or subcollection with this ID as the last segment of its path will be included. Cannot contain a slash. | + +Returns: + +[Query](./firestore_lite.query.md#query_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> + +The created `Query`. + +### connectFirestoreEmulator(firestore, host, port, options) {:#connectfirestoreemulator_7c247cd} + +Modify this instance to communicate with the Cloud Firestore emulator. + +Note: This must be called before this instance has been used to do any operations. + +Signature: + +```typescript +export declare function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: { + mockUserToken?: EmulatorMockTokenOptions | string; +}): void; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | The Firestore instance to configure to connect to the emulator. | +| host | string | the emulator host (ex: localhost). | +| port | number | the emulator port (ex: 9000). | +| options | { mockUserToken?: [EmulatorMockTokenOptions](./util.md#emulatormocktokenoptions) \| string; } | | + +Returns: + +void + +### doc(firestore, path, pathSegments) {:#doc_1eb4c23} + +Gets a `DocumentReference` instance that refers to the document at the specified absolute path. + +Signature: + +```typescript +export declare function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | A reference to the root Firestore instance. | +| path | string | A slash-separated path to a document. | +| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | + +Returns: + +[DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> + +The `DocumentReference` instance. + +#### Exceptions + +If the final path has an odd number of segments and does not point to a document. + +### pipeline(firestore) {:#pipeline_231a8e0} + +Experimental Modular API for console testing. + +Signature: + +```typescript +export declare function pipeline(firestore: Firestore): PipelineSource; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | | + +Returns: + +[PipelineSource](./firestore_lite.pipelinesource.md#pipelinesource_class) + +### runTransaction(firestore, updateFunction, options) {:#runtransaction_6f03ec4} + +Executes the given `updateFunction` and then attempts to commit the changes applied within the transaction. If any document read within the transaction has changed, Cloud Firestore retries the `updateFunction`. If it fails to commit after 5 attempts, the transaction fails. + +The maximum number of writes allowed in a single transaction is 500. + +Signature: + +```typescript +export declare function runTransaction(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise, options?: TransactionOptions): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | A reference to the Firestore database to run this transaction against. | +| updateFunction | (transaction: [Transaction](./firestore_lite.transaction.md#transaction_class)) => Promise<T> | The function to execute within the transaction context. | +| options | [TransactionOptions](./firestore_lite.transactionoptions.md#transactionoptions_interface) | An options object to configure maximum number of attempts to commit. | + +Returns: + +Promise<T> + +If the transaction completed successfully or was explicitly aborted (the `updateFunction` returned a failed promise), the promise returned by the `updateFunction `is returned here. Otherwise, if the transaction failed, a rejected promise with the corresponding failure error is returned. + +### terminate(firestore) {:#terminate_231a8e0} + +Terminates the provided `Firestore` instance. + +After calling `terminate()` only the `clearIndexedDbPersistence()` functions may be used. Any other function will throw a `FirestoreError`. Termination does not cancel any pending writes, and any promises that are awaiting a response from the server will not be resolved. + +To restart after termination, create a new instance of `Firestore` with [getFirestore()](./firestore_.md#getfirestore). + +Note: Under normal circumstances, calling `terminate()` is not required. This function is useful only when you want to force this instance to release all of its resources or in combination with [clearIndexedDbPersistence()](./firestore_.md#clearindexeddbpersistence_231a8e0) to ensure that all local state is destroyed between test runs. + +Signature: + +```typescript +export declare function terminate(firestore: Firestore): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | The Firestore instance to terminate. | + +Returns: + +Promise<void> + +A `Promise` that is resolved when the instance has been successfully terminated. + +### writeBatch(firestore) {:#writebatch_231a8e0} + +Creates a write batch, used for performing multiple writes as a single atomic operation. The maximum number of writes allowed in a single WriteBatch is 500. + +The result of these writes will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the write fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. + +Signature: + +```typescript +export declare function writeBatch(firestore: Firestore): WriteBatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | | + +Returns: + +[WriteBatch](./firestore_lite.writebatch.md#writebatch_class) + +A `WriteBatch` that can be used to atomically execute multiple writes. + +## function() + +### count() {:#count} + +Create an AggregateField object that can be used to compute the count of documents in the result set of a query. + +Signature: + +```typescript +export declare function count(): AggregateField; +``` +Returns: + +[AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<number> + +### countAll() {:#countall} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an aggregation that counts the total number of stage inputs. + +```typescript +// Count the total number of users +countAll().as("totalUsers"); + +``` + A new representing the 'countAll' aggregation. + +Signature: + +```typescript +export declare function countAll(): Count; +``` +Returns: + +[Count](./firestore_lite.count.md#count_class) + +### deleteField() {:#deletefield} + +Returns a sentinel for use with [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) or [setDoc()](./firestore_lite.md#setdoc_ee215ad) with `{merge: true}` to mark a field for deletion. + +Signature: + +```typescript +export declare function deleteField(): FieldValue; +``` +Returns: + +[FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) + +### documentId() {:#documentid} + +Returns a special sentinel `FieldPath` to refer to the ID of a document. It can be used in queries to sort or filter by the document ID. + +Signature: + +```typescript +export declare function documentId(): FieldPath; +``` +Returns: + +[FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) + +### getFirestore() {:#getfirestore} + +Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. + +Signature: + +```typescript +export declare function getFirestore(): Firestore; +``` +Returns: + +[Firestore](./firestore_lite.firestore.md#firestore_class) + +The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. + +### serverTimestamp() {:#servertimestamp} + +Returns a sentinel used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) to include a server-generated timestamp in the written data. + +Signature: + +```typescript +export declare function serverTimestamp(): FieldValue; +``` +Returns: + +[FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) + +### useFirestorePipelines() {:#usefirestorepipelines} + +Signature: + +```typescript +export declare function useFirestorePipelines(): void; +``` +Returns: + +void + +## function(array, ...) + +### arrayConcat(array, elements) {:#arrayconcat_0b3ddb9} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with other arrays. + +```typescript +// Combine the 'items' array with two new item arrays +arrayConcat(Field.of("items"), [Field.of("newItems"), Field.of("otherItems")]); + +``` + +Signature: + +```typescript +export declare function arrayConcat(array: Constant, elements: Constant[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_lite.constant.md#constant_class) | The array expression to concatenate to. | +| elements | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The array expressions to concatenate. A new representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) + +### arrayConcat(array, elements) {:#arrayconcat_21991c1} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates an array expression with other arrays and/or values. + +```typescript +// Combine the 'tags' array with a new array +arrayConcat(Field.of("tags"), ["newTag1", "newTag2"]); + +``` + +Signature: + +```typescript +export declare function arrayConcat(array: Constant, elements: any[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_lite.constant.md#constant_class) | The array expression to concatenate to. | +| elements | any\[\] | The array expressions or single values to concatenate. A new representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) + +### arrayConcat(array, elements) {:#arrayconcat_f8d5d5e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates a field's array value with other arrays. + +```typescript +// Combine the 'items' array with two new item arrays +arrayConcat("items", [Field.of("newItems"), Field.of("otherItems")]); + +``` + +Signature: + +```typescript +export declare function arrayConcat(array: string, elements: Constant[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | string | The field name containing array values. | +| elements | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The array expressions to concatenate. A new representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) + +### arrayConcat(array, elements) {:#arrayconcat_5a66d99} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates a field's array value with other arrays and/or values. + +```typescript +// Combine the 'tags' array with a new array +arrayConcat("tags", ["newTag1", "newTag2"]); + +``` + +Signature: + +```typescript +export declare function arrayConcat(array: string, elements: any[]): ArrayConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | string | The field name containing array values. | +| elements | any\[\] | The array expressions or single values to concatenate. A new representing the concatenated array. | + +Returns: + +[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) + +### arrayContains(array, element) {:#arraycontains_01ea7c0} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array expression contains a specific element. + +```typescript +// Check if the 'colors' array contains the value of field 'selectedColor' +arrayContains(Field.of("colors"), Field.of("selectedColor")); + +``` + +Signature: + +```typescript +export declare function arrayContains(array: Constant, element: Constant): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_lite.constant.md#constant_class) | The array expression to check. | +| element | [Constant](./firestore_lite.constant.md#constant_class) | The element to search for in the array. A new representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) + +### arrayContains(array, element) {:#arraycontains_60f8f2f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array expression contains a specific element. + +```typescript +// Check if the 'colors' array contains "red" +arrayContains(Field.of("colors"), "red"); + +``` + +Signature: + +```typescript +export declare function arrayContains(array: Constant, element: any): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_lite.constant.md#constant_class) | The array expression to check. | +| element | any | The element to search for in the array. A new representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) + +### arrayContains(array, element) {:#arraycontains_0ebdbfe} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's array value contains a specific element. + +```typescript +// Check if the 'colors' array contains the value of field 'selectedColor' +arrayContains("colors", Field.of("selectedColor")); + +``` + +Signature: + +```typescript +export declare function arrayContains(array: string, element: Constant): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | string | The field name to check. | +| element | [Constant](./firestore_lite.constant.md#constant_class) | The element to search for in the array. A new representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) + +### arrayContains(array, element) {:#arraycontains_8f718df} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's array value contains a specific value. + +```typescript +// Check if the 'colors' array contains "red" +arrayContains("colors", "red"); + +``` + +Signature: + +```typescript +export declare function arrayContains(array: string, element: any): ArrayContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | string | The field name to check. | +| element | any | The element to search for in the array. A new representing the 'array\_contains' comparison. | + +Returns: + +[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) + +### arrayContainsAll(array, values) {:#arraycontainsall_7b7433a} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array expression contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" +arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); + +``` + +Signature: + +```typescript +export declare function arrayContainsAll(array: Constant, values: Constant[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_lite.constant.md#constant_class) | The array expression to check. | +| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) + +### arrayContainsAll(array, values) {:#arraycontainsall_d919466} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array expression contains all the specified elements. + +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" +arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); + +``` + +Signature: + +```typescript +export declare function arrayContainsAll(array: Constant, values: any[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_lite.constant.md#constant_class) | The array expression to check. | +| values | any\[\] | The elements to check for in the array. A new representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) + +### arrayContainsAll(array, values) {:#arraycontainsall_b40e2df} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's array value contains all the specified values or expressions. + +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); + +``` + +Signature: + +```typescript +export declare function arrayContainsAll(array: string, values: Constant[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | string | The field name to check. | +| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) + +### arrayContainsAll(array, values) {:#arraycontainsall_b08efbb} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's array value contains all the specified values or expressions. + +```typescript +// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" +arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); + +``` + +Signature: + +```typescript +export declare function arrayContainsAll(array: string, values: any[]): ArrayContainsAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | string | The field name to check. | +| values | any\[\] | The elements to check for in the array. A new representing the 'array\_contains\_all' comparison. | + +Returns: + +[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) + +### arrayContainsAny(array, values) {:#arraycontainsany_7b7433a} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array expression contains any of the specified elements. + +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "Science" +arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); + +``` + +Signature: + +```typescript +export declare function arrayContainsAny(array: Constant, values: Constant[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_lite.constant.md#constant_class) | The array expression to check. | +| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) + +### arrayContainsAny(array, values) {:#arraycontainsany_d919466} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an array expression contains any of the specified elements. + +```typescript +// Check if the 'categories' array contains either values from field "cate1" or "Science" +arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); + +``` + +Signature: + +```typescript +export declare function arrayContainsAny(array: Constant, values: any[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_lite.constant.md#constant_class) | The array expression to check. | +| values | any\[\] | The elements to check for in the array. A new representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) + +### arrayContainsAny(array, values) {:#arraycontainsany_b40e2df} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's array value contains any of the specified elements. + +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +arrayContainsAny("categories", [Field.of("cate1"), "Science"]); + +``` + +Signature: + +```typescript +export declare function arrayContainsAny(array: string, values: Constant[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | string | The field name to check. | +| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) + +### arrayContainsAny(array, values) {:#arraycontainsany_b08efbb} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's array value contains any of the specified elements. + +```typescript +// Check if the 'groups' array contains either the value from the 'userGroup' field +// or the value "guest" +arrayContainsAny("categories", [Field.of("cate1"), "Science"]); + +``` + +Signature: + +```typescript +export declare function arrayContainsAny(array: string, values: any[]): ArrayContainsAny; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | string | The field name to check. | +| values | any\[\] | The elements to check for in the array. A new representing the 'array\_contains\_any' comparison. | + +Returns: + +[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) + +### arrayLength(array) {:#arraylength_0bb5dbb} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of an array expression. + +```typescript +// Get the number of items in the 'cart' array +arrayLength(Field.of("cart")); + +``` + +Signature: + +```typescript +export declare function arrayLength(array: Constant): ArrayLength; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| array | [Constant](./firestore_lite.constant.md#constant_class) | The array expression to calculate the length of. A new representing the length of the array. | + +Returns: + +[ArrayLength](./firestore_lite.arraylength.md#arraylength_class) + +## function(condition, ...) + +### ifFunction(condition, thenExpr, elseExpr) {:#iffunction_f7b2404} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates a conditional expression that evaluates to a 'then' expression if a condition is true and an 'else' expression if the condition is false. + +```typescript +// If 'age' is greater than 18, return "Adult"; otherwise, return "Minor". +ifFunction( + gt("age", 18), Constant.of("Adult"), Constant.of("Minor")); + +``` + +Signature: + +```typescript +export declare function ifFunction(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant): If; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| condition | [FilterExpr](./firestore_lite.md#filterexpr) | The condition to evaluate. | +| thenExpr | [Constant](./firestore_lite.constant.md#constant_class) | The expression to evaluate if the condition is true. | +| elseExpr | [Constant](./firestore_lite.constant.md#constant_class) | The expression to evaluate if the condition is false. A new representing the conditional expression. | + +Returns: + +[If](./firestore_lite.if.md#if_class) + +## function(databaseId, ...) + +### getFirestore(databaseId) {:#getfirestore_53dc891} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Returns the existing [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. + +Signature: + +```typescript +export declare function getFirestore(databaseId: string): Firestore; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| databaseId | string | The name of the database. | + +Returns: + +[Firestore](./firestore_lite.firestore.md#firestore_class) + +The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. + +## function(element, ...) + +### inAny(element, others) {:#inany_a73b259} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an expression is equal to any of the provided values or expressions. + +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +inAny(Field.of("category"), [Constant.of("Electronics"), Field.of("primaryType")]); + +``` + +Signature: + +```typescript +export declare function inAny(element: Constant, others: Constant[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare. | +| others | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The values to check against. A new representing the 'IN' comparison. | + +Returns: + +[In](./firestore_lite.in.md#in_class) + +### inAny(element, others) {:#inany_f5721c6} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an expression is equal to any of the provided values or expressions. + +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +inAny(Field.of("category"), ["Electronics", Field.of("primaryType")]); + +``` + +Signature: + +```typescript +export declare function inAny(element: Constant, others: any[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare. | +| others | any\[\] | The values to check against. A new representing the 'IN' comparison. | + +Returns: + +[In](./firestore_lite.in.md#in_class) + +### inAny(element, others) {:#inany_c6646ea} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is equal to any of the provided values or expressions. + +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +inAny("category", [Constant.of("Electronics"), Field.of("primaryType")]); + +``` + +Signature: + +```typescript +export declare function inAny(element: string, others: Constant[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | string | The field to compare. | +| others | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The values to check against. A new representing the 'IN' comparison. | + +Returns: + +[In](./firestore_lite.in.md#in_class) + +### inAny(element, others) {:#inany_e6877aa} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is equal to any of the provided values or expressions. + +```typescript +// Check if the 'category' field is either "Electronics" or value of field 'primaryType' +inAny("category", ["Electronics", Field.of("primaryType")]); + +``` + +Signature: + +```typescript +export declare function inAny(element: string, others: any[]): In; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | string | The field to compare. | +| others | any\[\] | The values to check against. A new representing the 'IN' comparison. | + +Returns: + +[In](./firestore_lite.in.md#in_class) + +### notInAny(element, others) {:#notinany_a73b259} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an expression is not equal to any of the provided values or expressions. + +```typescript +// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' +notInAny(Field.of("status"), [Constant.of("pending"), Field.of("rejectedStatus")]); + +``` + +Signature: + +```typescript +export declare function notInAny(element: Constant, others: Constant[]): Not; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare. | +| others | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The values to check against. A new representing the 'NOT IN' comparison. | + +Returns: + +[Not](./firestore_lite.not.md#not_class) + +### notInAny(element, others) {:#notinany_f5721c6} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an expression is not equal to any of the provided values or expressions. + +```typescript +// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' +notInAny(Field.of("status"), ["pending", Field.of("rejectedStatus")]); + +``` + +Signature: + +```typescript +export declare function notInAny(element: Constant, others: any[]): Not; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare. | +| others | any\[\] | The values to check against. A new representing the 'NOT IN' comparison. | + +Returns: + +[Not](./firestore_lite.not.md#not_class) + +### notInAny(element, others) {:#notinany_c6646ea} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is not equal to any of the provided values or expressions. + +```typescript +// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' +notInAny("status", [Constant.of("pending"), Field.of("rejectedStatus")]); + +``` + +Signature: + +```typescript +export declare function notInAny(element: string, others: Constant[]): Not; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | string | The field name to compare. | +| others | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The values to check against. A new representing the 'NOT IN' comparison. | + +Returns: + +[Not](./firestore_lite.not.md#not_class) + +### notInAny(element, others) {:#notinany_e6877aa} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is not equal to any of the provided values or expressions. + +```typescript +// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' +notInAny("status", ["pending", Field.of("rejectedStatus")]); + +``` + +Signature: + +```typescript +export declare function notInAny(element: string, others: any[]): Not; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| element | string | The field name to compare. | +| others | any\[\] | The values to check against. A new representing the 'NOT IN' comparison. | + +Returns: + +[Not](./firestore_lite.not.md#not_class) + +## function(elements, ...) + +### arrayRemove(elements) {:#arrayremove_7d853aa} + +Returns a special value that can be used with [setDoc()](./firestore_.md#setdoc_ee215ad) or that tells the server to remove the given elements from any array value that already exists on the server. All instances of each element specified will be removed from the array. If the field being modified is not already an array it will be overwritten with an empty array. + +Signature: + +```typescript +export declare function arrayRemove(...elements: unknown[]): FieldValue; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| elements | unknown\[\] | The elements to remove from the array. | + +Returns: + +[FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) + +The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()` + +### arrayUnion(elements) {:#arrayunion_7d853aa} + +Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to union the given elements with any array value that already exists on the server. Each specified element that doesn't already exist in the array will be added to the end. If the field being modified is not already an array it will be overwritten with an array containing exactly the specified elements. + +Signature: + +```typescript +export declare function arrayUnion(...elements: unknown[]): FieldValue; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| elements | unknown\[\] | The elements to union into the array. | + +Returns: + +[FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) + +The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()`. + +## function(expr, ...) + +### ascending(expr) {:#ascending_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. + +```typescript +// Sort documents by the 'name' field in ascending order +firestore.pipeline().collection("users") + .sort(ascending(Field.of("name"))); + +``` + +Signature: + +```typescript +export declare function ascending(expr: Constant): Ordering; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression to create an ascending ordering for. A new Ordering for ascending sorting. | + +Returns: + +[Ordering](./firestore_lite.ordering.md#ordering_class) + +### byteLength(expr) {:#bytelength_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the byte length of a string in UTF-8, or just the length of a Blob. + +```typescript +// Calculate the length of the 'myString' field in bytes. +byteLength(Field.of("myString")); + +``` + +Signature: + +```typescript +export declare function byteLength(expr: Constant): ByteLength; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string. A new representing the length of the string in bytes. | + +Returns: + +[ByteLength](./firestore_lite.bytelength.md#bytelength_class) + +### charLength(expr) {:#charlength_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the character length of a string expression in UTF-8. + +```typescript +// Get the character length of the 'name' field in UTF-8. +strLength(Field.of("name")); + +``` + +Signature: + +```typescript +export declare function charLength(expr: Constant): CharLength; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to calculate the length of. A new representing the length of the string. | + +Returns: + +[CharLength](./firestore_lite.charlength.md#charlength_class) + +### cosineDistance(expr, other) {:#cosinedistance_b4c7dc2} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between a field's vector value and a double array. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +cosineDistance("location", [37.7749, -122.4194]); + +``` + +Signature: + +```typescript +export declare function cosineDistance(expr: string, other: number[]): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the first vector. | +| other | number\[\] | The other vector (as an array of doubles) to compare against. A new representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) + +### cosineDistance(expr, other) {:#cosinedistance_8d2bd9d} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between a field's vector value and a VectorValue. + +```typescript +// Calculate the Cosine distance between the 'location' field and a target location +cosineDistance("location", new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +export declare function cosineDistance(expr: string, other: VectorValue): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the first vector. | +| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new representing the Cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) + +### cosineDistance(expr, other) {:#cosinedistance_c9ae0bc} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between a field's vector value and a vector expression. + +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +cosineDistance("userVector", Field.of("itemVector")); + +``` + +Signature: + +```typescript +export declare function cosineDistance(expr: string, other: Constant): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the first vector. | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new representing the cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) + +### cosineDistance(expr, other) {:#cosinedistance_e701952} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between a vector expression and a double array. + +```typescript +// Calculate the cosine distance between the 'location' field and a target location +cosineDistance(Field.of("location"), [37.7749, -122.4194]); + +``` + +Signature: + +```typescript +export declare function cosineDistance(expr: Constant, other: number[]): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | +| other | number\[\] | The other vector (as an array of doubles) to compare against. A new representing the cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) + +### cosineDistance(expr, other) {:#cosinedistance_cc2e83e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between a vector expression and a VectorValue. + +```typescript +// Calculate the cosine distance between the 'location' field and a target location +cosineDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +export declare function cosineDistance(expr: Constant, other: VectorValue): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | +| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new representing the cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) + +### cosineDistance(expr, other) {:#cosinedistance_0896fbd} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Cosine distance between two vector expressions. + +```typescript +// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field +cosineDistance(Field.of("userVector"), Field.of("itemVector")); + +``` + +Signature: + +```typescript +export declare function cosineDistance(expr: Constant, other: Constant): CosineDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new representing the cosine distance between the two vectors. | + +Returns: + +[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) + +### descending(expr) {:#descending_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. + +```typescript +// Sort documents by the 'createdAt' field in descending order +firestore.pipeline().collection("users") + .sort(descending(Field.of("createdAt"))); + +``` + +Signature: + +```typescript +export declare function descending(expr: Constant): Ordering; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression to create a descending ordering for. A new Ordering for descending sorting. | + +Returns: + +[Ordering](./firestore_lite.ordering.md#ordering_class) + +### dotProduct(expr, other) {:#dotproduct_b4c7dc2} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between a field's vector value and a double array. + +```typescript +// Calculate the dot product distance between a feature vector and a target vector +dotProduct("features", [0.5, 0.8, 0.2]); + +``` + +Signature: + +```typescript +export declare function dotProduct(expr: string, other: number[]): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the first vector. | +| other | number\[\] | The other vector (as an array of doubles) to calculate with. A new representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) + +### dotProduct(expr, other) {:#dotproduct_8d2bd9d} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between a field's vector value and a VectorValue. + +```typescript +// Calculate the dot product distance between a feature vector and a target vector +dotProduct("features", new VectorValue([0.5, 0.8, 0.2])); + +``` + +Signature: + +```typescript +export declare function dotProduct(expr: string, other: VectorValue): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the first vector. | +| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to calculate with. A new representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) + +### dotProduct(expr, other) {:#dotproduct_c9ae0bc} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between a field's vector value and a vector expression. + +```typescript +// Calculate the dot product distance between two document vectors: 'docVector1' and 'docVector2' +dotProduct("docVector1", Field.of("docVector2")); + +``` + +Signature: + +```typescript +export declare function dotProduct(expr: string, other: Constant): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the first vector. | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to calculate with. A new representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) + +### dotProduct(expr, other) {:#dotproduct_e701952} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between a vector expression and a double array. + +```typescript +// Calculate the dot product between a feature vector and a target vector +dotProduct(Field.of("features"), [0.5, 0.8, 0.2]); + +``` + +Signature: + +```typescript +export declare function dotProduct(expr: Constant, other: number[]): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The first vector (represented as an Expr) to calculate with. | +| other | number\[\] | The other vector (as an array of doubles) to calculate with. A new representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) + +### dotProduct(expr, other) {:#dotproduct_cc2e83e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between a vector expression and a VectorValue. + +```typescript +// Calculate the dot product between a feature vector and a target vector +dotProduct(Field.of("features"), new VectorValue([0.5, 0.8, 0.2])); + +``` + +Signature: + +```typescript +export declare function dotProduct(expr: Constant, other: VectorValue): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The first vector (represented as an Expr) to calculate with. | +| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to calculate with. A new representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) + +### dotProduct(expr, other) {:#dotproduct_0896fbd} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the dot product between two vector expressions. + +```typescript +// Calculate the dot product between two document vectors: 'docVector1' and 'docVector2' +dotProduct(Field.of("docVector1"), Field.of("docVector2")); + +``` + +Signature: + +```typescript +export declare function dotProduct(expr: Constant, other: Constant): DotProduct; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The first vector (represented as an Expr) to calculate with. | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to calculate with. A new representing the dot product between the two vectors. | + +Returns: + +[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) + +### endsWith(expr, suffix) {:#endswith_88569cd} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value ends with a given postfix. + +```typescript +// Check if the 'filename' field ends with ".txt" +endsWith("filename", ".txt"); + +``` + +Signature: + +```typescript +export declare function endsWith(expr: string, suffix: string): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The field name to check. | +| suffix | string | The postfix to check for. A new representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_lite.endswith.md#endswith_class) + +### endsWith(expr, suffix) {:#endswith_e2e794e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value ends with a given postfix. + +```typescript +// Check if the 'url' field ends with the value of the 'extension' field +endsWith("url", Field.of("extension")); + +``` + +Signature: + +```typescript +export declare function endsWith(expr: string, suffix: Constant): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The field name to check. | +| suffix | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the postfix. A new representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_lite.endswith.md#endswith_class) + +### endsWith(expr, suffix) {:#endswith_6308b81} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string expression ends with a given postfix. + +```typescript +// Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." +endsWith(Field.of("fullName"), "Jr."); + +``` + +Signature: + +```typescript +export declare function endsWith(expr: Constant, suffix: string): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression to check. | +| suffix | string | The postfix to check for. A new representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_lite.endswith.md#endswith_class) + +### endsWith(expr, suffix) {:#endswith_ab1cc39} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string expression ends with a given postfix. + +```typescript +// Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." +endsWith(Field.of("fullName"), Constant.of("Jr.")); + +``` + +Signature: + +```typescript +export declare function endsWith(expr: Constant, suffix: Constant): EndsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression to check. | +| suffix | [Constant](./firestore_lite.constant.md#constant_class) | The postfix to check for. A new representing the 'ends with' comparison. | + +Returns: + +[EndsWith](./firestore_lite.endswith.md#endswith_class) + +### euclideanDistance(expr, other) {:#euclideandistance_b4c7dc2} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between a field's vector value and a double array. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +euclideanDistance("location", [37.7749, -122.4194]); + +``` + +Signature: + +```typescript +export declare function euclideanDistance(expr: string, other: number[]): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the first vector. | +| other | number\[\] | The other vector (as an array of doubles) to compare against. A new representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) + +### euclideanDistance(expr, other) {:#euclideandistance_8d2bd9d} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between a field's vector value and a VectorValue. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +euclideanDistance("location", new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +export declare function euclideanDistance(expr: string, other: VectorValue): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the first vector. | +| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) + +### euclideanDistance(expr, other) {:#euclideandistance_c9ae0bc} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between a field's vector value and a vector expression. + +```typescript +// Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' +euclideanDistance("pointA", Field.of("pointB")); + +``` + +Signature: + +```typescript +export declare function euclideanDistance(expr: string, other: Constant): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the first vector. | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) + +### euclideanDistance(expr, other) {:#euclideandistance_e701952} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between a vector expression and a double array. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location + +euclideanDistance(Field.of("location"), [37.7749, -122.4194]); + +``` + +Signature: + +```typescript +export declare function euclideanDistance(expr: Constant, other: number[]): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | +| other | number\[\] | The other vector (as an array of doubles) to compare against. A new representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) + +### euclideanDistance(expr, other) {:#euclideandistance_cc2e83e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between a vector expression and a VectorValue. + +```typescript +// Calculate the Euclidean distance between the 'location' field and a target location +euclideanDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); + +``` + +Signature: + +```typescript +export declare function euclideanDistance(expr: Constant, other: VectorValue): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | +| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) + +### euclideanDistance(expr, other) {:#euclideandistance_0896fbd} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Calculates the Euclidean distance between two vector expressions. + +```typescript +// Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' +euclideanDistance(Field.of("pointA"), Field.of("pointB")); + +``` + +Signature: + +```typescript +export declare function euclideanDistance(expr: Constant, other: Constant): EuclideanDistance; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | +| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new representing the Euclidean distance between the two vectors. | + +Returns: + +[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) + +### reverse(expr) {:#reverse_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that reverses a string. + +```typescript +// Reverse the value of the 'myString' field. +reverse(Field.of("myString")); + +``` + +Signature: + +```typescript +export declare function reverse(expr: Constant): Reverse; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to reverse. A new representing the reversed string. | + +Returns: + +[Reverse](./firestore_lite.reverse.md#reverse_class) + +### startsWith(expr, prefix) {:#startswith_484d9f3} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value starts with a given prefix. + +```typescript +// Check if the 'name' field starts with "Mr." +startsWith("name", "Mr."); + +``` + +Signature: + +```typescript +export declare function startsWith(expr: string, prefix: string): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The field name to check. | +| prefix | string | The prefix to check for. A new representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_lite.startswith.md#startswith_class) + +### startsWith(expr, prefix) {:#startswith_7deb5c7} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value starts with a given prefix. + +```typescript +// Check if the 'fullName' field starts with the value of the 'firstName' field +startsWith("fullName", Field.of("firstName")); + +``` + +Signature: + +```typescript +export declare function startsWith(expr: string, prefix: Constant): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The field name to check. | +| prefix | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the prefix. A new representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_lite.startswith.md#startswith_class) + +### startsWith(expr, prefix) {:#startswith_68300d1} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string expression starts with a given prefix. + +```typescript +// Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." +startsWith(Field.of("fullName"), "Mr."); + +``` + +Signature: + +```typescript +export declare function startsWith(expr: Constant, prefix: string): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression to check. | +| prefix | string | The prefix to check for. A new representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_lite.startswith.md#startswith_class) + +### startsWith(expr, prefix) {:#startswith_5774b68} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string expression starts with a given prefix. + +```typescript +// Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." +startsWith(Field.of("fullName"), Field.of("prefix")); + +``` + +Signature: + +```typescript +export declare function startsWith(expr: Constant, prefix: Constant): StartsWith; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression to check. | +| prefix | [Constant](./firestore_lite.constant.md#constant_class) | The prefix to check for. A new representing the 'starts with' comparison. | + +Returns: + +[StartsWith](./firestore_lite.startswith.md#startswith_class) + +### timestampToUnixMicros(expr) {:#timestamptounixmicros_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +timestampToUnixMicros(Field.of("timestamp")); + +``` + +Signature: + +```typescript +export declare function timestampToUnixMicros(expr: Constant): TimestampToUnixMicros; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the timestamp. A new representing the number of microseconds since epoch. | + +Returns: + +[TimestampToUnixMicros](./firestore_lite.timestamptounixmicros.md#timestamptounixmicros_class) + +### timestampToUnixMillis(expr) {:#timestamptounixmillis_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +timestampToUnixMillis(Field.of("timestamp")); + +``` + +Signature: + +```typescript +export declare function timestampToUnixMillis(expr: Constant): TimestampToUnixMillis; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the timestamp. A new representing the number of milliseconds since epoch. | + +Returns: + +[TimestampToUnixMillis](./firestore_lite.timestamptounixmillis.md#timestamptounixmillis_class) + +### timestampToUnixSeconds(expr) {:#timestamptounixseconds_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to seconds since epoch. +timestampToUnixSeconds(Field.of("timestamp")); + +``` + +Signature: + +```typescript +export declare function timestampToUnixSeconds(expr: Constant): TimestampToUnixSeconds; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the timestamp. A new representing the number of seconds since epoch. | + +Returns: + +[TimestampToUnixSeconds](./firestore_lite.timestamptounixseconds.md#timestamptounixseconds_class) + +### toLower(expr) {:#tolower_1e536ed} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string field to lowercase. + +```typescript +// Convert the 'name' field to lowercase +toLower("name"); + +``` + +Signature: + +```typescript +export declare function toLower(expr: string): ToLower; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the string. A new representing the lowercase string. | + +Returns: + +[ToLower](./firestore_lite.tolower.md#tolower_class) + +### toLower(expr) {:#tolower_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string expression to lowercase. + +```typescript +// Convert the 'name' field to lowercase +toLower(Field.of("name")); + +``` + +Signature: + +```typescript +export declare function toLower(expr: Constant): ToLower; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to convert to lowercase. A new representing the lowercase string. | + +Returns: + +[ToLower](./firestore_lite.tolower.md#tolower_class) + +### toUpper(expr) {:#toupper_1e536ed} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string field to uppercase. + +```typescript +// Convert the 'title' field to uppercase +toUpper("title"); + +``` + +Signature: + +```typescript +export declare function toUpper(expr: string): ToUpper; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the string. A new representing the uppercase string. | + +Returns: + +[ToUpper](./firestore_lite.toupper.md#toupper_class) + +### toUpper(expr) {:#toupper_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a string expression to uppercase. + +```typescript +// Convert the 'title' field to uppercase +toUppercase(Field.of("title")); + +``` + +Signature: + +```typescript +export declare function toUpper(expr: Constant): ToUpper; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to convert to uppercase. A new representing the uppercase string. | + +Returns: + +[ToUpper](./firestore_lite.toupper.md#toupper_class) + +### trim(expr) {:#trim_1e536ed} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that removes leading and trailing whitespace from a string field. + +```typescript +// Trim whitespace from the 'userInput' field +trim("userInput"); + +``` + +Signature: + +```typescript +export declare function trim(expr: string): Trim; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | string | The name of the field containing the string. A new representing the trimmed string. | + +Returns: + +[Trim](./firestore_lite.trim.md#trim_class) + +### trim(expr) {:#trim_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that removes leading and trailing whitespace from a string expression. + +```typescript +// Trim whitespace from the 'userInput' field +trim(Field.of("userInput")); + +``` + +Signature: + +```typescript +export declare function trim(expr: Constant): Trim; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to trim. A new representing the trimmed string. | + +Returns: + +[Trim](./firestore_lite.trim.md#trim_class) + +### unixMicrosToTimestamp(expr) {:#unixmicrostotimestamp_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets an expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +unixMicrosToTimestamp(Field.of("microseconds")); + +``` + +Signature: + +```typescript +export declare function unixMicrosToTimestamp(expr: Constant): UnixMicrosToTimestamp; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the number of microseconds since epoch. A new representing the timestamp. | + +Returns: + +[UnixMicrosToTimestamp](./firestore_lite.unixmicrostotimestamp.md#unixmicrostotimestamp_class) + +### unixMillisToTimestamp(expr) {:#unixmillistotimestamp_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets an expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +unixMillisToTimestamp(Field.of("milliseconds")); + +``` + +Signature: + +```typescript +export declare function unixMillisToTimestamp(expr: Constant): UnixMillisToTimestamp; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the number of milliseconds since epoch. A new representing the timestamp. | + +Returns: + +[UnixMillisToTimestamp](./firestore_lite.unixmillistotimestamp.md#unixmillistotimestamp_class) + +### unixSecondsToTimestamp(expr) {:#unixsecondstotimestamp_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets an expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'seconds' field as seconds since epoch. +unixSecondsToTimestamp(Field.of("seconds")); + +``` + +Signature: + +```typescript +export declare function unixSecondsToTimestamp(expr: Constant): UnixSecondsToTimestamp; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the number of seconds since epoch. A new representing the timestamp. | + +Returns: + +[UnixSecondsToTimestamp](./firestore_lite.unixsecondstotimestamp.md#unixsecondstotimestamp_class) + +### vectorLength(expr) {:#vectorlength_f3fb767} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of a Firestore Vector. + +```typescript +// Get the vector length (dimension) of the field 'embedding'. +vectorLength(Field.of("embedding")); + +``` + +Signature: + +```typescript +export declare function vectorLength(expr: Constant): VectorLength; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the Firestore Vector. A new representing the length of the array. | + +Returns: + +[VectorLength](./firestore_lite.vectorlength.md#vectorlength_class) + +## function(field, ...) + +### average(field) {:#average_aacc3a9} + +Create an AggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query. + +Signature: + +```typescript +export declare function average(field: string | FieldPath): AggregateField; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | Specifies the field to average across the result set. | + +Returns: + +[AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<number \| null> + +### byteLength(field) {:#bytelength_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of a string represented by a field in UTF-8 bytes, or just the length of a Blob. + +```typescript +// Calculate the length of the 'myString' field in bytes. +byteLength("myString"); + +``` + +Signature: + +```typescript +export declare function byteLength(field: string): ByteLength; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the string. A new representing the length of the string in bytes. | + +Returns: + +[ByteLength](./firestore_lite.bytelength.md#bytelength_class) + +### charLength(field) {:#charlength_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the character length of a string field in UTF8. + +```typescript +// Get the character length of the 'name' field in UTF-8. +strLength("name"); + +``` + +Signature: + +```typescript +export declare function charLength(field: string): CharLength; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field containing the string. A new representing the length of the string. | + +Returns: + +[CharLength](./firestore_lite.charlength.md#charlength_class) + +### exists(field) {:#exists_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field exists. + +```typescript +// Check if the document has a field named "phoneNumber" +exists("phoneNumber"); + +``` + +Signature: + +```typescript +export declare function exists(field: string): Exists; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The field name to check. A new representing the 'exists' check. | + +Returns: + +[Exists](./firestore_lite.exists.md#exists_class) + +### replaceAll(field, find, replace) {:#replaceall_b257ab0} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces all occurrences of a substring within a string represented by a field with another substring. + +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field. +replaceAll("message", "hello", "hi"); + +``` + +Signature: + +```typescript +export declare function replaceAll(field: string, find: string, replace: string): ReplaceAll; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the string to perform the replacement on. | +| find | string | The substring to search for. | +| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | + +Returns: + +[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) + +### replaceFirst(field, find, replace) {:#replacefirst_b257ab0} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that replaces the first occurrence of a substring within a string represented by a field with another substring. + +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field. +replaceFirst("message", "hello", "hi"); + +``` + +Signature: + +```typescript +export declare function replaceFirst(field: string, find: string, replace: string): ReplaceFirst; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the string to perform the replacement on. | +| find | string | The substring to search for. | +| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | + +Returns: + +[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) + +### reverse(field) {:#reverse_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that reverses a string represented by a field. + +```typescript +// Reverse the value of the 'myString' field. +reverse("myString"); + +``` + +Signature: + +```typescript +export declare function reverse(field: string): Reverse; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the string to reverse. A new representing the reversed string. | + +Returns: + +[Reverse](./firestore_lite.reverse.md#reverse_class) + +### sum(field) {:#sum_aacc3a9} + +Create an AggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query. + +Signature: + +```typescript +export declare function sum(field: string | FieldPath): AggregateField; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | Specifies the field to sum across the result set. | + +Returns: + +[AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<number> + +### timestampAdd(field, unit, amount) {:#timestampadd_565792c} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to a timestamp represented by a field. + +```typescript +// Add 1 day to the 'timestamp' field. +timestampAdd("timestamp", "day", 1); + +``` + +Signature: + +```typescript +export declare function timestampAdd(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the timestamp. | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | +| amount | number | The amount of time to add. A new representing the resulting timestamp. | + +Returns: + +[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) + +### timestampSub(field, unit, amount) {:#timestampsub_565792c} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a specified amount of time from a timestamp represented by a field. + +```typescript +// Subtract 1 day from the 'timestamp' field. +timestampSub("timestamp", "day", 1); + +``` + +Signature: + +```typescript +export declare function timestampSub(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the timestamp. | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | +| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | + +Returns: + +[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) + +### timestampToUnixMicros(field) {:#timestamptounixmicros_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a timestamp field to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to microseconds since epoch. +timestampToUnixMicros("timestamp"); + +``` + +Signature: + +```typescript +export declare function timestampToUnixMicros(field: string): TimestampToUnixMicros; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the timestamp. A new representing the number of microseconds since epoch. | + +Returns: + +[TimestampToUnixMicros](./firestore_lite.timestamptounixmicros.md#timestamptounixmicros_class) + +### timestampToUnixMillis(field) {:#timestamptounixmillis_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a timestamp field to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to milliseconds since epoch. +timestampToUnixMillis("timestamp"); + +``` + +Signature: + +```typescript +export declare function timestampToUnixMillis(field: string): TimestampToUnixMillis; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the timestamp. A new representing the number of milliseconds since epoch. | + +Returns: + +[TimestampToUnixMillis](./firestore_lite.timestamptounixmillis.md#timestamptounixmillis_class) + +### timestampToUnixSeconds(field) {:#timestamptounixseconds_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that converts a timestamp field to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). + +```typescript +// Convert the 'timestamp' field to seconds since epoch. +timestampToUnixSeconds("timestamp"); + +``` + +Signature: + +```typescript +export declare function timestampToUnixSeconds(field: string): TimestampToUnixSeconds; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the timestamp. A new representing the number of seconds since epoch. | + +Returns: + +[TimestampToUnixSeconds](./firestore_lite.timestamptounixseconds.md#timestamptounixseconds_class) + +### unixMicrosToTimestamp(field) {:#unixmicrostotimestamp_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets a field's value as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'microseconds' field as microseconds since epoch. +unixMicrosToTimestamp("microseconds"); + +``` + +Signature: + +```typescript +export declare function unixMicrosToTimestamp(field: string): UnixMicrosToTimestamp; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the number of microseconds since epoch. A new representing the timestamp. | + +Returns: + +[UnixMicrosToTimestamp](./firestore_lite.unixmicrostotimestamp.md#unixmicrostotimestamp_class) + +### unixMillisToTimestamp(field) {:#unixmillistotimestamp_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets a field's value as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'milliseconds' field as milliseconds since epoch. +unixMillisToTimestamp("milliseconds"); + +``` + +Signature: + +```typescript +export declare function unixMillisToTimestamp(field: string): UnixMillisToTimestamp; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the number of milliseconds since epoch. A new representing the timestamp. | + +Returns: + +[UnixMillisToTimestamp](./firestore_lite.unixmillistotimestamp.md#unixmillistotimestamp_class) + +### unixSecondsToTimestamp(field) {:#unixsecondstotimestamp_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that interprets a field's value as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + +```typescript +// Interpret the 'seconds' field as seconds since epoch. +unixSecondsToTimestamp("seconds"); + +``` + +Signature: + +```typescript +export declare function unixSecondsToTimestamp(field: string): UnixSecondsToTimestamp; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the number of seconds since epoch. A new representing the timestamp. | + +Returns: + +[UnixSecondsToTimestamp](./firestore_lite.unixsecondstotimestamp.md#unixsecondstotimestamp_class) + +### vectorLength(field) {:#vectorlength_0fb8cd4} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the length of a Firestore Vector represented by a field. + +```typescript +// Get the vector length (dimension) of the field 'embedding'. +vectorLength("embedding"); + +``` + +Signature: + +```typescript +export declare function vectorLength(field: string): VectorLength; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| field | string | The name of the field representing the Firestore Vector. A new representing the length of the array. | + +Returns: + +[VectorLength](./firestore_lite.vectorlength.md#vectorlength_class) + +## function(fieldPath, ...) + +### orderBy(fieldPath, directionStr) {:#orderby_006d61f} + +Creates a [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) that sorts the query result by the specified field, optionally in descending order instead of ascending. + +Note: Documents that do not contain the specified field will not be present in the query result. + +Signature: + +```typescript +export declare function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryOrderByConstraint; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| fieldPath | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | The field to sort by. | +| directionStr | [OrderByDirection](./firestore_lite.md#orderbydirection) | Optional direction to sort by ('asc' or 'desc'). If not specified, order will be ascending. | + +Returns: + +[QueryOrderByConstraint](./firestore_lite.queryorderbyconstraint.md#queryorderbyconstraint_class) + +The created [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class). + +### where(fieldPath, opStr, value) {:#where_0fae4bf} + +Creates a [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) that enforces that documents must contain the specified field and that the value should satisfy the relation constraint provided. + +Signature: + +```typescript +export declare function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryFieldFilterConstraint; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| fieldPath | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | The path to compare | +| opStr | [WhereFilterOp](./firestore_lite.md#wherefilterop) | The operation string (e.g "&lt;", "&lt;=", "==", "&lt;", "&lt;=", "!="). | +| value | unknown | The value for comparison | + +Returns: + +[QueryFieldFilterConstraint](./firestore_lite.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) + +The created [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class). + +## function(fieldValues, ...) + +### endAt(fieldValues) {:#endat_8b2f2c8} + +Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. + +Signature: + +```typescript +export declare function endAt(...fieldValues: unknown[]): QueryEndAtConstraint; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| fieldValues | unknown\[\] | The field values to end this query at, in order of the query's order by. | + +Returns: + +[QueryEndAtConstraint](./firestore_lite.queryendatconstraint.md#queryendatconstraint_class) + +A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` + +### endBefore(fieldValues) {:#endbefore_8b2f2c8} + +Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. + +Signature: + +```typescript +export declare function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| fieldValues | unknown\[\] | The field values to end this query before, in order of the query's order by. | + +Returns: + +[QueryEndAtConstraint](./firestore_lite.queryendatconstraint.md#queryendatconstraint_class) + +A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` + +### startAfter(fieldValues) {:#startafter_8b2f2c8} + +Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. + +Signature: + +```typescript +export declare function startAfter(...fieldValues: unknown[]): QueryStartAtConstraint; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| fieldValues | unknown\[\] | The field values to start this query after, in order of the query's order by. | + +Returns: + +[QueryStartAtConstraint](./firestore_lite.querystartatconstraint.md#querystartatconstraint_class) + +A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()` + +### startAt(fieldValues) {:#startat_8b2f2c8} + +Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. + +Signature: + +```typescript +export declare function startAt(...fieldValues: unknown[]): QueryStartAtConstraint; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| fieldValues | unknown\[\] | The field values to start this query at, in order of the query's order by. | + +Returns: + +[QueryStartAtConstraint](./firestore_lite.querystartatconstraint.md#querystartatconstraint_class) + +A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()`. + +## function(filter, ...) + +### not(filter) {:#not_5520849} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that negates a filter condition. + +```typescript +// Find documents where the 'completed' field is NOT true +not(eq("completed", true)); + +``` + +Signature: + +```typescript +export declare function not(filter: FilterExpr): Not; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| filter | [FilterExpr](./firestore_lite.md#filterexpr) | The filter condition to negate. A new representing the negated filter condition. | + +Returns: + +[Not](./firestore_lite.not.md#not_class) + +## function(first, ...) + +### strConcat(first, elements) {:#strconcat_0f1bdbf} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates string functions, fields or constants together. + +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +strConcat("firstName", " ", Field.of("lastName")); + +``` + +Signature: + +```typescript +export declare function strConcat(first: string, ...elements: Array): StrConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| first | string | The field name containing the initial string value. | +| elements | Array<[Constant](./firestore_lite.constant.md#constant_class) \| string> | The expressions (typically strings) to concatenate. A new representing the concatenated string. | + +Returns: + +[StrConcat](./firestore_lite.strconcat.md#strconcat_class) + +### strConcat(first, elements) {:#strconcat_1eb0ac1} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that concatenates string expressions together. + +```typescript +// Combine the 'firstName', " ", and 'lastName' fields into a single string +strConcat(Field.of("firstName"), " ", Field.of("lastName")); + +``` + +Signature: + +```typescript +export declare function strConcat(first: Constant, ...elements: Array): StrConcat; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| first | [Constant](./firestore_lite.constant.md#constant_class) | The initial string expression to concatenate to. | +| elements | Array<[Constant](./firestore_lite.constant.md#constant_class) \| string> | The expressions (typically strings) to concatenate. A new representing the concatenated string. | + +Returns: + +[StrConcat](./firestore_lite.strconcat.md#strconcat_class) + +## function(left, ...) + +### add(left, right) {:#add_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds two expressions together. + +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +add(Field.of("quantity"), Field.of("reserve")); + +``` + +Signature: + +```typescript +export declare function add(left: Constant, right: Constant): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The first expression to add. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The second expression to add. A new representing the addition operation. | + +Returns: + +[Add](./firestore_lite.add.md#add_class) + +### add(left, right) {:#add_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds an expression to a constant value. + +```typescript +// Add 5 to the value of the 'age' field +add(Field.of("age"), 5); + +``` + +Signature: + +```typescript +export declare function add(left: Constant, right: any): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to add to. | +| right | any | The constant value to add. A new representing the addition operation. | + +Returns: + +[Add](./firestore_lite.add.md#add_class) + +### add(left, right) {:#add_674c63f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a field's value to an expression. + +```typescript +// Add the value of the 'quantity' field and the 'reserve' field. +add("quantity", Field.of("reserve")); + +``` + +Signature: + +```typescript +export declare function add(left: string, right: Constant): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to add to. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to add. A new representing the addition operation. | + +Returns: + +[Add](./firestore_lite.add.md#add_class) + +### add(left, right) {:#add_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a field's value to a constant value. + +```typescript +// Add 5 to the value of the 'age' field +add("age", 5); + +``` + +Signature: + +```typescript +export declare function add(left: string, right: any): Add; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to add to. | +| right | any | The constant value to add. A new representing the addition operation. | + +Returns: + +[Add](./firestore_lite.add.md#add_class) + +### aggregateFieldEqual(left, right) {:#aggregatefieldequal_e80a2b2} + +Compares two 'AggregateField\` instances for equality. + +Signature: + +```typescript +export declare function aggregateFieldEqual(left: AggregateField, right: AggregateField): boolean; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<unknown> | Compare this AggregateField to the right. | +| right | [AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<unknown> | Compare this AggregateField to the left. | + +Returns: + +boolean + +### aggregateQuerySnapshotEqual(left, right) {:#aggregatequerysnapshotequal_1529a20} + +Compares two `AggregateQuerySnapshot` instances for equality. + +Two `AggregateQuerySnapshot` instances are considered "equal" if they have underlying queries that compare equal, and the same data. + +Signature: + +```typescript +export declare function aggregateQuerySnapshotEqual(left: AggregateQuerySnapshot, right: AggregateQuerySnapshot): boolean; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [AggregateQuerySnapshot](./firestore_lite.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType> | The first AggregateQuerySnapshot to compare. | +| right | [AggregateQuerySnapshot](./firestore_lite.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType> | The second AggregateQuerySnapshot to compare. | + +Returns: + +boolean + +`true` if the objects are "equal", as defined above, or `false` otherwise. + +### and(left, right) {:#and_eba7e36} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that performs a logical 'AND' operation on multiple filter conditions. + +```typescript +// Check if the 'age' field is greater than 18 AND the 'city' field is "London" AND +// the 'status' field is "active" +const condition = and(gt("age", 18), eq("city", "London"), eq("status", "active")); + +``` + +Signature: + +```typescript +export declare function and(left: FilterExpr, ...right: FilterExpr[]): And; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [FilterExpr](./firestore_lite.md#filterexpr) | The first filter condition. | +| right | [FilterExpr](./firestore_lite.md#filterexpr)\[\] | Additional filter conditions to 'AND' together. A new representing the logical 'AND' operation. | + +Returns: + +[And](./firestore_lite.and.md#and_class) + +### divide(left, right) {:#divide_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides two expressions. + +```typescript +// Divide the 'total' field by the 'count' field +divide(Field.of("total"), Field.of("count")); + +``` + +Signature: + +```typescript +export declare function divide(left: Constant, right: Constant): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to be divided. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new representing the division operation. | + +Returns: + +[Divide](./firestore_lite.divide.md#divide_class) + +### divide(left, right) {:#divide_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides an expression by a constant value. + +```typescript +// Divide the 'value' field by 10 +divide(Field.of("value"), 10); + +``` + +Signature: + +```typescript +export declare function divide(left: Constant, right: any): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to be divided. | +| right | any | The constant value to divide by. A new representing the division operation. | + +Returns: + +[Divide](./firestore_lite.divide.md#divide_class) + +### divide(left, right) {:#divide_674c63f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides a field's value by an expression. + +```typescript +// Divide the 'total' field by the 'count' field +divide("total", Field.of("count")); + +``` + +Signature: + +```typescript +export declare function divide(left: string, right: Constant): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to be divided. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new representing the division operation. | + +Returns: + +[Divide](./firestore_lite.divide.md#divide_class) + +### divide(left, right) {:#divide_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that divides a field's value by a constant value. + +```typescript +// Divide the 'value' field by 10 +divide("value", 10); + +``` + +Signature: + +```typescript +export declare function divide(left: string, right: any): Divide; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to be divided. | +| right | any | The constant value to divide by. A new representing the division operation. | + +Returns: + +[Divide](./firestore_lite.divide.md#divide_class) + +### eq(left, right) {:#eq_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if two expressions are equal. + +```typescript +// Check if the 'age' field is equal to an expression +eq(Field.of("age"), Field.of("minAge").add(10)); + +``` + +Signature: + +```typescript +export declare function eq(left: Constant, right: Constant): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The first expression to compare. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The second expression to compare. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_lite.eq.md#eq_class) + +### eq(left, right) {:#eq_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an expression is equal to a constant value. + +```typescript +// Check if the 'age' field is equal to 21 +eq(Field.of("age"), 21); + +``` + +Signature: + +```typescript +export declare function eq(left: Constant, right: any): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare. | +| right | any | The constant value to compare to. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_lite.eq.md#eq_class) + +### eq(left, right) {:#eq_674c63f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is equal to an expression. + +```typescript +// Check if the 'age' field is equal to the 'limit' field +eq("age", Field.of("limit")); + +``` + +Signature: + +```typescript +export declare function eq(left: string, right: Constant): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare to. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_lite.eq.md#eq_class) + +### eq(left, right) {:#eq_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is equal to a constant value. + +```typescript +// Check if the 'city' field is equal to string constant "London" +eq("city", "London"); + +``` + +Signature: + +```typescript +export declare function eq(left: string, right: any): Eq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | any | The constant value to compare to. A new Expr representing the equality comparison. | + +Returns: + +[Eq](./firestore_lite.eq.md#eq_class) + +### gt(left, right) {:#gt_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if the first expression is greater than the second expression. + +```typescript +// Check if the 'age' field is greater than 18 +gt(Field.of("age"), Constant(9).add(9)); + +``` + +Signature: + +```typescript +export declare function gt(left: Constant, right: Constant): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The first expression to compare. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The second expression to compare. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_lite.gt.md#gt_class) + +### gt(left, right) {:#gt_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an expression is greater than a constant value. + +```typescript +// Check if the 'age' field is greater than 18 +gt(Field.of("age"), 18); + +``` + +Signature: + +```typescript +export declare function gt(left: Constant, right: any): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare. | +| right | any | The constant value to compare to. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_lite.gt.md#gt_class) + +### gt(left, right) {:#gt_674c63f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is greater than an expression. + +```typescript +// Check if the value of field 'age' is greater than the value of field 'limit' +gt("age", Field.of("limit")); + +``` + +Signature: + +```typescript +export declare function gt(left: string, right: Constant): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare to. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_lite.gt.md#gt_class) + +### gt(left, right) {:#gt_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is greater than a constant value. + +```typescript +// Check if the 'price' field is greater than 100 +gt("price", 100); + +``` + +Signature: + +```typescript +export declare function gt(left: string, right: any): Gt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | any | The constant value to compare to. A new Expr representing the greater than comparison. | + +Returns: + +[Gt](./firestore_lite.gt.md#gt_class) + +### gte(left, right) {:#gte_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if the first expression is greater than or equal to the second expression. + +```typescript +// Check if the 'quantity' field is greater than or equal to the field "threshold" +gte(Field.of("quantity"), Field.of("threshold")); + +``` + +Signature: + +```typescript +export declare function gte(left: Constant, right: Constant): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The first expression to compare. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The second expression to compare. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_lite.gte.md#gte_class) + +### gte(left, right) {:#gte_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an expression is greater than or equal to a constant value. + +```typescript +// Check if the 'quantity' field is greater than or equal to 10 +gte(Field.of("quantity"), 10); + +``` + +Signature: + +```typescript +export declare function gte(left: Constant, right: any): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare. | +| right | any | The constant value to compare to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_lite.gte.md#gte_class) + +### gte(left, right) {:#gte_674c63f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is greater than or equal to an expression. + +```typescript +// Check if the value of field 'age' is greater than or equal to the value of field 'limit' +gte("age", Field.of("limit")); + +``` + +Signature: + +```typescript +export declare function gte(left: string, right: Constant): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_lite.gte.md#gte_class) + +### gte(left, right) {:#gte_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is greater than or equal to a constant value. + +```typescript +// Check if the 'score' field is greater than or equal to 80 +gte("score", 80); + +``` + +Signature: + +```typescript +export declare function gte(left: string, right: any): Gte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | any | The constant value to compare to. A new Expr representing the greater than or equal to comparison. | + +Returns: + +[Gte](./firestore_lite.gte.md#gte_class) + +### like(left, pattern) {:#like_33ec01b} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that performs a case-sensitive wildcard string comparison against a field. + +```typescript +// Check if the 'title' field contains the string "guide" +like("title", "%guide%"); + +``` + +Signature: + +```typescript +export declare function like(left: string, pattern: string): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The name of the field containing the string. | +| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new representing the 'like' comparison. | + +Returns: + +[Like](./firestore_lite.like.md#like_class) + +### like(left, pattern) {:#like_dd84184} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that performs a case-sensitive wildcard string comparison against a field. + +```typescript +// Check if the 'title' field contains the string "guide" +like("title", Field.of("pattern")); + +``` + +Signature: + +```typescript +export declare function like(left: string, pattern: Constant): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The name of the field containing the string. | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The pattern to search for. You can use "%" as a wildcard character. A new representing the 'like' comparison. | + +Returns: + +[Like](./firestore_lite.like.md#like_class) + +### like(left, pattern) {:#like_3aaffe0} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that performs a case-sensitive wildcard string comparison. + +```typescript +// Check if the 'title' field contains the string "guide" +like(Field.of("title"), "%guide%"); + +``` + +Signature: + +```typescript +export declare function like(left: Constant, pattern: string): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to perform the comparison on. | +| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new representing the 'like' comparison. | + +Returns: + +[Like](./firestore_lite.like.md#like_class) + +### like(left, pattern) {:#like_a2c3e8b} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that performs a case-sensitive wildcard string comparison. + +```typescript +// Check if the 'title' field contains the string "guide" +like(Field.of("title"), Field.of("pattern")); + +``` + +Signature: + +```typescript +export declare function like(left: Constant, pattern: Constant): Like; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to perform the comparison on. | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The pattern to search for. You can use "%" as a wildcard character. A new representing the 'like' comparison. | + +Returns: + +[Like](./firestore_lite.like.md#like_class) + +### logicalMax(left, right) {:#logicalmax_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between two expressions, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'field1' field and the 'field2' field. +logicalMax(Field.of("field1"), Field.of("field2")); + +``` + +Signature: + +```typescript +export declare function logicalMax(left: Constant, right: Constant): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The left operand expression. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The right operand expression. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) + +### logicalMax(left, right) {:#logicalmax_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between an expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'value' field and 10. +logicalMax(Field.of("value"), 10); + +``` + +Signature: + +```typescript +export declare function logicalMax(left: Constant, right: any): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The left operand expression. | +| right | any | The right operand constant. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) + +### logicalMax(left, right) {:#logicalmax_674c63f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between a field and an expression, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'field1' field and the 'field2' field. +logicalMax("field1", Field.of('field2')); + +``` + +Signature: + +```typescript +export declare function logicalMax(left: string, right: Constant): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The left operand field name. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The right operand expression. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) + +### logicalMax(left, right) {:#logicalmax_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the larger value between a field and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the larger value between the 'value' field and 10. +logicalMax("value", 10); + +``` + +Signature: + +```typescript +export declare function logicalMax(left: string, right: any): LogicalMax; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The left operand field name. | +| right | any | The right operand constant. A new representing the logical max operation. | + +Returns: + +[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) + +### logicalMin(left, right) {:#logicalmin_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between two expressions, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'field1' field and the 'field2' field. +logicalMin(Field.of("field1"), Field.of("field2")); + +``` + +Signature: + +```typescript +export declare function logicalMin(left: Constant, right: Constant): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The left operand expression. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The right operand expression. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) + +### logicalMin(left, right) {:#logicalmin_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between an expression and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'value' field and 10. +logicalMin(Field.of("value"), 10); + +``` + +Signature: + +```typescript +export declare function logicalMin(left: Constant, right: any): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The left operand expression. | +| right | any | The right operand constant. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) + +### logicalMin(left, right) {:#logicalmin_674c63f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between a field and an expression, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'field1' field and the 'field2' field. +logicalMin("field1", Field.of("field2")); + +``` + +Signature: + +```typescript +export declare function logicalMin(left: string, right: Constant): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The left operand field name. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The right operand expression. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) + +### logicalMin(left, right) {:#logicalmin_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that returns the smaller value between a field and a constant value, based on Firestore's value type ordering. + +```typescript +// Returns the smaller value between the 'value' field and 10. +logicalMin("value", 10); + +``` + +Signature: + +```typescript +export declare function logicalMin(left: string, right: any): LogicalMin; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The left operand field name. | +| right | any | The right operand constant. A new representing the logical min operation. | + +Returns: + +[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) + +### lt(left, right) {:#lt_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if the first expression is less than the second expression. + +```typescript +// Check if the 'age' field is less than 30 +lt(Field.of("age"), Field.of("limit")); + +``` + +Signature: + +```typescript +export declare function lt(left: Constant, right: Constant): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The first expression to compare. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The second expression to compare. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_lite.lt.md#lt_class) + +### lt(left, right) {:#lt_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an expression is less than a constant value. + +```typescript +// Check if the 'age' field is less than 30 +lt(Field.of("age"), 30); + +``` + +Signature: + +```typescript +export declare function lt(left: Constant, right: any): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare. | +| right | any | The constant value to compare to. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_lite.lt.md#lt_class) + +### lt(left, right) {:#lt_674c63f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is less than an expression. + +```typescript +// Check if the 'age' field is less than the 'limit' field +lt("age", Field.of("limit")); + +``` + +Signature: + +```typescript +export declare function lt(left: string, right: Constant): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare to. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_lite.lt.md#lt_class) + +### lt(left, right) {:#lt_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is less than a constant value. + +```typescript +// Check if the 'price' field is less than 50 +lt("price", 50); + +``` + +Signature: + +```typescript +export declare function lt(left: string, right: any): Lt; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | any | The constant value to compare to. A new Expr representing the less than comparison. | + +Returns: + +[Lt](./firestore_lite.lt.md#lt_class) + +### lte(left, right) {:#lte_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if the first expression is less than or equal to the second expression. + +```typescript +// Check if the 'quantity' field is less than or equal to 20 +lte(Field.of("quantity"), Field.of("limit")); + +``` + +Signature: + +```typescript +export declare function lte(left: Constant, right: Constant): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The first expression to compare. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The second expression to compare. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_lite.lte.md#lte_class) + +### lte(left, right) {:#lte_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an expression is less than or equal to a constant value. + +```typescript +// Check if the 'quantity' field is less than or equal to 20 +lte(Field.of("quantity"), 20); + +``` + +Signature: + +```typescript +export declare function lte(left: Constant, right: any): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare. | +| right | any | The constant value to compare to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_lite.lte.md#lte_class) + +### lte(left, right) {:#lte_674c63f} + +Creates an expression that checks if a field's value is less than or equal to an expression. + +```typescript +// Check if the 'quantity' field is less than or equal to the 'limit' field +lte("quantity", Field.of("limit")); + +``` + +Signature: + +```typescript +export declare function lte(left: string, right: Constant): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_lite.lte.md#lte_class) + +### lte(left, right) {:#lte_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is less than or equal to a constant value. + +```typescript +// Check if the 'score' field is less than or equal to 70 +lte("score", 70); + +``` + +Signature: + +```typescript +export declare function lte(left: string, right: any): Lte; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | any | The constant value to compare to. A new Expr representing the less than or equal to comparison. | + +Returns: + +[Lte](./firestore_lite.lte.md#lte_class) + +### mod(left, right) {:#mod_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing two expressions. + +```typescript +// Calculate the remainder of dividing 'field1' by 'field2'. +mod(Field.of("field1"), Field.of("field2")); + +``` + +Signature: + +```typescript +export declare function mod(left: Constant, right: Constant): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The dividend expression. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The divisor expression. A new representing the modulo operation. | + +Returns: + +[Mod](./firestore_lite.mod.md#mod_class) + +### mod(left, right) {:#mod_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing an expression by a constant. + +```typescript +// Calculate the remainder of dividing 'field1' by 5. +mod(Field.of("field1"), 5); + +``` + +Signature: + +```typescript +export declare function mod(left: Constant, right: any): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The dividend expression. | +| right | any | The divisor constant. A new representing the modulo operation. | + +Returns: + +[Mod](./firestore_lite.mod.md#mod_class) + +### mod(left, right) {:#mod_674c63f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing a field's value by an expression. + +```typescript +// Calculate the remainder of dividing 'field1' by 'field2'. +mod("field1", Field.of("field2")); + +``` + +Signature: + +```typescript +export declare function mod(left: string, right: Constant): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The dividend field name. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The divisor expression. A new representing the modulo operation. | + +Returns: + +[Mod](./firestore_lite.mod.md#mod_class) + +### mod(left, right) {:#mod_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that calculates the modulo (remainder) of dividing a field's value by a constant. + +```typescript +// Calculate the remainder of dividing 'field1' by 5. +mod("field1", 5); + +``` + +Signature: + +```typescript +export declare function mod(left: string, right: any): Mod; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The dividend field name. | +| right | any | The divisor constant. A new representing the modulo operation. | + +Returns: + +[Mod](./firestore_lite.mod.md#mod_class) + +### multiply(left, right) {:#multiply_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies two expressions together. + +```typescript +// Multiply the 'quantity' field by the 'price' field +multiply(Field.of("quantity"), Field.of("price")); + +``` + +Signature: + +```typescript +export declare function multiply(left: Constant, right: Constant): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The first expression to multiply. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The second expression to multiply. A new representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_lite.multiply.md#multiply_class) + +### multiply(left, right) {:#multiply_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies an expression by a constant value. + +```typescript +// Multiply the value of the 'price' field by 2 +multiply(Field.of("price"), 2); + +``` + +Signature: + +```typescript +export declare function multiply(left: Constant, right: any): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to multiply. | +| right | any | The constant value to multiply by. A new representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_lite.multiply.md#multiply_class) + +### multiply(left, right) {:#multiply_674c63f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies a field's value by an expression. + +```typescript +// Multiply the 'quantity' field by the 'price' field +multiply("quantity", Field.of("price")); + +``` + +Signature: + +```typescript +export declare function multiply(left: string, right: Constant): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to multiply. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to multiply by. A new representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_lite.multiply.md#multiply_class) + +### multiply(left, right) {:#multiply_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that multiplies a field's value by a constant value. + +```typescript +// Multiply the 'value' field by 2 +multiply("value", 2); + +``` + +Signature: + +```typescript +export declare function multiply(left: string, right: any): Multiply; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to multiply. | +| right | any | The constant value to multiply by. A new representing the multiplication operation. | + +Returns: + +[Multiply](./firestore_lite.multiply.md#multiply_class) + +### neq(left, right) {:#neq_be96f75} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if two expressions are not equal. + +```typescript +// Check if the 'status' field is not equal to field 'finalState' +neq(Field.of("status"), Field.of("finalState")); + +``` + +Signature: + +```typescript +export declare function neq(left: Constant, right: Constant): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The first expression to compare. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The second expression to compare. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_lite.neq.md#neq_class) + +### neq(left, right) {:#neq_010ba9e} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if an expression is not equal to a constant value. + +```typescript +// Check if the 'status' field is not equal to "completed" +neq(Field.of("status"), "completed"); + +``` + +Signature: + +```typescript +export declare function neq(left: Constant, right: any): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare. | +| right | any | The constant value to compare to. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_lite.neq.md#neq_class) + +### neq(left, right) {:#neq_674c63f} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is not equal to an expression. + +```typescript +// Check if the 'status' field is not equal to the value of 'expectedStatus' +neq("status", Field.of("expectedStatus")); + +``` + +Signature: + +```typescript +export declare function neq(left: string, right: Constant): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare to. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_lite.neq.md#neq_class) + +### neq(left, right) {:#neq_1f46a76} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a field's value is not equal to a constant value. + +```typescript +// Check if the 'country' field is not equal to "USA" +neq("country", "USA"); + +``` + +Signature: + +```typescript +export declare function neq(left: string, right: any): Neq; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The field name to compare. | +| right | any | The constant value to compare to. A new Expr representing the inequality comparison. | + +Returns: + +[Neq](./firestore_lite.neq.md#neq_class) + +### or(left, right) {:#or_eba7e36} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that performs a logical 'OR' operation on multiple filter conditions. + +```typescript +// Check if the 'age' field is greater than 18 OR the 'city' field is "London" OR +// the 'status' field is "active" +const condition = or(gt("age", 18), eq("city", "London"), eq("status", "active")); + +``` + +Signature: + +```typescript +export declare function or(left: FilterExpr, ...right: FilterExpr[]): Or; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [FilterExpr](./firestore_lite.md#filterexpr) | The first filter condition. | +| right | [FilterExpr](./firestore_lite.md#filterexpr)\[\] | Additional filter conditions to 'OR' together. A new representing the logical 'OR' operation. | + +Returns: + +[Or](./firestore_lite.or.md#or_class) -| Class | Description | -| --- | --- | -| [AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class) | Represents an aggregation that can be performed by Firestore. | -| [AggregateQuerySnapshot](./firestore_lite.aggregatequerysnapshot.md#aggregatequerysnapshot_class) | The results of executing an aggregation query. | -| [Bytes](./firestore_lite.bytes.md#bytes_class) | An immutable object representing an array of bytes. | -| [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class) | A CollectionReference object can be used for adding documents, getting document references, and querying for documents (using [query()](./firestore_.md#query_9f7b0f4)). | -| [DocumentReference](./firestore_lite.documentreference.md#documentreference_class) | A DocumentReference refers to a document location in a Firestore database and can be used to write, read, or listen to the location. The document at the referenced location may or may not exist. | -| [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class) | A DocumentSnapshot contains data read from a document in your Firestore database. The data can be extracted with .data() or .get(<field>) to get a specific field.For a DocumentSnapshot that points to a non-existing document, any data access will return 'undefined'. You can use the exists() method to explicitly verify a document's existence. | -| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | A FieldPath refers to a field in a document. The path may consist of a single field name (referring to a top-level field in the document), or a list of field names (referring to a nested field in the document).Create a FieldPath by providing field names. If more than one field name is provided, the path will point to a nested field in a document. | -| [FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) | Sentinel values that can be used when writing document fields with set() or update(). | -| [Firestore](./firestore_lite.firestore.md#firestore_class) | The Cloud Firestore service interface.Do not call this constructor directly. Instead, use [getFirestore()](./firestore_.md#getfirestore). | -| [FirestoreError](./firestore_lite.firestoreerror.md#firestoreerror_class) | An error returned by a Firestore operation. | -| [GeoPoint](./firestore_lite.geopoint.md#geopoint_class) | An immutable object representing a geographic location in Firestore. The location is represented as latitude/longitude pair.Latitude values are in the range of \[-90, 90\]. Longitude values are in the range of \[-180, 180\]. | -| [Query](./firestore_lite.query.md#query_class) | A Query refers to a query which you can read or listen to. You can also construct refined Query objects by adding filters and ordering. | -| [QueryCompositeFilterConstraint](./firestore_lite.querycompositefilterconstraint.md#querycompositefilterconstraint_class) | A QueryCompositeFilterConstraint is used to narrow the set of documents returned by a Firestore query by performing the logical OR or AND of multiple [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class)s or [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class)s. QueryCompositeFilterConstraints are created by invoking [or()](./firestore_.md#or_e72c712) or [and()](./firestore_.md#and_e72c712) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the QueryCompositeFilterConstraint. | -| [QueryConstraint](./firestore_lite.queryconstraint.md#queryconstraint_class) | A QueryConstraint is used to narrow the set of documents returned by a Firestore query. QueryConstraints are created by invoking [where()](./firestore_.md#where_0fae4bf), [orderBy()](./firestore_.md#orderby_006d61f), [startAt()](./firestore_.md#startat_9a4477f), [startAfter()](./firestore_.md#startafter_9a4477f), [endBefore()](./firestore_.md#endbefore_9a4477f), [endAt()](./firestore_.md#endat_9a4477f), [limit()](./firestore_.md#limit_ec46c78), [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryConstraint. | -| [QueryDocumentSnapshot](./firestore_lite.querydocumentsnapshot.md#querydocumentsnapshot_class) | A QueryDocumentSnapshot contains data read from a document in your Firestore database as part of a query. The document is guaranteed to exist and its data can be extracted with .data() or .get(<field>) to get a specific field.A QueryDocumentSnapshot offers the same API surface as a DocumentSnapshot. Since query results contain only existing documents, the exists property will always be true and data() will never return 'undefined'. | -| [QueryEndAtConstraint](./firestore_lite.queryendatconstraint.md#queryendatconstraint_class) | A QueryEndAtConstraint is used to exclude documents from the end of a result set returned by a Firestore query. QueryEndAtConstraints are created by invoking [endAt()](./firestore_.md#endat_9a4477f) or [endBefore()](./firestore_.md#endbefore_9a4477f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryEndAtConstraint. | -| [QueryFieldFilterConstraint](./firestore_lite.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) | A QueryFieldFilterConstraint is used to narrow the set of documents returned by a Firestore query by filtering on one or more document fields. QueryFieldFilterConstraints are created by invoking [where()](./firestore_.md#where_0fae4bf) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryFieldFilterConstraint. | -| [QueryLimitConstraint](./firestore_lite.querylimitconstraint.md#querylimitconstraint_class) | A QueryLimitConstraint is used to limit the number of documents returned by a Firestore query. QueryLimitConstraints are created by invoking [limit()](./firestore_.md#limit_ec46c78) or [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryLimitConstraint. | -| [QueryOrderByConstraint](./firestore_lite.queryorderbyconstraint.md#queryorderbyconstraint_class) | A QueryOrderByConstraint is used to sort the set of documents returned by a Firestore query. QueryOrderByConstraints are created by invoking [orderBy()](./firestore_.md#orderby_006d61f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryOrderByConstraint.Note: Documents that do not contain the orderBy field will not be present in the query result. | -| [QuerySnapshot](./firestore_lite.querysnapshot.md#querysnapshot_class) | A QuerySnapshot contains zero or more DocumentSnapshot objects representing the results of a query. The documents can be accessed as an array via the docs property or enumerated using the forEach method. The number of documents can be determined via the empty and size properties. | -| [QueryStartAtConstraint](./firestore_lite.querystartatconstraint.md#querystartatconstraint_class) | A QueryStartAtConstraint is used to exclude documents from the start of a result set returned by a Firestore query. QueryStartAtConstraints are created by invoking [startAt()](./firestore_.md#startat_9a4477f) or [startAfter()](./firestore_.md#startafter_9a4477f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryStartAtConstraint. | -| [Timestamp](./firestore_lite.timestamp.md#timestamp_class) | A Timestamp represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time.It is encoded using the Proleptic Gregorian Calendar which extends the Gregorian calendar backwards to year one. It is encoded assuming all minutes are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.For examples and further specifications, refer to the [Timestamp definition](https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto). | -| [Transaction](./firestore_lite.transaction.md#transaction_class) | A reference to a transaction.The Transaction object passed to a transaction's updateFunction provides the methods to read and write data within the transaction context. See [runTransaction()](./firestore_.md#runtransaction_6f03ec4). | -| [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | Represents a vector type in Firestore documents. Create an instance with . VectorValue | -| [WriteBatch](./firestore_lite.writebatch.md#writebatch_class) | A write batch, used to perform multiple writes as a single atomic unit.A WriteBatch object can be acquired by calling [writeBatch()](./firestore_.md#writebatch_231a8e0). It provides methods for adding writes to the write batch. None of the writes will be committed (or visible locally) until [WriteBatch.commit()](./firestore_.writebatch.md#writebatchcommit) is called. | +### queryEqual(left, right) {:#queryequal_7a1f045} + +Returns true if the provided queries point to the same collection and apply the same constraints. + +Signature: + +```typescript +export declare function queryEqual(left: Query, right: Query): boolean; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | A Query to compare. | +| right | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | A Query to compare. | + +Returns: + +boolean + +true if the references point to the same location in the same Firestore database. + +### refEqual(left, right) {:#refequal_598b780} + +Returns true if the provided references are equal. + +Signature: + +```typescript +export declare function refEqual(left: DocumentReference | CollectionReference, right: DocumentReference | CollectionReference): boolean; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> \| [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to compare. | +| right | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> \| [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to compare. | + +Returns: + +boolean + +true if the references point to the same location in the same Firestore database. + +### regexContains(left, pattern) {:#regexcontains_33ec01b} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string field contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +regexContains("description", "(?i)example"); + +``` + +Signature: + +```typescript +export declare function regexContains(left: string, pattern: string): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The name of the field containing the string. | +| pattern | string | The regular expression to use for the search. A new representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) + +### regexContains(left, pattern) {:#regexcontains_dd84184} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string field contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +regexContains("description", Field.of("pattern")); + +``` + +Signature: + +```typescript +export declare function regexContains(left: string, pattern: Constant): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The name of the field containing the string. | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the search. A new representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) + +### regexContains(left, pattern) {:#regexcontains_3aaffe0} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string expression contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +regexContains(Field.of("description"), "(?i)example"); + +``` + +Signature: + +```typescript +export declare function regexContains(left: Constant, pattern: string): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to perform the comparison on. | +| pattern | string | The regular expression to use for the search. A new representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) + +### regexContains(left, pattern) {:#regexcontains_a2c3e8b} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string expression contains a specified regular expression as a substring. + +```typescript +// Check if the 'description' field contains "example" (case-insensitive) +regexContains(Field.of("description"), Field.of("pattern")); + +``` + +Signature: + +```typescript +export declare function regexContains(left: Constant, pattern: Constant): RegexContains; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to perform the comparison on. | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the search. A new representing the 'contains' comparison. | + +Returns: + +[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) + +### regexMatch(left, pattern) {:#regexmatch_33ec01b} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string field matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a valid email pattern +regexMatch("email", "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + +Signature: + +```typescript +export declare function regexMatch(left: string, pattern: string): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The name of the field containing the string. | +| pattern | string | The regular expression to use for the match. A new representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) + +### regexMatch(left, pattern) {:#regexmatch_dd84184} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string field matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a valid email pattern +regexMatch("email", Field.of("pattern")); + +``` + +Signature: + +```typescript +export declare function regexMatch(left: string, pattern: Constant): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | string | The name of the field containing the string. | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the match. A new representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) + +### regexMatch(left, pattern) {:#regexmatch_3aaffe0} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string expression matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a valid email pattern +regexMatch(Field.of("email"), "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + +``` + +Signature: + +```typescript +export declare function regexMatch(left: Constant, pattern: string): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to match against. | +| pattern | string | The regular expression to use for the match. A new representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) + +### regexMatch(left, pattern) {:#regexmatch_a2c3e8b} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string expression matches a specified regular expression. + +```typescript +// Check if the 'email' field matches a valid email pattern +regexMatch(Field.of("email"), Field.of("pattern")); + +``` + +Signature: + +```typescript +export declare function regexMatch(left: Constant, pattern: Constant): RegexMatch; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to match against. | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the match. A new representing the regular expression match. | + +Returns: + +[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) + +### snapshotEqual(left, right) {:#snapshotequal_5109204} + +Returns true if the provided snapshots are equal. + +Signature: + +```typescript +export declare function snapshotEqual(left: DocumentSnapshot | QuerySnapshot, right: DocumentSnapshot | QuerySnapshot): boolean; +``` -## Interfaces +#### Parameters -| Interface | Description | -| --- | --- | -| [AggregateSpec](./firestore_lite.aggregatespec.md#aggregatespec_interface) | Specifies a set of aggregations and their aliases. | -| [DocumentData](./firestore_lite.documentdata.md#documentdata_interface) | Document data (for use with [setDoc()](./firestore_lite.md#setdoc_ee215ad)) consists of fields mapped to values. | -| [FirestoreDataConverter](./firestore_lite.firestoredataconverter.md#firestoredataconverter_interface) | Converter used by withConverter() to transform user objects of type AppModelType into Firestore data of type DbModelType.Using the converter allows you to specify generic type arguments when storing and retrieving objects from Firestore.In this context, an "AppModel" is a class that is used in an application to package together related information and functionality. Such a class could, for example, have properties with complex, nested data types, properties used for memoization, properties of types not supported by Firestore (such as symbol and bigint), and helper functions that perform compound operations. Such classes are not suitable and/or possible to store into a Firestore database. Instead, instances of such classes need to be converted to "plain old JavaScript objects" (POJOs) with exclusively primitive properties, potentially nested inside other POJOs or arrays of POJOs. In this context, this type is referred to as the "DbModel" and would be an object suitable for persisting into Firestore. For convenience, applications can implement FirestoreDataConverter and register the converter with Firestore objects, such as DocumentReference or Query, to automatically convert AppModel to DbModel when storing into Firestore, and convert DbModel to AppModel when retrieving from Firestore. | -| [Settings](./firestore_lite.settings.md#settings_interface) | Specifies custom configurations for your Cloud Firestore instance. You must set these before invoking any other methods. | -| [TransactionOptions](./firestore_lite.transactionoptions.md#transactionoptions_interface) | Options to customize transaction behavior. | +| Parameter | Type | Description | +| --- | --- | --- | +| left | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> \| [QuerySnapshot](./firestore_lite.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType> | A snapshot to compare. | +| right | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> \| [QuerySnapshot](./firestore_lite.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType> | A snapshot to compare. | -## Type Aliases +Returns: -| Type Alias | Description | -| --- | --- | -| [AddPrefixToKeys](./firestore_lite.md#addprefixtokeys) | Returns a new map where every key is prefixed with the outer key appended to a dot. | -| [AggregateFieldType](./firestore_lite.md#aggregatefieldtype) | The union of all AggregateField types that are supported by Firestore. | -| [AggregateSpecData](./firestore_lite.md#aggregatespecdata) | A type whose keys are taken from an AggregateSpec, and whose values are the result of the aggregation performed by the corresponding AggregateField from the input AggregateSpec. | -| [AggregateType](./firestore_lite.md#aggregatetype) | Union type representing the aggregate type to be performed. | -| [ChildUpdateFields](./firestore_lite.md#childupdatefields) | Helper for calculating the nested fields for a given type T1. This is needed to distribute union types such as undefined | {...} (happens for optional props) or {a: A} | {b: B}.In this use case, V is used to distribute the union types of T[K] on Record, since T[K] is evaluated as an expression and not distributed.See https://www.typescriptlang.org/docs/handbook/advanced-types.html\#distributive-conditional-types | -| [FirestoreErrorCode](./firestore_lite.md#firestoreerrorcode) | The set of Firestore status codes. The codes are the same at the ones exposed by gRPC here: https://github.com/grpc/grpc/blob/master/doc/statuscodes.mdPossible values: - 'cancelled': The operation was cancelled (typically by the caller). - 'unknown': Unknown error or an error from a different error domain. - 'invalid-argument': Client specified an invalid argument. Note that this differs from 'failed-precondition'. 'invalid-argument' indicates arguments that are problematic regardless of the state of the system (e.g. an invalid field name). - 'deadline-exceeded': Deadline expired before operation could complete. For operations that change the state of the system, this error may be returned even if the operation has completed successfully. For example, a successful response from a server could have been delayed long enough for the deadline to expire. - 'not-found': Some requested document was not found. - 'already-exists': Some document that we attempted to create already exists. - 'permission-denied': The caller does not have permission to execute the specified operation. - 'resource-exhausted': Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space. - 'failed-precondition': Operation was rejected because the system is not in a state required for the operation's execution. - 'aborted': The operation was aborted, typically due to a concurrency issue like transaction aborts, etc. - 'out-of-range': Operation was attempted past the valid range. - 'unimplemented': Operation is not implemented or not supported/enabled. - 'internal': Internal errors. Means some invariants expected by underlying system has been broken. If you see one of these errors, something is very broken. - 'unavailable': The service is currently unavailable. This is most likely a transient condition and may be corrected by retrying with a backoff. - 'data-loss': Unrecoverable data loss or corruption. - 'unauthenticated': The request does not have valid authentication credentials for the operation. | -| [NestedUpdateFields](./firestore_lite.md#nestedupdatefields) | For each field (e.g. 'bar'), find all nested keys (e.g. {'bar.baz': T1, 'bar.qux': T2}). Intersect them together to make a single map containing all possible keys that are all marked as optional | -| [OrderByDirection](./firestore_lite.md#orderbydirection) | The direction of a [orderBy()](./firestore_.md#orderby_006d61f) clause is specified as 'desc' or 'asc' (descending or ascending). | -| [PartialWithFieldValue](./firestore_lite.md#partialwithfieldvalue) | Similar to TypeScript's Partial<T>, but allows nested fields to be omitted and FieldValues to be passed in as property values. | -| [Primitive](./firestore_lite.md#primitive) | Primitive types. | -| [QueryConstraintType](./firestore_lite.md#queryconstrainttype) | Describes the different query constraints available in this SDK. | -| [QueryFilterConstraint](./firestore_lite.md#queryfilterconstraint) | QueryFilterConstraint is a helper union type that represents [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) and [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). | -| [QueryNonFilterConstraint](./firestore_lite.md#querynonfilterconstraint) | QueryNonFilterConstraint is a helper union type that represents QueryConstraints which are used to narrow or order the set of documents, but that do not explicitly filter on a document field. QueryNonFilterConstraints are created by invoking [orderBy()](./firestore_.md#orderby_006d61f), [startAt()](./firestore_.md#startat_9a4477f), [startAfter()](./firestore_.md#startafter_9a4477f), [endBefore()](./firestore_.md#endbefore_9a4477f), [endAt()](./firestore_.md#endat_9a4477f), [limit()](./firestore_.md#limit_ec46c78) or [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the QueryConstraint. | -| [SetOptions](./firestore_lite.md#setoptions) | An options object that configures the behavior of [setDoc()](./firestore_lite.md#setdoc_ee215ad), and calls. These calls can be configured to perform granular merges instead of overwriting the target documents in their entirety by providing a SetOptions with merge: true. | -| [UnionToIntersection](./firestore_lite.md#uniontointersection) | Given a union type U = T1 | T2 | ..., returns an intersected type (T1 & T2 & ...).Uses distributive conditional types and inference from conditional types. This works because multiple candidates for the same type variable in contra-variant positions causes an intersection type to be inferred. https://www.typescriptlang.org/docs/handbook/advanced-types.html\#type-inference-in-conditional-types https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type | -| [UpdateData](./firestore_lite.md#updatedata) | Update data (for use with [updateDoc()](./firestore_.md#updatedoc_51a65e3)) that consists of field paths (e.g. 'foo' or 'foo.baz') mapped to values. Fields that contain dots reference nested fields within the document. FieldValues can be passed in as property values. | -| [WhereFilterOp](./firestore_lite.md#wherefilterop) | Filter conditions in a [where()](./firestore_.md#where_0fae4bf) clause are specified using the strings '&lt;', '&lt;=', '==', '!=', '&gt;=', '&gt;', 'array-contains', 'in', 'array-contains-any', and 'not-in'. | -| [WithFieldValue](./firestore_lite.md#withfieldvalue) | Allows FieldValues to be passed in as a property value while maintaining type safety. | +boolean -## function(app, ...) +true if the snapshots are equal. -### getFirestore(app) {:#getfirestore_cf608e1} +### strContains(left, substring) {:#strcontains_18eaf5d} -Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that checks if a string field contains a specified substring. + +```typescript +// Check if the 'description' field contains "example". +strContains("description", "example"); + +``` Signature: ```typescript -export declare function getFirestore(app: FirebaseApp): Firestore; +export declare function strContains(left: string, substring: string): StrContains; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) instance that the returned [Firestore](./firestore_.firestore.md#firestore_class) instance is associated with. | +| left | string | The name of the field containing the string. | +| substring | string | The substring to search for. A new representing the 'contains' comparison. | Returns: -[Firestore](./firestore_lite.firestore.md#firestore_class) - -The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. +[StrContains](./firestore_lite.strcontains.md#strcontains_class) -### getFirestore(app, databaseId) {:#getfirestore_48de6cb} +### strContains(left, substring) {:#strcontains_f0f1f2f} > This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. > -Returns the existing [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. +Creates an expression that checks if a string field contains a substring specified by an expression. + +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +strContains("description", Field.of("keyword")); + +``` Signature: ```typescript -export declare function getFirestore(app: FirebaseApp, databaseId: string): Firestore; +export declare function strContains(left: string, substring: Constant): StrContains; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) instance that the returned [Firestore](./firestore_.firestore.md#firestore_class) instance is associated with. | -| databaseId | string | The name of the database. | +| left | string | The name of the field containing the string. | +| substring | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. A new representing the 'contains' comparison. | Returns: -[Firestore](./firestore_lite.firestore.md#firestore_class) +[StrContains](./firestore_lite.strcontains.md#strcontains_class) -The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. +### strContains(left, substring) {:#strcontains_5fdbd29} -### initializeFirestore(app, settings) {:#initializefirestore_87c6318} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Initializes a new instance of Cloud Firestore with the provided settings. Can only be called before any other functions, including [getFirestore()](./firestore_.md#getfirestore). If the custom settings are empty, this function is equivalent to calling [getFirestore()](./firestore_.md#getfirestore). +Creates an expression that checks if a string expression contains a specified substring. + +```typescript +// Check if the 'description' field contains "example". +strContains(Field.of("description"), "example"); + +``` Signature: ```typescript -export declare function initializeFirestore(app: FirebaseApp, settings: Settings): Firestore; +export declare function strContains(left: Constant, substring: string): StrContains; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) with which the Firestore instance will be associated. | -| settings | [Settings](./firestore_lite.settings.md#settings_interface) | A settings object to configure the Firestore instance. | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to perform the comparison on. | +| substring | string | The substring to search for. A new representing the 'contains' comparison. | Returns: -[Firestore](./firestore_lite.firestore.md#firestore_class) - -A newly initialized `Firestore` instance. +[StrContains](./firestore_lite.strcontains.md#strcontains_class) -### initializeFirestore(app, settings, databaseId) {:#initializefirestore_37baaaf} +### strContains(left, substring) {:#strcontains_d9d749f} > This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. > -Initializes a new instance of Cloud Firestore with the provided settings. Can only be called before any other functions, including [getFirestore()](./firestore_.md#getfirestore). If the custom settings are empty, this function is equivalent to calling [getFirestore()](./firestore_.md#getfirestore). +Creates an expression that checks if a string expression contains a substring specified by another expression. + +```typescript +// Check if the 'description' field contains the value of the 'keyword' field. +strContains(Field.of("description"), Field.of("keyword")); + +``` Signature: ```typescript -export declare function initializeFirestore(app: FirebaseApp, settings: Settings, databaseId?: string): Firestore; +export declare function strContains(left: Constant, substring: Constant): StrContains; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) with which the Firestore instance will be associated. | -| settings | [Settings](./firestore_lite.settings.md#settings_interface) | A settings object to configure the Firestore instance. | -| databaseId | string | The name of the database. | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to perform the comparison on. | +| substring | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. A new representing the 'contains' comparison. | Returns: -[Firestore](./firestore_lite.firestore.md#firestore_class) +[StrContains](./firestore_lite.strcontains.md#strcontains_class) -A newly initialized `Firestore` instance. +### subtract(left, right) {:#subtract_be96f75} -## function(firestore, ...) +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -### collection(firestore, path, pathSegments) {:#collection_1eb4c23} +Creates an expression that subtracts two expressions. -Gets a `CollectionReference` instance that refers to the collection at the specified absolute path. +```typescript +// Subtract the 'discount' field from the 'price' field +subtract(Field.of("price"), Field.of("discount")); + +``` Signature: ```typescript -export declare function collection(firestore: Firestore, path: string, ...pathSegments: string[]): CollectionReference; +export declare function subtract(left: Constant, right: Constant): Subtract; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | A reference to the root Firestore instance. | -| path | string | A slash-separated path to a collection. | -| pathSegments | string\[\] | Additional path segments to apply relative to the first argument. | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to subtract from. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to subtract. A new representing the subtraction operation. | Returns: -[CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> +[Subtract](./firestore_lite.subtract.md#subtract_class) -The `CollectionReference` instance. +### subtract(left, right) {:#subtract_010ba9e} -#### Exceptions +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -If the final path has an even number of segments and does not point to a collection. +Creates an expression that subtracts a constant value from an expression. -### collectionGroup(firestore, collectionId) {:#collectiongroup_1838fc3} +```typescript +// Subtract the constant value 2 from the 'value' field +subtract(Field.of("value"), 2); -Creates and returns a new `Query` instance that includes all documents in the database that are contained in a collection or subcollection with the given `collectionId`. +``` Signature: ```typescript -export declare function collectionGroup(firestore: Firestore, collectionId: string): Query; +export declare function subtract(left: Constant, right: any): Subtract; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | A reference to the root Firestore instance. | -| collectionId | string | Identifies the collections to query over. Every collection or subcollection with this ID as the last segment of its path will be included. Cannot contain a slash. | +| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to subtract from. | +| right | any | The constant value to subtract. A new representing the subtraction operation. | Returns: -[Query](./firestore_lite.query.md#query_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> +[Subtract](./firestore_lite.subtract.md#subtract_class) -The created `Query`. +### subtract(left, right) {:#subtract_674c63f} -### connectFirestoreEmulator(firestore, host, port, options) {:#connectfirestoreemulator_7c247cd} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Modify this instance to communicate with the Cloud Firestore emulator. +Creates an expression that subtracts an expression from a field's value. -Note: This must be called before this instance has been used to do any operations. +```typescript +// Subtract the 'discount' field from the 'price' field +subtract("price", Field.of("discount")); + +``` Signature: ```typescript -export declare function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: { - mockUserToken?: EmulatorMockTokenOptions | string; -}): void; +export declare function subtract(left: string, right: Constant): Subtract; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | The Firestore instance to configure to connect to the emulator. | -| host | string | the emulator host (ex: localhost). | -| port | number | the emulator port (ex: 9000). | -| options | { mockUserToken?: [EmulatorMockTokenOptions](./util.md#emulatormocktokenoptions) \| string; } | | +| left | string | The field name to subtract from. | +| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to subtract. A new representing the subtraction operation. | Returns: -void +[Subtract](./firestore_lite.subtract.md#subtract_class) -### doc(firestore, path, pathSegments) {:#doc_1eb4c23} +### subtract(left, right) {:#subtract_1f46a76} -Gets a `DocumentReference` instance that refers to the document at the specified absolute path. +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that subtracts a constant value from a field's value. + +```typescript +// Subtract 20 from the value of the 'total' field +subtract("total", 20); + +``` Signature: ```typescript -export declare function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference; +export declare function subtract(left: string, right: any): Subtract; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | A reference to the root Firestore instance. | -| path | string | A slash-separated path to a document. | -| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | +| left | string | The field name to subtract from. | +| right | any | The constant value to subtract. A new representing the subtraction operation. | Returns: -[DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> +[Subtract](./firestore_lite.subtract.md#subtract_class) -The `DocumentReference` instance. +### xor(left, right) {:#xor_eba7e36} -#### Exceptions +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -If the final path has an odd number of segments and does not point to a document. +Creates an expression that performs a logical 'XOR' (exclusive OR) operation on multiple filter conditions. -### runTransaction(firestore, updateFunction, options) {:#runtransaction_6f03ec4} +```typescript +// Check if only one of the conditions is true: 'age' greater than 18, 'city' is "London", +// or 'status' is "active". +const condition = xor( + gt("age", 18), + eq("city", "London"), + eq("status", "active")); -Executes the given `updateFunction` and then attempts to commit the changes applied within the transaction. If any document read within the transaction has changed, Cloud Firestore retries the `updateFunction`. If it fails to commit after 5 attempts, the transaction fails. +``` -The maximum number of writes allowed in a single transaction is 500. +Signature: + +```typescript +export declare function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [FilterExpr](./firestore_lite.md#filterexpr) | The first filter condition. | +| right | [FilterExpr](./firestore_lite.md#filterexpr)\[\] | Additional filter conditions to 'XOR' together. A new representing the logical 'XOR' operation. | + +Returns: + +[Xor](./firestore_lite.xor.md#xor_class) + +## function(limit, ...) + +### limit(limit) {:#limit_ec46c78} + +Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the first matching documents. Signature: ```typescript -export declare function runTransaction(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise, options?: TransactionOptions): Promise; +export declare function limit(limit: number): QueryLimitConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | A reference to the Firestore database to run this transaction against. | -| updateFunction | (transaction: [Transaction](./firestore_lite.transaction.md#transaction_class)) => Promise<T> | The function to execute within the transaction context. | -| options | [TransactionOptions](./firestore_lite.transactionoptions.md#transactionoptions_interface) | An options object to configure maximum number of attempts to commit. | +| limit | number | The maximum number of items to return. | Returns: -Promise<T> +[QueryLimitConstraint](./firestore_lite.querylimitconstraint.md#querylimitconstraint_class) -If the transaction completed successfully or was explicitly aborted (the `updateFunction` returned a failed promise), the promise returned by the `updateFunction `is returned here. Otherwise, if the transaction failed, a rejected promise with the corresponding failure error is returned. +The created [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class). -### terminate(firestore) {:#terminate_231a8e0} +### limitToLast(limit) {:#limittolast_ec46c78} -Terminates the provided `Firestore` instance. +Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the last matching documents. -After calling `terminate()` only the `clearIndexedDbPersistence()` functions may be used. Any other function will throw a `FirestoreError`. Termination does not cancel any pending writes, and any promises that are awaiting a response from the server will not be resolved. +You must specify at least one `orderBy` clause for `limitToLast` queries, otherwise an exception will be thrown during execution. -To restart after termination, create a new instance of `Firestore` with [getFirestore()](./firestore_.md#getfirestore). +Signature: -Note: Under normal circumstances, calling `terminate()` is not required. This function is useful only when you want to force this instance to release all of its resources or in combination with [clearIndexedDbPersistence()](./firestore_.md#clearindexeddbpersistence_231a8e0) to ensure that all local state is destroyed between test runs. +```typescript +export declare function limitToLast(limit: number): QueryLimitConstraint; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| limit | number | The maximum number of items to return. | + +Returns: + +[QueryLimitConstraint](./firestore_lite.querylimitconstraint.md#querylimitconstraint_class) + +The created [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class). + +## function(logLevel, ...) + +### setLogLevel(logLevel) {:#setloglevel_d02fda2} + +Sets the verbosity of Cloud Firestore logs (debug, error, or silent). Signature: ```typescript -export declare function terminate(firestore: Firestore): Promise; +export declare function setLogLevel(logLevel: LogLevel): void; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | The Firestore instance to terminate. | +| logLevel | LogLevel | The verbosity you set for activity and error logging. Can be any of the following values:

  • debug for the most verbose logging level, primarily for debugging.
  • error to log errors only.
  • silent to turn off logging.
| Returns: -Promise<void> +void -A `Promise` that is resolved when the instance has been successfully terminated. +## function(mapExpr, ...) -### writeBatch(firestore) {:#writebatch_231a8e0} +### mapGet(mapExpr, subField) {:#mapget_9715f90} -Creates a write batch, used for performing multiple writes as a single atomic operation. The maximum number of writes allowed in a single WriteBatch is 500. +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -The result of these writes will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the write fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. +Accesses a value from a map (object) expression using the provided key. + +```typescript +// Get the 'city' value from the 'address' map field +mapGet(Field.of("address"), "city"); + +``` Signature: ```typescript -export declare function writeBatch(firestore: Firestore): WriteBatch; +export declare function mapGet(mapExpr: Constant, subField: string): MapGet; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | | +| mapExpr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the map. | +| subField | string | The key to access in the map. A new representing the value associated with the given key in the map. | Returns: -[WriteBatch](./firestore_lite.writebatch.md#writebatch_class) +[MapGet](./firestore_lite.mapget.md#mapget_class) -A `WriteBatch` that can be used to atomically execute multiple writes. +## function(mapField, ...) -## function() +### mapGet(mapField, subField) {:#mapget_b37bbb6} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Accesses a value from a map (object) field using the provided key. + +```typescript +// Get the 'city' value from the 'address' map field +mapGet("address", "city"); + +``` + +Signature: + +```typescript +export declare function mapGet(mapField: string, subField: string): MapGet; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| mapField | string | The field name of the map field. | +| subField | string | The key to access in the map. A new representing the value associated with the given key in the map. | -### count() {:#count} +Returns: -Create an AggregateField object that can be used to compute the count of documents in the result set of a query. +[MapGet](./firestore_lite.mapget.md#mapget_class) -Signature: +## function(n, ...) -```typescript -export declare function count(): AggregateField; -``` -Returns: +### increment(n) {:#increment_5685735} -[AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<number> +Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to increment the field's current value by the given value. -### deleteField() {:#deletefield} +If either the operand or the current field value uses floating point precision, all arithmetic follows IEEE 754 semantics. If both values are integers, values outside of JavaScript's safe number range (`Number.MIN_SAFE_INTEGER` to `Number.MAX_SAFE_INTEGER`) are also subject to precision loss. Furthermore, once processed by the Firestore backend, all integer operations are capped between -2^63 and 2^63-1. -Returns a sentinel for use with [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) or [setDoc()](./firestore_lite.md#setdoc_ee215ad) with `{merge: true}` to mark a field for deletion. +If the current field value is not of type `number`, or if the field does not yet exist, the transformation sets the field to the given value. Signature: ```typescript -export declare function deleteField(): FieldValue; +export declare function increment(n: number): FieldValue; ``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| n | number | The value to increment by. | + Returns: [FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) -### documentId() {:#documentid} +The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()` -Returns a special sentinel `FieldPath` to refer to the ID of a document. It can be used in queries to sort or filter by the document ID. +## function(name, ...) -Signature: +### genericFunction(name, params) {:#genericfunction_b886545} -```typescript -export declare function documentId(): FieldPath; -``` -Returns: +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -[FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) +Creates functions that work on the backend but do not exist in the SDK yet. -### getFirestore() {:#getfirestore} +```typescript +// Call a user defined function named "myFunc" with the arguments 10 and 20 +// This is the same of the 'sum(Field.of("price"))', if it did not exist +genericFunction("sum", [Field.of("price")]); -Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. +``` Signature: ```typescript -export declare function getFirestore(): Firestore; +export declare function genericFunction(name: string, params: Constant[]): FirestoreFunction; ``` -Returns: - -[Firestore](./firestore_lite.firestore.md#firestore_class) - -The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. - -### serverTimestamp() {:#servertimestamp} -Returns a sentinel used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) to include a server-generated timestamp in the written data. +#### Parameters -Signature: +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | The name of the user defined function. | +| params | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The arguments to pass to the function. A new representing the function call. | -```typescript -export declare function serverTimestamp(): FieldValue; -``` Returns: -[FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) +[FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) -## function(databaseId, ...) +## function(pipeline, ...) -### getFirestore(databaseId) {:#getfirestore_53dc891} +### execute(pipeline) {:#execute_86486e6} > This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. > -Returns the existing [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. +Modular API for console experimentation. Signature: ```typescript -export declare function getFirestore(databaseId: string): Firestore; +export declare function execute(pipeline: Pipeline): Promise>>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| databaseId | string | The name of the database. | +| pipeline | [Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> | Execute this pipeline. | Returns: -[Firestore](./firestore_lite.firestore.md#firestore_class) +Promise<Array<[PipelineResult](./firestore_lite.pipelineresult.md#pipelineresult_class)<AppModelType>>> -The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. +## function(query, ...) -## function(elements, ...) +### getAggregate(query, aggregateSpec) {:#getaggregate_2073a74} -### arrayRemove(elements) {:#arrayremove_7d853aa} +Calculates the specified aggregations over the documents in the result set of the given query without actually downloading the documents. -Returns a special value that can be used with [setDoc()](./firestore_.md#setdoc_ee215ad) or that tells the server to remove the given elements from any array value that already exists on the server. All instances of each element specified will be removed from the array. If the field being modified is not already an array it will be overwritten with an empty array. +Using this function to perform aggregations is efficient because only the final aggregation values, not the documents' data, are downloaded. This function can perform aggregations of the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). Signature: ```typescript -export declare function arrayRemove(...elements: unknown[]): FieldValue; +export declare function getAggregate(query: Query, aggregateSpec: AggregateSpecType): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| elements | unknown\[\] | The elements to remove from the array. | +| query | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | The query whose result set is aggregated over. | +| aggregateSpec | AggregateSpecType | An AggregateSpec object that specifies the aggregates to perform over the result set. The AggregateSpec specifies aliases for each aggregate, which can be used to retrieve the aggregate result. | Returns: -[FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) +Promise<[AggregateQuerySnapshot](./firestore_lite.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType>> -The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()` +### Example -### arrayUnion(elements) {:#arrayunion_7d853aa} -Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to union the given elements with any array value that already exists on the server. Each specified element that doesn't already exist in the array will be added to the end. If the field being modified is not already an array it will be overwritten with an array containing exactly the specified elements. +```typescript +const aggregateSnapshot = await getAggregate(query, { + countOfDocs: count(), + totalHours: sum('hours'), + averageScore: average('score') +}); + +const countOfDocs: number = aggregateSnapshot.data().countOfDocs; +const totalHours: number = aggregateSnapshot.data().totalHours; +const averageScore: number | null = aggregateSnapshot.data().averageScore; + +``` + +### getCount(query) {:#getcount_4e56953} + +Calculates the number of documents in the result set of the given query without actually downloading the documents. + +Using this function to count the documents is efficient because only the final count, not the documents' data, is downloaded. This function can count the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). Signature: ```typescript -export declare function arrayUnion(...elements: unknown[]): FieldValue; +export declare function getCount(query: Query): Promise; +}, AppModelType, DbModelType>>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| elements | unknown\[\] | The elements to union into the array. | +| query | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | The query whose result set size is calculated. | Returns: -[FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) +Promise<[AggregateQuerySnapshot](./firestore_lite.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<{ count: [AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<number>; }, AppModelType, DbModelType>> -The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()`. +A Promise that will be resolved with the count; the count can be retrieved from `snapshot.data().count`, where `snapshot` is the `AggregateQuerySnapshot` to which the returned Promise resolves. -## function(field, ...) +### getDocs(query) {:#getdocs_4e56953} -### average(field) {:#average_aacc3a9} +Executes the query and returns the results as a [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class). -Create an AggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query. +All queries are executed directly by the server, even if the query was previously executed. Recent modifications are only reflected in the retrieved results if they have already been applied by the backend. If the client is offline, the operation fails. To see previously cached result and local modifications, use the full Firestore SDK. Signature: ```typescript -export declare function average(field: string | FieldPath): AggregateField; +export declare function getDocs(query: Query): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| field | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | Specifies the field to average across the result set. | +| query | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | The Query to execute. | Returns: -[AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<number \| null> +Promise<[QuerySnapshot](./firestore_lite.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>> -### sum(field) {:#sum_aacc3a9} +A Promise that will be resolved with the results of the query. -Create an AggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query. +### pipeline(query) {:#pipeline_20b2416} + +Experimental Modular API for console testing. Signature: ```typescript -export declare function sum(field: string | FieldPath): AggregateField; +export declare function pipeline(query: Query): Pipeline; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| field | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | Specifies the field to sum across the result set. | +| query | [Query](./firestore_lite.query.md#query_class) | | Returns: -[AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<number> - -## function(fieldPath, ...) - -### orderBy(fieldPath, directionStr) {:#orderby_006d61f} +[Pipeline](./firestore_lite.pipeline.md#pipeline_class) -Creates a [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) that sorts the query result by the specified field, optionally in descending order instead of ascending. +### query(query, compositeFilter, queryConstraints) {:#query_9f7b0f4} -Note: Documents that do not contain the specified field will not be present in the query result. +Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. Signature: ```typescript -export declare function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryOrderByConstraint; +export declare function query(query: Query, compositeFilter: QueryCompositeFilterConstraint, ...queryConstraints: QueryNonFilterConstraint[]): Query; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| fieldPath | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | The field to sort by. | -| directionStr | [OrderByDirection](./firestore_lite.md#orderbydirection) | Optional direction to sort by ('asc' or 'desc'). If not specified, order will be ascending. | +| query | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | The [Query](./firestore_.query.md#query_class) instance to use as a base for the new constraints. | +| compositeFilter | [QueryCompositeFilterConstraint](./firestore_lite.querycompositefilterconstraint.md#querycompositefilterconstraint_class) | The [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) to apply. Create [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) using or . | +| queryConstraints | [QueryNonFilterConstraint](./firestore_lite.md#querynonfilterconstraint)\[\] | Additional [QueryNonFilterConstraint](./firestore_.md#querynonfilterconstraint)s to apply (e.g. [orderBy()](./firestore_.md#orderby_006d61f), [limit()](./firestore_.md#limit_ec46c78)). | Returns: -[QueryOrderByConstraint](./firestore_lite.queryorderbyconstraint.md#queryorderbyconstraint_class) +[Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> -The created [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class). +#### Exceptions -### where(fieldPath, opStr, value) {:#where_0fae4bf} +if any of the provided query constraints cannot be combined with the existing or new constraints. -Creates a [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) that enforces that documents must contain the specified field and that the value should satisfy the relation constraint provided. +### query(query, queryConstraints) {:#query_0f46da1} + +Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. Signature: ```typescript -export declare function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryFieldFilterConstraint; +export declare function query(query: Query, ...queryConstraints: QueryConstraint[]): Query; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| fieldPath | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | The path to compare | -| opStr | [WhereFilterOp](./firestore_lite.md#wherefilterop) | The operation string (e.g "&lt;", "&lt;=", "==", "&lt;", "&lt;=", "!="). | -| value | unknown | The value for comparison | +| query | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | The [Query](./firestore_.query.md#query_class) instance to use as a base for the new constraints. | +| queryConstraints | [QueryConstraint](./firestore_lite.queryconstraint.md#queryconstraint_class)\[\] | The list of [QueryConstraint](./firestore_.queryconstraint.md#queryconstraint_class)s to apply. | Returns: -[QueryFieldFilterConstraint](./firestore_lite.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) +[Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> -The created [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class). +#### Exceptions -## function(fieldValues, ...) +if any of the provided query constraints cannot be combined with the existing or new constraints. -### endAt(fieldValues) {:#endat_8b2f2c8} +## function(queryConstraints, ...) -Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. +### and(queryConstraints) {:#and_e72c712} + +Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a conjunction of the given filter constraints. A conjunction filter includes a document if it satisfies all of the given filters. Signature: ```typescript -export declare function endAt(...fieldValues: unknown[]): QueryEndAtConstraint; +export declare function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| fieldValues | unknown\[\] | The field values to end this query at, in order of the query's order by. | +| queryConstraints | [QueryFilterConstraint](./firestore_lite.md#queryfilterconstraint)\[\] | Optional. The list of [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)s to perform a conjunction for. These must be created with calls to [where()](./firestore_.md#where_0fae4bf), , or . | Returns: -[QueryEndAtConstraint](./firestore_lite.queryendatconstraint.md#queryendatconstraint_class) +[QueryCompositeFilterConstraint](./firestore_lite.querycompositefilterconstraint.md#querycompositefilterconstraint_class) -A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` +The newly created [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). -### endBefore(fieldValues) {:#endbefore_8b2f2c8} +### or(queryConstraints) {:#or_e72c712} -Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. +Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a disjunction of the given filter constraints. A disjunction filter includes a document if it satisfies any of the given filters. Signature: ```typescript -export declare function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint; +export declare function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| fieldValues | unknown\[\] | The field values to end this query before, in order of the query's order by. | +| queryConstraints | [QueryFilterConstraint](./firestore_lite.md#queryfilterconstraint)\[\] | Optional. The list of [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)s to perform a disjunction for. These must be created with calls to [where()](./firestore_.md#where_0fae4bf), , or . | Returns: -[QueryEndAtConstraint](./firestore_lite.queryendatconstraint.md#queryendatconstraint_class) +[QueryCompositeFilterConstraint](./firestore_lite.querycompositefilterconstraint.md#querycompositefilterconstraint_class) -A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` +The newly created [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). -### startAfter(fieldValues) {:#startafter_8b2f2c8} +## function(reference, ...) -Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. +### addDoc(reference, data) {:#adddoc_6e783ff} + +Add a new document to specified `CollectionReference` with the given data, assigning it a document ID automatically. + +The result of this write will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the write fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. Signature: ```typescript -export declare function startAfter(...fieldValues: unknown[]): QueryStartAtConstraint; +export declare function addDoc(reference: CollectionReference, data: WithFieldValue): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| fieldValues | unknown\[\] | The field values to start this query after, in order of the query's order by. | +| reference | [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to the collection to add this document to. | +| data | [WithFieldValue](./firestore_lite.md#withfieldvalue)<AppModelType> | An Object containing the data for the new document. | Returns: -[QueryStartAtConstraint](./firestore_lite.querystartatconstraint.md#querystartatconstraint_class) +Promise<[DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType>> -A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()` +A `Promise` resolved with a `DocumentReference` pointing to the newly created document after it has been written to the backend. -### startAt(fieldValues) {:#startat_8b2f2c8} +#### Exceptions -Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. +Error - If the provided input is not a valid Firestore document. + +### collection(reference, path, pathSegments) {:#collection_568f98d} + +Gets a `CollectionReference` instance that refers to a subcollection of `reference` at the specified relative path. Signature: ```typescript -export declare function startAt(...fieldValues: unknown[]): QueryStartAtConstraint; +export declare function collection(reference: CollectionReference, path: string, ...pathSegments: string[]): CollectionReference; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| fieldValues | unknown\[\] | The field values to start this query at, in order of the query's order by. | +| reference | [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to a collection. | +| path | string | A slash-separated path to a collection. | +| pathSegments | string\[\] | Additional path segments to apply relative to the first argument. | Returns: -[QueryStartAtConstraint](./firestore_lite.querystartatconstraint.md#querystartatconstraint_class) +[CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> -A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()`. +The `CollectionReference` instance. -## function(left, ...) +#### Exceptions -### aggregateFieldEqual(left, right) {:#aggregatefieldequal_e80a2b2} +If the final path has an even number of segments and does not point to a collection. -Compares two 'AggregateField\` instances for equality. +### collection(reference, path, pathSegments) {:#collection_70b4396} + +Gets a `CollectionReference` instance that refers to a subcollection of `reference` at the specified relative path. Signature: ```typescript -export declare function aggregateFieldEqual(left: AggregateField, right: AggregateField): boolean; +export declare function collection(reference: DocumentReference, path: string, ...pathSegments: string[]): CollectionReference; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<unknown> | Compare this AggregateField to the right. | -| right | [AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<unknown> | Compare this AggregateField to the left. | +| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to a Firestore document. | +| path | string | A slash-separated path to a collection. | +| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | Returns: -boolean +[CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> -### aggregateQuerySnapshotEqual(left, right) {:#aggregatequerysnapshotequal_1529a20} +The `CollectionReference` instance. -Compares two `AggregateQuerySnapshot` instances for equality. +#### Exceptions -Two `AggregateQuerySnapshot` instances are considered "equal" if they have underlying queries that compare equal, and the same data. +If the final path has an even number of segments and does not point to a collection. + +### deleteDoc(reference) {:#deletedoc_4569087} + +Deletes the document referred to by the specified `DocumentReference`. + +The deletion will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the delete fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. Signature: ```typescript -export declare function aggregateQuerySnapshotEqual(left: AggregateQuerySnapshot, right: AggregateQuerySnapshot): boolean; +export declare function deleteDoc(reference: DocumentReference): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [AggregateQuerySnapshot](./firestore_lite.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType> | The first AggregateQuerySnapshot to compare. | -| right | [AggregateQuerySnapshot](./firestore_lite.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType> | The second AggregateQuerySnapshot to compare. | +| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to delete. | Returns: -boolean +Promise<void> -`true` if the objects are "equal", as defined above, or `false` otherwise. +A `Promise` resolved once the document has been successfully deleted from the backend. -### queryEqual(left, right) {:#queryequal_7a1f045} +### doc(reference, path, pathSegments) {:#doc_568f98d} -Returns true if the provided queries point to the same collection and apply the same constraints. +Gets a `DocumentReference` instance that refers to a document within `reference` at the specified relative path. If no path is specified, an automatically-generated unique ID will be used for the returned `DocumentReference`. Signature: ```typescript -export declare function queryEqual(left: Query, right: Query): boolean; +export declare function doc(reference: CollectionReference, path?: string, ...pathSegments: string[]): DocumentReference; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | A Query to compare. | -| right | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | A Query to compare. | +| reference | [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to a collection. | +| path | string | A slash-separated path to a document. Has to be omitted to use auto-generated IDs. | +| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | Returns: -boolean +[DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> -true if the references point to the same location in the same Firestore database. +The `DocumentReference` instance. -### refEqual(left, right) {:#refequal_598b780} +#### Exceptions -Returns true if the provided references are equal. +If the final path has an odd number of segments and does not point to a document. + +### doc(reference, path, pathSegments) {:#doc_70b4396} + +Gets a `DocumentReference` instance that refers to a document within `reference` at the specified relative path. Signature: ```typescript -export declare function refEqual(left: DocumentReference | CollectionReference, right: DocumentReference | CollectionReference): boolean; +export declare function doc(reference: DocumentReference, path: string, ...pathSegments: string[]): DocumentReference; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> \| [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to compare. | -| right | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> \| [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to compare. | +| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to a Firestore document. | +| path | string | A slash-separated path to a document. | +| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | Returns: -boolean +[DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> -true if the references point to the same location in the same Firestore database. +The `DocumentReference` instance. -### snapshotEqual(left, right) {:#snapshotequal_5109204} +#### Exceptions -Returns true if the provided snapshots are equal. +If the final path has an odd number of segments and does not point to a document. + +### getDoc(reference) {:#getdoc_4569087} + +Reads the document referred to by the specified document reference. + +All documents are directly fetched from the server, even if the document was previously read or modified. Recent modifications are only reflected in the retrieved `DocumentSnapshot` if they have already been applied by the backend. If the client is offline, the read fails. If you like to use caching or see local modifications, please use the full Firestore SDK. Signature: ```typescript -export declare function snapshotEqual(left: DocumentSnapshot | QuerySnapshot, right: DocumentSnapshot | QuerySnapshot): boolean; +export declare function getDoc(reference: DocumentReference): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> \| [QuerySnapshot](./firestore_lite.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType> | A snapshot to compare. | -| right | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> \| [QuerySnapshot](./firestore_lite.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType> | A snapshot to compare. | +| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | The reference of the document to fetch. | Returns: -boolean +Promise<[DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>> -true if the snapshots are equal. +A Promise resolved with a `DocumentSnapshot` containing the current document contents. -## function(limit, ...) +### setDoc(reference, data) {:#setdoc_ee215ad} -### limit(limit) {:#limit_ec46c78} +Writes to the document referred to by the specified `DocumentReference`. If the document does not yet exist, it will be created. -Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the first matching documents. +The result of this write will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the write fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. Signature: ```typescript -export declare function limit(limit: number): QueryLimitConstraint; +export declare function setDoc(reference: DocumentReference, data: WithFieldValue): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| limit | number | The maximum number of items to return. | +| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to write. | +| data | [WithFieldValue](./firestore_lite.md#withfieldvalue)<AppModelType> | A map of the fields and values for the document. | Returns: -[QueryLimitConstraint](./firestore_lite.querylimitconstraint.md#querylimitconstraint_class) +Promise<void> -The created [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class). +A `Promise` resolved once the data has been successfully written to the backend. -### limitToLast(limit) {:#limittolast_ec46c78} +#### Exceptions -Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the last matching documents. +Error - If the provided input is not a valid Firestore document. -You must specify at least one `orderBy` clause for `limitToLast` queries, otherwise an exception will be thrown during execution. +### setDoc(reference, data, options) {:#setdoc_ff80739} + +Writes to the document referred to by the specified `DocumentReference`. If the document does not yet exist, it will be created. If you provide `merge` or `mergeFields`, the provided data can be merged into an existing document. + +The result of this write will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the write fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. Signature: ```typescript -export declare function limitToLast(limit: number): QueryLimitConstraint; +export declare function setDoc(reference: DocumentReference, data: PartialWithFieldValue, options: SetOptions): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| limit | number | The maximum number of items to return. | +| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to write. | +| data | [PartialWithFieldValue](./firestore_lite.md#partialwithfieldvalue)<AppModelType> | A map of the fields and values for the document. | +| options | [SetOptions](./firestore_lite.md#setoptions) | An object to configure the set behavior. | Returns: -[QueryLimitConstraint](./firestore_lite.querylimitconstraint.md#querylimitconstraint_class) +Promise<void> -The created [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class). +A `Promise` resolved once the data has been successfully written to the backend. -## function(logLevel, ...) +#### Exceptions -### setLogLevel(logLevel) {:#setloglevel_d02fda2} +Error - If the provided input is not a valid Firestore document. -Sets the verbosity of Cloud Firestore logs (debug, error, or silent). +### updateDoc(reference, data) {:#updatedoc_51a65e3} + +Updates fields in the document referred to by the specified `DocumentReference`. The update will fail if applied to a document that does not exist. + +The result of this update will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the update fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. Signature: ```typescript -export declare function setLogLevel(logLevel: LogLevel): void; +export declare function updateDoc(reference: DocumentReference, data: UpdateData): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| logLevel | LogLevel | The verbosity you set for activity and error logging. Can be any of the following values:
  • debug for the most verbose logging level, primarily for debugging.
  • error to log errors only.
  • silent to turn off logging.
| +| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to update. | +| data | [UpdateData](./firestore_lite.md#updatedata)<DbModelType> | An object containing the fields and values with which to update the document. Fields can contain dots to reference nested fields within the document. | Returns: -void +Promise<void> -## function(n, ...) +A `Promise` resolved once the data has been successfully written to the backend. -### increment(n) {:#increment_5685735} +#### Exceptions -Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to increment the field's current value by the given value. +Error - If the provided input is not valid Firestore data. -If either the operand or the current field value uses floating point precision, all arithmetic follows IEEE 754 semantics. If both values are integers, values outside of JavaScript's safe number range (`Number.MIN_SAFE_INTEGER` to `Number.MAX_SAFE_INTEGER`) are also subject to precision loss. Furthermore, once processed by the Firestore backend, all integer operations are capped between -2^63 and 2^63-1. +### updateDoc(reference, field, value, moreFieldsAndValues) {:#updatedoc_7c28659} -If the current field value is not of type `number`, or if the field does not yet exist, the transformation sets the field to the given value. +Updates fields in the document referred to by the specified `DocumentReference` The update will fail if applied to a document that does not exist. + +Nested fields can be updated by providing dot-separated field path strings or by providing `FieldPath` objects. + +The result of this update will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the update fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. Signature: ```typescript -export declare function increment(n: number): FieldValue; +export declare function updateDoc(reference: DocumentReference, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| n | number | The value to increment by. | +| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to update. | +| field | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | The first field to update. | +| value | unknown | The first value. | +| moreFieldsAndValues | unknown\[\] | Additional key value pairs. | Returns: -[FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) +Promise<void> -The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()` +A `Promise` resolved once the data has been successfully written to the backend. -## function(query, ...) +#### Exceptions -### getAggregate(query, aggregateSpec) {:#getaggregate_2073a74} +Error - If the provided input is not valid Firestore data. -Calculates the specified aggregations over the documents in the result set of the given query without actually downloading the documents. +## function(snapshot, ...) -Using this function to perform aggregations is efficient because only the final aggregation values, not the documents' data, are downloaded. This function can perform aggregations of the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). +### endAt(snapshot) {:#endat_9a4477f} + +Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided document (inclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. Signature: ```typescript -export declare function getAggregate(query: Query, aggregateSpec: AggregateSpecType): Promise>; +export declare function endAt(snapshot: DocumentSnapshot): QueryEndAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | The query whose result set is aggregated over. | -| aggregateSpec | AggregateSpecType | An AggregateSpec object that specifies the aggregates to perform over the result set. The AggregateSpec specifies aliases for each aggregate, which can be used to retrieve the aggregate result. | +| snapshot | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to end at. | Returns: -Promise<[AggregateQuerySnapshot](./firestore_lite.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType>> +[QueryEndAtConstraint](./firestore_lite.queryendatconstraint.md#queryendatconstraint_class) -### Example +A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` +### endBefore(snapshot) {:#endbefore_9a4477f} -```typescript -const aggregateSnapshot = await getAggregate(query, { - countOfDocs: count(), - totalHours: sum('hours'), - averageScore: average('score') -}); +Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided document (exclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. -const countOfDocs: number = aggregateSnapshot.data().countOfDocs; -const totalHours: number = aggregateSnapshot.data().totalHours; -const averageScore: number | null = aggregateSnapshot.data().averageScore; +Signature: +```typescript +export declare function endBefore(snapshot: DocumentSnapshot): QueryEndAtConstraint; ``` -### getCount(query) {:#getcount_4e56953} +#### Parameters -Calculates the number of documents in the result set of the given query without actually downloading the documents. +| Parameter | Type | Description | +| --- | --- | --- | +| snapshot | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to end before. | -Using this function to count the documents is efficient because only the final count, not the documents' data, is downloaded. This function can count the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). +Returns: + +[QueryEndAtConstraint](./firestore_lite.queryendatconstraint.md#queryendatconstraint_class) + +A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` + +### startAfter(snapshot) {:#startafter_9a4477f} + +Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided document (exclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. Signature: ```typescript -export declare function getCount(query: Query): Promise; -}, AppModelType, DbModelType>>; +export declare function startAfter(snapshot: DocumentSnapshot): QueryStartAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | The query whose result set size is calculated. | +| snapshot | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to start after. | Returns: -Promise<[AggregateQuerySnapshot](./firestore_lite.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<{ count: [AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<number>; }, AppModelType, DbModelType>> - -A Promise that will be resolved with the count; the count can be retrieved from `snapshot.data().count`, where `snapshot` is the `AggregateQuerySnapshot` to which the returned Promise resolves. +[QueryStartAtConstraint](./firestore_lite.querystartatconstraint.md#querystartatconstraint_class) -### getDocs(query) {:#getdocs_4e56953} +A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()` -Executes the query and returns the results as a [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class). +### startAt(snapshot) {:#startat_9a4477f} -All queries are executed directly by the server, even if the query was previously executed. Recent modifications are only reflected in the retrieved results if they have already been applied by the backend. If the client is offline, the operation fails. To see previously cached result and local modifications, use the full Firestore SDK. +Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided document (inclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the `orderBy` of this query. Signature: ```typescript -export declare function getDocs(query: Query): Promise>; +export declare function startAt(snapshot: DocumentSnapshot): QueryStartAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | The Query to execute. | +| snapshot | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to start at. | Returns: -Promise<[QuerySnapshot](./firestore_lite.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>> +[QueryStartAtConstraint](./firestore_lite.querystartatconstraint.md#querystartatconstraint_class) -A Promise that will be resolved with the results of the query. +A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()`. -### query(query, compositeFilter, queryConstraints) {:#query_9f7b0f4} +## function(timestamp, ...) -Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. +### timestampAdd(timestamp, unit, amount) {:#timestampadd_87db576} + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Creates an expression that adds a specified amount of time to a timestamp. + +```typescript +// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. +timestampAdd(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); + +``` Signature: ```typescript -export declare function query(query: Query, compositeFilter: QueryCompositeFilterConstraint, ...queryConstraints: QueryNonFilterConstraint[]): Query; +export declare function timestampAdd(timestamp: Constant, unit: Constant, amount: Constant): TimestampAdd; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | The [Query](./firestore_.query.md#query_class) instance to use as a base for the new constraints. | -| compositeFilter | [QueryCompositeFilterConstraint](./firestore_lite.querycompositefilterconstraint.md#querycompositefilterconstraint_class) | The [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) to apply. Create [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) using [and()](./firestore_.md#and_e72c712) or [or()](./firestore_.md#or_e72c712). | -| queryConstraints | [QueryNonFilterConstraint](./firestore_lite.md#querynonfilterconstraint)\[\] | Additional [QueryNonFilterConstraint](./firestore_.md#querynonfilterconstraint)s to apply (e.g. [orderBy()](./firestore_.md#orderby_006d61f), [limit()](./firestore_.md#limit_ec46c78)). | +| timestamp | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the timestamp. | +| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | Returns: -[Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> +[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) -#### Exceptions +### timestampAdd(timestamp, unit, amount) {:#timestampadd_46a2d7e} -if any of the provided query constraints cannot be combined with the existing or new constraints. +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -### query(query, queryConstraints) {:#query_0f46da1} +Creates an expression that adds a specified amount of time to a timestamp. -Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. +```typescript +// Add 1 day to the 'timestamp' field. +timestampAdd(Field.of("timestamp"), "day", 1); + +``` Signature: ```typescript -export declare function query(query: Query, ...queryConstraints: QueryConstraint[]): Query; +export declare function timestampAdd(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | The [Query](./firestore_.query.md#query_class) instance to use as a base for the new constraints. | -| queryConstraints | [QueryConstraint](./firestore_lite.queryconstraint.md#queryconstraint_class)\[\] | The list of [QueryConstraint](./firestore_.queryconstraint.md#queryconstraint_class)s to apply. | +| timestamp | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the timestamp. | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | +| amount | number | The amount of time to add. A new representing the resulting timestamp. | Returns: -[Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> +[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) -#### Exceptions +### timestampSub(timestamp, unit, amount) {:#timestampsub_87db576} -if any of the provided query constraints cannot be combined with the existing or new constraints. +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -## function(queryConstraints, ...) +Creates an expression that subtracts a specified amount of time from a timestamp. -### and(queryConstraints) {:#and_e72c712} +```typescript +// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. +timestampSub(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); -Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a conjunction of the given filter constraints. A conjunction filter includes a document if it satisfies all of the given filters. +``` Signature: ```typescript -export declare function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; +export declare function timestampSub(timestamp: Constant, unit: Constant, amount: Constant): TimestampSub; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| queryConstraints | [QueryFilterConstraint](./firestore_lite.md#queryfilterconstraint)\[\] | Optional. The list of [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)s to perform a conjunction for. These must be created with calls to [where()](./firestore_.md#where_0fae4bf), [or()](./firestore_.md#or_e72c712), or [and()](./firestore_.md#and_e72c712). | +| timestamp | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the timestamp. | +| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | +| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | Returns: -[QueryCompositeFilterConstraint](./firestore_lite.querycompositefilterconstraint.md#querycompositefilterconstraint_class) +[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) -The newly created [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). +### timestampSub(timestamp, unit, amount) {:#timestampsub_46a2d7e} -### or(queryConstraints) {:#or_e72c712} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a disjunction of the given filter constraints. A disjunction filter includes a document if it satisfies any of the given filters. +Creates an expression that subtracts a specified amount of time from a timestamp. + +```typescript +// Subtract 1 day from the 'timestamp' field. +timestampSub(Field.of("timestamp"), "day", 1); + +``` Signature: ```typescript -export declare function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; +export declare function timestampSub(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| queryConstraints | [QueryFilterConstraint](./firestore_lite.md#queryfilterconstraint)\[\] | Optional. The list of [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)s to perform a disjunction for. These must be created with calls to [where()](./firestore_.md#where_0fae4bf), [or()](./firestore_.md#or_e72c712), or [and()](./firestore_.md#and_e72c712). | +| timestamp | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the timestamp. | +| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | +| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | Returns: -[QueryCompositeFilterConstraint](./firestore_lite.querycompositefilterconstraint.md#querycompositefilterconstraint_class) +[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) -The newly created [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). +## function(value, ...) -## function(reference, ...) +### avgFunction(value) {:#avgfunction_f83680a} -### addDoc(reference, data) {:#adddoc_6e783ff} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Add a new document to specified `CollectionReference` with the given data, assigning it a document ID automatically. +Creates an aggregation that calculates the average (mean) of values from an expression across multiple stage inputs. -The result of this write will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the write fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. +```typescript +// Calculate the average age of users +avg(Field.of("age")).as("averageAge"); + +``` Signature: ```typescript -export declare function addDoc(reference: CollectionReference, data: WithFieldValue): Promise>; +export declare function avgFunction(value: Constant): Avg; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to the collection to add this document to. | -| data | [WithFieldValue](./firestore_lite.md#withfieldvalue)<AppModelType> | An Object containing the data for the new document. | +| value | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the values to average. A new representing the 'avg' aggregation. | Returns: -Promise<[DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType>> +[Avg](./firestore_lite.avg.md#avg_class) -A `Promise` resolved with a `DocumentReference` pointing to the newly created document after it has been written to the backend. +### avgFunction(value) {:#avgfunction_7c807cd} -#### Exceptions +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Error - If the provided input is not a valid Firestore document. +Creates an aggregation that calculates the average (mean) of a field's values across multiple stage inputs. -### collection(reference, path, pathSegments) {:#collection_568f98d} +```typescript +// Calculate the average age of users +avg("age").as("averageAge"); -Gets a `CollectionReference` instance that refers to a subcollection of `reference` at the specified relative path. +``` Signature: ```typescript -export declare function collection(reference: CollectionReference, path: string, ...pathSegments: string[]): CollectionReference; +export declare function avgFunction(value: string): Avg; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to a collection. | -| path | string | A slash-separated path to a collection. | -| pathSegments | string\[\] | Additional path segments to apply relative to the first argument. | +| value | string | The name of the field containing numeric values to average. A new representing the 'avg' aggregation. | Returns: -[CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> +[Avg](./firestore_lite.avg.md#avg_class) -The `CollectionReference` instance. +### exists(value) {:#exists_f83680a} -#### Exceptions +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -If the final path has an even number of segments and does not point to a collection. +Creates an expression that checks if a field exists. -### collection(reference, path, pathSegments) {:#collection_70b4396} +```typescript +// Check if the document has a field named "phoneNumber" +exists(Field.of("phoneNumber")); -Gets a `CollectionReference` instance that refers to a subcollection of `reference` at the specified relative path. +``` Signature: ```typescript -export declare function collection(reference: DocumentReference, path: string, ...pathSegments: string[]): CollectionReference; +export declare function exists(value: Constant): Exists; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to a Firestore document. | -| path | string | A slash-separated path to a collection. | -| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | +| value | [Constant](./firestore_lite.constant.md#constant_class) | An expression evaluates to the name of the field to check. A new representing the 'exists' check. | Returns: -[CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> - -The `CollectionReference` instance. +[Exists](./firestore_lite.exists.md#exists_class) -#### Exceptions +### isNan(value) {:#isnan_f83680a} -If the final path has an even number of segments and does not point to a collection. +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -### deleteDoc(reference) {:#deletedoc_4569087} +Creates an expression that checks if an expression evaluates to 'NaN' (Not a Number). -Deletes the document referred to by the specified `DocumentReference`. +```typescript +// Check if the result of a calculation is NaN +isNaN(Field.of("value").divide(0)); -The deletion will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the delete fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. +``` Signature: ```typescript -export declare function deleteDoc(reference: DocumentReference): Promise; +export declare function isNan(value: Constant): IsNan; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to delete. | +| value | [Constant](./firestore_lite.constant.md#constant_class) | The expression to check. A new representing the 'isNaN' check. | Returns: -Promise<void> +[IsNan](./firestore_lite.isnan.md#isnan_class) -A `Promise` resolved once the document has been successfully deleted from the backend. +### isNan(value) {:#isnan_7c807cd} -### doc(reference, path, pathSegments) {:#doc_568f98d} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Gets a `DocumentReference` instance that refers to a document within `reference` at the specified relative path. If no path is specified, an automatically-generated unique ID will be used for the returned `DocumentReference`. +Creates an expression that checks if a field's value evaluates to 'NaN' (Not a Number). + +```typescript +// Check if the result of a calculation is NaN +isNaN("value"); + +``` Signature: ```typescript -export declare function doc(reference: CollectionReference, path?: string, ...pathSegments: string[]): DocumentReference; +export declare function isNan(value: string): IsNan; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to a collection. | -| path | string | A slash-separated path to a document. Has to be omitted to use auto-generated IDs. | -| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | +| value | string | The name of the field to check. A new representing the 'isNaN' check. | Returns: -[DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> +[IsNan](./firestore_lite.isnan.md#isnan_class) -The `DocumentReference` instance. +### max(value) {:#max_f83680a} -#### Exceptions +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -If the final path has an odd number of segments and does not point to a document. +Creates an aggregation that finds the maximum value of an expression across multiple stage inputs. -### doc(reference, path, pathSegments) {:#doc_70b4396} +```typescript +// Find the highest score in a leaderboard +max(Field.of("score")).as("highestScore"); -Gets a `DocumentReference` instance that refers to a document within `reference` at the specified relative path. +``` Signature: ```typescript -export declare function doc(reference: DocumentReference, path: string, ...pathSegments: string[]): DocumentReference; +export declare function max(value: Constant): Max; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to a Firestore document. | -| path | string | A slash-separated path to a document. | -| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | +| value | [Constant](./firestore_lite.constant.md#constant_class) | The expression to find the maximum value of. A new representing the 'max' aggregation. | Returns: -[DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> - -The `DocumentReference` instance. +[Max](./firestore_lite.max.md#max_class) -#### Exceptions +### max(value) {:#max_7c807cd} -If the final path has an odd number of segments and does not point to a document. +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -### getDoc(reference) {:#getdoc_4569087} +Creates an aggregation that finds the maximum value of a field across multiple stage inputs. -Reads the document referred to by the specified document reference. +```typescript +// Find the highest score in a leaderboard +max("score").as("highestScore"); -All documents are directly fetched from the server, even if the document was previously read or modified. Recent modifications are only reflected in the retrieved `DocumentSnapshot` if they have already been applied by the backend. If the client is offline, the read fails. If you like to use caching or see local modifications, please use the full Firestore SDK. +``` Signature: ```typescript -export declare function getDoc(reference: DocumentReference): Promise>; +export declare function max(value: string): Max; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | The reference of the document to fetch. | +| value | string | The name of the field to find the maximum value of. A new representing the 'max' aggregation. | Returns: -Promise<[DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>> +[Max](./firestore_lite.max.md#max_class) -A Promise resolved with a `DocumentSnapshot` containing the current document contents. +### min(value) {:#min_f83680a} -### setDoc(reference, data) {:#setdoc_ee215ad} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Writes to the document referred to by the specified `DocumentReference`. If the document does not yet exist, it will be created. +Creates an aggregation that finds the minimum value of an expression across multiple stage inputs. -The result of this write will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the write fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. +```typescript +// Find the lowest price of all products +min(Field.of("price")).as("lowestPrice"); + +``` Signature: ```typescript -export declare function setDoc(reference: DocumentReference, data: WithFieldValue): Promise; +export declare function min(value: Constant): Min; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to write. | -| data | [WithFieldValue](./firestore_lite.md#withfieldvalue)<AppModelType> | A map of the fields and values for the document. | +| value | [Constant](./firestore_lite.constant.md#constant_class) | The expression to find the minimum value of. A new representing the 'min' aggregation. | Returns: -Promise<void> - -A `Promise` resolved once the data has been successfully written to the backend. +[Min](./firestore_lite.min.md#min_class) -#### Exceptions +### min(value) {:#min_7c807cd} -Error - If the provided input is not a valid Firestore document. +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -### setDoc(reference, data, options) {:#setdoc_ff80739} +Creates an aggregation that finds the minimum value of a field across multiple stage inputs. -Writes to the document referred to by the specified `DocumentReference`. If the document does not yet exist, it will be created. If you provide `merge` or `mergeFields`, the provided data can be merged into an existing document. +```typescript +// Find the lowest price of all products +min("price").as("lowestPrice"); -The result of this write will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the write fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. +``` Signature: ```typescript -export declare function setDoc(reference: DocumentReference, data: PartialWithFieldValue, options: SetOptions): Promise; +export declare function min(value: string): Min; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to write. | -| data | [PartialWithFieldValue](./firestore_lite.md#partialwithfieldvalue)<AppModelType> | A map of the fields and values for the document. | -| options | [SetOptions](./firestore_lite.md#setoptions) | An object to configure the set behavior. | +| value | string | The name of the field to find the minimum value of. A new representing the 'min' aggregation. | Returns: -Promise<void> - -A `Promise` resolved once the data has been successfully written to the backend. +[Min](./firestore_lite.min.md#min_class) -#### Exceptions +### replaceAll(value, find, replace) {:#replaceall_f06d323} -Error - If the provided input is not a valid Firestore document. +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -### updateDoc(reference, data) {:#updatedoc_51a65e3} +Creates an expression that replaces all occurrences of a substring within a string with another substring. -Updates fields in the document referred to by the specified `DocumentReference`. The update will fail if applied to a document that does not exist. +```typescript +// Replace all occurrences of "hello" with "hi" in the 'message' field. +replaceAll(Field.of("message"), "hello", "hi"); -The result of this update will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the update fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. +``` Signature: ```typescript -export declare function updateDoc(reference: DocumentReference, data: UpdateData): Promise; +export declare function replaceAll(value: Constant, find: string, replace: string): ReplaceAll; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to update. | -| data | [UpdateData](./firestore_lite.md#updatedata)<DbModelType> | An object containing the fields and values with which to update the document. Fields can contain dots to reference nested fields within the document. | +| value | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to perform the replacement on. | +| find | string | The substring to search for. | +| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | Returns: -Promise<void> - -A `Promise` resolved once the data has been successfully written to the backend. - -#### Exceptions +[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) -Error - If the provided input is not valid Firestore data. +### replaceAll(value, find, replace) {:#replaceall_26a7926} -### updateDoc(reference, field, value, moreFieldsAndValues) {:#updatedoc_7c28659} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Updates fields in the document referred to by the specified `DocumentReference` The update will fail if applied to a document that does not exist. +Creates an expression that replaces all occurrences of a substring within a string with another substring, where the substring to find and the replacement substring are specified by expressions. -Nested fields can be updated by providing dot-separated field path strings or by providing `FieldPath` objects. +```typescript +// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field. +replaceAll(Field.of("message"), Field.of("findField"), Field.of("replaceField")); -The result of this update will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the update fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. +``` Signature: ```typescript -export declare function updateDoc(reference: DocumentReference, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise; +export declare function replaceAll(value: Constant, find: Constant, replace: Constant): ReplaceAll; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to update. | -| field | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | The first field to update. | -| value | unknown | The first value. | -| moreFieldsAndValues | unknown\[\] | Additional key value pairs. | +| value | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to perform the replacement on. | +| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | Returns: -Promise<void> - -A `Promise` resolved once the data has been successfully written to the backend. +[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) -#### Exceptions +### replaceFirst(value, find, replace) {:#replacefirst_f06d323} -Error - If the provided input is not valid Firestore data. +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -## function(snapshot, ...) +Creates an expression that replaces the first occurrence of a substring within a string with another substring. -### endAt(snapshot) {:#endat_9a4477f} +```typescript +// Replace the first occurrence of "hello" with "hi" in the 'message' field. +replaceFirst(Field.of("message"), "hello", "hi"); -Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided document (inclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. +``` Signature: ```typescript -export declare function endAt(snapshot: DocumentSnapshot): QueryEndAtConstraint; +export declare function replaceFirst(value: Constant, find: string, replace: string): ReplaceFirst; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| snapshot | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to end at. | +| value | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to perform the replacement on. | +| find | string | The substring to search for. | +| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | Returns: -[QueryEndAtConstraint](./firestore_lite.queryendatconstraint.md#queryendatconstraint_class) +[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) -A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` +### replaceFirst(value, find, replace) {:#replacefirst_26a7926} -### endBefore(snapshot) {:#endbefore_9a4477f} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided document (exclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. +Creates an expression that replaces the first occurrence of a substring within a string with another substring, where the substring to find and the replacement substring are specified by expressions. + +```typescript +// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field. +replaceFirst(Field.of("message"), Field.of("findField"), Field.of("replaceField")); + +``` Signature: ```typescript -export declare function endBefore(snapshot: DocumentSnapshot): QueryEndAtConstraint; +export declare function replaceFirst(value: Constant, find: Constant, replace: Constant): ReplaceFirst; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| snapshot | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to end before. | +| value | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to perform the replacement on. | +| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | +| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | Returns: -[QueryEndAtConstraint](./firestore_lite.queryendatconstraint.md#queryendatconstraint_class) +[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) -A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` +### sumFunction(value) {:#sumfunction_f83680a} -### startAfter(snapshot) {:#startafter_9a4477f} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided document (exclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. +Creates an aggregation that calculates the sum of values from an expression across multiple stage inputs. + +```typescript +// Calculate the total revenue from a set of orders +sum(Field.of("orderAmount")).as("totalRevenue"); + +``` Signature: ```typescript -export declare function startAfter(snapshot: DocumentSnapshot): QueryStartAtConstraint; +export declare function sumFunction(value: Constant): Sum; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| snapshot | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to start after. | +| value | [Constant](./firestore_lite.constant.md#constant_class) | The expression to sum up. A new representing the 'sum' aggregation. | Returns: -[QueryStartAtConstraint](./firestore_lite.querystartatconstraint.md#querystartatconstraint_class) +[Sum](./firestore_lite.sum.md#sum_class) -A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()` +### sumFunction(value) {:#sumfunction_7c807cd} -### startAt(snapshot) {:#startat_9a4477f} +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> -Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided document (inclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the `orderBy` of this query. +Creates an aggregation that calculates the sum of a field's values across multiple stage inputs. + +```typescript +// Calculate the total revenue from a set of orders +sum("orderAmount").as("totalRevenue"); + +``` Signature: ```typescript -export declare function startAt(snapshot: DocumentSnapshot): QueryStartAtConstraint; +export declare function sumFunction(value: string): Sum; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| snapshot | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to start at. | +| value | string | The name of the field containing numeric values to sum up. A new representing the 'sum' aggregation. | Returns: -[QueryStartAtConstraint](./firestore_lite.querystartatconstraint.md#querystartatconstraint_class) - -A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()`. +[Sum](./firestore_lite.sum.md#sum_class) ## function(values, ...) @@ -1595,6 +8548,19 @@ export declare function vector(values?: number[]): VectorValue; A new `VectorValue` constructed with a copy of the given array of numbers. +## AccumulatorTarget + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +An accumulator target, which is an expression with an alias that also implements the Accumulator interface. + +Signature: + +```typescript +export declare type AccumulatorTarget = ExprWithAlias; +``` + ## AddPrefixToKeys Returns a new map where every key is prefixed with the outer key appended to a dot. @@ -1653,6 +8619,32 @@ See https://www.typescriptlang.org/docs/handbook/advanced-types.html\#distributi export declare type ChildUpdateFields = V extends Record ? AddPrefixToKeys> : never; ``` +## ExprType + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +An enumeration of the different types of expressions. + +Signature: + +```typescript +export declare type ExprType = 'Field' | 'Constant' | 'Function' | 'ListOfExprs' | 'ExprWithAlias'; +``` + +## FilterExpr + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +A filter expression, which is an expression that also implements the FilterCondition interface. + +Signature: + +```typescript +export declare type FilterExpr = Constant & FilterCondition; +``` + ## FirestoreErrorCode The set of Firestore status codes. The codes are the same at the ones exposed by gRPC here: https://github.com/grpc/grpc/blob/master/doc/statuscodes.md @@ -1739,6 +8731,19 @@ export declare type QueryFilterConstraint = QueryFieldFilterConstraint | QueryCo export declare type QueryNonFilterConstraint = QueryOrderByConstraint | QueryLimitConstraint | QueryStartAtConstraint | QueryEndAtConstraint; ``` +## SelectableExpr + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +A selectable expression, which is an expression that also implements the Selectable interface. + +Signature: + +```typescript +export declare type SelectableExpr = Constant & Selectable; +``` + ## SetOptions An options object that configures the behavior of [setDoc()](./firestore_lite.md#setdoc_ee215ad), and calls. These calls can be configured to perform granular merges instead of overwriting the target documents in their entirety by providing a `SetOptions` with `merge: true`. diff --git a/docs-devsite/firestore_lite.min.md b/docs-devsite/firestore_lite.min.md new file mode 100644 index 00000000000..684db43d806 --- /dev/null +++ b/docs-devsite/firestore_lite.min.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Min class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Min extends FirestoreFunction implements Accumulator +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [Accumulator](./firestore_lite.accumulator.md#accumulator_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value, distinct)](./firestore_lite.min.md#minconstructor) | | (BETA) Constructs a new instance of the Min class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [accumulator](./firestore_lite.min.md#minaccumulator) | | true | (BETA) | + +## Min.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Min` class + +Signature: + +```typescript +constructor(value: Constant, distinct: boolean); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_lite.constant.md#constant_class) | | +| distinct | boolean | | + +## Min.accumulator + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +accumulator: true; +``` diff --git a/docs-devsite/firestore_lite.mod.md b/docs-devsite/firestore_lite.mod.md new file mode 100644 index 00000000000..f007f09a87e --- /dev/null +++ b/docs-devsite/firestore_lite.mod.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Mod class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Mod extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_lite.mod.md#modconstructor) | | (BETA) Constructs a new instance of the Mod class | + +## Mod.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Mod` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | | +| right | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.multiply.md b/docs-devsite/firestore_lite.multiply.md new file mode 100644 index 00000000000..38ca6014b2c --- /dev/null +++ b/docs-devsite/firestore_lite.multiply.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Multiply class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Multiply extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_lite.multiply.md#multiplyconstructor) | | (BETA) Constructs a new instance of the Multiply class | + +## Multiply.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Multiply` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | | +| right | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.neq.md b/docs-devsite/firestore_lite.neq.md new file mode 100644 index 00000000000..132e5721b8f --- /dev/null +++ b/docs-devsite/firestore_lite.neq.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Neq class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Neq extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_lite.neq.md#neqconstructor) | | (BETA) Constructs a new instance of the Neq class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_lite.neq.md#neqfilterable) | | true | (BETA) | + +## Neq.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Neq` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | | +| right | [Constant](./firestore_lite.constant.md#constant_class) | | + +## Neq.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.not.md b/docs-devsite/firestore_lite.not.md new file mode 100644 index 00000000000..362ccd8a789 --- /dev/null +++ b/docs-devsite/firestore_lite.not.md @@ -0,0 +1,66 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Not class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Not extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr)](./firestore_lite.not.md#notconstructor) | | (BETA) Constructs a new instance of the Not class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_lite.not.md#notfilterable) | | true | (BETA) | + +## Not.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Not` class + +Signature: + +```typescript +constructor(expr: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | | + +## Not.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.offset.md b/docs-devsite/firestore_lite.offset.md new file mode 100644 index 00000000000..dc09ac97be6 --- /dev/null +++ b/docs-devsite/firestore_lite.offset.md @@ -0,0 +1,64 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Offset class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Offset implements Stage +``` +Implements: [Stage](./firestore_lite.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(offset)](./firestore_lite.offset.md#offsetconstructor) | | (BETA) Constructs a new instance of the Offset class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_lite.offset.md#offsetname) | | string | (BETA) | + +## Offset.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Offset` class + +Signature: + +```typescript +constructor(offset: number); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| offset | number | | + +## Offset.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_lite.or.md b/docs-devsite/firestore_lite.or.md new file mode 100644 index 00000000000..d2c506893a0 --- /dev/null +++ b/docs-devsite/firestore_lite.or.md @@ -0,0 +1,17 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# or namespace +Signature: + +```typescript +export declare namespace or +``` diff --git a/docs-devsite/firestore_lite.ordering.md b/docs-devsite/firestore_lite.ordering.md new file mode 100644 index 00000000000..c8dc1249d73 --- /dev/null +++ b/docs-devsite/firestore_lite.ordering.md @@ -0,0 +1,51 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Ordering class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Represents an ordering criterion for sorting documents in a Firestore pipeline. + +You create `Ordering` instances using the `ascending` and `descending` helper functions. + +Signature: + +```typescript +export declare class Ordering +``` + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr, direction)](./firestore_lite.ordering.md#orderingconstructor) | | (BETA) Constructs a new instance of the Ordering class | + +## Ordering.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Ordering` class + +Signature: + +```typescript +constructor(expr: Constant, direction: 'ascending' | 'descending'); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | | +| direction | 'ascending' \| 'descending' | | + diff --git a/docs-devsite/firestore_lite.pipeline.md b/docs-devsite/firestore_lite.pipeline.md new file mode 100644 index 00000000000..c34aa32109e --- /dev/null +++ b/docs-devsite/firestore_lite.pipeline.md @@ -0,0 +1,564 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Pipeline class +Base-class implementation + +Signature: + +```typescript +export declare class Pipeline +``` + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [addFields(fields)](./firestore_lite.pipeline.md#pipelineaddfields) | | Adds new fields to outputs from previous stages.This stage allows you to compute values on-the-fly based on existing data from previous stages or constants. You can use this to create new fields or overwrite existing ones (if there is name overlaps).The added fields are defined using [Selectable](./firestore_.selectable.md#selectable_interface)s, which can be:- [Field](./firestore_.field.md#field_class): References an existing document field. - : Performs a calculation using functions like add, multiply with assigned aliases using .Example: +```typescript +firestore.pipeline().collection("books") + .addFields( + Field.of("rating").as("bookRating"), // Rename 'rating' to 'bookRating' + add(5, Field.of("quantity")).as("totalCost") // Calculate 'totalCost' + ); + +``` + | +| [aggregate(accumulators)](./firestore_lite.pipeline.md#pipelineaggregate) | | Performs aggregation operations on the documents from previous stages.

This stage allows you to calculate aggregate values over a set of documents. You define the aggregations to perform using [AccumulatorTarget](./firestore_.md#accumulatortarget) expressions which are typically results of calling on [Accumulator](./firestore_.accumulator.md#accumulator_interface) instances.

Example: +```typescript +// Calculate the average rating and the total number of books +firestore.pipeline().collection("books") + .aggregate( + Field.of("rating").avg().as("averageRating"), + countAll().as("totalBooks") + ); + +``` + | +| [aggregate(options)](./firestore_lite.pipeline.md#pipelineaggregate) | | Performs optionally grouped aggregation operations on the documents from previous stages.

This stage allows you to calculate aggregate values over a set of documents, optionally grouped by one or more fields or functions. You can specify:

  • \*\*Grouping Fields or Functions:\*\* One or more fields or functions to group the documents by. For each distinct combination of values in these fields, a separate group is created. If no grouping fields are provided, a single group containing all documents is used. Not specifying groups is the same as putting the entire inputs into one group.
  • \*\*Accumulators:\*\* One or more accumulation operations to perform within each group. These are defined using [AccumulatorTarget](./firestore_.md#accumulatortarget) expressions, which are typically created by calling on [Accumulator](./firestore_.accumulator.md#accumulator_interface) instances. Each aggregation calculates a value (e.g., sum, average, count) based on the documents within its group.

Example: +```typescript +// Calculate the average rating for each genre. +firestore.pipeline().collection("books") + .aggregate({ + accumulators: [avg(Field.of("rating")).as("avg_rating")] + groups: ["genre"] + }); + +``` + | +| [distinct(groups)](./firestore_lite.pipeline.md#pipelinedistinct) | | Returns a set of distinct values from the inputs to this stage.

This stage run through the results from previous stages to include only results with unique combinations of values ([Field](./firestore_.field.md#field_class), , etc).

The parameters to this stage are defined using [Selectable](./firestore_.selectable.md#selectable_interface) expressions or s:

  • : Name of an existing field
  • [Field](./firestore_.field.md#field_class): References an existing document field.
  • : Represents the result of a function with an assigned alias name using

Example: +```typescript +// Get a list of unique author names in uppercase and genre combinations. +firestore.pipeline().collection("books") + .distinct(toUppercase(Field.of("author")).as("authorName"), Field.of("genre"), "publishedAt") + .select("authorName"); + +``` + | +| [execute()](./firestore_lite.pipeline.md#pipelineexecute) | | Executes this pipeline and returns a Promise to represent the asynchronous operation.

The returned Promise can be used to track the progress of the pipeline execution and retrieve the results (or handle any errors) asynchronously.

The pipeline results are returned as a list of [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) objects. Each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) typically represents a single key/value map that has passed through all the stages of the pipeline, however this might differ depending on the stages involved in the pipeline. For example:

  • If there are no stages or only transformation stages, each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) represents a single document.
  • If there is an aggregation, only a single [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) is returned, representing the aggregated results over the entire dataset .
  • If there is an aggregation stage with grouping, each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) represents a distinct group and its associated aggregated values.

Example: +```typescript +const futureResults = await firestore.pipeline().collection("books") + .where(gt(Field.of("rating"), 4.5)) + .select("title", "author", "rating") + .execute(); + +``` + A Promise representing the asynchronous pipeline execution. | +| [findNearest(options)](./firestore_lite.pipeline.md#pipelinefindnearest) | | | +| [genericStage(name, params)](./firestore_lite.pipeline.md#pipelinegenericstage) | | Adds a generic stage to the pipeline.

This method provides a flexible way to extend the pipeline's functionality by adding custom stages. Each generic stage is defined by a unique name and a set of params that control its behavior.

Example (Assuming there is no "where" stage available in SDK): +```typescript +// Assume we don't have a built-in "where" stage +firestore.pipeline().collection("books") + .genericStage("where", [Field.of("published").lt(1900)]) // Custom "where" stage + .select("title", "author"); + +``` + | +| [limit(limit)](./firestore_lite.pipeline.md#pipelinelimit) | | Limits the maximum number of documents returned by previous stages to limit.

This stage is particularly useful when you want to retrieve a controlled subset of data from a potentially large result set. It's often used for:

  • \*\*Pagination:\*\* In combination with to retrieve specific pages of results.
  • \*\*Limiting Data Retrieval:\*\* To prevent excessive data transfer and improve performance, especially when dealing with large collections.

Example: +```typescript +// Limit the results to the top 10 highest-rated books +firestore.pipeline().collection("books") + .sort(Field.of("rating").descending()) + .limit(10); + +``` + | +| [offset(offset)](./firestore_lite.pipeline.md#pipelineoffset) | | Skips the first offset number of documents from the results of previous stages.

This stage is useful for implementing pagination in your pipelines, allowing you to retrieve results in chunks. It is typically used in conjunction with to control the size of each page.

Example: +```typescript +// Retrieve the second page of 20 results +firestore.pipeline().collection("books") + .sort(Field.of("published").descending()) + .offset(20) // Skip the first 20 results + .limit(20); // Take the next 20 results + +``` + | +| [select(selections)](./firestore_lite.pipeline.md#pipelineselect) | | Selects or creates a set of fields from the outputs of previous stages.

The selected fields are defined using [Selectable](./firestore_.selectable.md#selectable_interface) expressions, which can be:

  • : Name of an existing field
  • [Field](./firestore_.field.md#field_class): References an existing field.
  • : Represents the result of a function with an assigned alias name using

If no selections are provided, the output of this stage is empty. Use instead if only additions are desired.

Example: +```typescript +firestore.pipeline().collection("books") + .select( + "firstName", + Field.of("lastName"), + Field.of("address").toUppercase().as("upperAddress"), + ); + +``` + | +| [sort(orderings)](./firestore_lite.pipeline.md#pipelinesort) | | Sorts the documents from previous stages based on one or more [Ordering](./firestore_.ordering.md#ordering_class) criteria.

This stage allows you to order the results of your pipeline. You can specify multiple [Ordering](./firestore_.ordering.md#ordering_class) instances to sort by multiple fields in ascending or descending order. If documents have the same value for a field used for sorting, the next specified ordering will be used. If all orderings result in equal comparison, the documents are considered equal and the order is unspecified.

Example: +```typescript +// Sort books by rating in descending order, and then by title in ascending order for books +// with the same rating +firestore.pipeline().collection("books") + .sort( + Ordering.of(Field.of("rating")).descending(), + Ordering.of(Field.of("title")) // Ascending order is the default + ); + +``` + | +| [sort(options)](./firestore_lite.pipeline.md#pipelinesort) | | | +| [where(condition)](./firestore_lite.pipeline.md#pipelinewhere) | | Filters the documents from previous stages to only include those matching the specified [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface).

This stage allows you to apply conditions to the data, similar to a "WHERE" clause in SQL. You can filter documents based on their field values, using implementations of [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface), typically including but not limited to:

  • field comparators: , (less than), (greater than), etc.
  • logical operators: , , , etc.
  • advanced functions: , , etc.

Example: +```typescript +firestore.pipeline().collection("books") + .where( + and( + gt(Field.of("rating"), 4.0), // Filter for ratings greater than 4.0 + Field.of("genre").eq("Science Fiction") // Equivalent to gt("genre", "Science Fiction") + ) + ); + +``` + | + +## Pipeline.addFields() + +Adds new fields to outputs from previous stages. + +This stage allows you to compute values on-the-fly based on existing data from previous stages or constants. You can use this to create new fields or overwrite existing ones (if there is name overlaps). + +The added fields are defined using [Selectable](./firestore_.selectable.md#selectable_interface)s, which can be: + +- [Field](./firestore_.field.md#field_class): References an existing document field. - : Performs a calculation using functions like `add`, `multiply` with assigned aliases using . + +Example: + +```typescript +firestore.pipeline().collection("books") + .addFields( + Field.of("rating").as("bookRating"), // Rename 'rating' to 'bookRating' + add(5, Field.of("quantity")).as("totalCost") // Calculate 'totalCost' + ); + +``` + +Signature: + +```typescript +addFields(...fields: Selectable[]): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| fields | [Selectable](./firestore_lite.selectable.md#selectable_interface)\[\] | The fields to add to the documents, specified as [Selectable](./firestore_.selectable.md#selectable_interface)s. A new Pipeline object with this stage appended to the stage list. | + +Returns: + +[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.aggregate() + +Performs aggregation operations on the documents from previous stages. + +

This stage allows you to calculate aggregate values over a set of documents. You define the aggregations to perform using [AccumulatorTarget](./firestore_.md#accumulatortarget) expressions which are typically results of calling on [Accumulator](./firestore_.accumulator.md#accumulator_interface) instances. + +

Example: + +```typescript +// Calculate the average rating and the total number of books +firestore.pipeline().collection("books") + .aggregate( + Field.of("rating").avg().as("averageRating"), + countAll().as("totalBooks") + ); + +``` + +Signature: + +```typescript +aggregate(...accumulators: AccumulatorTarget[]): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| accumulators | [AccumulatorTarget](./firestore_lite.md#accumulatortarget)\[\] | The [AccumulatorTarget](./firestore_.md#accumulatortarget) expressions, each wrapping an [Accumulator](./firestore_.accumulator.md#accumulator_interface) and provide a name for the accumulated results. A new Pipeline object with this stage appended to the stage list. | + +Returns: + +[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.aggregate() + +Performs optionally grouped aggregation operations on the documents from previous stages. + +

This stage allows you to calculate aggregate values over a set of documents, optionally grouped by one or more fields or functions. You can specify: + +

  • \*\*Grouping Fields or Functions:\*\* One or more fields or functions to group the documents by. For each distinct combination of values in these fields, a separate group is created. If no grouping fields are provided, a single group containing all documents is used. Not specifying groups is the same as putting the entire inputs into one group.
  • \*\*Accumulators:\*\* One or more accumulation operations to perform within each group. These are defined using [AccumulatorTarget](./firestore_.md#accumulatortarget) expressions, which are typically created by calling on [Accumulator](./firestore_.accumulator.md#accumulator_interface) instances. Each aggregation calculates a value (e.g., sum, average, count) based on the documents within its group.
+ +

Example: + +```typescript +// Calculate the average rating for each genre. +firestore.pipeline().collection("books") + .aggregate({ + accumulators: [avg(Field.of("rating")).as("avg_rating")] + groups: ["genre"] + }); + +``` + +Signature: + +```typescript +aggregate(options: { + accumulators: AccumulatorTarget[]; + groups?: Array; + }): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| options | { accumulators: [AccumulatorTarget](./firestore_lite.md#accumulatortarget)\[\]; groups?: Array<string \| [Selectable](./firestore_lite.selectable.md#selectable_interface)>; } | | + +Returns: + +[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.distinct() + +Returns a set of distinct values from the inputs to this stage. + +

This stage run through the results from previous stages to include only results with unique combinations of values ([Field](./firestore_.field.md#field_class), , etc). + +

The parameters to this stage are defined using [Selectable](./firestore_.selectable.md#selectable_interface) expressions or s: + +

  • : Name of an existing field
  • [Field](./firestore_.field.md#field_class): References an existing document field.
  • : Represents the result of a function with an assigned alias name using
+ +

Example: + +```typescript +// Get a list of unique author names in uppercase and genre combinations. +firestore.pipeline().collection("books") + .distinct(toUppercase(Field.of("author")).as("authorName"), Field.of("genre"), "publishedAt") + .select("authorName"); + +``` + +Signature: + +```typescript +distinct(...groups: Array): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| groups | Array<string \| [Selectable](./firestore_lite.selectable.md#selectable_interface)> | | + +Returns: + +[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.execute() + +Executes this pipeline and returns a Promise to represent the asynchronous operation. + +

The returned Promise can be used to track the progress of the pipeline execution and retrieve the results (or handle any errors) asynchronously. + +

The pipeline results are returned as a list of [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) objects. Each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) typically represents a single key/value map that has passed through all the stages of the pipeline, however this might differ depending on the stages involved in the pipeline. For example: + +

  • If there are no stages or only transformation stages, each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) represents a single document.
  • If there is an aggregation, only a single [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) is returned, representing the aggregated results over the entire dataset .
  • If there is an aggregation stage with grouping, each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) represents a distinct group and its associated aggregated values.
+ +

Example: + +```typescript +const futureResults = await firestore.pipeline().collection("books") + .where(gt(Field.of("rating"), 4.5)) + .select("title", "author", "rating") + .execute(); + +``` + A Promise representing the asynchronous pipeline execution. + +Signature: + +```typescript +execute(): Promise>>; +``` +Returns: + +Promise<Array<[PipelineResult](./firestore_lite.pipelineresult.md#pipelineresult_class)<AppModelType>>> + +## Pipeline.findNearest() + +Signature: + +```typescript +findNearest(options: FindNearestOptions): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| options | [FindNearestOptions](./firestore_lite.findnearestoptions.md#findnearestoptions_interface) | | + +Returns: + +[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.genericStage() + +Adds a generic stage to the pipeline. + +

This method provides a flexible way to extend the pipeline's functionality by adding custom stages. Each generic stage is defined by a unique `name` and a set of `params` that control its behavior. + +

Example (Assuming there is no "where" stage available in SDK): + +```typescript +// Assume we don't have a built-in "where" stage +firestore.pipeline().collection("books") + .genericStage("where", [Field.of("published").lt(1900)]) // Custom "where" stage + .select("title", "author"); + +``` + +Signature: + +```typescript +genericStage(name: string, params: any[]): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | The unique name of the generic stage to add. | +| params | any\[\] | A list of parameters to configure the generic stage's behavior. A new object with this stage appended to the stage list. | + +Returns: + +[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.limit() + +Limits the maximum number of documents returned by previous stages to `limit`. + +

This stage is particularly useful when you want to retrieve a controlled subset of data from a potentially large result set. It's often used for: + +

  • \*\*Pagination:\*\* In combination with to retrieve specific pages of results.
  • \*\*Limiting Data Retrieval:\*\* To prevent excessive data transfer and improve performance, especially when dealing with large collections.
+ +

Example: + +```typescript +// Limit the results to the top 10 highest-rated books +firestore.pipeline().collection("books") + .sort(Field.of("rating").descending()) + .limit(10); + +``` + +Signature: + +```typescript +limit(limit: number): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| limit | number | The maximum number of documents to return. A new Pipeline object with this stage appended to the stage list. | + +Returns: + +[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.offset() + +Skips the first `offset` number of documents from the results of previous stages. + +

This stage is useful for implementing pagination in your pipelines, allowing you to retrieve results in chunks. It is typically used in conjunction with to control the size of each page. + +

Example: + +```typescript +// Retrieve the second page of 20 results +firestore.pipeline().collection("books") + .sort(Field.of("published").descending()) + .offset(20) // Skip the first 20 results + .limit(20); // Take the next 20 results + +``` + +Signature: + +```typescript +offset(offset: number): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| offset | number | The number of documents to skip. A new Pipeline object with this stage appended to the stage list. | + +Returns: + +[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.select() + +Selects or creates a set of fields from the outputs of previous stages. + +

The selected fields are defined using [Selectable](./firestore_.selectable.md#selectable_interface) expressions, which can be: + +

  • : Name of an existing field
  • [Field](./firestore_.field.md#field_class): References an existing field.
  • : Represents the result of a function with an assigned alias name using
+ +

If no selections are provided, the output of this stage is empty. Use instead if only additions are desired. + +

Example: + +```typescript +firestore.pipeline().collection("books") + .select( + "firstName", + Field.of("lastName"), + Field.of("address").toUppercase().as("upperAddress"), + ); + +``` + +Signature: + +```typescript +select(...selections: Array): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| selections | Array<[Selectable](./firestore_lite.selectable.md#selectable_interface) \| string> | The fields to include in the output documents, specified as [Selectable](./firestore_.selectable.md#selectable_interface) expressions or values representing field names. A new Pipeline object with this stage appended to the stage list. | + +Returns: + +[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.sort() + +Sorts the documents from previous stages based on one or more [Ordering](./firestore_.ordering.md#ordering_class) criteria. + +

This stage allows you to order the results of your pipeline. You can specify multiple [Ordering](./firestore_.ordering.md#ordering_class) instances to sort by multiple fields in ascending or descending order. If documents have the same value for a field used for sorting, the next specified ordering will be used. If all orderings result in equal comparison, the documents are considered equal and the order is unspecified. + +

Example: + +```typescript +// Sort books by rating in descending order, and then by title in ascending order for books +// with the same rating +firestore.pipeline().collection("books") + .sort( + Ordering.of(Field.of("rating")).descending(), + Ordering.of(Field.of("title")) // Ascending order is the default + ); + +``` + +Signature: + +```typescript +sort(...orderings: Ordering[]): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| orderings | [Ordering](./firestore_lite.ordering.md#ordering_class)\[\] | | + +Returns: + +[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.sort() + +Signature: + +```typescript +sort(options: { + orderings: Ordering[]; + }): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| options | { orderings: [Ordering](./firestore_lite.ordering.md#ordering_class)\[\]; } | | + +Returns: + +[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> + +## Pipeline.where() + +Filters the documents from previous stages to only include those matching the specified [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface). + +

This stage allows you to apply conditions to the data, similar to a "WHERE" clause in SQL. You can filter documents based on their field values, using implementations of [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface), typically including but not limited to: + +

  • field comparators: , (less than), (greater than), etc.
  • logical operators: , , , etc.
  • advanced functions: , , etc.
+ +

Example: + +```typescript +firestore.pipeline().collection("books") + .where( + and( + gt(Field.of("rating"), 4.0), // Filter for ratings greater than 4.0 + Field.of("genre").eq("Science Fiction") // Equivalent to gt("genre", "Science Fiction") + ) + ); + +``` + +Signature: + +```typescript +where(condition: FilterCondition & Constant): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| condition | [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) & [Constant](./firestore_lite.constant.md#constant_class) | The [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) to apply. A new Pipeline object with this stage appended to the stage list. | + +Returns: + +[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> + diff --git a/docs-devsite/firestore_lite.pipelineresult.md b/docs-devsite/firestore_lite.pipelineresult.md new file mode 100644 index 00000000000..16a64fd9b7c --- /dev/null +++ b/docs-devsite/firestore_lite.pipelineresult.md @@ -0,0 +1,184 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# PipelineResult class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +A PipelineResult contains data read from a Firestore Pipeline. The data can be extracted with the or methods. + +

If the PipelineResult represents a non-document result, `ref` will return a undefined value. + +Signature: + +```typescript +export declare class PipelineResult +``` + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [createTime](./firestore_lite.pipelineresult.md#pipelineresultcreatetime) | | [Timestamp](./firestore_lite.timestamp.md#timestamp_class) \| undefined | (BETA) The time the document was created. Undefined if this result is not a document. {Timestamp\|undefined} | +| [executionTime](./firestore_lite.pipelineresult.md#pipelineresultexecutiontime) | | [Timestamp](./firestore_lite.timestamp.md#timestamp_class) | (BETA) The time at which the pipeline producing this result is executed. {Timestamp} | +| [id](./firestore_lite.pipelineresult.md#pipelineresultid) | | string \| undefined | (BETA) The ID of the document for which this PipelineResult contains data, if it is a document; otherwise undefined. {string} | +| [ref](./firestore_lite.pipelineresult.md#pipelineresultref) | | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class) \| undefined | (BETA) The reference of the document, if it is a document; otherwise undefined. | +| [updateTime](./firestore_lite.pipelineresult.md#pipelineresultupdatetime) | | [Timestamp](./firestore_lite.timestamp.md#timestamp_class) \| undefined | (BETA) The time the document was last updated (at the time the snapshot was generated). Undefined if this result is not a document. {Timestamp\|undefined} | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [data()](./firestore_lite.pipelineresult.md#pipelineresultdata) | | (BETA) Retrieves all fields in the result as an object. Returns 'undefined' if the document doesn't exist. | +| [get(fieldPath)](./firestore_lite.pipelineresult.md#pipelineresultget) | | (BETA) Retrieves the field specified by field. | + +## PipelineResult.createTime + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +The time the document was created. Undefined if this result is not a document. + + {Timestamp\|undefined} + +Signature: + +```typescript +get createTime(): Timestamp | undefined; +``` + +## PipelineResult.executionTime + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +The time at which the pipeline producing this result is executed. + + {Timestamp} + +Signature: + +```typescript +get executionTime(): Timestamp; +``` + +## PipelineResult.id + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +The ID of the document for which this PipelineResult contains data, if it is a document; otherwise `undefined`. + + {string} + +Signature: + +```typescript +get id(): string | undefined; +``` + +## PipelineResult.ref + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +The reference of the document, if it is a document; otherwise `undefined`. + +Signature: + +```typescript +get ref(): DocumentReference | undefined; +``` + +## PipelineResult.updateTime + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +The time the document was last updated (at the time the snapshot was generated). Undefined if this result is not a document. + + {Timestamp\|undefined} + +Signature: + +```typescript +get updateTime(): Timestamp | undefined; +``` + +## PipelineResult.data() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Retrieves all fields in the result as an object. Returns 'undefined' if the document doesn't exist. + +Signature: + +```typescript +data(): AppModelType | undefined; +``` +Returns: + +AppModelType \| undefined + +{T\|undefined} An object containing all fields in the document or 'undefined' if the document doesn't exist. + +### Example + + +``` +let p = firestore.pipeline().collection('col'); + +p.execute().then(results => { + let data = results[0].data(); + console.log(`Retrieved data: ${JSON.stringify(data)}`); +}); + +``` + +## PipelineResult.get() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Retrieves the field specified by `field`. + +Signature: + +```typescript +get(fieldPath: string | FieldPath): any; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| fieldPath | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | | + +Returns: + +any + +{\*} The data at the specified field location or undefined if no such field exists. + +### Example + + +``` +let p = firestore.pipeline().collection('col'); + +p.execute().then(results => { + let field = results[0].get('a.b'); + console.log(`Retrieved field value: ${field}`); +}); + +``` + diff --git a/docs-devsite/firestore_lite.pipelinesource.md b/docs-devsite/firestore_lite.pipelinesource.md new file mode 100644 index 00000000000..9a5f0362c93 --- /dev/null +++ b/docs-devsite/firestore_lite.pipelinesource.md @@ -0,0 +1,109 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# PipelineSource class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Represents the source of a Firestore [Pipeline](./firestore_.pipeline.md#pipeline_class). + +Signature: + +```typescript +export declare class PipelineSource +``` + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [collection(collectionPath)](./firestore_lite.pipelinesource.md#pipelinesourcecollection) | | (BETA) | +| [collectionGroup(collectionId)](./firestore_lite.pipelinesource.md#pipelinesourcecollectiongroup) | | (BETA) | +| [database()](./firestore_lite.pipelinesource.md#pipelinesourcedatabase) | | (BETA) | +| [documents(docs)](./firestore_lite.pipelinesource.md#pipelinesourcedocuments) | | (BETA) | + +## PipelineSource.collection() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +collection(collectionPath: string): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| collectionPath | string | | + +Returns: + +[Pipeline](./firestore_lite.pipeline.md#pipeline_class) + +## PipelineSource.collectionGroup() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +collectionGroup(collectionId: string): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| collectionId | string | | + +Returns: + +[Pipeline](./firestore_lite.pipeline.md#pipeline_class) + +## PipelineSource.database() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +database(): Pipeline; +``` +Returns: + +[Pipeline](./firestore_lite.pipeline.md#pipeline_class) + +## PipelineSource.documents() + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +documents(docs: DocumentReference[]): Pipeline; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| docs | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)\[\] | | + +Returns: + +[Pipeline](./firestore_lite.pipeline.md#pipeline_class) + diff --git a/docs-devsite/firestore_lite.query.md b/docs-devsite/firestore_lite.query.md index 48beee0e10c..210d2b0895e 100644 --- a/docs-devsite/firestore_lite.query.md +++ b/docs-devsite/firestore_lite.query.md @@ -36,6 +36,7 @@ export declare class QueryNewDbModelType and your custom type NewAppModelType. | @@ -79,6 +80,19 @@ The type of this Firestore reference. readonly type: 'query' | 'collection'; ``` +## Query.pipeline() + +Pipeline query. + +Signature: + +```typescript +pipeline(): Pipeline; +``` +Returns: + +[Pipeline](./firestore_lite.pipeline.md#pipeline_class) + ## Query.withConverter() Removes the current converter. diff --git a/docs-devsite/firestore_lite.querycompositefilterconstraint.md b/docs-devsite/firestore_lite.querycompositefilterconstraint.md index 1db79b79522..c32cfa1b5a0 100644 --- a/docs-devsite/firestore_lite.querycompositefilterconstraint.md +++ b/docs-devsite/firestore_lite.querycompositefilterconstraint.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # QueryCompositeFilterConstraint class -A `QueryCompositeFilterConstraint` is used to narrow the set of documents returned by a Firestore query by performing the logical OR or AND of multiple [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class)s or [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class)s. `QueryCompositeFilterConstraint`s are created by invoking [or()](./firestore_.md#or_e72c712) or [and()](./firestore_.md#and_e72c712) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the `QueryCompositeFilterConstraint`. +A `QueryCompositeFilterConstraint` is used to narrow the set of documents returned by a Firestore query by performing the logical OR or AND of multiple [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class)s or [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class)s. `QueryCompositeFilterConstraint`s are created by invoking or and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the `QueryCompositeFilterConstraint`. Signature: diff --git a/docs-devsite/firestore_lite.regexcontains.md b/docs-devsite/firestore_lite.regexcontains.md new file mode 100644 index 00000000000..aaf069cde7f --- /dev/null +++ b/docs-devsite/firestore_lite.regexcontains.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# RegexContains class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class RegexContains extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr, pattern)](./firestore_lite.regexcontains.md#regexcontainsconstructor) | | (BETA) Constructs a new instance of the RegexContains class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_lite.regexcontains.md#regexcontainsfilterable) | | true | (BETA) | + +## RegexContains.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `RegexContains` class + +Signature: + +```typescript +constructor(expr: Constant, pattern: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | | + +## RegexContains.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.regexmatch.md b/docs-devsite/firestore_lite.regexmatch.md new file mode 100644 index 00000000000..78d9029e3a9 --- /dev/null +++ b/docs-devsite/firestore_lite.regexmatch.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# RegexMatch class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class RegexMatch extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr, pattern)](./firestore_lite.regexmatch.md#regexmatchconstructor) | | (BETA) Constructs a new instance of the RegexMatch class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_lite.regexmatch.md#regexmatchfilterable) | | true | (BETA) | + +## RegexMatch.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `RegexMatch` class + +Signature: + +```typescript +constructor(expr: Constant, pattern: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | | +| pattern | [Constant](./firestore_lite.constant.md#constant_class) | | + +## RegexMatch.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.replaceall.md b/docs-devsite/firestore_lite.replaceall.md new file mode 100644 index 00000000000..d318d936b96 --- /dev/null +++ b/docs-devsite/firestore_lite.replaceall.md @@ -0,0 +1,50 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ReplaceAll class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ReplaceAll extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value, find, replace)](./firestore_lite.replaceall.md#replaceallconstructor) | | (BETA) Constructs a new instance of the ReplaceAll class | + +## ReplaceAll.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ReplaceAll` class + +Signature: + +```typescript +constructor(value: Constant, find: Constant, replace: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_lite.constant.md#constant_class) | | +| find | [Constant](./firestore_lite.constant.md#constant_class) | | +| replace | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.replacefirst.md b/docs-devsite/firestore_lite.replacefirst.md new file mode 100644 index 00000000000..d8e83dd2140 --- /dev/null +++ b/docs-devsite/firestore_lite.replacefirst.md @@ -0,0 +1,50 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ReplaceFirst class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ReplaceFirst extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value, find, replace)](./firestore_lite.replacefirst.md#replacefirstconstructor) | | (BETA) Constructs a new instance of the ReplaceFirst class | + +## ReplaceFirst.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ReplaceFirst` class + +Signature: + +```typescript +constructor(value: Constant, find: Constant, replace: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_lite.constant.md#constant_class) | | +| find | [Constant](./firestore_lite.constant.md#constant_class) | | +| replace | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.reverse.md b/docs-devsite/firestore_lite.reverse.md new file mode 100644 index 00000000000..65b4d256a5c --- /dev/null +++ b/docs-devsite/firestore_lite.reverse.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Reverse class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Reverse extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value)](./firestore_lite.reverse.md#reverseconstructor) | | (BETA) Constructs a new instance of the Reverse class | + +## Reverse.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Reverse` class + +Signature: + +```typescript +constructor(value: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.select.md b/docs-devsite/firestore_lite.select.md new file mode 100644 index 00000000000..6221a7c41a7 --- /dev/null +++ b/docs-devsite/firestore_lite.select.md @@ -0,0 +1,64 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Select class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Select implements Stage +``` +Implements: [Stage](./firestore_lite.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(projections)](./firestore_lite.select.md#selectconstructor) | | (BETA) Constructs a new instance of the Select class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_lite.select.md#selectname) | | string | (BETA) | + +## Select.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Select` class + +Signature: + +```typescript +constructor(projections: Map); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| projections | Map<string, [Constant](./firestore_lite.constant.md#constant_class)> | | + +## Select.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_lite.selectable.md b/docs-devsite/firestore_lite.selectable.md new file mode 100644 index 00000000000..aeb75036db3 --- /dev/null +++ b/docs-devsite/firestore_lite.selectable.md @@ -0,0 +1,39 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Selectable interface +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +An interface that represents a selectable expression. + +Signature: + +```typescript +export declare interface Selectable +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [selectable](./firestore_lite.selectable.md#selectableselectable) | true | (BETA) | + +## Selectable.selectable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +selectable: true; +``` diff --git a/docs-devsite/firestore_lite.sort.md b/docs-devsite/firestore_lite.sort.md new file mode 100644 index 00000000000..f387044b540 --- /dev/null +++ b/docs-devsite/firestore_lite.sort.md @@ -0,0 +1,64 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Sort class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Sort implements Stage +``` +Implements: [Stage](./firestore_lite.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(orders)](./firestore_lite.sort.md#sortconstructor) | | (BETA) Constructs a new instance of the Sort class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_lite.sort.md#sortname) | | string | (BETA) | + +## Sort.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Sort` class + +Signature: + +```typescript +constructor(orders: Ordering[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| orders | [Ordering](./firestore_lite.ordering.md#ordering_class)\[\] | | + +## Sort.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_lite.stage.md b/docs-devsite/firestore_lite.stage.md new file mode 100644 index 00000000000..9aa24210656 --- /dev/null +++ b/docs-devsite/firestore_lite.stage.md @@ -0,0 +1,38 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Stage interface +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare interface Stage +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [name](./firestore_lite.stage.md#stagename) | string | (BETA) | + +## Stage.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_lite.startswith.md b/docs-devsite/firestore_lite.startswith.md new file mode 100644 index 00000000000..a30cdae497a --- /dev/null +++ b/docs-devsite/firestore_lite.startswith.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# StartsWith class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class StartsWith extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr, prefix)](./firestore_lite.startswith.md#startswithconstructor) | | (BETA) Constructs a new instance of the StartsWith class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_lite.startswith.md#startswithfilterable) | | true | (BETA) | + +## StartsWith.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `StartsWith` class + +Signature: + +```typescript +constructor(expr: Constant, prefix: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | | +| prefix | [Constant](./firestore_lite.constant.md#constant_class) | | + +## StartsWith.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.strconcat.md b/docs-devsite/firestore_lite.strconcat.md new file mode 100644 index 00000000000..f3e1ad2bcde --- /dev/null +++ b/docs-devsite/firestore_lite.strconcat.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# StrConcat class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class StrConcat extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(first, rest)](./firestore_lite.strconcat.md#strconcatconstructor) | | (BETA) Constructs a new instance of the StrConcat class | + +## StrConcat.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `StrConcat` class + +Signature: + +```typescript +constructor(first: Constant, rest: Constant[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| first | [Constant](./firestore_lite.constant.md#constant_class) | | +| rest | [Constant](./firestore_lite.constant.md#constant_class)\[\] | | + diff --git a/docs-devsite/firestore_lite.strcontains.md b/docs-devsite/firestore_lite.strcontains.md new file mode 100644 index 00000000000..36fed4dd005 --- /dev/null +++ b/docs-devsite/firestore_lite.strcontains.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# StrContains class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class StrContains extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr, substring)](./firestore_lite.strcontains.md#strcontainsconstructor) | | (BETA) Constructs a new instance of the StrContains class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_lite.strcontains.md#strcontainsfilterable) | | true | (BETA) | + +## StrContains.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `StrContains` class + +Signature: + +```typescript +constructor(expr: Constant, substring: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | | +| substring | [Constant](./firestore_lite.constant.md#constant_class) | | + +## StrContains.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/firestore_lite.subtract.md b/docs-devsite/firestore_lite.subtract.md new file mode 100644 index 00000000000..7d692f3c779 --- /dev/null +++ b/docs-devsite/firestore_lite.subtract.md @@ -0,0 +1,49 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Subtract class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Subtract extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(left, right)](./firestore_lite.subtract.md#subtractconstructor) | | (BETA) Constructs a new instance of the Subtract class | + +## Subtract.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Subtract` class + +Signature: + +```typescript +constructor(left: Constant, right: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| left | [Constant](./firestore_lite.constant.md#constant_class) | | +| right | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.sum.md b/docs-devsite/firestore_lite.sum.md new file mode 100644 index 00000000000..0f65e6aa601 --- /dev/null +++ b/docs-devsite/firestore_lite.sum.md @@ -0,0 +1,67 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Sum class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Sum extends FirestoreFunction implements Accumulator +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [Accumulator](./firestore_lite.accumulator.md#accumulator_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value, distinct)](./firestore_lite.sum.md#sumconstructor) | | (BETA) Constructs a new instance of the Sum class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [accumulator](./firestore_lite.sum.md#sumaccumulator) | | true | (BETA) | + +## Sum.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Sum` class + +Signature: + +```typescript +constructor(value: Constant, distinct: boolean); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_lite.constant.md#constant_class) | | +| distinct | boolean | | + +## Sum.accumulator + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +accumulator: true; +``` diff --git a/docs-devsite/firestore_lite.timestampadd.md b/docs-devsite/firestore_lite.timestampadd.md new file mode 100644 index 00000000000..10f90f438e0 --- /dev/null +++ b/docs-devsite/firestore_lite.timestampadd.md @@ -0,0 +1,50 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# TimestampAdd class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class TimestampAdd extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(timestamp, unit, amount)](./firestore_lite.timestampadd.md#timestampaddconstructor) | | (BETA) Constructs a new instance of the TimestampAdd class | + +## TimestampAdd.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `TimestampAdd` class + +Signature: + +```typescript +constructor(timestamp: Constant, unit: Constant, amount: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| timestamp | [Constant](./firestore_lite.constant.md#constant_class) | | +| unit | [Constant](./firestore_lite.constant.md#constant_class) | | +| amount | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.timestampsub.md b/docs-devsite/firestore_lite.timestampsub.md new file mode 100644 index 00000000000..076e525cf10 --- /dev/null +++ b/docs-devsite/firestore_lite.timestampsub.md @@ -0,0 +1,50 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# TimestampSub class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class TimestampSub extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(timestamp, unit, amount)](./firestore_lite.timestampsub.md#timestampsubconstructor) | | (BETA) Constructs a new instance of the TimestampSub class | + +## TimestampSub.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `TimestampSub` class + +Signature: + +```typescript +constructor(timestamp: Constant, unit: Constant, amount: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| timestamp | [Constant](./firestore_lite.constant.md#constant_class) | | +| unit | [Constant](./firestore_lite.constant.md#constant_class) | | +| amount | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.timestamptounixmicros.md b/docs-devsite/firestore_lite.timestamptounixmicros.md new file mode 100644 index 00000000000..e9f398659a7 --- /dev/null +++ b/docs-devsite/firestore_lite.timestamptounixmicros.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# TimestampToUnixMicros class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class TimestampToUnixMicros extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(input)](./firestore_lite.timestamptounixmicros.md#timestamptounixmicrosconstructor) | | (BETA) Constructs a new instance of the TimestampToUnixMicros class | + +## TimestampToUnixMicros.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `TimestampToUnixMicros` class + +Signature: + +```typescript +constructor(input: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| input | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.timestamptounixmillis.md b/docs-devsite/firestore_lite.timestamptounixmillis.md new file mode 100644 index 00000000000..b354dcc5585 --- /dev/null +++ b/docs-devsite/firestore_lite.timestamptounixmillis.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# TimestampToUnixMillis class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class TimestampToUnixMillis extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(input)](./firestore_lite.timestamptounixmillis.md#timestamptounixmillisconstructor) | | (BETA) Constructs a new instance of the TimestampToUnixMillis class | + +## TimestampToUnixMillis.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `TimestampToUnixMillis` class + +Signature: + +```typescript +constructor(input: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| input | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.timestamptounixseconds.md b/docs-devsite/firestore_lite.timestamptounixseconds.md new file mode 100644 index 00000000000..2275fe6ebac --- /dev/null +++ b/docs-devsite/firestore_lite.timestamptounixseconds.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# TimestampToUnixSeconds class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class TimestampToUnixSeconds extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(input)](./firestore_lite.timestamptounixseconds.md#timestamptounixsecondsconstructor) | | (BETA) Constructs a new instance of the TimestampToUnixSeconds class | + +## TimestampToUnixSeconds.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `TimestampToUnixSeconds` class + +Signature: + +```typescript +constructor(input: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| input | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.tolower.md b/docs-devsite/firestore_lite.tolower.md new file mode 100644 index 00000000000..49128adf612 --- /dev/null +++ b/docs-devsite/firestore_lite.tolower.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ToLower class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ToLower extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr)](./firestore_lite.tolower.md#tolowerconstructor) | | (BETA) Constructs a new instance of the ToLower class | + +## ToLower.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ToLower` class + +Signature: + +```typescript +constructor(expr: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.toupper.md b/docs-devsite/firestore_lite.toupper.md new file mode 100644 index 00000000000..120c81d05bd --- /dev/null +++ b/docs-devsite/firestore_lite.toupper.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ToUpper class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class ToUpper extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr)](./firestore_lite.toupper.md#toupperconstructor) | | (BETA) Constructs a new instance of the ToUpper class | + +## ToUpper.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `ToUpper` class + +Signature: + +```typescript +constructor(expr: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.trim.md b/docs-devsite/firestore_lite.trim.md new file mode 100644 index 00000000000..8de73fd1667 --- /dev/null +++ b/docs-devsite/firestore_lite.trim.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Trim class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Trim extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(expr)](./firestore_lite.trim.md#trimconstructor) | | (BETA) Constructs a new instance of the Trim class | + +## Trim.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Trim` class + +Signature: + +```typescript +constructor(expr: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| expr | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.unixmicrostotimestamp.md b/docs-devsite/firestore_lite.unixmicrostotimestamp.md new file mode 100644 index 00000000000..a2e03a5dedf --- /dev/null +++ b/docs-devsite/firestore_lite.unixmicrostotimestamp.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# UnixMicrosToTimestamp class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class UnixMicrosToTimestamp extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(input)](./firestore_lite.unixmicrostotimestamp.md#unixmicrostotimestampconstructor) | | (BETA) Constructs a new instance of the UnixMicrosToTimestamp class | + +## UnixMicrosToTimestamp.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `UnixMicrosToTimestamp` class + +Signature: + +```typescript +constructor(input: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| input | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.unixmillistotimestamp.md b/docs-devsite/firestore_lite.unixmillistotimestamp.md new file mode 100644 index 00000000000..a48df96c0e9 --- /dev/null +++ b/docs-devsite/firestore_lite.unixmillistotimestamp.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# UnixMillisToTimestamp class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class UnixMillisToTimestamp extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(input)](./firestore_lite.unixmillistotimestamp.md#unixmillistotimestampconstructor) | | (BETA) Constructs a new instance of the UnixMillisToTimestamp class | + +## UnixMillisToTimestamp.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `UnixMillisToTimestamp` class + +Signature: + +```typescript +constructor(input: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| input | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.unixsecondstotimestamp.md b/docs-devsite/firestore_lite.unixsecondstotimestamp.md new file mode 100644 index 00000000000..99ad2f71285 --- /dev/null +++ b/docs-devsite/firestore_lite.unixsecondstotimestamp.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# UnixSecondsToTimestamp class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class UnixSecondsToTimestamp extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(input)](./firestore_lite.unixsecondstotimestamp.md#unixsecondstotimestampconstructor) | | (BETA) Constructs a new instance of the UnixSecondsToTimestamp class | + +## UnixSecondsToTimestamp.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `UnixSecondsToTimestamp` class + +Signature: + +```typescript +constructor(input: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| input | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.vectorlength.md b/docs-devsite/firestore_lite.vectorlength.md new file mode 100644 index 00000000000..58636d6f95a --- /dev/null +++ b/docs-devsite/firestore_lite.vectorlength.md @@ -0,0 +1,48 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# VectorLength class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class VectorLength extends FirestoreFunction +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(value)](./firestore_lite.vectorlength.md#vectorlengthconstructor) | | (BETA) Constructs a new instance of the VectorLength class | + +## VectorLength.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `VectorLength` class + +Signature: + +```typescript +constructor(value: Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | [Constant](./firestore_lite.constant.md#constant_class) | | + diff --git a/docs-devsite/firestore_lite.where.md b/docs-devsite/firestore_lite.where.md new file mode 100644 index 00000000000..1d3674f2659 --- /dev/null +++ b/docs-devsite/firestore_lite.where.md @@ -0,0 +1,64 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Where class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Where implements Stage +``` +Implements: [Stage](./firestore_lite.stage.md#stage_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(condition)](./firestore_lite.where.md#whereconstructor) | | (BETA) Constructs a new instance of the Where class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [name](./firestore_lite.where.md#wherename) | | string | (BETA) | + +## Where.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Where` class + +Signature: + +```typescript +constructor(condition: FilterCondition & Constant); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| condition | [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) & [Constant](./firestore_lite.constant.md#constant_class) | | + +## Where.name + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +name: string; +``` diff --git a/docs-devsite/firestore_lite.xor.md b/docs-devsite/firestore_lite.xor.md new file mode 100644 index 00000000000..2a94acbe570 --- /dev/null +++ b/docs-devsite/firestore_lite.xor.md @@ -0,0 +1,66 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Xor class +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + + +Signature: + +```typescript +export declare class Xor extends FirestoreFunction implements FilterCondition +``` +Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) + +Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(conditions)](./firestore_lite.xor.md#xorconstructor) | | (BETA) Constructs a new instance of the Xor class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [filterable](./firestore_lite.xor.md#xorfilterable) | | true | (BETA) | + +## Xor.(constructor) + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Constructs a new instance of the `Xor` class + +Signature: + +```typescript +constructor(conditions: FilterExpr[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| conditions | [FilterExpr](./firestore_lite.md#filterexpr)\[\] | | + +## Xor.filterable + +> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. +> + +Signature: + +```typescript +filterable: true; +``` diff --git a/docs-devsite/index.md b/docs-devsite/index.md index 82fdb36f076..2c22b58d80c 100644 --- a/docs-devsite/index.md +++ b/docs-devsite/index.md @@ -27,5 +27,5 @@ https://github.com/firebase/firebase-js-sdk | [@firebase/performance](./performance.md#performance_package) | The Firebase Performance Monitoring Web SDK. This SDK does not work in a Node.js environment. | | [@firebase/remote-config](./remote-config.md#remote-config_package) | The Firebase Remote Config Web SDK. This SDK does not work in a Node.js environment. | | [@firebase/storage](./storage.md#storage_package) | Cloud Storage for Firebase | -| [@firebase/vertexai](./vertexai.md#vertexai_package) | The Vertex AI in Firebase Web SDK. | +| [@firebase/vertexai-preview](./vertexai-preview.md#vertexai-preview_package) | The Vertex AI For Firebase Web SDK. | diff --git a/docs-devsite/vertexai.baseparams.md b/docs-devsite/vertexai-preview.baseparams.md similarity index 67% rename from docs-devsite/vertexai.baseparams.md rename to docs-devsite/vertexai-preview.baseparams.md index 382ec825210..6756c919ccc 100644 --- a/docs-devsite/vertexai.baseparams.md +++ b/docs-devsite/vertexai-preview.baseparams.md @@ -22,8 +22,8 @@ export interface BaseParams | Property | Type | Description | | --- | --- | --- | -| [generationConfig](./vertexai.baseparams.md#baseparamsgenerationconfig) | [GenerationConfig](./vertexai.generationconfig.md#generationconfig_interface) | | -| [safetySettings](./vertexai.baseparams.md#baseparamssafetysettings) | [SafetySetting](./vertexai.safetysetting.md#safetysetting_interface)\[\] | | +| [generationConfig](./vertexai-preview.baseparams.md#baseparamsgenerationconfig) | [GenerationConfig](./vertexai-preview.generationconfig.md#generationconfig_interface) | | +| [safetySettings](./vertexai-preview.baseparams.md#baseparamssafetysettings) | [SafetySetting](./vertexai-preview.safetysetting.md#safetysetting_interface)\[\] | | ## BaseParams.generationConfig diff --git a/docs-devsite/vertexai-preview.chatsession.md b/docs-devsite/vertexai-preview.chatsession.md new file mode 100644 index 00000000000..d8dc691d186 --- /dev/null +++ b/docs-devsite/vertexai-preview.chatsession.md @@ -0,0 +1,138 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ChatSession class +ChatSession class that enables sending chat messages and stores history of sent and received messages so far. + +Signature: + +```typescript +export declare class ChatSession +``` + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(apiSettings, model, params, requestOptions)](./vertexai-preview.chatsession.md#chatsessionconstructor) | | Constructs a new instance of the ChatSession class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [model](./vertexai-preview.chatsession.md#chatsessionmodel) | | string | | +| [params](./vertexai-preview.chatsession.md#chatsessionparams) | | [StartChatParams](./vertexai-preview.startchatparams.md#startchatparams_interface) \| undefined | | +| [requestOptions](./vertexai-preview.chatsession.md#chatsessionrequestoptions) | | [RequestOptions](./vertexai-preview.requestoptions.md#requestoptions_interface) \| undefined | | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [getHistory()](./vertexai-preview.chatsession.md#chatsessiongethistory) | | Gets the chat history so far. Blocked prompts are not added to history. Neither blocked candidates nor the prompts that generated them are added to history. | +| [sendMessage(request)](./vertexai-preview.chatsession.md#chatsessionsendmessage) | | Sends a chat message and receives a non-streaming [GenerateContentResult](./vertexai-preview.generatecontentresult.md#generatecontentresult_interface) | +| [sendMessageStream(request)](./vertexai-preview.chatsession.md#chatsessionsendmessagestream) | | Sends a chat message and receives the response as a [GenerateContentStreamResult](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresult_interface) containing an iterable stream and a response promise. | + +## ChatSession.(constructor) + +Constructs a new instance of the `ChatSession` class + +Signature: + +```typescript +constructor(apiSettings: ApiSettings, model: string, params?: StartChatParams | undefined, requestOptions?: RequestOptions | undefined); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| apiSettings | ApiSettings | | +| model | string | | +| params | [StartChatParams](./vertexai-preview.startchatparams.md#startchatparams_interface) \| undefined | | +| requestOptions | [RequestOptions](./vertexai-preview.requestoptions.md#requestoptions_interface) \| undefined | | + +## ChatSession.model + +Signature: + +```typescript +model: string; +``` + +## ChatSession.params + +Signature: + +```typescript +params?: StartChatParams | undefined; +``` + +## ChatSession.requestOptions + +Signature: + +```typescript +requestOptions?: RequestOptions | undefined; +``` + +## ChatSession.getHistory() + +Gets the chat history so far. Blocked prompts are not added to history. Neither blocked candidates nor the prompts that generated them are added to history. + +Signature: + +```typescript +getHistory(): Promise; +``` +Returns: + +Promise<[Content](./vertexai-preview.content.md#content_interface)\[\]> + +## ChatSession.sendMessage() + +Sends a chat message and receives a non-streaming [GenerateContentResult](./vertexai-preview.generatecontentresult.md#generatecontentresult_interface) + +Signature: + +```typescript +sendMessage(request: string | Array): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| request | string \| Array<string \| [Part](./vertexai-preview.md#part)> | | + +Returns: + +Promise<[GenerateContentResult](./vertexai-preview.generatecontentresult.md#generatecontentresult_interface)> + +## ChatSession.sendMessageStream() + +Sends a chat message and receives the response as a [GenerateContentStreamResult](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresult_interface) containing an iterable stream and a response promise. + +Signature: + +```typescript +sendMessageStream(request: string | Array): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| request | string \| Array<string \| [Part](./vertexai-preview.md#part)> | | + +Returns: + +Promise<[GenerateContentStreamResult](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresult_interface)> + diff --git a/docs-devsite/vertexai.citation.md b/docs-devsite/vertexai-preview.citation.md similarity index 68% rename from docs-devsite/vertexai.citation.md rename to docs-devsite/vertexai-preview.citation.md index b5f5a19f231..10a615ee247 100644 --- a/docs-devsite/vertexai.citation.md +++ b/docs-devsite/vertexai-preview.citation.md @@ -22,12 +22,12 @@ export interface Citation | Property | Type | Description | | --- | --- | --- | -| [endIndex](./vertexai.citation.md#citationendindex) | number | | -| [license](./vertexai.citation.md#citationlicense) | string | | -| [publicationDate](./vertexai.citation.md#citationpublicationdate) | Date | | -| [startIndex](./vertexai.citation.md#citationstartindex) | number | | -| [title](./vertexai.citation.md#citationtitle) | string | | -| [uri](./vertexai.citation.md#citationuri) | string | | +| [endIndex](./vertexai-preview.citation.md#citationendindex) | number | | +| [license](./vertexai-preview.citation.md#citationlicense) | string | | +| [publicationDate](./vertexai-preview.citation.md#citationpublicationdate) | Date | | +| [startIndex](./vertexai-preview.citation.md#citationstartindex) | number | | +| [title](./vertexai-preview.citation.md#citationtitle) | string | | +| [uri](./vertexai-preview.citation.md#citationuri) | string | | ## Citation.endIndex diff --git a/docs-devsite/vertexai.citationmetadata.md b/docs-devsite/vertexai-preview.citationmetadata.md similarity index 64% rename from docs-devsite/vertexai.citationmetadata.md rename to docs-devsite/vertexai-preview.citationmetadata.md index e3d41a37d98..fa740ca1af7 100644 --- a/docs-devsite/vertexai.citationmetadata.md +++ b/docs-devsite/vertexai-preview.citationmetadata.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # CitationMetadata interface -Citation metadata that may be found on a [GenerateContentCandidate](./vertexai.generatecontentcandidate.md#generatecontentcandidate_interface). +Citation metadata that may be found on a [GenerateContentCandidate](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidate_interface). Signature: @@ -22,7 +22,7 @@ export interface CitationMetadata | Property | Type | Description | | --- | --- | --- | -| [citations](./vertexai.citationmetadata.md#citationmetadatacitations) | [Citation](./vertexai.citation.md#citation_interface)\[\] | | +| [citations](./vertexai-preview.citationmetadata.md#citationmetadatacitations) | [Citation](./vertexai-preview.citation.md#citation_interface)\[\] | | ## CitationMetadata.citations diff --git a/docs-devsite/vertexai.content.md b/docs-devsite/vertexai-preview.content.md similarity index 76% rename from docs-devsite/vertexai.content.md rename to docs-devsite/vertexai-preview.content.md index 7a4634a62bc..26198a3951f 100644 --- a/docs-devsite/vertexai.content.md +++ b/docs-devsite/vertexai-preview.content.md @@ -22,8 +22,8 @@ export interface Content | Property | Type | Description | | --- | --- | --- | -| [parts](./vertexai.content.md#contentparts) | [Part](./vertexai.md#part)\[\] | | -| [role](./vertexai.content.md#contentrole) | [Role](./vertexai.md#role) | | +| [parts](./vertexai-preview.content.md#contentparts) | [Part](./vertexai-preview.md#part)\[\] | | +| [role](./vertexai-preview.content.md#contentrole) | [Role](./vertexai-preview.md#role) | | ## Content.parts diff --git a/docs-devsite/vertexai.counttokensrequest.md b/docs-devsite/vertexai-preview.counttokensrequest.md similarity index 68% rename from docs-devsite/vertexai.counttokensrequest.md rename to docs-devsite/vertexai-preview.counttokensrequest.md index db519b7eb11..07e5f0d85f3 100644 --- a/docs-devsite/vertexai.counttokensrequest.md +++ b/docs-devsite/vertexai-preview.counttokensrequest.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # CountTokensRequest interface -Params for calling [GenerativeModel.countTokens()](./vertexai.generativemodel.md#generativemodelcounttokens) +Params for calling [GenerativeModel.countTokens()](./vertexai-preview.generativemodel.md#generativemodelcounttokens) Signature: @@ -22,7 +22,7 @@ export interface CountTokensRequest | Property | Type | Description | | --- | --- | --- | -| [contents](./vertexai.counttokensrequest.md#counttokensrequestcontents) | [Content](./vertexai.content.md#content_interface)\[\] | | +| [contents](./vertexai-preview.counttokensrequest.md#counttokensrequestcontents) | [Content](./vertexai-preview.content.md#content_interface)\[\] | | ## CountTokensRequest.contents diff --git a/docs-devsite/vertexai.counttokensresponse.md b/docs-devsite/vertexai-preview.counttokensresponse.md similarity index 67% rename from docs-devsite/vertexai.counttokensresponse.md rename to docs-devsite/vertexai-preview.counttokensresponse.md index 2978f9a45bb..d097d5aacff 100644 --- a/docs-devsite/vertexai.counttokensresponse.md +++ b/docs-devsite/vertexai-preview.counttokensresponse.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # CountTokensResponse interface -Response from calling [GenerativeModel.countTokens()](./vertexai.generativemodel.md#generativemodelcounttokens). +Response from calling [GenerativeModel.countTokens()](./vertexai-preview.generativemodel.md#generativemodelcounttokens). Signature: @@ -22,8 +22,8 @@ export interface CountTokensResponse | Property | Type | Description | | --- | --- | --- | -| [totalBillableCharacters](./vertexai.counttokensresponse.md#counttokensresponsetotalbillablecharacters) | number | The total number of billable characters counted across all instances from the request. | -| [totalTokens](./vertexai.counttokensresponse.md#counttokensresponsetotaltokens) | number | The total number of tokens counted across all instances from the request. | +| [totalBillableCharacters](./vertexai-preview.counttokensresponse.md#counttokensresponsetotalbillablecharacters) | number | The total number of billable characters counted across all instances from the request. | +| [totalTokens](./vertexai-preview.counttokensresponse.md#counttokensresponsetotaltokens) | number | The total number of tokens counted across all instances from the request. | ## CountTokensResponse.totalBillableCharacters diff --git a/docs-devsite/vertexai.customerrordata.md b/docs-devsite/vertexai-preview.customerrordata.md similarity index 54% rename from docs-devsite/vertexai.customerrordata.md rename to docs-devsite/vertexai-preview.customerrordata.md index 701b1b84c49..f0af0574161 100644 --- a/docs-devsite/vertexai.customerrordata.md +++ b/docs-devsite/vertexai-preview.customerrordata.md @@ -22,10 +22,10 @@ export interface CustomErrorData | Property | Type | Description | | --- | --- | --- | -| [errorDetails](./vertexai.customerrordata.md#customerrordataerrordetails) | [ErrorDetails](./vertexai.errordetails.md#errordetails_interface)\[\] | Optional additional details about the error. | -| [response](./vertexai.customerrordata.md#customerrordataresponse) | [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface) | Response from a [GenerateContentRequest](./vertexai.generatecontentrequest.md#generatecontentrequest_interface) | -| [status](./vertexai.customerrordata.md#customerrordatastatus) | number | HTTP status code of the error response. | -| [statusText](./vertexai.customerrordata.md#customerrordatastatustext) | string | HTTP status text of the error response. | +| [errorDetails](./vertexai-preview.customerrordata.md#customerrordataerrordetails) | [ErrorDetails](./vertexai-preview.errordetails.md#errordetails_interface)\[\] | Optional additional details about the error. | +| [response](./vertexai-preview.customerrordata.md#customerrordataresponse) | [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface) | Response from a [GenerateContentRequest](./vertexai-preview.generatecontentrequest.md#generatecontentrequest_interface) | +| [status](./vertexai-preview.customerrordata.md#customerrordatastatus) | number | HTTP status code of the error response. | +| [statusText](./vertexai-preview.customerrordata.md#customerrordatastatustext) | string | HTTP status text of the error response. | ## CustomErrorData.errorDetails @@ -39,7 +39,7 @@ errorDetails?: ErrorDetails[]; ## CustomErrorData.response -Response from a [GenerateContentRequest](./vertexai.generatecontentrequest.md#generatecontentrequest_interface) +Response from a [GenerateContentRequest](./vertexai-preview.generatecontentrequest.md#generatecontentrequest_interface) Signature: diff --git a/docs-devsite/vertexai.date_2.md b/docs-devsite/vertexai-preview.date_2.md similarity index 78% rename from docs-devsite/vertexai.date_2.md rename to docs-devsite/vertexai-preview.date_2.md index cf073bb86fe..5af031447c4 100644 --- a/docs-devsite/vertexai.date_2.md +++ b/docs-devsite/vertexai-preview.date_2.md @@ -22,9 +22,9 @@ export interface Date | Property | Type | Description | | --- | --- | --- | -| [day](./vertexai.date_2.md#date_2day) | number | | -| [month](./vertexai.date_2.md#date_2month) | number | | -| [year](./vertexai.date_2.md#date_2year) | number | | +| [day](./vertexai-preview.date_2.md#date_2day) | number | | +| [month](./vertexai-preview.date_2.md#date_2month) | number | | +| [year](./vertexai-preview.date_2.md#date_2year) | number | | ## Date\_2.day diff --git a/docs-devsite/vertexai.enhancedgeneratecontentresponse.md b/docs-devsite/vertexai-preview.enhancedgeneratecontentresponse.md similarity index 61% rename from docs-devsite/vertexai.enhancedgeneratecontentresponse.md rename to docs-devsite/vertexai-preview.enhancedgeneratecontentresponse.md index 535fb9def8f..132c5ed0be2 100644 --- a/docs-devsite/vertexai.enhancedgeneratecontentresponse.md +++ b/docs-devsite/vertexai-preview.enhancedgeneratecontentresponse.md @@ -17,14 +17,14 @@ Response object wrapped with helper methods. ```typescript export interface EnhancedGenerateContentResponse extends GenerateContentResponse ``` -Extends: [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface) +Extends: [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface) ## Properties | Property | Type | Description | | --- | --- | --- | -| [functionCalls](./vertexai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponsefunctioncalls) | () => [FunctionCall](./vertexai.functioncall.md#functioncall_interface)\[\] \| undefined | | -| [text](./vertexai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponsetext) | () => string | Returns the text string from the response, if available. Throws if the prompt or candidate was blocked. | +| [functionCalls](./vertexai-preview.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponsefunctioncalls) | () => [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface)\[\] \| undefined | | +| [text](./vertexai-preview.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponsetext) | () => string | Returns the text string from the response, if available. Throws if the prompt or candidate was blocked. | ## EnhancedGenerateContentResponse.functionCalls diff --git a/docs-devsite/vertexai.errordetails.md b/docs-devsite/vertexai-preview.errordetails.md similarity index 68% rename from docs-devsite/vertexai.errordetails.md rename to docs-devsite/vertexai-preview.errordetails.md index 68959343439..45e84a618ab 100644 --- a/docs-devsite/vertexai.errordetails.md +++ b/docs-devsite/vertexai-preview.errordetails.md @@ -22,10 +22,10 @@ export interface ErrorDetails | Property | Type | Description | | --- | --- | --- | -| ["@type"](./vertexai.errordetails.md#errordetails"@type") | string | | -| [domain](./vertexai.errordetails.md#errordetailsdomain) | string | The domain where the error occurred. | -| [metadata](./vertexai.errordetails.md#errordetailsmetadata) | Record<string, unknown> | Additional metadata about the error. | -| [reason](./vertexai.errordetails.md#errordetailsreason) | string | The reason for the error. | +| ["@type"](./vertexai-preview.errordetails.md#errordetails"@type") | string | | +| [domain](./vertexai-preview.errordetails.md#errordetailsdomain) | string | The domain where the error occurred. | +| [metadata](./vertexai-preview.errordetails.md#errordetailsmetadata) | Record<string, unknown> | Additional metadata about the error. | +| [reason](./vertexai-preview.errordetails.md#errordetailsreason) | string | The reason for the error. | ## ErrorDetails."@type" diff --git a/docs-devsite/vertexai.filedata.md b/docs-devsite/vertexai-preview.filedata.md similarity index 81% rename from docs-devsite/vertexai.filedata.md rename to docs-devsite/vertexai-preview.filedata.md index 7e000174692..577b4b1910d 100644 --- a/docs-devsite/vertexai.filedata.md +++ b/docs-devsite/vertexai-preview.filedata.md @@ -22,8 +22,8 @@ export interface FileData | Property | Type | Description | | --- | --- | --- | -| [fileUri](./vertexai.filedata.md#filedatafileuri) | string | | -| [mimeType](./vertexai.filedata.md#filedatamimetype) | string | | +| [fileUri](./vertexai-preview.filedata.md#filedatafileuri) | string | | +| [mimeType](./vertexai-preview.filedata.md#filedatamimetype) | string | | ## FileData.fileUri diff --git a/docs-devsite/vertexai.filedatapart.md b/docs-devsite/vertexai-preview.filedatapart.md similarity index 60% rename from docs-devsite/vertexai.filedatapart.md rename to docs-devsite/vertexai-preview.filedatapart.md index 74512fa6d29..e03c056f588 100644 --- a/docs-devsite/vertexai.filedatapart.md +++ b/docs-devsite/vertexai-preview.filedatapart.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # FileDataPart interface -Content part interface if the part represents [FileData](./vertexai.filedata.md#filedata_interface) +Content part interface if the part represents [FileData](./vertexai-preview.filedata.md#filedata_interface) Signature: @@ -22,11 +22,11 @@ export interface FileDataPart | Property | Type | Description | | --- | --- | --- | -| [fileData](./vertexai.filedatapart.md#filedatapartfiledata) | [FileData](./vertexai.filedata.md#filedata_interface) | | -| [functionCall](./vertexai.filedatapart.md#filedatapartfunctioncall) | never | | -| [functionResponse](./vertexai.filedatapart.md#filedatapartfunctionresponse) | never | | -| [inlineData](./vertexai.filedatapart.md#filedatapartinlinedata) | never | | -| [text](./vertexai.filedatapart.md#filedataparttext) | never | | +| [fileData](./vertexai-preview.filedatapart.md#filedatapartfiledata) | [FileData](./vertexai-preview.filedata.md#filedata_interface) | | +| [functionCall](./vertexai-preview.filedatapart.md#filedatapartfunctioncall) | never | | +| [functionResponse](./vertexai-preview.filedatapart.md#filedatapartfunctionresponse) | never | | +| [inlineData](./vertexai-preview.filedatapart.md#filedatapartinlinedata) | never | | +| [text](./vertexai-preview.filedatapart.md#filedataparttext) | never | | ## FileDataPart.fileData diff --git a/docs-devsite/vertexai.functioncall.md b/docs-devsite/vertexai-preview.functioncall.md similarity index 57% rename from docs-devsite/vertexai.functioncall.md rename to docs-devsite/vertexai-preview.functioncall.md index ca7bc015438..60e0ea50dc4 100644 --- a/docs-devsite/vertexai.functioncall.md +++ b/docs-devsite/vertexai-preview.functioncall.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # FunctionCall interface -A predicted [FunctionCall](./vertexai.functioncall.md#functioncall_interface) returned from the model that contains a string representing the [FunctionDeclaration.name](./vertexai.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing the parameters and their values. +A predicted [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) returned from the model that contains a string representing the [FunctionDeclaration.name](./vertexai-preview.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing the parameters and their values. Signature: @@ -22,8 +22,8 @@ export interface FunctionCall | Property | Type | Description | | --- | --- | --- | -| [args](./vertexai.functioncall.md#functioncallargs) | object | | -| [name](./vertexai.functioncall.md#functioncallname) | string | | +| [args](./vertexai-preview.functioncall.md#functioncallargs) | object | | +| [name](./vertexai-preview.functioncall.md#functioncallname) | string | | ## FunctionCall.args diff --git a/docs-devsite/vertexai.functioncallingconfig.md b/docs-devsite/vertexai-preview.functioncallingconfig.md similarity index 71% rename from docs-devsite/vertexai.functioncallingconfig.md rename to docs-devsite/vertexai-preview.functioncallingconfig.md index 3724fec5bf7..1965fb76e95 100644 --- a/docs-devsite/vertexai.functioncallingconfig.md +++ b/docs-devsite/vertexai-preview.functioncallingconfig.md @@ -21,8 +21,8 @@ export interface FunctionCallingConfig | Property | Type | Description | | --- | --- | --- | -| [allowedFunctionNames](./vertexai.functioncallingconfig.md#functioncallingconfigallowedfunctionnames) | string\[\] | | -| [mode](./vertexai.functioncallingconfig.md#functioncallingconfigmode) | [FunctionCallingMode](./vertexai.md#functioncallingmode) | | +| [allowedFunctionNames](./vertexai-preview.functioncallingconfig.md#functioncallingconfigallowedfunctionnames) | string\[\] | | +| [mode](./vertexai-preview.functioncallingconfig.md#functioncallingconfigmode) | [FunctionCallingMode](./vertexai-preview.md#functioncallingmode) | | ## FunctionCallingConfig.allowedFunctionNames diff --git a/docs-devsite/vertexai.functioncallpart.md b/docs-devsite/vertexai-preview.functioncallpart.md similarity index 59% rename from docs-devsite/vertexai.functioncallpart.md rename to docs-devsite/vertexai-preview.functioncallpart.md index af8ccf1109a..5da204692f9 100644 --- a/docs-devsite/vertexai.functioncallpart.md +++ b/docs-devsite/vertexai-preview.functioncallpart.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # FunctionCallPart interface -Content part interface if the part represents a [FunctionCall](./vertexai.functioncall.md#functioncall_interface). +Content part interface if the part represents a [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface). Signature: @@ -22,10 +22,10 @@ export interface FunctionCallPart | Property | Type | Description | | --- | --- | --- | -| [functionCall](./vertexai.functioncallpart.md#functioncallpartfunctioncall) | [FunctionCall](./vertexai.functioncall.md#functioncall_interface) | | -| [functionResponse](./vertexai.functioncallpart.md#functioncallpartfunctionresponse) | never | | -| [inlineData](./vertexai.functioncallpart.md#functioncallpartinlinedata) | never | | -| [text](./vertexai.functioncallpart.md#functioncallparttext) | never | | +| [functionCall](./vertexai-preview.functioncallpart.md#functioncallpartfunctioncall) | [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) | | +| [functionResponse](./vertexai-preview.functioncallpart.md#functioncallpartfunctionresponse) | never | | +| [inlineData](./vertexai-preview.functioncallpart.md#functioncallpartinlinedata) | never | | +| [text](./vertexai-preview.functioncallpart.md#functioncallparttext) | never | | ## FunctionCallPart.functionCall diff --git a/docs-devsite/vertexai.functiondeclaration.md b/docs-devsite/vertexai-preview.functiondeclaration.md similarity index 57% rename from docs-devsite/vertexai.functiondeclaration.md rename to docs-devsite/vertexai-preview.functiondeclaration.md index 211c1dd868d..e178c7e8bc3 100644 --- a/docs-devsite/vertexai.functiondeclaration.md +++ b/docs-devsite/vertexai-preview.functiondeclaration.md @@ -22,18 +22,18 @@ export declare interface FunctionDeclaration | Property | Type | Description | | --- | --- | --- | -| [description](./vertexai.functiondeclaration.md#functiondeclarationdescription) | string | Description and purpose of the function. Model uses it to decide how and whether to call the function. | -| [name](./vertexai.functiondeclaration.md#functiondeclarationname) | string | The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a max length of 64. | -| [parameters](./vertexai.functiondeclaration.md#functiondeclarationparameters) | [ObjectSchemaInterface](./vertexai.objectschemainterface.md#objectschemainterface_interface) | Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. Parameter names are case-sensitive. For a function with no parameters, this can be left unset. | +| [description](./vertexai-preview.functiondeclaration.md#functiondeclarationdescription) | string | Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function. | +| [name](./vertexai-preview.functiondeclaration.md#functiondeclarationname) | string | The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a max length of 64. | +| [parameters](./vertexai-preview.functiondeclaration.md#functiondeclarationparameters) | [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface) | Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. Parameter names are case-sensitive. For a function with no parameters, this can be left unset. | ## FunctionDeclaration.description -Description and purpose of the function. Model uses it to decide how and whether to call the function. +Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function. Signature: ```typescript -description: string; +description?: string; ``` ## FunctionDeclaration.name @@ -53,5 +53,5 @@ Optional. Describes the parameters to this function in JSON Schema Object format Signature: ```typescript -parameters?: ObjectSchemaInterface; +parameters?: FunctionDeclarationSchema; ``` diff --git a/docs-devsite/vertexai-preview.functiondeclarationschema.md b/docs-devsite/vertexai-preview.functiondeclarationschema.md new file mode 100644 index 00000000000..7d0e5809d41 --- /dev/null +++ b/docs-devsite/vertexai-preview.functiondeclarationschema.md @@ -0,0 +1,70 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# FunctionDeclarationSchema interface +Schema for parameters passed to [FunctionDeclaration.parameters](./vertexai-preview.functiondeclaration.md#functiondeclarationparameters). + +Signature: + +```typescript +export interface FunctionDeclarationSchema +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [description](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschemadescription) | string | Optional. Description of the parameter. | +| [properties](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschemaproperties) | { \[k: string\]: [FunctionDeclarationSchemaProperty](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemaproperty_interface); } | The format of the parameter. | +| [required](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschemarequired) | string\[\] | Optional. Array of required parameters. | +| [type](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschematype) | [FunctionDeclarationSchemaType](./vertexai-preview.md#functiondeclarationschematype) | The type of the parameter. | + +## FunctionDeclarationSchema.description + +Optional. Description of the parameter. + +Signature: + +```typescript +description?: string; +``` + +## FunctionDeclarationSchema.properties + +The format of the parameter. + +Signature: + +```typescript +properties: { + [k: string]: FunctionDeclarationSchemaProperty; + }; +``` + +## FunctionDeclarationSchema.required + +Optional. Array of required parameters. + +Signature: + +```typescript +required?: string[]; +``` + +## FunctionDeclarationSchema.type + +The type of the parameter. + +Signature: + +```typescript +type: FunctionDeclarationSchemaType; +``` diff --git a/docs-devsite/vertexai-preview.functiondeclarationschemaproperty.md b/docs-devsite/vertexai-preview.functiondeclarationschemaproperty.md new file mode 100644 index 00000000000..ac2e1262dd0 --- /dev/null +++ b/docs-devsite/vertexai-preview.functiondeclarationschemaproperty.md @@ -0,0 +1,125 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# FunctionDeclarationSchemaProperty interface +Schema is used to define the format of input/output data. Represents a select subset of an OpenAPI 3.0 schema object. More fields may be added in the future as needed. + +Signature: + +```typescript +export interface FunctionDeclarationSchemaProperty +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [description](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertydescription) | string | Optional. The description of the property. | +| [enum](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertyenum) | string\[\] | Optional. The enum of the property. | +| [example](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertyexample) | unknown | Optional. The example of the property. | +| [format](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertyformat) | string | Optional. The format of the property. | +| [items](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertyitems) | [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface) | Optional. The items of the property. [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface) | +| [nullable](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertynullable) | boolean | Optional. Whether the property is nullable. | +| [properties](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertyproperties) | { \[k: string\]: [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface); } | Optional. Map of [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface). | +| [required](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertyrequired) | string\[\] | Optional. Array of required property. | +| [type](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertytype) | [FunctionDeclarationSchemaType](./vertexai-preview.md#functiondeclarationschematype) | Optional. The type of the property. [FunctionDeclarationSchemaType](./vertexai-preview.md#functiondeclarationschematype). | + +## FunctionDeclarationSchemaProperty.description + +Optional. The description of the property. + +Signature: + +```typescript +description?: string; +``` + +## FunctionDeclarationSchemaProperty.enum + +Optional. The enum of the property. + +Signature: + +```typescript +enum?: string[]; +``` + +## FunctionDeclarationSchemaProperty.example + +Optional. The example of the property. + +Signature: + +```typescript +example?: unknown; +``` + +## FunctionDeclarationSchemaProperty.format + +Optional. The format of the property. + +Signature: + +```typescript +format?: string; +``` + +## FunctionDeclarationSchemaProperty.items + +Optional. The items of the property. [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface) + +Signature: + +```typescript +items?: FunctionDeclarationSchema; +``` + +## FunctionDeclarationSchemaProperty.nullable + +Optional. Whether the property is nullable. + +Signature: + +```typescript +nullable?: boolean; +``` + +## FunctionDeclarationSchemaProperty.properties + +Optional. Map of [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface). + +Signature: + +```typescript +properties?: { + [k: string]: FunctionDeclarationSchema; + }; +``` + +## FunctionDeclarationSchemaProperty.required + +Optional. Array of required property. + +Signature: + +```typescript +required?: string[]; +``` + +## FunctionDeclarationSchemaProperty.type + +Optional. The type of the property. [FunctionDeclarationSchemaType](./vertexai-preview.md#functiondeclarationschematype). + +Signature: + +```typescript +type?: FunctionDeclarationSchemaType; +``` diff --git a/docs-devsite/vertexai-preview.functiondeclarationstool.md b/docs-devsite/vertexai-preview.functiondeclarationstool.md new file mode 100644 index 00000000000..d1af4351a23 --- /dev/null +++ b/docs-devsite/vertexai-preview.functiondeclarationstool.md @@ -0,0 +1,35 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# FunctionDeclarationsTool interface +A `FunctionDeclarationsTool` is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. + +Signature: + +```typescript +export declare interface FunctionDeclarationsTool +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [functionDeclarations](./vertexai-preview.functiondeclarationstool.md#functiondeclarationstoolfunctiondeclarations) | [FunctionDeclaration](./vertexai-preview.functiondeclaration.md#functiondeclaration_interface)\[\] | Optional. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) in the response. User should provide a [FunctionResponse](./vertexai-preview.functionresponse.md#functionresponse_interface) for each function call in the next turn. Based on the function responses, the model will generate the final response back to the user. Maximum 64 function declarations can be provided. | + +## FunctionDeclarationsTool.functionDeclarations + +Optional. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) in the response. User should provide a [FunctionResponse](./vertexai-preview.functionresponse.md#functionresponse_interface) for each function call in the next turn. Based on the function responses, the model will generate the final response back to the user. Maximum 64 function declarations can be provided. + +Signature: + +```typescript +functionDeclarations?: FunctionDeclaration[]; +``` diff --git a/docs-devsite/vertexai.functionresponse.md b/docs-devsite/vertexai-preview.functionresponse.md similarity index 50% rename from docs-devsite/vertexai.functionresponse.md rename to docs-devsite/vertexai-preview.functionresponse.md index 0ca553e0e6b..d89ace08df1 100644 --- a/docs-devsite/vertexai.functionresponse.md +++ b/docs-devsite/vertexai-preview.functionresponse.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # FunctionResponse interface -The result output from a [FunctionCall](./vertexai.functioncall.md#functioncall_interface) that contains a string representing the [FunctionDeclaration.name](./vertexai.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a [FunctionCall](./vertexai.functioncall.md#functioncall_interface) made based on model prediction. +The result output from a [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) that contains a string representing the [FunctionDeclaration.name](./vertexai-preview.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) made based on model prediction. Signature: @@ -22,8 +22,8 @@ export interface FunctionResponse | Property | Type | Description | | --- | --- | --- | -| [name](./vertexai.functionresponse.md#functionresponsename) | string | | -| [response](./vertexai.functionresponse.md#functionresponseresponse) | object | | +| [name](./vertexai-preview.functionresponse.md#functionresponsename) | string | | +| [response](./vertexai-preview.functionresponse.md#functionresponseresponse) | object | | ## FunctionResponse.name diff --git a/docs-devsite/vertexai.functionresponsepart.md b/docs-devsite/vertexai-preview.functionresponsepart.md similarity index 58% rename from docs-devsite/vertexai.functionresponsepart.md rename to docs-devsite/vertexai-preview.functionresponsepart.md index 1905c98cdc7..4e246d625f6 100644 --- a/docs-devsite/vertexai.functionresponsepart.md +++ b/docs-devsite/vertexai-preview.functionresponsepart.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # FunctionResponsePart interface -Content part interface if the part represents [FunctionResponse](./vertexai.functionresponse.md#functionresponse_interface). +Content part interface if the part represents [FunctionResponse](./vertexai-preview.functionresponse.md#functionresponse_interface). Signature: @@ -22,10 +22,10 @@ export interface FunctionResponsePart | Property | Type | Description | | --- | --- | --- | -| [functionCall](./vertexai.functionresponsepart.md#functionresponsepartfunctioncall) | never | | -| [functionResponse](./vertexai.functionresponsepart.md#functionresponsepartfunctionresponse) | [FunctionResponse](./vertexai.functionresponse.md#functionresponse_interface) | | -| [inlineData](./vertexai.functionresponsepart.md#functionresponsepartinlinedata) | never | | -| [text](./vertexai.functionresponsepart.md#functionresponseparttext) | never | | +| [functionCall](./vertexai-preview.functionresponsepart.md#functionresponsepartfunctioncall) | never | | +| [functionResponse](./vertexai-preview.functionresponsepart.md#functionresponsepartfunctionresponse) | [FunctionResponse](./vertexai-preview.functionresponse.md#functionresponse_interface) | | +| [inlineData](./vertexai-preview.functionresponsepart.md#functionresponsepartinlinedata) | never | | +| [text](./vertexai-preview.functionresponsepart.md#functionresponseparttext) | never | | ## FunctionResponsePart.functionCall diff --git a/docs-devsite/vertexai-preview.generatecontentcandidate.md b/docs-devsite/vertexai-preview.generatecontentcandidate.md new file mode 100644 index 00000000000..9f36fab1e87 --- /dev/null +++ b/docs-devsite/vertexai-preview.generatecontentcandidate.md @@ -0,0 +1,87 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# GenerateContentCandidate interface +A candidate returned as part of a [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface). + +Signature: + +```typescript +export interface GenerateContentCandidate +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [citationMetadata](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidatecitationmetadata) | [CitationMetadata](./vertexai-preview.citationmetadata.md#citationmetadata_interface) | | +| [content](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidatecontent) | [Content](./vertexai-preview.content.md#content_interface) | | +| [finishMessage](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidatefinishmessage) | string | | +| [finishReason](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidatefinishreason) | [FinishReason](./vertexai-preview.md#finishreason) | | +| [groundingMetadata](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidategroundingmetadata) | [GroundingMetadata](./vertexai-preview.groundingmetadata.md#groundingmetadata_interface) | | +| [index](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidateindex) | number | | +| [safetyRatings](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidatesafetyratings) | [SafetyRating](./vertexai-preview.safetyrating.md#safetyrating_interface)\[\] | | + +## GenerateContentCandidate.citationMetadata + +Signature: + +```typescript +citationMetadata?: CitationMetadata; +``` + +## GenerateContentCandidate.content + +Signature: + +```typescript +content: Content; +``` + +## GenerateContentCandidate.finishMessage + +Signature: + +```typescript +finishMessage?: string; +``` + +## GenerateContentCandidate.finishReason + +Signature: + +```typescript +finishReason?: FinishReason; +``` + +## GenerateContentCandidate.groundingMetadata + +Signature: + +```typescript +groundingMetadata?: GroundingMetadata; +``` + +## GenerateContentCandidate.index + +Signature: + +```typescript +index: number; +``` + +## GenerateContentCandidate.safetyRatings + +Signature: + +```typescript +safetyRatings?: SafetyRating[]; +``` diff --git a/docs-devsite/vertexai.generatecontentrequest.md b/docs-devsite/vertexai-preview.generatecontentrequest.md similarity index 54% rename from docs-devsite/vertexai.generatecontentrequest.md rename to docs-devsite/vertexai-preview.generatecontentrequest.md index 31f1103a2e2..68ce52340e8 100644 --- a/docs-devsite/vertexai.generatecontentrequest.md +++ b/docs-devsite/vertexai-preview.generatecontentrequest.md @@ -10,23 +10,23 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # GenerateContentRequest interface -Request sent through [GenerativeModel.generateContent()](./vertexai.generativemodel.md#generativemodelgeneratecontent) +Request sent through [GenerativeModel.generateContent()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontent) Signature: ```typescript export interface GenerateContentRequest extends BaseParams ``` -Extends: [BaseParams](./vertexai.baseparams.md#baseparams_interface) +Extends: [BaseParams](./vertexai-preview.baseparams.md#baseparams_interface) ## Properties | Property | Type | Description | | --- | --- | --- | -| [contents](./vertexai.generatecontentrequest.md#generatecontentrequestcontents) | [Content](./vertexai.content.md#content_interface)\[\] | | -| [systemInstruction](./vertexai.generatecontentrequest.md#generatecontentrequestsysteminstruction) | string \| [Part](./vertexai.md#part) \| [Content](./vertexai.content.md#content_interface) | | -| [toolConfig](./vertexai.generatecontentrequest.md#generatecontentrequesttoolconfig) | [ToolConfig](./vertexai.toolconfig.md#toolconfig_interface) | | -| [tools](./vertexai.generatecontentrequest.md#generatecontentrequesttools) | [Tool](./vertexai.md#tool)\[\] | | +| [contents](./vertexai-preview.generatecontentrequest.md#generatecontentrequestcontents) | [Content](./vertexai-preview.content.md#content_interface)\[\] | | +| [systemInstruction](./vertexai-preview.generatecontentrequest.md#generatecontentrequestsysteminstruction) | string \| [Part](./vertexai-preview.md#part) \| [Content](./vertexai-preview.content.md#content_interface) | | +| [toolConfig](./vertexai-preview.generatecontentrequest.md#generatecontentrequesttoolconfig) | [ToolConfig](./vertexai-preview.toolconfig.md#toolconfig_interface) | | +| [tools](./vertexai-preview.generatecontentrequest.md#generatecontentrequesttools) | [Tool](./vertexai-preview.md#tool)\[\] | | ## GenerateContentRequest.contents diff --git a/docs-devsite/vertexai.generatecontentresponse.md b/docs-devsite/vertexai-preview.generatecontentresponse.md similarity index 50% rename from docs-devsite/vertexai.generatecontentresponse.md rename to docs-devsite/vertexai-preview.generatecontentresponse.md index 304674c9b6f..cb0fb0e3209 100644 --- a/docs-devsite/vertexai.generatecontentresponse.md +++ b/docs-devsite/vertexai-preview.generatecontentresponse.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # GenerateContentResponse interface -Individual response from [GenerativeModel.generateContent()](./vertexai.generativemodel.md#generativemodelgeneratecontent) and [GenerativeModel.generateContentStream()](./vertexai.generativemodel.md#generativemodelgeneratecontentstream). `generateContentStream()` will return one in each chunk until the stream is done. +Individual response from [GenerativeModel.generateContent()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontent) and [GenerativeModel.generateContentStream()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontentstream). `generateContentStream()` will return one in each chunk until the stream is done. Signature: @@ -22,9 +22,9 @@ export interface GenerateContentResponse | Property | Type | Description | | --- | --- | --- | -| [candidates](./vertexai.generatecontentresponse.md#generatecontentresponsecandidates) | [GenerateContentCandidate](./vertexai.generatecontentcandidate.md#generatecontentcandidate_interface)\[\] | | -| [promptFeedback](./vertexai.generatecontentresponse.md#generatecontentresponsepromptfeedback) | [PromptFeedback](./vertexai.promptfeedback.md#promptfeedback_interface) | | -| [usageMetadata](./vertexai.generatecontentresponse.md#generatecontentresponseusagemetadata) | [UsageMetadata](./vertexai.usagemetadata.md#usagemetadata_interface) | | +| [candidates](./vertexai-preview.generatecontentresponse.md#generatecontentresponsecandidates) | [GenerateContentCandidate](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidate_interface)\[\] | | +| [promptFeedback](./vertexai-preview.generatecontentresponse.md#generatecontentresponsepromptfeedback) | [PromptFeedback](./vertexai-preview.promptfeedback.md#promptfeedback_interface) | | +| [usageMetadata](./vertexai-preview.generatecontentresponse.md#generatecontentresponseusagemetadata) | [UsageMetadata](./vertexai-preview.usagemetadata.md#usagemetadata_interface) | | ## GenerateContentResponse.candidates diff --git a/docs-devsite/vertexai.generatecontentresult.md b/docs-devsite/vertexai-preview.generatecontentresult.md similarity index 69% rename from docs-devsite/vertexai.generatecontentresult.md rename to docs-devsite/vertexai-preview.generatecontentresult.md index 3e162f9ebb2..87249a5bc55 100644 --- a/docs-devsite/vertexai.generatecontentresult.md +++ b/docs-devsite/vertexai-preview.generatecontentresult.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # GenerateContentResult interface -Result object returned from [GenerativeModel.generateContent()](./vertexai.generativemodel.md#generativemodelgeneratecontent) call. +Result object returned from [GenerativeModel.generateContent()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontent) call. Signature: @@ -22,7 +22,7 @@ export interface GenerateContentResult | Property | Type | Description | | --- | --- | --- | -| [response](./vertexai.generatecontentresult.md#generatecontentresultresponse) | [EnhancedGenerateContentResponse](./vertexai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface) | | +| [response](./vertexai-preview.generatecontentresult.md#generatecontentresultresponse) | [EnhancedGenerateContentResponse](./vertexai-preview.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface) | | ## GenerateContentResult.response diff --git a/docs-devsite/vertexai.generatecontentstreamresult.md b/docs-devsite/vertexai-preview.generatecontentstreamresult.md similarity index 52% rename from docs-devsite/vertexai.generatecontentstreamresult.md rename to docs-devsite/vertexai-preview.generatecontentstreamresult.md index 340abb1d0bd..6fd46600079 100644 --- a/docs-devsite/vertexai.generatecontentstreamresult.md +++ b/docs-devsite/vertexai-preview.generatecontentstreamresult.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # GenerateContentStreamResult interface -Result object returned from [GenerativeModel.generateContentStream()](./vertexai.generativemodel.md#generativemodelgeneratecontentstream) call. Iterate over `stream` to get chunks as they come in and/or use the `response` promise to get the aggregated response when the stream is done. +Result object returned from [GenerativeModel.generateContentStream()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontentstream) call. Iterate over `stream` to get chunks as they come in and/or use the `response` promise to get the aggregated response when the stream is done. Signature: @@ -22,8 +22,8 @@ export interface GenerateContentStreamResult | Property | Type | Description | | --- | --- | --- | -| [response](./vertexai.generatecontentstreamresult.md#generatecontentstreamresultresponse) | Promise<[EnhancedGenerateContentResponse](./vertexai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface)> | | -| [stream](./vertexai.generatecontentstreamresult.md#generatecontentstreamresultstream) | AsyncGenerator<[EnhancedGenerateContentResponse](./vertexai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface)> | | +| [response](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresultresponse) | Promise<[EnhancedGenerateContentResponse](./vertexai-preview.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface)> | | +| [stream](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresultstream) | AsyncGenerator<[EnhancedGenerateContentResponse](./vertexai-preview.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface)> | | ## GenerateContentStreamResult.response diff --git a/docs-devsite/vertexai-preview.generationconfig.md b/docs-devsite/vertexai-preview.generationconfig.md new file mode 100644 index 00000000000..b14dfea053b --- /dev/null +++ b/docs-devsite/vertexai-preview.generationconfig.md @@ -0,0 +1,107 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# GenerationConfig interface +Config options for content-related requests + +Signature: + +```typescript +export interface GenerationConfig +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [candidateCount](./vertexai-preview.generationconfig.md#generationconfigcandidatecount) | number | | +| [frequencyPenalty](./vertexai-preview.generationconfig.md#generationconfigfrequencypenalty) | number | | +| [maxOutputTokens](./vertexai-preview.generationconfig.md#generationconfigmaxoutputtokens) | number | | +| [presencePenalty](./vertexai-preview.generationconfig.md#generationconfigpresencepenalty) | number | | +| [responseMimeType](./vertexai-preview.generationconfig.md#generationconfigresponsemimetype) | string | Output response mimetype of the generated candidate text. Supported mimetypes are text/plain (default, text output) and application/json (JSON response in the candidates). The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined. This is a preview feature. | +| [stopSequences](./vertexai-preview.generationconfig.md#generationconfigstopsequences) | string\[\] | | +| [temperature](./vertexai-preview.generationconfig.md#generationconfigtemperature) | number | | +| [topK](./vertexai-preview.generationconfig.md#generationconfigtopk) | number | | +| [topP](./vertexai-preview.generationconfig.md#generationconfigtopp) | number | | + +## GenerationConfig.candidateCount + +Signature: + +```typescript +candidateCount?: number; +``` + +## GenerationConfig.frequencyPenalty + +Signature: + +```typescript +frequencyPenalty?: number; +``` + +## GenerationConfig.maxOutputTokens + +Signature: + +```typescript +maxOutputTokens?: number; +``` + +## GenerationConfig.presencePenalty + +Signature: + +```typescript +presencePenalty?: number; +``` + +## GenerationConfig.responseMimeType + +Output response mimetype of the generated candidate text. Supported mimetypes are `text/plain` (default, text output) and `application/json` (JSON response in the candidates). The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined. This is a preview feature. + +Signature: + +```typescript +responseMimeType?: string; +``` + +## GenerationConfig.stopSequences + +Signature: + +```typescript +stopSequences?: string[]; +``` + +## GenerationConfig.temperature + +Signature: + +```typescript +temperature?: number; +``` + +## GenerationConfig.topK + +Signature: + +```typescript +topK?: number; +``` + +## GenerationConfig.topP + +Signature: + +```typescript +topP?: number; +``` diff --git a/docs-devsite/vertexai.generativecontentblob.md b/docs-devsite/vertexai-preview.generativecontentblob.md similarity index 76% rename from docs-devsite/vertexai.generativecontentblob.md rename to docs-devsite/vertexai-preview.generativecontentblob.md index dfcd098291f..b5dcb272027 100644 --- a/docs-devsite/vertexai.generativecontentblob.md +++ b/docs-devsite/vertexai-preview.generativecontentblob.md @@ -22,8 +22,8 @@ export interface GenerativeContentBlob | Property | Type | Description | | --- | --- | --- | -| [data](./vertexai.generativecontentblob.md#generativecontentblobdata) | string | Image as a base64 string. | -| [mimeType](./vertexai.generativecontentblob.md#generativecontentblobmimetype) | string | | +| [data](./vertexai-preview.generativecontentblob.md#generativecontentblobdata) | string | Image as a base64 string. | +| [mimeType](./vertexai-preview.generativecontentblob.md#generativecontentblobmimetype) | string | | ## GenerativeContentBlob.data diff --git a/docs-devsite/vertexai-preview.generativemodel.md b/docs-devsite/vertexai-preview.generativemodel.md new file mode 100644 index 00000000000..a50fac631cc --- /dev/null +++ b/docs-devsite/vertexai-preview.generativemodel.md @@ -0,0 +1,201 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# GenerativeModel class +Class for generative model APIs. + +Signature: + +```typescript +export declare class GenerativeModel +``` + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(vertexAI, modelParams, requestOptions)](./vertexai-preview.generativemodel.md#generativemodelconstructor) | | Constructs a new instance of the GenerativeModel class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [generationConfig](./vertexai-preview.generativemodel.md#generativemodelgenerationconfig) | | [GenerationConfig](./vertexai-preview.generationconfig.md#generationconfig_interface) | | +| [model](./vertexai-preview.generativemodel.md#generativemodelmodel) | | string | | +| [requestOptions](./vertexai-preview.generativemodel.md#generativemodelrequestoptions) | | [RequestOptions](./vertexai-preview.requestoptions.md#requestoptions_interface) | | +| [safetySettings](./vertexai-preview.generativemodel.md#generativemodelsafetysettings) | | [SafetySetting](./vertexai-preview.safetysetting.md#safetysetting_interface)\[\] | | +| [systemInstruction](./vertexai-preview.generativemodel.md#generativemodelsysteminstruction) | | [Content](./vertexai-preview.content.md#content_interface) | | +| [toolConfig](./vertexai-preview.generativemodel.md#generativemodeltoolconfig) | | [ToolConfig](./vertexai-preview.toolconfig.md#toolconfig_interface) | | +| [tools](./vertexai-preview.generativemodel.md#generativemodeltools) | | [Tool](./vertexai-preview.md#tool)\[\] | | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [countTokens(request)](./vertexai-preview.generativemodel.md#generativemodelcounttokens) | | Counts the tokens in the provided request. | +| [generateContent(request)](./vertexai-preview.generativemodel.md#generativemodelgeneratecontent) | | Makes a single non-streaming call to the model and returns an object containing a single [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface). | +| [generateContentStream(request)](./vertexai-preview.generativemodel.md#generativemodelgeneratecontentstream) | | Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response. | +| [startChat(startChatParams)](./vertexai-preview.generativemodel.md#generativemodelstartchat) | | Gets a new [ChatSession](./vertexai-preview.chatsession.md#chatsession_class) instance which can be used for multi-turn chats. | + +## GenerativeModel.(constructor) + +Constructs a new instance of the `GenerativeModel` class + +Signature: + +```typescript +constructor(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| vertexAI | [VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) | | +| modelParams | [ModelParams](./vertexai-preview.modelparams.md#modelparams_interface) | | +| requestOptions | [RequestOptions](./vertexai-preview.requestoptions.md#requestoptions_interface) | | + +## GenerativeModel.generationConfig + +Signature: + +```typescript +generationConfig: GenerationConfig; +``` + +## GenerativeModel.model + +Signature: + +```typescript +model: string; +``` + +## GenerativeModel.requestOptions + +Signature: + +```typescript +requestOptions?: RequestOptions; +``` + +## GenerativeModel.safetySettings + +Signature: + +```typescript +safetySettings: SafetySetting[]; +``` + +## GenerativeModel.systemInstruction + +Signature: + +```typescript +systemInstruction?: Content; +``` + +## GenerativeModel.toolConfig + +Signature: + +```typescript +toolConfig?: ToolConfig; +``` + +## GenerativeModel.tools + +Signature: + +```typescript +tools?: Tool[]; +``` + +## GenerativeModel.countTokens() + +Counts the tokens in the provided request. + +Signature: + +```typescript +countTokens(request: CountTokensRequest | string | Array): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| request | [CountTokensRequest](./vertexai-preview.counttokensrequest.md#counttokensrequest_interface) \| string \| Array<string \| [Part](./vertexai-preview.md#part)> | | + +Returns: + +Promise<[CountTokensResponse](./vertexai-preview.counttokensresponse.md#counttokensresponse_interface)> + +## GenerativeModel.generateContent() + +Makes a single non-streaming call to the model and returns an object containing a single [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface). + +Signature: + +```typescript +generateContent(request: GenerateContentRequest | string | Array): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| request | [GenerateContentRequest](./vertexai-preview.generatecontentrequest.md#generatecontentrequest_interface) \| string \| Array<string \| [Part](./vertexai-preview.md#part)> | | + +Returns: + +Promise<[GenerateContentResult](./vertexai-preview.generatecontentresult.md#generatecontentresult_interface)> + +## GenerativeModel.generateContentStream() + +Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response. + +Signature: + +```typescript +generateContentStream(request: GenerateContentRequest | string | Array): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| request | [GenerateContentRequest](./vertexai-preview.generatecontentrequest.md#generatecontentrequest_interface) \| string \| Array<string \| [Part](./vertexai-preview.md#part)> | | + +Returns: + +Promise<[GenerateContentStreamResult](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresult_interface)> + +## GenerativeModel.startChat() + +Gets a new [ChatSession](./vertexai-preview.chatsession.md#chatsession_class) instance which can be used for multi-turn chats. + +Signature: + +```typescript +startChat(startChatParams?: StartChatParams): ChatSession; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| startChatParams | [StartChatParams](./vertexai-preview.startchatparams.md#startchatparams_interface) | | + +Returns: + +[ChatSession](./vertexai-preview.chatsession.md#chatsession_class) + diff --git a/docs-devsite/vertexai.groundingattribution.md b/docs-devsite/vertexai-preview.groundingattribution.md similarity index 58% rename from docs-devsite/vertexai.groundingattribution.md rename to docs-devsite/vertexai-preview.groundingattribution.md index b72d8150635..2c7d2f09e0b 100644 --- a/docs-devsite/vertexai.groundingattribution.md +++ b/docs-devsite/vertexai-preview.groundingattribution.md @@ -21,10 +21,10 @@ export interface GroundingAttribution | Property | Type | Description | | --- | --- | --- | -| [confidenceScore](./vertexai.groundingattribution.md#groundingattributionconfidencescore) | number | | -| [retrievedContext](./vertexai.groundingattribution.md#groundingattributionretrievedcontext) | [RetrievedContextAttribution](./vertexai.retrievedcontextattribution.md#retrievedcontextattribution_interface) | | -| [segment](./vertexai.groundingattribution.md#groundingattributionsegment) | [Segment](./vertexai.segment.md#segment_interface) | | -| [web](./vertexai.groundingattribution.md#groundingattributionweb) | [WebAttribution](./vertexai.webattribution.md#webattribution_interface) | | +| [confidenceScore](./vertexai-preview.groundingattribution.md#groundingattributionconfidencescore) | number | | +| [retrievedContext](./vertexai-preview.groundingattribution.md#groundingattributionretrievedcontext) | [RetrievedContextAttribution](./vertexai-preview.retrievedcontextattribution.md#retrievedcontextattribution_interface) | | +| [segment](./vertexai-preview.groundingattribution.md#groundingattributionsegment) | [Segment](./vertexai-preview.segment.md#segment_interface) | | +| [web](./vertexai-preview.groundingattribution.md#groundingattributionweb) | [WebAttribution](./vertexai-preview.webattribution.md#webattribution_interface) | | ## GroundingAttribution.confidenceScore diff --git a/docs-devsite/vertexai.groundingmetadata.md b/docs-devsite/vertexai-preview.groundingmetadata.md similarity index 66% rename from docs-devsite/vertexai.groundingmetadata.md rename to docs-devsite/vertexai-preview.groundingmetadata.md index 186f00d29a7..5f40a00457d 100644 --- a/docs-devsite/vertexai.groundingmetadata.md +++ b/docs-devsite/vertexai-preview.groundingmetadata.md @@ -22,9 +22,9 @@ export interface GroundingMetadata | Property | Type | Description | | --- | --- | --- | -| [groundingAttributions](./vertexai.groundingmetadata.md#groundingmetadatagroundingattributions) | [GroundingAttribution](./vertexai.groundingattribution.md#groundingattribution_interface)\[\] | | -| [retrievalQueries](./vertexai.groundingmetadata.md#groundingmetadataretrievalqueries) | string\[\] | | -| [webSearchQueries](./vertexai.groundingmetadata.md#groundingmetadatawebsearchqueries) | string\[\] | | +| [groundingAttributions](./vertexai-preview.groundingmetadata.md#groundingmetadatagroundingattributions) | [GroundingAttribution](./vertexai-preview.groundingattribution.md#groundingattribution_interface)\[\] | | +| [retrievalQueries](./vertexai-preview.groundingmetadata.md#groundingmetadataretrievalqueries) | string\[\] | | +| [webSearchQueries](./vertexai-preview.groundingmetadata.md#groundingmetadatawebsearchqueries) | string\[\] | | ## GroundingMetadata.groundingAttributions diff --git a/docs-devsite/vertexai.inlinedatapart.md b/docs-devsite/vertexai-preview.inlinedatapart.md similarity index 60% rename from docs-devsite/vertexai.inlinedatapart.md rename to docs-devsite/vertexai-preview.inlinedatapart.md index 0cb064fc357..ae05f80ddb7 100644 --- a/docs-devsite/vertexai.inlinedatapart.md +++ b/docs-devsite/vertexai-preview.inlinedatapart.md @@ -22,11 +22,11 @@ export interface InlineDataPart | Property | Type | Description | | --- | --- | --- | -| [functionCall](./vertexai.inlinedatapart.md#inlinedatapartfunctioncall) | never | | -| [functionResponse](./vertexai.inlinedatapart.md#inlinedatapartfunctionresponse) | never | | -| [inlineData](./vertexai.inlinedatapart.md#inlinedatapartinlinedata) | [GenerativeContentBlob](./vertexai.generativecontentblob.md#generativecontentblob_interface) | | -| [text](./vertexai.inlinedatapart.md#inlinedataparttext) | never | | -| [videoMetadata](./vertexai.inlinedatapart.md#inlinedatapartvideometadata) | [VideoMetadata](./vertexai.videometadata.md#videometadata_interface) | Applicable if inlineData is a video. | +| [functionCall](./vertexai-preview.inlinedatapart.md#inlinedatapartfunctioncall) | never | | +| [functionResponse](./vertexai-preview.inlinedatapart.md#inlinedatapartfunctionresponse) | never | | +| [inlineData](./vertexai-preview.inlinedatapart.md#inlinedatapartinlinedata) | [GenerativeContentBlob](./vertexai-preview.generativecontentblob.md#generativecontentblob_interface) | | +| [text](./vertexai-preview.inlinedatapart.md#inlinedataparttext) | never | | +| [videoMetadata](./vertexai-preview.inlinedatapart.md#inlinedatapartvideometadata) | [VideoMetadata](./vertexai-preview.videometadata.md#videometadata_interface) | Applicable if inlineData is a video. | ## InlineDataPart.functionCall diff --git a/docs-devsite/vertexai-preview.md b/docs-devsite/vertexai-preview.md new file mode 100644 index 00000000000..57fbab35909 --- /dev/null +++ b/docs-devsite/vertexai-preview.md @@ -0,0 +1,397 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# vertexai-preview package +The Vertex AI For Firebase Web SDK. + +## Functions + +| Function | Description | +| --- | --- | +| function(app, ...) | +| [getVertexAI(app, options)](./vertexai-preview.md#getvertexai_04094cf) | Returns a [VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) instance for the given app. | +| function(vertexAI, ...) | +| [getGenerativeModel(vertexAI, modelParams, requestOptions)](./vertexai-preview.md#getgenerativemodel_e3037c9) | Returns a [GenerativeModel](./vertexai-preview.generativemodel.md#generativemodel_class) class with methods for inference and other functionality. | + +## Classes + +| Class | Description | +| --- | --- | +| [ChatSession](./vertexai-preview.chatsession.md#chatsession_class) | ChatSession class that enables sending chat messages and stores history of sent and received messages so far. | +| [GenerativeModel](./vertexai-preview.generativemodel.md#generativemodel_class) | Class for generative model APIs. | +| [VertexAIError](./vertexai-preview.vertexaierror.md#vertexaierror_class) | Error class for the Vertex AI for Firebase SDK. | + +## Enumerations + +| Enumeration | Description | +| --- | --- | +| [BlockReason](./vertexai-preview.md#blockreason) | Reason that a prompt was blocked. | +| [FinishReason](./vertexai-preview.md#finishreason) | Reason that a candidate finished. | +| [FunctionCallingMode](./vertexai-preview.md#functioncallingmode) | | +| [FunctionDeclarationSchemaType](./vertexai-preview.md#functiondeclarationschematype) | Contains the list of OpenAPI data types as defined by https://swagger.io/docs/specification/data-models/data-types/ | +| [HarmBlockMethod](./vertexai-preview.md#harmblockmethod) | | +| [HarmBlockThreshold](./vertexai-preview.md#harmblockthreshold) | Threshold above which a prompt or candidate will be blocked. | +| [HarmCategory](./vertexai-preview.md#harmcategory) | Harm categories that would cause prompts or candidates to be blocked. | +| [HarmProbability](./vertexai-preview.md#harmprobability) | Probability that a prompt or candidate matches a harm category. | +| [HarmSeverity](./vertexai-preview.md#harmseverity) | Harm severity levels. | +| [VertexAIErrorCode](./vertexai-preview.md#vertexaierrorcode) | Standardized error codes that [VertexAIError](./vertexai-preview.vertexaierror.md#vertexaierror_class) can have. | + +## Interfaces + +| Interface | Description | +| --- | --- | +| [BaseParams](./vertexai-preview.baseparams.md#baseparams_interface) | Base parameters for a number of methods. | +| [Citation](./vertexai-preview.citation.md#citation_interface) | A single citation. | +| [CitationMetadata](./vertexai-preview.citationmetadata.md#citationmetadata_interface) | Citation metadata that may be found on a [GenerateContentCandidate](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidate_interface). | +| [Content](./vertexai-preview.content.md#content_interface) | Content type for both prompts and response candidates. | +| [CountTokensRequest](./vertexai-preview.counttokensrequest.md#counttokensrequest_interface) | Params for calling [GenerativeModel.countTokens()](./vertexai-preview.generativemodel.md#generativemodelcounttokens) | +| [CountTokensResponse](./vertexai-preview.counttokensresponse.md#counttokensresponse_interface) | Response from calling [GenerativeModel.countTokens()](./vertexai-preview.generativemodel.md#generativemodelcounttokens). | +| [CustomErrorData](./vertexai-preview.customerrordata.md#customerrordata_interface) | Details object that contains data originating from a bad HTTP response. | +| [Date\_2](./vertexai-preview.date_2.md#date_2_interface) | Protobuf google.type.Date | +| [EnhancedGenerateContentResponse](./vertexai-preview.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface) | Response object wrapped with helper methods. | +| [ErrorDetails](./vertexai-preview.errordetails.md#errordetails_interface) | Details object that may be included in an error response. | +| [FileData](./vertexai-preview.filedata.md#filedata_interface) | Data pointing to a file uploaded on Google Cloud Storage. | +| [FileDataPart](./vertexai-preview.filedatapart.md#filedatapart_interface) | Content part interface if the part represents [FileData](./vertexai-preview.filedata.md#filedata_interface) | +| [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) | A predicted [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) returned from the model that contains a string representing the [FunctionDeclaration.name](./vertexai-preview.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing the parameters and their values. | +| [FunctionCallingConfig](./vertexai-preview.functioncallingconfig.md#functioncallingconfig_interface) | | +| [FunctionCallPart](./vertexai-preview.functioncallpart.md#functioncallpart_interface) | Content part interface if the part represents a [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface). | +| [FunctionDeclaration](./vertexai-preview.functiondeclaration.md#functiondeclaration_interface) | Structured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3). Included in this declaration are the function name and parameters. This FunctionDeclaration is a representation of a block of code that can be used as a Tool by the model and executed by the client. | +| [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface) | Schema for parameters passed to [FunctionDeclaration.parameters](./vertexai-preview.functiondeclaration.md#functiondeclarationparameters). | +| [FunctionDeclarationSchemaProperty](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemaproperty_interface) | Schema is used to define the format of input/output data. Represents a select subset of an OpenAPI 3.0 schema object. More fields may be added in the future as needed. | +| [FunctionDeclarationsTool](./vertexai-preview.functiondeclarationstool.md#functiondeclarationstool_interface) | A FunctionDeclarationsTool is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. | +| [FunctionResponse](./vertexai-preview.functionresponse.md#functionresponse_interface) | The result output from a [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) that contains a string representing the [FunctionDeclaration.name](./vertexai-preview.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) made based on model prediction. | +| [FunctionResponsePart](./vertexai-preview.functionresponsepart.md#functionresponsepart_interface) | Content part interface if the part represents [FunctionResponse](./vertexai-preview.functionresponse.md#functionresponse_interface). | +| [GenerateContentCandidate](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidate_interface) | A candidate returned as part of a [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface). | +| [GenerateContentRequest](./vertexai-preview.generatecontentrequest.md#generatecontentrequest_interface) | Request sent through [GenerativeModel.generateContent()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontent) | +| [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface) | Individual response from [GenerativeModel.generateContent()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontent) and [GenerativeModel.generateContentStream()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontentstream). generateContentStream() will return one in each chunk until the stream is done. | +| [GenerateContentResult](./vertexai-preview.generatecontentresult.md#generatecontentresult_interface) | Result object returned from [GenerativeModel.generateContent()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontent) call. | +| [GenerateContentStreamResult](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresult_interface) | Result object returned from [GenerativeModel.generateContentStream()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontentstream) call. Iterate over stream to get chunks as they come in and/or use the response promise to get the aggregated response when the stream is done. | +| [GenerationConfig](./vertexai-preview.generationconfig.md#generationconfig_interface) | Config options for content-related requests | +| [GenerativeContentBlob](./vertexai-preview.generativecontentblob.md#generativecontentblob_interface) | Interface for sending an image. | +| [GroundingAttribution](./vertexai-preview.groundingattribution.md#groundingattribution_interface) | | +| [GroundingMetadata](./vertexai-preview.groundingmetadata.md#groundingmetadata_interface) | Metadata returned to client when grounding is enabled. | +| [InlineDataPart](./vertexai-preview.inlinedatapart.md#inlinedatapart_interface) | Content part interface if the part represents an image. | +| [ModelParams](./vertexai-preview.modelparams.md#modelparams_interface) | Params passed to [getGenerativeModel()](./vertexai-preview.md#getgenerativemodel_e3037c9). | +| [PromptFeedback](./vertexai-preview.promptfeedback.md#promptfeedback_interface) | If the prompt was blocked, this will be populated with blockReason and the relevant safetyRatings. | +| [RequestOptions](./vertexai-preview.requestoptions.md#requestoptions_interface) | Params passed to [getGenerativeModel()](./vertexai-preview.md#getgenerativemodel_e3037c9). | +| [RetrievedContextAttribution](./vertexai-preview.retrievedcontextattribution.md#retrievedcontextattribution_interface) | | +| [SafetyRating](./vertexai-preview.safetyrating.md#safetyrating_interface) | A safety rating associated with a [GenerateContentCandidate](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidate_interface) | +| [SafetySetting](./vertexai-preview.safetysetting.md#safetysetting_interface) | Safety setting that can be sent as part of request parameters. | +| [Segment](./vertexai-preview.segment.md#segment_interface) | | +| [StartChatParams](./vertexai-preview.startchatparams.md#startchatparams_interface) | Params for [GenerativeModel.startChat()](./vertexai-preview.generativemodel.md#generativemodelstartchat). | +| [TextPart](./vertexai-preview.textpart.md#textpart_interface) | Content part interface if the part represents a text string. | +| [ToolConfig](./vertexai-preview.toolconfig.md#toolconfig_interface) | Tool config. This config is shared for all tools provided in the request. | +| [UsageMetadata](./vertexai-preview.usagemetadata.md#usagemetadata_interface) | Usage metadata about a [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface). | +| [VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) | An instance of the Vertex AI for Firebase SDK. | +| [VertexAIOptions](./vertexai-preview.vertexaioptions.md#vertexaioptions_interface) | Options when initializing the Vertex AI for Firebase SDK. | +| [VideoMetadata](./vertexai-preview.videometadata.md#videometadata_interface) | Describes the input video content. | +| [WebAttribution](./vertexai-preview.webattribution.md#webattribution_interface) | | + +## Variables + +| Variable | Description | +| --- | --- | +| [POSSIBLE\_ROLES](./vertexai-preview.md#possible_roles) | Possible roles. | + +## Type Aliases + +| Type Alias | Description | +| --- | --- | +| [Part](./vertexai-preview.md#part) | Content part - includes text, image/video, or function call/response part types. | +| [Role](./vertexai-preview.md#role) | Role is the producer of the content. | +| [Tool](./vertexai-preview.md#tool) | Defines a tool that model can call to access external knowledge. | + +## function(app, ...) + +### getVertexAI(app, options) {:#getvertexai_04094cf} + +Returns a [VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) instance for the given app. + +Signature: + +```typescript +export declare function getVertexAI(app?: FirebaseApp, options?: VertexAIOptions): VertexAI; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) to use. | +| options | [VertexAIOptions](./vertexai-preview.vertexaioptions.md#vertexaioptions_interface) | | + +Returns: + +[VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) + +## function(vertexAI, ...) + +### getGenerativeModel(vertexAI, modelParams, requestOptions) {:#getgenerativemodel_e3037c9} + +Returns a [GenerativeModel](./vertexai-preview.generativemodel.md#generativemodel_class) class with methods for inference and other functionality. + +Signature: + +```typescript +export declare function getGenerativeModel(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| vertexAI | [VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) | | +| modelParams | [ModelParams](./vertexai-preview.modelparams.md#modelparams_interface) | | +| requestOptions | [RequestOptions](./vertexai-preview.requestoptions.md#requestoptions_interface) | | + +Returns: + +[GenerativeModel](./vertexai-preview.generativemodel.md#generativemodel_class) + +## POSSIBLE\_ROLES + +Possible roles. + +Signature: + +```typescript +POSSIBLE_ROLES: readonly ["user", "model", "function", "system"] +``` + +## Part + +Content part - includes text, image/video, or function call/response part types. + +Signature: + +```typescript +export declare type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart; +``` + +## Role + +Role is the producer of the content. + +Signature: + +```typescript +export declare type Role = (typeof POSSIBLE_ROLES)[number]; +``` + +## Tool + +Defines a tool that model can call to access external knowledge. + +Signature: + +```typescript +export declare type Tool = FunctionDeclarationsTool; +``` + +## BlockReason + +Reason that a prompt was blocked. + +Signature: + +```typescript +export declare enum BlockReason +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| BLOCKED\_REASON\_UNSPECIFIED | "BLOCKED_REASON_UNSPECIFIED" | | +| OTHER | "OTHER" | | +| SAFETY | "SAFETY" | | + +## FinishReason + +Reason that a candidate finished. + +Signature: + +```typescript +export declare enum FinishReason +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| FINISH\_REASON\_UNSPECIFIED | "FINISH_REASON_UNSPECIFIED" | | +| MAX\_TOKENS | "MAX_TOKENS" | | +| OTHER | "OTHER" | | +| RECITATION | "RECITATION" | | +| SAFETY | "SAFETY" | | +| STOP | "STOP" | | + +## FunctionCallingMode + + +Signature: + +```typescript +export declare enum FunctionCallingMode +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| ANY | "ANY" | | +| AUTO | "AUTO" | | +| MODE\_UNSPECIFIED | "MODE_UNSPECIFIED" | | +| NONE | "NONE" | | + +## FunctionDeclarationSchemaType + +Contains the list of OpenAPI data types as defined by https://swagger.io/docs/specification/data-models/data-types/ + +Signature: + +```typescript +export declare enum FunctionDeclarationSchemaType +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| ARRAY | "ARRAY" | Array type. | +| BOOLEAN | "BOOLEAN" | Boolean type. | +| INTEGER | "INTEGER" | Integer type. | +| NUMBER | "NUMBER" | Number type. | +| OBJECT | "OBJECT" | Object type. | +| STRING | "STRING" | String type. | + +## HarmBlockMethod + + +Signature: + +```typescript +export declare enum HarmBlockMethod +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| HARM\_BLOCK\_METHOD\_UNSPECIFIED | "HARM_BLOCK_METHOD_UNSPECIFIED" | | +| PROBABILITY | "PROBABILITY" | | +| SEVERITY | "SEVERITY" | | + +## HarmBlockThreshold + +Threshold above which a prompt or candidate will be blocked. + +Signature: + +```typescript +export declare enum HarmBlockThreshold +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| BLOCK\_LOW\_AND\_ABOVE | "BLOCK_LOW_AND_ABOVE" | | +| BLOCK\_MEDIUM\_AND\_ABOVE | "BLOCK_MEDIUM_AND_ABOVE" | | +| BLOCK\_NONE | "BLOCK_NONE" | | +| BLOCK\_ONLY\_HIGH | "BLOCK_ONLY_HIGH" | | +| HARM\_BLOCK\_THRESHOLD\_UNSPECIFIED | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | | + +## HarmCategory + +Harm categories that would cause prompts or candidates to be blocked. + +Signature: + +```typescript +export declare enum HarmCategory +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| HARM\_CATEGORY\_DANGEROUS\_CONTENT | "HARM_CATEGORY_DANGEROUS_CONTENT" | | +| HARM\_CATEGORY\_HARASSMENT | "HARM_CATEGORY_HARASSMENT" | | +| HARM\_CATEGORY\_HATE\_SPEECH | "HARM_CATEGORY_HATE_SPEECH" | | +| HARM\_CATEGORY\_SEXUALLY\_EXPLICIT | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | | +| HARM\_CATEGORY\_UNSPECIFIED | "HARM_CATEGORY_UNSPECIFIED" | | + +## HarmProbability + +Probability that a prompt or candidate matches a harm category. + +Signature: + +```typescript +export declare enum HarmProbability +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| HARM\_PROBABILITY\_UNSPECIFIED | "HARM_PROBABILITY_UNSPECIFIED" | | +| HIGH | "HIGH" | | +| LOW | "LOW" | | +| MEDIUM | "MEDIUM" | | +| NEGLIGIBLE | "NEGLIGIBLE" | | + +## HarmSeverity + +Harm severity levels. + +Signature: + +```typescript +export declare enum HarmSeverity +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| HARM\_SEVERITY\_HIGH | "HARM_SEVERITY_HIGH" | | +| HARM\_SEVERITY\_LOW | "HARM_SEVERITY_LOW" | | +| HARM\_SEVERITY\_MEDIUM | "HARM_SEVERITY_MEDIUM" | | +| HARM\_SEVERITY\_NEGLIGIBLE | "HARM_SEVERITY_NEGLIGIBLE" | | +| HARM\_SEVERITY\_UNSPECIFIED | "HARM_SEVERITY_UNSPECIFIED" | | + +## VertexAIErrorCode + +Standardized error codes that [VertexAIError](./vertexai-preview.vertexaierror.md#vertexaierror_class) can have. + +Signature: + +```typescript +export declare const enum VertexAIErrorCode +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| ERROR | "error" | A generic error occurred. | +| FETCH\_ERROR | "fetch-error" | An error occurred while performing a fetch. | +| INVALID\_CONTENT | "invalid-content" | An error associated with a Content object. | +| NO\_API\_KEY | "no-api-key" | An error occurred due to a missing Firebase API key. | +| NO\_MODEL | "no-model" | An error occurred due to a model name not being specified during initialization. | +| NO\_PROJECT\_ID | "no-project-id" | An error occurred due to a missing project ID. | +| PARSE\_FAILED | "parse-failed" | An error occurred while parsing. | +| REQUEST\_ERROR | "request-error" | An error occurred in a request. | +| RESPONSE\_ERROR | "response-error" | An error occurred in a response. | + diff --git a/docs-devsite/vertexai.modelparams.md b/docs-devsite/vertexai-preview.modelparams.md similarity index 54% rename from docs-devsite/vertexai.modelparams.md rename to docs-devsite/vertexai-preview.modelparams.md index 590bc14e435..34d68f86714 100644 --- a/docs-devsite/vertexai.modelparams.md +++ b/docs-devsite/vertexai-preview.modelparams.md @@ -10,23 +10,23 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # ModelParams interface -Params passed to [getGenerativeModel()](./vertexai.md#getgenerativemodel_e3037c9). +Params passed to [getGenerativeModel()](./vertexai-preview.md#getgenerativemodel_e3037c9). Signature: ```typescript export interface ModelParams extends BaseParams ``` -Extends: [BaseParams](./vertexai.baseparams.md#baseparams_interface) +Extends: [BaseParams](./vertexai-preview.baseparams.md#baseparams_interface) ## Properties | Property | Type | Description | | --- | --- | --- | -| [model](./vertexai.modelparams.md#modelparamsmodel) | string | | -| [systemInstruction](./vertexai.modelparams.md#modelparamssysteminstruction) | string \| [Part](./vertexai.md#part) \| [Content](./vertexai.content.md#content_interface) | | -| [toolConfig](./vertexai.modelparams.md#modelparamstoolconfig) | [ToolConfig](./vertexai.toolconfig.md#toolconfig_interface) | | -| [tools](./vertexai.modelparams.md#modelparamstools) | [Tool](./vertexai.md#tool)\[\] | | +| [model](./vertexai-preview.modelparams.md#modelparamsmodel) | string | | +| [systemInstruction](./vertexai-preview.modelparams.md#modelparamssysteminstruction) | string \| [Part](./vertexai-preview.md#part) \| [Content](./vertexai-preview.content.md#content_interface) | | +| [toolConfig](./vertexai-preview.modelparams.md#modelparamstoolconfig) | [ToolConfig](./vertexai-preview.toolconfig.md#toolconfig_interface) | | +| [tools](./vertexai-preview.modelparams.md#modelparamstools) | [Tool](./vertexai-preview.md#tool)\[\] | | ## ModelParams.model diff --git a/docs-devsite/vertexai.promptfeedback.md b/docs-devsite/vertexai-preview.promptfeedback.md similarity index 66% rename from docs-devsite/vertexai.promptfeedback.md rename to docs-devsite/vertexai-preview.promptfeedback.md index 369ef02051d..cb27f10c8c3 100644 --- a/docs-devsite/vertexai.promptfeedback.md +++ b/docs-devsite/vertexai-preview.promptfeedback.md @@ -22,16 +22,16 @@ export interface PromptFeedback | Property | Type | Description | | --- | --- | --- | -| [blockReason](./vertexai.promptfeedback.md#promptfeedbackblockreason) | [BlockReason](./vertexai.md#blockreason) | | -| [blockReasonMessage](./vertexai.promptfeedback.md#promptfeedbackblockreasonmessage) | string | | -| [safetyRatings](./vertexai.promptfeedback.md#promptfeedbacksafetyratings) | [SafetyRating](./vertexai.safetyrating.md#safetyrating_interface)\[\] | | +| [blockReason](./vertexai-preview.promptfeedback.md#promptfeedbackblockreason) | [BlockReason](./vertexai-preview.md#blockreason) | | +| [blockReasonMessage](./vertexai-preview.promptfeedback.md#promptfeedbackblockreasonmessage) | string | | +| [safetyRatings](./vertexai-preview.promptfeedback.md#promptfeedbacksafetyratings) | [SafetyRating](./vertexai-preview.safetyrating.md#safetyrating_interface)\[\] | | ## PromptFeedback.blockReason Signature: ```typescript -blockReason?: BlockReason; +blockReason: BlockReason; ``` ## PromptFeedback.blockReasonMessage diff --git a/docs-devsite/vertexai.requestoptions.md b/docs-devsite/vertexai-preview.requestoptions.md similarity index 55% rename from docs-devsite/vertexai.requestoptions.md rename to docs-devsite/vertexai-preview.requestoptions.md index 6d074775520..550ec44ce96 100644 --- a/docs-devsite/vertexai.requestoptions.md +++ b/docs-devsite/vertexai-preview.requestoptions.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # RequestOptions interface -Params passed to [getGenerativeModel()](./vertexai.md#getgenerativemodel_e3037c9). +Params passed to [getGenerativeModel()](./vertexai-preview.md#getgenerativemodel_e3037c9). Signature: @@ -22,12 +22,12 @@ export interface RequestOptions | Property | Type | Description | | --- | --- | --- | -| [baseUrl](./vertexai.requestoptions.md#requestoptionsbaseurl) | string | Base url for endpoint. Defaults to https://firebasevertexai.googleapis.com | -| [timeout](./vertexai.requestoptions.md#requestoptionstimeout) | number | Request timeout in milliseconds. Defaults to 180 seconds (180000ms). | +| [baseUrl](./vertexai-preview.requestoptions.md#requestoptionsbaseurl) | string | Base url for endpoint. Defaults to https://firebaseml.googleapis.com | +| [timeout](./vertexai-preview.requestoptions.md#requestoptionstimeout) | number | Request timeout in milliseconds. | ## RequestOptions.baseUrl -Base url for endpoint. Defaults to https://firebasevertexai.googleapis.com +Base url for endpoint. Defaults to https://firebaseml.googleapis.com Signature: @@ -37,7 +37,7 @@ baseUrl?: string; ## RequestOptions.timeout -Request timeout in milliseconds. Defaults to 180 seconds (180000ms). +Request timeout in milliseconds. Signature: diff --git a/docs-devsite/vertexai.retrievedcontextattribution.md b/docs-devsite/vertexai-preview.retrievedcontextattribution.md similarity index 76% rename from docs-devsite/vertexai.retrievedcontextattribution.md rename to docs-devsite/vertexai-preview.retrievedcontextattribution.md index e36bfacb3ec..0a121cdc004 100644 --- a/docs-devsite/vertexai.retrievedcontextattribution.md +++ b/docs-devsite/vertexai-preview.retrievedcontextattribution.md @@ -21,8 +21,8 @@ export interface RetrievedContextAttribution | Property | Type | Description | | --- | --- | --- | -| [title](./vertexai.retrievedcontextattribution.md#retrievedcontextattributiontitle) | string | | -| [uri](./vertexai.retrievedcontextattribution.md#retrievedcontextattributionuri) | string | | +| [title](./vertexai-preview.retrievedcontextattribution.md#retrievedcontextattributiontitle) | string | | +| [uri](./vertexai-preview.retrievedcontextattribution.md#retrievedcontextattributionuri) | string | | ## RetrievedContextAttribution.title diff --git a/docs-devsite/vertexai.safetyrating.md b/docs-devsite/vertexai-preview.safetyrating.md similarity index 55% rename from docs-devsite/vertexai.safetyrating.md rename to docs-devsite/vertexai-preview.safetyrating.md index b5f204bef2c..65b1bc8fb42 100644 --- a/docs-devsite/vertexai.safetyrating.md +++ b/docs-devsite/vertexai-preview.safetyrating.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # SafetyRating interface -A safety rating associated with a [GenerateContentCandidate](./vertexai.generatecontentcandidate.md#generatecontentcandidate_interface) +A safety rating associated with a [GenerateContentCandidate](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidate_interface) Signature: @@ -22,12 +22,12 @@ export interface SafetyRating | Property | Type | Description | | --- | --- | --- | -| [blocked](./vertexai.safetyrating.md#safetyratingblocked) | boolean | | -| [category](./vertexai.safetyrating.md#safetyratingcategory) | [HarmCategory](./vertexai.md#harmcategory) | | -| [probability](./vertexai.safetyrating.md#safetyratingprobability) | [HarmProbability](./vertexai.md#harmprobability) | | -| [probabilityScore](./vertexai.safetyrating.md#safetyratingprobabilityscore) | number | | -| [severity](./vertexai.safetyrating.md#safetyratingseverity) | [HarmSeverity](./vertexai.md#harmseverity) | | -| [severityScore](./vertexai.safetyrating.md#safetyratingseverityscore) | number | | +| [blocked](./vertexai-preview.safetyrating.md#safetyratingblocked) | boolean | | +| [category](./vertexai-preview.safetyrating.md#safetyratingcategory) | [HarmCategory](./vertexai-preview.md#harmcategory) | | +| [probability](./vertexai-preview.safetyrating.md#safetyratingprobability) | [HarmProbability](./vertexai-preview.md#harmprobability) | | +| [probabilityScore](./vertexai-preview.safetyrating.md#safetyratingprobabilityscore) | number | | +| [severity](./vertexai-preview.safetyrating.md#safetyratingseverity) | [HarmSeverity](./vertexai-preview.md#harmseverity) | | +| [severityScore](./vertexai-preview.safetyrating.md#safetyratingseverityscore) | number | | ## SafetyRating.blocked diff --git a/docs-devsite/vertexai.safetysetting.md b/docs-devsite/vertexai-preview.safetysetting.md similarity index 64% rename from docs-devsite/vertexai.safetysetting.md rename to docs-devsite/vertexai-preview.safetysetting.md index 17fa1cff839..78678315805 100644 --- a/docs-devsite/vertexai.safetysetting.md +++ b/docs-devsite/vertexai-preview.safetysetting.md @@ -22,9 +22,9 @@ export interface SafetySetting | Property | Type | Description | | --- | --- | --- | -| [category](./vertexai.safetysetting.md#safetysettingcategory) | [HarmCategory](./vertexai.md#harmcategory) | | -| [method](./vertexai.safetysetting.md#safetysettingmethod) | [HarmBlockMethod](./vertexai.md#harmblockmethod) | | -| [threshold](./vertexai.safetysetting.md#safetysettingthreshold) | [HarmBlockThreshold](./vertexai.md#harmblockthreshold) | | +| [category](./vertexai-preview.safetysetting.md#safetysettingcategory) | [HarmCategory](./vertexai-preview.md#harmcategory) | | +| [method](./vertexai-preview.safetysetting.md#safetysettingmethod) | [HarmBlockMethod](./vertexai-preview.md#harmblockmethod) | | +| [threshold](./vertexai-preview.safetysetting.md#safetysettingthreshold) | [HarmBlockThreshold](./vertexai-preview.md#harmblockthreshold) | | ## SafetySetting.category @@ -39,7 +39,7 @@ category: HarmCategory; Signature: ```typescript -method?: HarmBlockMethod; +method: HarmBlockMethod; ``` ## SafetySetting.threshold diff --git a/docs-devsite/vertexai.segment.md b/docs-devsite/vertexai-preview.segment.md similarity index 75% rename from docs-devsite/vertexai.segment.md rename to docs-devsite/vertexai-preview.segment.md index db61f00a149..c64bc3ffcda 100644 --- a/docs-devsite/vertexai.segment.md +++ b/docs-devsite/vertexai-preview.segment.md @@ -21,9 +21,9 @@ export interface Segment | Property | Type | Description | | --- | --- | --- | -| [endIndex](./vertexai.segment.md#segmentendindex) | number | | -| [partIndex](./vertexai.segment.md#segmentpartindex) | number | | -| [startIndex](./vertexai.segment.md#segmentstartindex) | number | | +| [endIndex](./vertexai-preview.segment.md#segmentendindex) | number | | +| [partIndex](./vertexai-preview.segment.md#segmentpartindex) | number | | +| [startIndex](./vertexai-preview.segment.md#segmentstartindex) | number | | ## Segment.endIndex diff --git a/docs-devsite/vertexai.startchatparams.md b/docs-devsite/vertexai-preview.startchatparams.md similarity index 51% rename from docs-devsite/vertexai.startchatparams.md rename to docs-devsite/vertexai-preview.startchatparams.md index e07bbd91d82..f422f7a1ff0 100644 --- a/docs-devsite/vertexai.startchatparams.md +++ b/docs-devsite/vertexai-preview.startchatparams.md @@ -10,23 +10,23 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # StartChatParams interface -Params for [GenerativeModel.startChat()](./vertexai.generativemodel.md#generativemodelstartchat). +Params for [GenerativeModel.startChat()](./vertexai-preview.generativemodel.md#generativemodelstartchat). Signature: ```typescript export interface StartChatParams extends BaseParams ``` -Extends: [BaseParams](./vertexai.baseparams.md#baseparams_interface) +Extends: [BaseParams](./vertexai-preview.baseparams.md#baseparams_interface) ## Properties | Property | Type | Description | | --- | --- | --- | -| [history](./vertexai.startchatparams.md#startchatparamshistory) | [Content](./vertexai.content.md#content_interface)\[\] | | -| [systemInstruction](./vertexai.startchatparams.md#startchatparamssysteminstruction) | string \| [Part](./vertexai.md#part) \| [Content](./vertexai.content.md#content_interface) | | -| [toolConfig](./vertexai.startchatparams.md#startchatparamstoolconfig) | [ToolConfig](./vertexai.toolconfig.md#toolconfig_interface) | | -| [tools](./vertexai.startchatparams.md#startchatparamstools) | [Tool](./vertexai.md#tool)\[\] | | +| [history](./vertexai-preview.startchatparams.md#startchatparamshistory) | [Content](./vertexai-preview.content.md#content_interface)\[\] | | +| [systemInstruction](./vertexai-preview.startchatparams.md#startchatparamssysteminstruction) | string \| [Part](./vertexai-preview.md#part) \| [Content](./vertexai-preview.content.md#content_interface) | | +| [toolConfig](./vertexai-preview.startchatparams.md#startchatparamstoolconfig) | [ToolConfig](./vertexai-preview.toolconfig.md#toolconfig_interface) | | +| [tools](./vertexai-preview.startchatparams.md#startchatparamstools) | [Tool](./vertexai-preview.md#tool)\[\] | | ## StartChatParams.history diff --git a/docs-devsite/vertexai.textpart.md b/docs-devsite/vertexai-preview.textpart.md similarity index 72% rename from docs-devsite/vertexai.textpart.md rename to docs-devsite/vertexai-preview.textpart.md index afee40a369d..206168180b2 100644 --- a/docs-devsite/vertexai.textpart.md +++ b/docs-devsite/vertexai-preview.textpart.md @@ -22,10 +22,10 @@ export interface TextPart | Property | Type | Description | | --- | --- | --- | -| [functionCall](./vertexai.textpart.md#textpartfunctioncall) | never | | -| [functionResponse](./vertexai.textpart.md#textpartfunctionresponse) | never | | -| [inlineData](./vertexai.textpart.md#textpartinlinedata) | never | | -| [text](./vertexai.textpart.md#textparttext) | string | | +| [functionCall](./vertexai-preview.textpart.md#textpartfunctioncall) | never | | +| [functionResponse](./vertexai-preview.textpart.md#textpartfunctionresponse) | never | | +| [inlineData](./vertexai-preview.textpart.md#textpartinlinedata) | never | | +| [text](./vertexai-preview.textpart.md#textparttext) | string | | ## TextPart.functionCall diff --git a/docs-devsite/vertexai.toolconfig.md b/docs-devsite/vertexai-preview.toolconfig.md similarity index 71% rename from docs-devsite/vertexai.toolconfig.md rename to docs-devsite/vertexai-preview.toolconfig.md index 30c62c17c01..4278eef509b 100644 --- a/docs-devsite/vertexai.toolconfig.md +++ b/docs-devsite/vertexai-preview.toolconfig.md @@ -22,12 +22,12 @@ export interface ToolConfig | Property | Type | Description | | --- | --- | --- | -| [functionCallingConfig](./vertexai.toolconfig.md#toolconfigfunctioncallingconfig) | [FunctionCallingConfig](./vertexai.functioncallingconfig.md#functioncallingconfig_interface) | | +| [functionCallingConfig](./vertexai-preview.toolconfig.md#toolconfigfunctioncallingconfig) | [FunctionCallingConfig](./vertexai-preview.functioncallingconfig.md#functioncallingconfig_interface) | | ## ToolConfig.functionCallingConfig Signature: ```typescript -functionCallingConfig?: FunctionCallingConfig; +functionCallingConfig: FunctionCallingConfig; ``` diff --git a/docs-devsite/vertexai.usagemetadata.md b/docs-devsite/vertexai-preview.usagemetadata.md similarity index 63% rename from docs-devsite/vertexai.usagemetadata.md rename to docs-devsite/vertexai-preview.usagemetadata.md index d254f34335f..2829c9dbd5d 100644 --- a/docs-devsite/vertexai.usagemetadata.md +++ b/docs-devsite/vertexai-preview.usagemetadata.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # UsageMetadata interface -Usage metadata about a [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface). +Usage metadata about a [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface). Signature: @@ -22,9 +22,9 @@ export interface UsageMetadata | Property | Type | Description | | --- | --- | --- | -| [candidatesTokenCount](./vertexai.usagemetadata.md#usagemetadatacandidatestokencount) | number | | -| [promptTokenCount](./vertexai.usagemetadata.md#usagemetadataprompttokencount) | number | | -| [totalTokenCount](./vertexai.usagemetadata.md#usagemetadatatotaltokencount) | number | | +| [candidatesTokenCount](./vertexai-preview.usagemetadata.md#usagemetadatacandidatestokencount) | number | | +| [promptTokenCount](./vertexai-preview.usagemetadata.md#usagemetadataprompttokencount) | number | | +| [totalTokenCount](./vertexai-preview.usagemetadata.md#usagemetadatatotaltokencount) | number | | ## UsageMetadata.candidatesTokenCount diff --git a/docs-devsite/vertexai.vertexai.md b/docs-devsite/vertexai-preview.vertexai.md similarity index 58% rename from docs-devsite/vertexai.vertexai.md rename to docs-devsite/vertexai-preview.vertexai.md index 4797bf8bada..35991f2be12 100644 --- a/docs-devsite/vertexai.vertexai.md +++ b/docs-devsite/vertexai-preview.vertexai.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # VertexAI interface -An instance of the Vertex AI in Firebase SDK. +An instance of the Vertex AI for Firebase SDK. Signature: @@ -22,12 +22,12 @@ export interface VertexAI | Property | Type | Description | | --- | --- | --- | -| [app](./vertexai.vertexai.md#vertexaiapp) | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) this [VertexAI](./vertexai.vertexai.md#vertexai_interface) instance is associated with. | -| [location](./vertexai.vertexai.md#vertexailocation) | string | | +| [app](./vertexai-preview.vertexai.md#vertexaiapp) | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) this [VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) instance is associated with. | +| [location](./vertexai-preview.vertexai.md#vertexailocation) | string | | ## VertexAI.app -The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) this [VertexAI](./vertexai.vertexai.md#vertexai_interface) instance is associated with. +The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) this [VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) instance is associated with. Signature: diff --git a/docs-devsite/vertexai.vertexaierror.md b/docs-devsite/vertexai-preview.vertexaierror.md similarity index 55% rename from docs-devsite/vertexai.vertexaierror.md rename to docs-devsite/vertexai-preview.vertexaierror.md index 86532ac6018..05a12c62b8e 100644 --- a/docs-devsite/vertexai.vertexaierror.md +++ b/docs-devsite/vertexai-preview.vertexaierror.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # VertexAIError class -Error class for the Vertex AI in Firebase SDK. +Error class for the Vertex AI for Firebase SDK. Signature: @@ -23,14 +23,15 @@ export declare class VertexAIError extends FirebaseError | Constructor | Modifiers | Description | | --- | --- | --- | -| [(constructor)(code, message, customErrorData)](./vertexai.vertexaierror.md#vertexaierrorconstructor) | | Constructs a new instance of the VertexAIError class. | +| [(constructor)(code, message, customErrorData)](./vertexai-preview.vertexaierror.md#vertexaierrorconstructor) | | Constructs a new instance of the VertexAIError class. | ## Properties | Property | Modifiers | Type | Description | | --- | --- | --- | --- | -| [code](./vertexai.vertexaierror.md#vertexaierrorcode) | | [VertexAIErrorCode](./vertexai.md#vertexaierrorcode) | | -| [customErrorData](./vertexai.vertexaierror.md#vertexaierrorcustomerrordata) | | [CustomErrorData](./vertexai.customerrordata.md#customerrordata_interface) \| undefined | | +| [code](./vertexai-preview.vertexaierror.md#vertexaierrorcode) | | [VertexAIErrorCode](./vertexai-preview.md#vertexaierrorcode) | | +| [customErrorData](./vertexai-preview.vertexaierror.md#vertexaierrorcustomerrordata) | | [CustomErrorData](./vertexai-preview.customerrordata.md#customerrordata_interface) \| undefined | | +| [message](./vertexai-preview.vertexaierror.md#vertexaierrormessage) | | string | | ## VertexAIError.(constructor) @@ -46,9 +47,9 @@ constructor(code: VertexAIErrorCode, message: string, customErrorData?: CustomEr | Parameter | Type | Description | | --- | --- | --- | -| code | [VertexAIErrorCode](./vertexai.md#vertexaierrorcode) | The error code from [VertexAIErrorCode](./vertexai.md#vertexaierrorcode). | +| code | [VertexAIErrorCode](./vertexai-preview.md#vertexaierrorcode) | The error code from [VertexAIErrorCode](./vertexai-preview.md#vertexaierrorcode). | | message | string | A human-readable message describing the error. | -| customErrorData | [CustomErrorData](./vertexai.customerrordata.md#customerrordata_interface) \| undefined | Optional error data. | +| customErrorData | [CustomErrorData](./vertexai-preview.customerrordata.md#customerrordata_interface) \| undefined | Optional error data. | ## VertexAIError.code @@ -65,3 +66,11 @@ readonly code: VertexAIErrorCode; ```typescript readonly customErrorData?: CustomErrorData | undefined; ``` + +## VertexAIError.message + +Signature: + +```typescript +readonly message: string; +``` diff --git a/docs-devsite/vertexai.vertexaioptions.md b/docs-devsite/vertexai-preview.vertexaioptions.md similarity index 79% rename from docs-devsite/vertexai.vertexaioptions.md rename to docs-devsite/vertexai-preview.vertexaioptions.md index e15b525bfed..320132c22f9 100644 --- a/docs-devsite/vertexai.vertexaioptions.md +++ b/docs-devsite/vertexai-preview.vertexaioptions.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # VertexAIOptions interface -Options when initializing the Vertex AI in Firebase SDK. +Options when initializing the Vertex AI for Firebase SDK. Signature: @@ -22,7 +22,7 @@ export interface VertexAIOptions | Property | Type | Description | | --- | --- | --- | -| [location](./vertexai.vertexaioptions.md#vertexaioptionslocation) | string | | +| [location](./vertexai-preview.vertexaioptions.md#vertexaioptionslocation) | string | | ## VertexAIOptions.location diff --git a/docs-devsite/vertexai.videometadata.md b/docs-devsite/vertexai-preview.videometadata.md similarity index 66% rename from docs-devsite/vertexai.videometadata.md rename to docs-devsite/vertexai-preview.videometadata.md index b4f872c4e3d..04d8883bae9 100644 --- a/docs-devsite/vertexai.videometadata.md +++ b/docs-devsite/vertexai-preview.videometadata.md @@ -22,8 +22,8 @@ export interface VideoMetadata | Property | Type | Description | | --- | --- | --- | -| [endOffset](./vertexai.videometadata.md#videometadataendoffset) | string | The end offset of the video in protobuf [Duration](https://cloud.google.com/ruby/docs/reference/google-cloud-workflows-v1/latest/Google-Protobuf-Duration#json-mapping) format. | -| [startOffset](./vertexai.videometadata.md#videometadatastartoffset) | string | The start offset of the video in protobuf [Duration](https://cloud.google.com/ruby/docs/reference/google-cloud-workflows-v1/latest/Google-Protobuf-Duration#json-mapping) format. | +| [endOffset](./vertexai-preview.videometadata.md#videometadataendoffset) | string | The end offset of the video in protobuf [Duration](https://cloud.google.com/ruby/docs/reference/google-cloud-workflows-v1/latest/Google-Protobuf-Duration#json-mapping) format. | +| [startOffset](./vertexai-preview.videometadata.md#videometadatastartoffset) | string | The start offset of the video in protobuf [Duration](https://cloud.google.com/ruby/docs/reference/google-cloud-workflows-v1/latest/Google-Protobuf-Duration#json-mapping) format. | ## VideoMetadata.endOffset diff --git a/docs-devsite/vertexai.webattribution.md b/docs-devsite/vertexai-preview.webattribution.md similarity index 79% rename from docs-devsite/vertexai.webattribution.md rename to docs-devsite/vertexai-preview.webattribution.md index bb4fecf874d..5db6f94b82e 100644 --- a/docs-devsite/vertexai.webattribution.md +++ b/docs-devsite/vertexai-preview.webattribution.md @@ -21,8 +21,8 @@ export interface WebAttribution | Property | Type | Description | | --- | --- | --- | -| [title](./vertexai.webattribution.md#webattributiontitle) | string | | -| [uri](./vertexai.webattribution.md#webattributionuri) | string | | +| [title](./vertexai-preview.webattribution.md#webattributiontitle) | string | | +| [uri](./vertexai-preview.webattribution.md#webattributionuri) | string | | ## WebAttribution.title diff --git a/docs-devsite/vertexai.arrayschema.md b/docs-devsite/vertexai.arrayschema.md deleted file mode 100644 index 8f228baf9e8..00000000000 --- a/docs-devsite/vertexai.arrayschema.md +++ /dev/null @@ -1,57 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ArraySchema class -Schema class for "array" types. The `items` param should refer to the type of item that can be a member of the array. - -Signature: - -```typescript -export declare class ArraySchema extends Schema -``` -Extends: [Schema](./vertexai.schema.md#schema_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(schemaParams, items)](./vertexai.arrayschema.md#arrayschemaconstructor) | | Constructs a new instance of the ArraySchema class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [items](./vertexai.arrayschema.md#arrayschemaitems) | | [TypedSchema](./vertexai.md#typedschema) | | - -## ArraySchema.(constructor) - -Constructs a new instance of the `ArraySchema` class - -Signature: - -```typescript -constructor(schemaParams: SchemaParams, items: TypedSchema); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| schemaParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | -| items | [TypedSchema](./vertexai.md#typedschema) | | - -## ArraySchema.items - -Signature: - -```typescript -items: TypedSchema; -``` diff --git a/docs-devsite/vertexai.booleanschema.md b/docs-devsite/vertexai.booleanschema.md deleted file mode 100644 index 89449f26142..00000000000 --- a/docs-devsite/vertexai.booleanschema.md +++ /dev/null @@ -1,43 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# BooleanSchema class -Schema class for "boolean" types. - -Signature: - -```typescript -export declare class BooleanSchema extends Schema -``` -Extends: [Schema](./vertexai.schema.md#schema_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(schemaParams)](./vertexai.booleanschema.md#booleanschemaconstructor) | | Constructs a new instance of the BooleanSchema class | - -## BooleanSchema.(constructor) - -Constructs a new instance of the `BooleanSchema` class - -Signature: - -```typescript -constructor(schemaParams?: SchemaParams); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| schemaParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | - diff --git a/docs-devsite/vertexai.chatsession.md b/docs-devsite/vertexai.chatsession.md deleted file mode 100644 index cc5a75ace16..00000000000 --- a/docs-devsite/vertexai.chatsession.md +++ /dev/null @@ -1,138 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ChatSession class -ChatSession class that enables sending chat messages and stores history of sent and received messages so far. - -Signature: - -```typescript -export declare class ChatSession -``` - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(apiSettings, model, params, requestOptions)](./vertexai.chatsession.md#chatsessionconstructor) | | Constructs a new instance of the ChatSession class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [model](./vertexai.chatsession.md#chatsessionmodel) | | string | | -| [params](./vertexai.chatsession.md#chatsessionparams) | | [StartChatParams](./vertexai.startchatparams.md#startchatparams_interface) \| undefined | | -| [requestOptions](./vertexai.chatsession.md#chatsessionrequestoptions) | | [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) \| undefined | | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [getHistory()](./vertexai.chatsession.md#chatsessiongethistory) | | Gets the chat history so far. Blocked prompts are not added to history. Neither blocked candidates nor the prompts that generated them are added to history. | -| [sendMessage(request)](./vertexai.chatsession.md#chatsessionsendmessage) | | Sends a chat message and receives a non-streaming [GenerateContentResult](./vertexai.generatecontentresult.md#generatecontentresult_interface) | -| [sendMessageStream(request)](./vertexai.chatsession.md#chatsessionsendmessagestream) | | Sends a chat message and receives the response as a [GenerateContentStreamResult](./vertexai.generatecontentstreamresult.md#generatecontentstreamresult_interface) containing an iterable stream and a response promise. | - -## ChatSession.(constructor) - -Constructs a new instance of the `ChatSession` class - -Signature: - -```typescript -constructor(apiSettings: ApiSettings, model: string, params?: StartChatParams | undefined, requestOptions?: RequestOptions | undefined); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| apiSettings | ApiSettings | | -| model | string | | -| params | [StartChatParams](./vertexai.startchatparams.md#startchatparams_interface) \| undefined | | -| requestOptions | [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) \| undefined | | - -## ChatSession.model - -Signature: - -```typescript -model: string; -``` - -## ChatSession.params - -Signature: - -```typescript -params?: StartChatParams | undefined; -``` - -## ChatSession.requestOptions - -Signature: - -```typescript -requestOptions?: RequestOptions | undefined; -``` - -## ChatSession.getHistory() - -Gets the chat history so far. Blocked prompts are not added to history. Neither blocked candidates nor the prompts that generated them are added to history. - -Signature: - -```typescript -getHistory(): Promise; -``` -Returns: - -Promise<[Content](./vertexai.content.md#content_interface)\[\]> - -## ChatSession.sendMessage() - -Sends a chat message and receives a non-streaming [GenerateContentResult](./vertexai.generatecontentresult.md#generatecontentresult_interface) - -Signature: - -```typescript -sendMessage(request: string | Array): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| request | string \| Array<string \| [Part](./vertexai.md#part)> | | - -Returns: - -Promise<[GenerateContentResult](./vertexai.generatecontentresult.md#generatecontentresult_interface)> - -## ChatSession.sendMessageStream() - -Sends a chat message and receives the response as a [GenerateContentStreamResult](./vertexai.generatecontentstreamresult.md#generatecontentstreamresult_interface) containing an iterable stream and a response promise. - -Signature: - -```typescript -sendMessageStream(request: string | Array): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| request | string \| Array<string \| [Part](./vertexai.md#part)> | | - -Returns: - -Promise<[GenerateContentStreamResult](./vertexai.generatecontentstreamresult.md#generatecontentstreamresult_interface)> - diff --git a/docs-devsite/vertexai.functiondeclarationstool.md b/docs-devsite/vertexai.functiondeclarationstool.md deleted file mode 100644 index 5e728046639..00000000000 --- a/docs-devsite/vertexai.functiondeclarationstool.md +++ /dev/null @@ -1,35 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# FunctionDeclarationsTool interface -A `FunctionDeclarationsTool` is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. - -Signature: - -```typescript -export declare interface FunctionDeclarationsTool -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [functionDeclarations](./vertexai.functiondeclarationstool.md#functiondeclarationstoolfunctiondeclarations) | [FunctionDeclaration](./vertexai.functiondeclaration.md#functiondeclaration_interface)\[\] | Optional. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating [FunctionCall](./vertexai.functioncall.md#functioncall_interface) in the response. User should provide a [FunctionResponse](./vertexai.functionresponse.md#functionresponse_interface) for each function call in the next turn. Based on the function responses, the model will generate the final response back to the user. Maximum 64 function declarations can be provided. | - -## FunctionDeclarationsTool.functionDeclarations - -Optional. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating [FunctionCall](./vertexai.functioncall.md#functioncall_interface) in the response. User should provide a [FunctionResponse](./vertexai.functionresponse.md#functionresponse_interface) for each function call in the next turn. Based on the function responses, the model will generate the final response back to the user. Maximum 64 function declarations can be provided. - -Signature: - -```typescript -functionDeclarations?: FunctionDeclaration[]; -``` diff --git a/docs-devsite/vertexai.generatecontentcandidate.md b/docs-devsite/vertexai.generatecontentcandidate.md deleted file mode 100644 index a30eef55485..00000000000 --- a/docs-devsite/vertexai.generatecontentcandidate.md +++ /dev/null @@ -1,87 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# GenerateContentCandidate interface -A candidate returned as part of a [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface). - -Signature: - -```typescript -export interface GenerateContentCandidate -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [citationMetadata](./vertexai.generatecontentcandidate.md#generatecontentcandidatecitationmetadata) | [CitationMetadata](./vertexai.citationmetadata.md#citationmetadata_interface) | | -| [content](./vertexai.generatecontentcandidate.md#generatecontentcandidatecontent) | [Content](./vertexai.content.md#content_interface) | | -| [finishMessage](./vertexai.generatecontentcandidate.md#generatecontentcandidatefinishmessage) | string | | -| [finishReason](./vertexai.generatecontentcandidate.md#generatecontentcandidatefinishreason) | [FinishReason](./vertexai.md#finishreason) | | -| [groundingMetadata](./vertexai.generatecontentcandidate.md#generatecontentcandidategroundingmetadata) | [GroundingMetadata](./vertexai.groundingmetadata.md#groundingmetadata_interface) | | -| [index](./vertexai.generatecontentcandidate.md#generatecontentcandidateindex) | number | | -| [safetyRatings](./vertexai.generatecontentcandidate.md#generatecontentcandidatesafetyratings) | [SafetyRating](./vertexai.safetyrating.md#safetyrating_interface)\[\] | | - -## GenerateContentCandidate.citationMetadata - -Signature: - -```typescript -citationMetadata?: CitationMetadata; -``` - -## GenerateContentCandidate.content - -Signature: - -```typescript -content: Content; -``` - -## GenerateContentCandidate.finishMessage - -Signature: - -```typescript -finishMessage?: string; -``` - -## GenerateContentCandidate.finishReason - -Signature: - -```typescript -finishReason?: FinishReason; -``` - -## GenerateContentCandidate.groundingMetadata - -Signature: - -```typescript -groundingMetadata?: GroundingMetadata; -``` - -## GenerateContentCandidate.index - -Signature: - -```typescript -index: number; -``` - -## GenerateContentCandidate.safetyRatings - -Signature: - -```typescript -safetyRatings?: SafetyRating[]; -``` diff --git a/docs-devsite/vertexai.generationconfig.md b/docs-devsite/vertexai.generationconfig.md deleted file mode 100644 index 3c3d0a14ffa..00000000000 --- a/docs-devsite/vertexai.generationconfig.md +++ /dev/null @@ -1,118 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# GenerationConfig interface -Config options for content-related requests - -Signature: - -```typescript -export interface GenerationConfig -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [candidateCount](./vertexai.generationconfig.md#generationconfigcandidatecount) | number | | -| [frequencyPenalty](./vertexai.generationconfig.md#generationconfigfrequencypenalty) | number | | -| [maxOutputTokens](./vertexai.generationconfig.md#generationconfigmaxoutputtokens) | number | | -| [presencePenalty](./vertexai.generationconfig.md#generationconfigpresencepenalty) | number | | -| [responseMimeType](./vertexai.generationconfig.md#generationconfigresponsemimetype) | string | Output response MIME type of the generated candidate text. Supported MIME types are text/plain (default, text output), application/json (JSON response in the candidates), and text/x.enum. | -| [responseSchema](./vertexai.generationconfig.md#generationconfigresponseschema) | [TypedSchema](./vertexai.md#typedschema) \| [SchemaRequest](./vertexai.schemarequest.md#schemarequest_interface) | Output response schema of the generated candidate text. This value can be a class generated with a [Schema](./vertexai.schema.md#schema_class) static method like Schema.string() or Schema.object() or it can be a plain JS object matching the [SchemaRequest](./vertexai.schemarequest.md#schemarequest_interface) interface.
Note: This only applies when the specified responseMIMEType supports a schema; currently this is limited to application/json and text/x.enum. | -| [stopSequences](./vertexai.generationconfig.md#generationconfigstopsequences) | string\[\] | | -| [temperature](./vertexai.generationconfig.md#generationconfigtemperature) | number | | -| [topK](./vertexai.generationconfig.md#generationconfigtopk) | number | | -| [topP](./vertexai.generationconfig.md#generationconfigtopp) | number | | - -## GenerationConfig.candidateCount - -Signature: - -```typescript -candidateCount?: number; -``` - -## GenerationConfig.frequencyPenalty - -Signature: - -```typescript -frequencyPenalty?: number; -``` - -## GenerationConfig.maxOutputTokens - -Signature: - -```typescript -maxOutputTokens?: number; -``` - -## GenerationConfig.presencePenalty - -Signature: - -```typescript -presencePenalty?: number; -``` - -## GenerationConfig.responseMimeType - -Output response MIME type of the generated candidate text. Supported MIME types are `text/plain` (default, text output), `application/json` (JSON response in the candidates), and `text/x.enum`. - -Signature: - -```typescript -responseMimeType?: string; -``` - -## GenerationConfig.responseSchema - -Output response schema of the generated candidate text. This value can be a class generated with a [Schema](./vertexai.schema.md#schema_class) static method like `Schema.string()` or `Schema.object()` or it can be a plain JS object matching the [SchemaRequest](./vertexai.schemarequest.md#schemarequest_interface) interface.
Note: This only applies when the specified `responseMIMEType` supports a schema; currently this is limited to `application/json` and `text/x.enum`. - -Signature: - -```typescript -responseSchema?: TypedSchema | SchemaRequest; -``` - -## GenerationConfig.stopSequences - -Signature: - -```typescript -stopSequences?: string[]; -``` - -## GenerationConfig.temperature - -Signature: - -```typescript -temperature?: number; -``` - -## GenerationConfig.topK - -Signature: - -```typescript -topK?: number; -``` - -## GenerationConfig.topP - -Signature: - -```typescript -topP?: number; -``` diff --git a/docs-devsite/vertexai.generativemodel.md b/docs-devsite/vertexai.generativemodel.md deleted file mode 100644 index 7105f9c100b..00000000000 --- a/docs-devsite/vertexai.generativemodel.md +++ /dev/null @@ -1,201 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# GenerativeModel class -Class for generative model APIs. - -Signature: - -```typescript -export declare class GenerativeModel -``` - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(vertexAI, modelParams, requestOptions)](./vertexai.generativemodel.md#generativemodelconstructor) | | Constructs a new instance of the GenerativeModel class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [generationConfig](./vertexai.generativemodel.md#generativemodelgenerationconfig) | | [GenerationConfig](./vertexai.generationconfig.md#generationconfig_interface) | | -| [model](./vertexai.generativemodel.md#generativemodelmodel) | | string | | -| [requestOptions](./vertexai.generativemodel.md#generativemodelrequestoptions) | | [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) | | -| [safetySettings](./vertexai.generativemodel.md#generativemodelsafetysettings) | | [SafetySetting](./vertexai.safetysetting.md#safetysetting_interface)\[\] | | -| [systemInstruction](./vertexai.generativemodel.md#generativemodelsysteminstruction) | | [Content](./vertexai.content.md#content_interface) | | -| [toolConfig](./vertexai.generativemodel.md#generativemodeltoolconfig) | | [ToolConfig](./vertexai.toolconfig.md#toolconfig_interface) | | -| [tools](./vertexai.generativemodel.md#generativemodeltools) | | [Tool](./vertexai.md#tool)\[\] | | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [countTokens(request)](./vertexai.generativemodel.md#generativemodelcounttokens) | | Counts the tokens in the provided request. | -| [generateContent(request)](./vertexai.generativemodel.md#generativemodelgeneratecontent) | | Makes a single non-streaming call to the model and returns an object containing a single [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface). | -| [generateContentStream(request)](./vertexai.generativemodel.md#generativemodelgeneratecontentstream) | | Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response. | -| [startChat(startChatParams)](./vertexai.generativemodel.md#generativemodelstartchat) | | Gets a new [ChatSession](./vertexai.chatsession.md#chatsession_class) instance which can be used for multi-turn chats. | - -## GenerativeModel.(constructor) - -Constructs a new instance of the `GenerativeModel` class - -Signature: - -```typescript -constructor(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| vertexAI | [VertexAI](./vertexai.vertexai.md#vertexai_interface) | | -| modelParams | [ModelParams](./vertexai.modelparams.md#modelparams_interface) | | -| requestOptions | [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) | | - -## GenerativeModel.generationConfig - -Signature: - -```typescript -generationConfig: GenerationConfig; -``` - -## GenerativeModel.model - -Signature: - -```typescript -model: string; -``` - -## GenerativeModel.requestOptions - -Signature: - -```typescript -requestOptions?: RequestOptions; -``` - -## GenerativeModel.safetySettings - -Signature: - -```typescript -safetySettings: SafetySetting[]; -``` - -## GenerativeModel.systemInstruction - -Signature: - -```typescript -systemInstruction?: Content; -``` - -## GenerativeModel.toolConfig - -Signature: - -```typescript -toolConfig?: ToolConfig; -``` - -## GenerativeModel.tools - -Signature: - -```typescript -tools?: Tool[]; -``` - -## GenerativeModel.countTokens() - -Counts the tokens in the provided request. - -Signature: - -```typescript -countTokens(request: CountTokensRequest | string | Array): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| request | [CountTokensRequest](./vertexai.counttokensrequest.md#counttokensrequest_interface) \| string \| Array<string \| [Part](./vertexai.md#part)> | | - -Returns: - -Promise<[CountTokensResponse](./vertexai.counttokensresponse.md#counttokensresponse_interface)> - -## GenerativeModel.generateContent() - -Makes a single non-streaming call to the model and returns an object containing a single [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface). - -Signature: - -```typescript -generateContent(request: GenerateContentRequest | string | Array): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| request | [GenerateContentRequest](./vertexai.generatecontentrequest.md#generatecontentrequest_interface) \| string \| Array<string \| [Part](./vertexai.md#part)> | | - -Returns: - -Promise<[GenerateContentResult](./vertexai.generatecontentresult.md#generatecontentresult_interface)> - -## GenerativeModel.generateContentStream() - -Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response. - -Signature: - -```typescript -generateContentStream(request: GenerateContentRequest | string | Array): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| request | [GenerateContentRequest](./vertexai.generatecontentrequest.md#generatecontentrequest_interface) \| string \| Array<string \| [Part](./vertexai.md#part)> | | - -Returns: - -Promise<[GenerateContentStreamResult](./vertexai.generatecontentstreamresult.md#generatecontentstreamresult_interface)> - -## GenerativeModel.startChat() - -Gets a new [ChatSession](./vertexai.chatsession.md#chatsession_class) instance which can be used for multi-turn chats. - -Signature: - -```typescript -startChat(startChatParams?: StartChatParams): ChatSession; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| startChatParams | [StartChatParams](./vertexai.startchatparams.md#startchatparams_interface) | | - -Returns: - -[ChatSession](./vertexai.chatsession.md#chatsession_class) - diff --git a/docs-devsite/vertexai.integerschema.md b/docs-devsite/vertexai.integerschema.md deleted file mode 100644 index 4822bdd618b..00000000000 --- a/docs-devsite/vertexai.integerschema.md +++ /dev/null @@ -1,43 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# IntegerSchema class -Schema class for "integer" types. - -Signature: - -```typescript -export declare class IntegerSchema extends Schema -``` -Extends: [Schema](./vertexai.schema.md#schema_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(schemaParams)](./vertexai.integerschema.md#integerschemaconstructor) | | Constructs a new instance of the IntegerSchema class | - -## IntegerSchema.(constructor) - -Constructs a new instance of the `IntegerSchema` class - -Signature: - -```typescript -constructor(schemaParams?: SchemaParams); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| schemaParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | - diff --git a/docs-devsite/vertexai.md b/docs-devsite/vertexai.md deleted file mode 100644 index d9e26eabc5d..00000000000 --- a/docs-devsite/vertexai.md +++ /dev/null @@ -1,412 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# vertexai package -The Vertex AI in Firebase Web SDK. - -## Functions - -| Function | Description | -| --- | --- | -| function(app, ...) | -| [getVertexAI(app, options)](./vertexai.md#getvertexai_04094cf) | Returns a [VertexAI](./vertexai.vertexai.md#vertexai_interface) instance for the given app. | -| function(vertexAI, ...) | -| [getGenerativeModel(vertexAI, modelParams, requestOptions)](./vertexai.md#getgenerativemodel_e3037c9) | Returns a [GenerativeModel](./vertexai.generativemodel.md#generativemodel_class) class with methods for inference and other functionality. | - -## Classes - -| Class | Description | -| --- | --- | -| [ArraySchema](./vertexai.arrayschema.md#arrayschema_class) | Schema class for "array" types. The items param should refer to the type of item that can be a member of the array. | -| [BooleanSchema](./vertexai.booleanschema.md#booleanschema_class) | Schema class for "boolean" types. | -| [ChatSession](./vertexai.chatsession.md#chatsession_class) | ChatSession class that enables sending chat messages and stores history of sent and received messages so far. | -| [GenerativeModel](./vertexai.generativemodel.md#generativemodel_class) | Class for generative model APIs. | -| [IntegerSchema](./vertexai.integerschema.md#integerschema_class) | Schema class for "integer" types. | -| [NumberSchema](./vertexai.numberschema.md#numberschema_class) | Schema class for "number" types. | -| [ObjectSchema](./vertexai.objectschema.md#objectschema_class) | Schema class for "object" types. The properties param must be a map of Schema objects. | -| [Schema](./vertexai.schema.md#schema_class) | Parent class encompassing all Schema types, with static methods that allow building specific Schema types. This class can be converted with JSON.stringify() into a JSON string accepted by Vertex AI REST endpoints. (This string conversion is automatically done when calling SDK methods.) | -| [StringSchema](./vertexai.stringschema.md#stringschema_class) | Schema class for "string" types. Can be used with or without enum values. | -| [VertexAIError](./vertexai.vertexaierror.md#vertexaierror_class) | Error class for the Vertex AI in Firebase SDK. | - -## Enumerations - -| Enumeration | Description | -| --- | --- | -| [BlockReason](./vertexai.md#blockreason) | Reason that a prompt was blocked. | -| [FinishReason](./vertexai.md#finishreason) | Reason that a candidate finished. | -| [FunctionCallingMode](./vertexai.md#functioncallingmode) | | -| [HarmBlockMethod](./vertexai.md#harmblockmethod) | | -| [HarmBlockThreshold](./vertexai.md#harmblockthreshold) | Threshold above which a prompt or candidate will be blocked. | -| [HarmCategory](./vertexai.md#harmcategory) | Harm categories that would cause prompts or candidates to be blocked. | -| [HarmProbability](./vertexai.md#harmprobability) | Probability that a prompt or candidate matches a harm category. | -| [HarmSeverity](./vertexai.md#harmseverity) | Harm severity levels. | -| [SchemaType](./vertexai.md#schematype) | Contains the list of OpenAPI data types as defined by the [OpenAPI specification](https://swagger.io/docs/specification/data-models/data-types/) | -| [VertexAIErrorCode](./vertexai.md#vertexaierrorcode) | Standardized error codes that [VertexAIError](./vertexai.vertexaierror.md#vertexaierror_class) can have. | - -## Interfaces - -| Interface | Description | -| --- | --- | -| [BaseParams](./vertexai.baseparams.md#baseparams_interface) | Base parameters for a number of methods. | -| [Citation](./vertexai.citation.md#citation_interface) | A single citation. | -| [CitationMetadata](./vertexai.citationmetadata.md#citationmetadata_interface) | Citation metadata that may be found on a [GenerateContentCandidate](./vertexai.generatecontentcandidate.md#generatecontentcandidate_interface). | -| [Content](./vertexai.content.md#content_interface) | Content type for both prompts and response candidates. | -| [CountTokensRequest](./vertexai.counttokensrequest.md#counttokensrequest_interface) | Params for calling [GenerativeModel.countTokens()](./vertexai.generativemodel.md#generativemodelcounttokens) | -| [CountTokensResponse](./vertexai.counttokensresponse.md#counttokensresponse_interface) | Response from calling [GenerativeModel.countTokens()](./vertexai.generativemodel.md#generativemodelcounttokens). | -| [CustomErrorData](./vertexai.customerrordata.md#customerrordata_interface) | Details object that contains data originating from a bad HTTP response. | -| [Date\_2](./vertexai.date_2.md#date_2_interface) | Protobuf google.type.Date | -| [EnhancedGenerateContentResponse](./vertexai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface) | Response object wrapped with helper methods. | -| [ErrorDetails](./vertexai.errordetails.md#errordetails_interface) | Details object that may be included in an error response. | -| [FileData](./vertexai.filedata.md#filedata_interface) | Data pointing to a file uploaded on Google Cloud Storage. | -| [FileDataPart](./vertexai.filedatapart.md#filedatapart_interface) | Content part interface if the part represents [FileData](./vertexai.filedata.md#filedata_interface) | -| [FunctionCall](./vertexai.functioncall.md#functioncall_interface) | A predicted [FunctionCall](./vertexai.functioncall.md#functioncall_interface) returned from the model that contains a string representing the [FunctionDeclaration.name](./vertexai.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing the parameters and their values. | -| [FunctionCallingConfig](./vertexai.functioncallingconfig.md#functioncallingconfig_interface) | | -| [FunctionCallPart](./vertexai.functioncallpart.md#functioncallpart_interface) | Content part interface if the part represents a [FunctionCall](./vertexai.functioncall.md#functioncall_interface). | -| [FunctionDeclaration](./vertexai.functiondeclaration.md#functiondeclaration_interface) | Structured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3). Included in this declaration are the function name and parameters. This FunctionDeclaration is a representation of a block of code that can be used as a Tool by the model and executed by the client. | -| [FunctionDeclarationsTool](./vertexai.functiondeclarationstool.md#functiondeclarationstool_interface) | A FunctionDeclarationsTool is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. | -| [FunctionResponse](./vertexai.functionresponse.md#functionresponse_interface) | The result output from a [FunctionCall](./vertexai.functioncall.md#functioncall_interface) that contains a string representing the [FunctionDeclaration.name](./vertexai.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a [FunctionCall](./vertexai.functioncall.md#functioncall_interface) made based on model prediction. | -| [FunctionResponsePart](./vertexai.functionresponsepart.md#functionresponsepart_interface) | Content part interface if the part represents [FunctionResponse](./vertexai.functionresponse.md#functionresponse_interface). | -| [GenerateContentCandidate](./vertexai.generatecontentcandidate.md#generatecontentcandidate_interface) | A candidate returned as part of a [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface). | -| [GenerateContentRequest](./vertexai.generatecontentrequest.md#generatecontentrequest_interface) | Request sent through [GenerativeModel.generateContent()](./vertexai.generativemodel.md#generativemodelgeneratecontent) | -| [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface) | Individual response from [GenerativeModel.generateContent()](./vertexai.generativemodel.md#generativemodelgeneratecontent) and [GenerativeModel.generateContentStream()](./vertexai.generativemodel.md#generativemodelgeneratecontentstream). generateContentStream() will return one in each chunk until the stream is done. | -| [GenerateContentResult](./vertexai.generatecontentresult.md#generatecontentresult_interface) | Result object returned from [GenerativeModel.generateContent()](./vertexai.generativemodel.md#generativemodelgeneratecontent) call. | -| [GenerateContentStreamResult](./vertexai.generatecontentstreamresult.md#generatecontentstreamresult_interface) | Result object returned from [GenerativeModel.generateContentStream()](./vertexai.generativemodel.md#generativemodelgeneratecontentstream) call. Iterate over stream to get chunks as they come in and/or use the response promise to get the aggregated response when the stream is done. | -| [GenerationConfig](./vertexai.generationconfig.md#generationconfig_interface) | Config options for content-related requests | -| [GenerativeContentBlob](./vertexai.generativecontentblob.md#generativecontentblob_interface) | Interface for sending an image. | -| [GroundingAttribution](./vertexai.groundingattribution.md#groundingattribution_interface) | | -| [GroundingMetadata](./vertexai.groundingmetadata.md#groundingmetadata_interface) | Metadata returned to client when grounding is enabled. | -| [InlineDataPart](./vertexai.inlinedatapart.md#inlinedatapart_interface) | Content part interface if the part represents an image. | -| [ModelParams](./vertexai.modelparams.md#modelparams_interface) | Params passed to [getGenerativeModel()](./vertexai.md#getgenerativemodel_e3037c9). | -| [ObjectSchemaInterface](./vertexai.objectschemainterface.md#objectschemainterface_interface) | Interface for [ObjectSchema](./vertexai.objectschema.md#objectschema_class) class. | -| [PromptFeedback](./vertexai.promptfeedback.md#promptfeedback_interface) | If the prompt was blocked, this will be populated with blockReason and the relevant safetyRatings. | -| [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) | Params passed to [getGenerativeModel()](./vertexai.md#getgenerativemodel_e3037c9). | -| [RetrievedContextAttribution](./vertexai.retrievedcontextattribution.md#retrievedcontextattribution_interface) | | -| [SafetyRating](./vertexai.safetyrating.md#safetyrating_interface) | A safety rating associated with a [GenerateContentCandidate](./vertexai.generatecontentcandidate.md#generatecontentcandidate_interface) | -| [SafetySetting](./vertexai.safetysetting.md#safetysetting_interface) | Safety setting that can be sent as part of request parameters. | -| [SchemaInterface](./vertexai.schemainterface.md#schemainterface_interface) | Interface for [Schema](./vertexai.schema.md#schema_class) class. | -| [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | Params passed to [Schema](./vertexai.schema.md#schema_class) static methods to create specific [Schema](./vertexai.schema.md#schema_class) classes. | -| [SchemaRequest](./vertexai.schemarequest.md#schemarequest_interface) | Final format for [Schema](./vertexai.schema.md#schema_class) params passed to backend requests. | -| [SchemaShared](./vertexai.schemashared.md#schemashared_interface) | Basic [Schema](./vertexai.schema.md#schema_class) properties shared across several Schema-related types. | -| [Segment](./vertexai.segment.md#segment_interface) | | -| [StartChatParams](./vertexai.startchatparams.md#startchatparams_interface) | Params for [GenerativeModel.startChat()](./vertexai.generativemodel.md#generativemodelstartchat). | -| [TextPart](./vertexai.textpart.md#textpart_interface) | Content part interface if the part represents a text string. | -| [ToolConfig](./vertexai.toolconfig.md#toolconfig_interface) | Tool config. This config is shared for all tools provided in the request. | -| [UsageMetadata](./vertexai.usagemetadata.md#usagemetadata_interface) | Usage metadata about a [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface). | -| [VertexAI](./vertexai.vertexai.md#vertexai_interface) | An instance of the Vertex AI in Firebase SDK. | -| [VertexAIOptions](./vertexai.vertexaioptions.md#vertexaioptions_interface) | Options when initializing the Vertex AI in Firebase SDK. | -| [VideoMetadata](./vertexai.videometadata.md#videometadata_interface) | Describes the input video content. | -| [WebAttribution](./vertexai.webattribution.md#webattribution_interface) | | - -## Variables - -| Variable | Description | -| --- | --- | -| [POSSIBLE\_ROLES](./vertexai.md#possible_roles) | Possible roles. | - -## Type Aliases - -| Type Alias | Description | -| --- | --- | -| [Part](./vertexai.md#part) | Content part - includes text, image/video, or function call/response part types. | -| [Role](./vertexai.md#role) | Role is the producer of the content. | -| [Tool](./vertexai.md#tool) | Defines a tool that model can call to access external knowledge. | -| [TypedSchema](./vertexai.md#typedschema) | A type that includes all specific Schema types. | - -## function(app, ...) - -### getVertexAI(app, options) {:#getvertexai_04094cf} - -Returns a [VertexAI](./vertexai.vertexai.md#vertexai_interface) instance for the given app. - -Signature: - -```typescript -export declare function getVertexAI(app?: FirebaseApp, options?: VertexAIOptions): VertexAI; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) to use. | -| options | [VertexAIOptions](./vertexai.vertexaioptions.md#vertexaioptions_interface) | | - -Returns: - -[VertexAI](./vertexai.vertexai.md#vertexai_interface) - -## function(vertexAI, ...) - -### getGenerativeModel(vertexAI, modelParams, requestOptions) {:#getgenerativemodel_e3037c9} - -Returns a [GenerativeModel](./vertexai.generativemodel.md#generativemodel_class) class with methods for inference and other functionality. - -Signature: - -```typescript -export declare function getGenerativeModel(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| vertexAI | [VertexAI](./vertexai.vertexai.md#vertexai_interface) | | -| modelParams | [ModelParams](./vertexai.modelparams.md#modelparams_interface) | | -| requestOptions | [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) | | - -Returns: - -[GenerativeModel](./vertexai.generativemodel.md#generativemodel_class) - -## POSSIBLE\_ROLES - -Possible roles. - -Signature: - -```typescript -POSSIBLE_ROLES: readonly ["user", "model", "function", "system"] -``` - -## Part - -Content part - includes text, image/video, or function call/response part types. - -Signature: - -```typescript -export type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart; -``` - -## Role - -Role is the producer of the content. - -Signature: - -```typescript -export type Role = (typeof POSSIBLE_ROLES)[number]; -``` - -## Tool - -Defines a tool that model can call to access external knowledge. - -Signature: - -```typescript -export declare type Tool = FunctionDeclarationsTool; -``` - -## TypedSchema - -A type that includes all specific Schema types. - -Signature: - -```typescript -export type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema; -``` - -## BlockReason - -Reason that a prompt was blocked. - -Signature: - -```typescript -export declare enum BlockReason -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| OTHER | "OTHER" | | -| SAFETY | "SAFETY" | | - -## FinishReason - -Reason that a candidate finished. - -Signature: - -```typescript -export declare enum FinishReason -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| MAX\_TOKENS | "MAX_TOKENS" | | -| OTHER | "OTHER" | | -| RECITATION | "RECITATION" | | -| SAFETY | "SAFETY" | | -| STOP | "STOP" | | - -## FunctionCallingMode - - -Signature: - -```typescript -export declare enum FunctionCallingMode -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| ANY | "ANY" | | -| AUTO | "AUTO" | | -| NONE | "NONE" | | - -## HarmBlockMethod - - -Signature: - -```typescript -export declare enum HarmBlockMethod -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| PROBABILITY | "PROBABILITY" | | -| SEVERITY | "SEVERITY" | | - -## HarmBlockThreshold - -Threshold above which a prompt or candidate will be blocked. - -Signature: - -```typescript -export declare enum HarmBlockThreshold -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| BLOCK\_LOW\_AND\_ABOVE | "BLOCK_LOW_AND_ABOVE" | | -| BLOCK\_MEDIUM\_AND\_ABOVE | "BLOCK_MEDIUM_AND_ABOVE" | | -| BLOCK\_NONE | "BLOCK_NONE" | | -| BLOCK\_ONLY\_HIGH | "BLOCK_ONLY_HIGH" | | - -## HarmCategory - -Harm categories that would cause prompts or candidates to be blocked. - -Signature: - -```typescript -export declare enum HarmCategory -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| HARM\_CATEGORY\_DANGEROUS\_CONTENT | "HARM_CATEGORY_DANGEROUS_CONTENT" | | -| HARM\_CATEGORY\_HARASSMENT | "HARM_CATEGORY_HARASSMENT" | | -| HARM\_CATEGORY\_HATE\_SPEECH | "HARM_CATEGORY_HATE_SPEECH" | | -| HARM\_CATEGORY\_SEXUALLY\_EXPLICIT | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | | - -## HarmProbability - -Probability that a prompt or candidate matches a harm category. - -Signature: - -```typescript -export declare enum HarmProbability -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| HIGH | "HIGH" | | -| LOW | "LOW" | | -| MEDIUM | "MEDIUM" | | -| NEGLIGIBLE | "NEGLIGIBLE" | | - -## HarmSeverity - -Harm severity levels. - -Signature: - -```typescript -export declare enum HarmSeverity -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| HARM\_SEVERITY\_HIGH | "HARM_SEVERITY_HIGH" | | -| HARM\_SEVERITY\_LOW | "HARM_SEVERITY_LOW" | | -| HARM\_SEVERITY\_MEDIUM | "HARM_SEVERITY_MEDIUM" | | -| HARM\_SEVERITY\_NEGLIGIBLE | "HARM_SEVERITY_NEGLIGIBLE" | | - -## SchemaType - -Contains the list of OpenAPI data types as defined by the [OpenAPI specification](https://swagger.io/docs/specification/data-models/data-types/) - -Signature: - -```typescript -export declare enum SchemaType -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| ARRAY | "array" | Array type. | -| BOOLEAN | "boolean" | Boolean type. | -| INTEGER | "integer" | Integer type. | -| NUMBER | "number" | Number type. | -| OBJECT | "object" | Object type. | -| STRING | "string" | String type. | - -## VertexAIErrorCode - -Standardized error codes that [VertexAIError](./vertexai.vertexaierror.md#vertexaierror_class) can have. - -Signature: - -```typescript -export declare const enum VertexAIErrorCode -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| API\_NOT\_ENABLED | "api-not-enabled" | An error due to the Firebase API not being enabled in the Console. | -| ERROR | "error" | A generic error occurred. | -| FETCH\_ERROR | "fetch-error" | An error occurred while performing a fetch. | -| INVALID\_CONTENT | "invalid-content" | An error associated with a Content object. | -| INVALID\_SCHEMA | "invalid-schema" | An error due to invalid Schema input. | -| NO\_API\_KEY | "no-api-key" | An error occurred due to a missing Firebase API key. | -| NO\_MODEL | "no-model" | An error occurred due to a model name not being specified during initialization. | -| NO\_PROJECT\_ID | "no-project-id" | An error occurred due to a missing project ID. | -| PARSE\_FAILED | "parse-failed" | An error occurred while parsing. | -| REQUEST\_ERROR | "request-error" | An error occurred in a request. | -| RESPONSE\_ERROR | "response-error" | An error occurred in a response. | - diff --git a/docs-devsite/vertexai.numberschema.md b/docs-devsite/vertexai.numberschema.md deleted file mode 100644 index 8fdd9374652..00000000000 --- a/docs-devsite/vertexai.numberschema.md +++ /dev/null @@ -1,43 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# NumberSchema class -Schema class for "number" types. - -Signature: - -```typescript -export declare class NumberSchema extends Schema -``` -Extends: [Schema](./vertexai.schema.md#schema_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(schemaParams)](./vertexai.numberschema.md#numberschemaconstructor) | | Constructs a new instance of the NumberSchema class | - -## NumberSchema.(constructor) - -Constructs a new instance of the `NumberSchema` class - -Signature: - -```typescript -constructor(schemaParams?: SchemaParams); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| schemaParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | - diff --git a/docs-devsite/vertexai.objectschema.md b/docs-devsite/vertexai.objectschema.md deleted file mode 100644 index 8731960b220..00000000000 --- a/docs-devsite/vertexai.objectschema.md +++ /dev/null @@ -1,71 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ObjectSchema class -Schema class for "object" types. The `properties` param must be a map of `Schema` objects. - -Signature: - -```typescript -export declare class ObjectSchema extends Schema -``` -Extends: [Schema](./vertexai.schema.md#schema_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(schemaParams, properties, optionalProperties)](./vertexai.objectschema.md#objectschemaconstructor) | | Constructs a new instance of the ObjectSchema class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [optionalProperties](./vertexai.objectschema.md#objectschemaoptionalproperties) | | string\[\] | | -| [properties](./vertexai.objectschema.md#objectschemaproperties) | | { \[k: string\]: [TypedSchema](./vertexai.md#typedschema); } | | - -## ObjectSchema.(constructor) - -Constructs a new instance of the `ObjectSchema` class - -Signature: - -```typescript -constructor(schemaParams: SchemaParams, properties: { - [k: string]: TypedSchema; - }, optionalProperties?: string[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| schemaParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | -| properties | { \[k: string\]: [TypedSchema](./vertexai.md#typedschema); } | | -| optionalProperties | string\[\] | | - -## ObjectSchema.optionalProperties - -Signature: - -```typescript -optionalProperties: string[]; -``` - -## ObjectSchema.properties - -Signature: - -```typescript -properties: { - [k: string]: TypedSchema; - }; -``` diff --git a/docs-devsite/vertexai.objectschemainterface.md b/docs-devsite/vertexai.objectschemainterface.md deleted file mode 100644 index 6a4e052d183..00000000000 --- a/docs-devsite/vertexai.objectschemainterface.md +++ /dev/null @@ -1,43 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ObjectSchemaInterface interface -Interface for [ObjectSchema](./vertexai.objectschema.md#objectschema_class) class. - -Signature: - -```typescript -export interface ObjectSchemaInterface extends SchemaInterface -``` -Extends: [SchemaInterface](./vertexai.schemainterface.md#schemainterface_interface) - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [optionalProperties](./vertexai.objectschemainterface.md#objectschemainterfaceoptionalproperties) | string\[\] | | -| [type](./vertexai.objectschemainterface.md#objectschemainterfacetype) | [SchemaType.OBJECT](./vertexai.md#schematypeobject_enummember) | | - -## ObjectSchemaInterface.optionalProperties - -Signature: - -```typescript -optionalProperties?: string[]; -``` - -## ObjectSchemaInterface.type - -Signature: - -```typescript -type: SchemaType.OBJECT; -``` diff --git a/docs-devsite/vertexai.schema.md b/docs-devsite/vertexai.schema.md deleted file mode 100644 index f4a36c3c506..00000000000 --- a/docs-devsite/vertexai.schema.md +++ /dev/null @@ -1,250 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Schema class -Parent class encompassing all Schema types, with static methods that allow building specific Schema types. This class can be converted with `JSON.stringify()` into a JSON string accepted by Vertex AI REST endpoints. (This string conversion is automatically done when calling SDK methods.) - -Signature: - -```typescript -export declare abstract class Schema implements SchemaInterface -``` -Implements: [SchemaInterface](./vertexai.schemainterface.md#schemainterface_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(schemaParams)](./vertexai.schema.md#schemaconstructor) | | Constructs a new instance of the Schema class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [description](./vertexai.schema.md#schemadescription) | | string | Optional. The description of the property. | -| [example](./vertexai.schema.md#schemaexample) | | unknown | Optional. The example of the property. | -| [format](./vertexai.schema.md#schemaformat) | | string | Optional. The format of the property. Supported formats:

  • for NUMBER type: "float", "double"
  • for INTEGER type: "int32", "int64"
  • for STRING type: "email", "byte", etc
| -| [nullable](./vertexai.schema.md#schemanullable) | | boolean | Optional. Whether the property is nullable. Defaults to false. | -| [type](./vertexai.schema.md#schematype) | | [SchemaType](./vertexai.md#schematype) | Optional. The type of the property. [SchemaType](./vertexai.md#schematype). | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [array(arrayParams)](./vertexai.schema.md#schemaarray) | static | | -| [boolean(booleanParams)](./vertexai.schema.md#schemaboolean) | static | | -| [enumString(stringParams)](./vertexai.schema.md#schemaenumstring) | static | | -| [integer(integerParams)](./vertexai.schema.md#schemainteger) | static | | -| [number(numberParams)](./vertexai.schema.md#schemanumber) | static | | -| [object(objectParams)](./vertexai.schema.md#schemaobject) | static | | -| [string(stringParams)](./vertexai.schema.md#schemastring) | static | | - -## Schema.(constructor) - -Constructs a new instance of the `Schema` class - -Signature: - -```typescript -constructor(schemaParams: SchemaInterface); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| schemaParams | [SchemaInterface](./vertexai.schemainterface.md#schemainterface_interface) | | - -## Schema.description - -Optional. The description of the property. - -Signature: - -```typescript -description?: string; -``` - -## Schema.example - -Optional. The example of the property. - -Signature: - -```typescript -example?: unknown; -``` - -## Schema.format - -Optional. The format of the property. Supported formats:
  • for NUMBER type: "float", "double"
  • for INTEGER type: "int32", "int64"
  • for STRING type: "email", "byte", etc
- -Signature: - -```typescript -format?: string; -``` - -## Schema.nullable - -Optional. Whether the property is nullable. Defaults to false. - -Signature: - -```typescript -nullable: boolean; -``` - -## Schema.type - -Optional. The type of the property. [SchemaType](./vertexai.md#schematype). - -Signature: - -```typescript -type: SchemaType; -``` - -## Schema.array() - -Signature: - -```typescript -static array(arrayParams: SchemaParams & { - items: Schema; - }): ArraySchema; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| arrayParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) & { items: [Schema](./vertexai.schema.md#schema_class); } | | - -Returns: - -[ArraySchema](./vertexai.arrayschema.md#arrayschema_class) - -## Schema.boolean() - -Signature: - -```typescript -static boolean(booleanParams?: SchemaParams): BooleanSchema; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| booleanParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | - -Returns: - -[BooleanSchema](./vertexai.booleanschema.md#booleanschema_class) - -## Schema.enumString() - -Signature: - -```typescript -static enumString(stringParams: SchemaParams & { - enum: string[]; - }): StringSchema; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| stringParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) & { enum: string\[\]; } | | - -Returns: - -[StringSchema](./vertexai.stringschema.md#stringschema_class) - -## Schema.integer() - -Signature: - -```typescript -static integer(integerParams?: SchemaParams): IntegerSchema; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| integerParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | - -Returns: - -[IntegerSchema](./vertexai.integerschema.md#integerschema_class) - -## Schema.number() - -Signature: - -```typescript -static number(numberParams?: SchemaParams): NumberSchema; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| numberParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | - -Returns: - -[NumberSchema](./vertexai.numberschema.md#numberschema_class) - -## Schema.object() - -Signature: - -```typescript -static object(objectParams: SchemaParams & { - properties: { - [k: string]: Schema; - }; - optionalProperties?: string[]; - }): ObjectSchema; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| objectParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) & { properties: { \[k: string\]: [Schema](./vertexai.schema.md#schema_class); }; optionalProperties?: string\[\]; } | | - -Returns: - -[ObjectSchema](./vertexai.objectschema.md#objectschema_class) - -## Schema.string() - -Signature: - -```typescript -static string(stringParams?: SchemaParams): StringSchema; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| stringParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | - -Returns: - -[StringSchema](./vertexai.stringschema.md#stringschema_class) - diff --git a/docs-devsite/vertexai.schemainterface.md b/docs-devsite/vertexai.schemainterface.md deleted file mode 100644 index 3992c9e5116..00000000000 --- a/docs-devsite/vertexai.schemainterface.md +++ /dev/null @@ -1,36 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# SchemaInterface interface -Interface for [Schema](./vertexai.schema.md#schema_class) class. - -Signature: - -```typescript -export interface SchemaInterface extends SchemaShared -``` -Extends: [SchemaShared](./vertexai.schemashared.md#schemashared_interface)<[SchemaInterface](./vertexai.schemainterface.md#schemainterface_interface)> - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [type](./vertexai.schemainterface.md#schemainterfacetype) | [SchemaType](./vertexai.md#schematype) | The type of the property. [SchemaType](./vertexai.md#schematype). | - -## SchemaInterface.type - -The type of the property. [SchemaType](./vertexai.md#schematype). - -Signature: - -```typescript -type: SchemaType; -``` diff --git a/docs-devsite/vertexai.schemaparams.md b/docs-devsite/vertexai.schemaparams.md deleted file mode 100644 index 3c6d9f385fd..00000000000 --- a/docs-devsite/vertexai.schemaparams.md +++ /dev/null @@ -1,21 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# SchemaParams interface -Params passed to [Schema](./vertexai.schema.md#schema_class) static methods to create specific [Schema](./vertexai.schema.md#schema_class) classes. - -Signature: - -```typescript -export interface SchemaParams extends SchemaShared -``` -Extends: [SchemaShared](./vertexai.schemashared.md#schemashared_interface)<[SchemaInterface](./vertexai.schemainterface.md#schemainterface_interface)> - diff --git a/docs-devsite/vertexai.schemarequest.md b/docs-devsite/vertexai.schemarequest.md deleted file mode 100644 index f12259b1608..00000000000 --- a/docs-devsite/vertexai.schemarequest.md +++ /dev/null @@ -1,47 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# SchemaRequest interface -Final format for [Schema](./vertexai.schema.md#schema_class) params passed to backend requests. - -Signature: - -```typescript -export interface SchemaRequest extends SchemaShared -``` -Extends: [SchemaShared](./vertexai.schemashared.md#schemashared_interface)<[SchemaRequest](./vertexai.schemarequest.md#schemarequest_interface)> - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [required](./vertexai.schemarequest.md#schemarequestrequired) | string\[\] | Optional. Array of required property. | -| [type](./vertexai.schemarequest.md#schemarequesttype) | [SchemaType](./vertexai.md#schematype) | The type of the property. [SchemaType](./vertexai.md#schematype). | - -## SchemaRequest.required - -Optional. Array of required property. - -Signature: - -```typescript -required?: string[]; -``` - -## SchemaRequest.type - -The type of the property. [SchemaType](./vertexai.md#schematype). - -Signature: - -```typescript -type: SchemaType; -``` diff --git a/docs-devsite/vertexai.schemashared.md b/docs-devsite/vertexai.schemashared.md deleted file mode 100644 index 50cc6464ecf..00000000000 --- a/docs-devsite/vertexai.schemashared.md +++ /dev/null @@ -1,103 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# SchemaShared interface -Basic [Schema](./vertexai.schema.md#schema_class) properties shared across several Schema-related types. - -Signature: - -```typescript -export interface SchemaShared -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [description](./vertexai.schemashared.md#schemashareddescription) | string | Optional. The description of the property. | -| [enum](./vertexai.schemashared.md#schemasharedenum) | string\[\] | Optional. The enum of the property. | -| [example](./vertexai.schemashared.md#schemasharedexample) | unknown | Optional. The example of the property. | -| [format](./vertexai.schemashared.md#schemasharedformat) | string | Optional. The format of the property. | -| [items](./vertexai.schemashared.md#schemashareditems) | T | Optional. The items of the property. | -| [nullable](./vertexai.schemashared.md#schemasharednullable) | boolean | Optional. Whether the property is nullable. | -| [properties](./vertexai.schemashared.md#schemasharedproperties) | { \[k: string\]: T; } | Optional. Map of Schema objects. | - -## SchemaShared.description - -Optional. The description of the property. - -Signature: - -```typescript -description?: string; -``` - -## SchemaShared.enum - -Optional. The enum of the property. - -Signature: - -```typescript -enum?: string[]; -``` - -## SchemaShared.example - -Optional. The example of the property. - -Signature: - -```typescript -example?: unknown; -``` - -## SchemaShared.format - -Optional. The format of the property. - -Signature: - -```typescript -format?: string; -``` - -## SchemaShared.items - -Optional. The items of the property. - -Signature: - -```typescript -items?: T; -``` - -## SchemaShared.nullable - -Optional. Whether the property is nullable. - -Signature: - -```typescript -nullable?: boolean; -``` - -## SchemaShared.properties - -Optional. Map of `Schema` objects. - -Signature: - -```typescript -properties?: { - [k: string]: T; - }; -``` diff --git a/docs-devsite/vertexai.stringschema.md b/docs-devsite/vertexai.stringschema.md deleted file mode 100644 index bfafe0fe9df..00000000000 --- a/docs-devsite/vertexai.stringschema.md +++ /dev/null @@ -1,57 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# StringSchema class -Schema class for "string" types. Can be used with or without enum values. - -Signature: - -```typescript -export declare class StringSchema extends Schema -``` -Extends: [Schema](./vertexai.schema.md#schema_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(schemaParams, enumValues)](./vertexai.stringschema.md#stringschemaconstructor) | | Constructs a new instance of the StringSchema class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [enum](./vertexai.stringschema.md#stringschemaenum) | | string\[\] | | - -## StringSchema.(constructor) - -Constructs a new instance of the `StringSchema` class - -Signature: - -```typescript -constructor(schemaParams?: SchemaParams, enumValues?: string[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| schemaParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | -| enumValues | string\[\] | | - -## StringSchema.enum - -Signature: - -```typescript -enum?: string[]; -``` From 9c4d5561924fc6e62a1650ca69dbf54169f81deb Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 13 Nov 2024 14:30:10 -0700 Subject: [PATCH 32/59] license headers --- .../src/api/database_augmentation.ts | 17 +++++++++++ packages/firestore/src/api/pipeline.ts | 17 +++++++++++ .../firestore/src/api/user_data_writer.ts | 17 +++++++++++ packages/firestore/src/core/pipeline-util.ts | 29 ++++++++++--------- .../src/lite-api/database_augmentation.ts | 17 +++++++++++ .../firestore/src/lite-api/expressions.ts | 29 ++++++++++--------- packages/firestore/src/lite-api/overloads.ts | 17 +++++++++++ .../firestore/src/lite-api/pipeline-result.ts | 29 ++++++++++--------- .../firestore/src/lite-api/pipeline-source.ts | 29 ++++++++++--------- packages/firestore/src/lite-api/pipeline.ts | 29 ++++++++++--------- .../firestore/src/lite-api/pipeline_impl.ts | 17 +++++++++++ packages/firestore/src/lite-api/stage.ts | 29 ++++++++++--------- .../src/model/pipeline_stream_element.ts | 17 +++++++++++ .../test/integration/api/pipeline.test.ts | 29 ++++++++++--------- 14 files changed, 231 insertions(+), 91 deletions(-) diff --git a/packages/firestore/src/api/database_augmentation.ts b/packages/firestore/src/api/database_augmentation.ts index dcaff555a04..b59f160c1ba 100644 --- a/packages/firestore/src/api/database_augmentation.ts +++ b/packages/firestore/src/api/database_augmentation.ts @@ -1,3 +1,20 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import { And, FilterExpr, Or } from '../lite-api/expressions'; import { and, or } from '../lite-api/overloads'; import { Pipeline } from '../lite-api/pipeline'; diff --git a/packages/firestore/src/api/pipeline.ts b/packages/firestore/src/api/pipeline.ts index 3122fc36412..14532ba85c0 100644 --- a/packages/firestore/src/api/pipeline.ts +++ b/packages/firestore/src/api/pipeline.ts @@ -1,3 +1,20 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import { firestoreClientExecutePipeline } from '../core/firestore_client'; import { Pipeline as LitePipeline } from '../lite-api/pipeline'; import { PipelineResult } from '../lite-api/pipeline-result'; diff --git a/packages/firestore/src/api/user_data_writer.ts b/packages/firestore/src/api/user_data_writer.ts index e21dcb70506..3567f72cd93 100644 --- a/packages/firestore/src/api/user_data_writer.ts +++ b/packages/firestore/src/api/user_data_writer.ts @@ -1,3 +1,20 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import { Bytes } from '../lite-api/bytes'; import { DocumentReference } from '../lite-api/reference'; import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; diff --git a/packages/firestore/src/core/pipeline-util.ts b/packages/firestore/src/core/pipeline-util.ts index 49704e06381..5f0f418d2e4 100644 --- a/packages/firestore/src/core/pipeline-util.ts +++ b/packages/firestore/src/core/pipeline-util.ts @@ -1,16 +1,19 @@ -// Copyright 2024 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { Constant, diff --git a/packages/firestore/src/lite-api/database_augmentation.ts b/packages/firestore/src/lite-api/database_augmentation.ts index cce1214138a..a2c3652bd71 100644 --- a/packages/firestore/src/lite-api/database_augmentation.ts +++ b/packages/firestore/src/lite-api/database_augmentation.ts @@ -1,3 +1,20 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import { DocumentKey } from '../model/document_key'; import { Firestore } from './database'; diff --git a/packages/firestore/src/lite-api/expressions.ts b/packages/firestore/src/lite-api/expressions.ts index 82729147e75..336a7b7d2b1 100644 --- a/packages/firestore/src/lite-api/expressions.ts +++ b/packages/firestore/src/lite-api/expressions.ts @@ -1,16 +1,19 @@ -// Copyright 2024 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* eslint @typescript-eslint/no-explicit-any: 0 */ diff --git a/packages/firestore/src/lite-api/overloads.ts b/packages/firestore/src/lite-api/overloads.ts index 2b3675db521..6a4b87e96c5 100644 --- a/packages/firestore/src/lite-api/overloads.ts +++ b/packages/firestore/src/lite-api/overloads.ts @@ -1,3 +1,20 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import { CompositeOperator } from '../core/filter'; import { And, FilterExpr, Or } from './expressions'; diff --git a/packages/firestore/src/lite-api/pipeline-result.ts b/packages/firestore/src/lite-api/pipeline-result.ts index 9ebaeb1b306..f3951099ba2 100644 --- a/packages/firestore/src/lite-api/pipeline-result.ts +++ b/packages/firestore/src/lite-api/pipeline-result.ts @@ -1,16 +1,19 @@ -// Copyright 2024 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { ObjectValue } from '../model/object_value'; import { isOptionalEqual } from '../util/misc'; diff --git a/packages/firestore/src/lite-api/pipeline-source.ts b/packages/firestore/src/lite-api/pipeline-source.ts index 4b913e26ce7..a79c5cafc31 100644 --- a/packages/firestore/src/lite-api/pipeline-source.ts +++ b/packages/firestore/src/lite-api/pipeline-source.ts @@ -1,16 +1,19 @@ -// Copyright 2024 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { DocumentKey } from '../model/document_key'; diff --git a/packages/firestore/src/lite-api/pipeline.ts b/packages/firestore/src/lite-api/pipeline.ts index 5b9c061c1b9..4d13d5dfddd 100644 --- a/packages/firestore/src/lite-api/pipeline.ts +++ b/packages/firestore/src/lite-api/pipeline.ts @@ -1,16 +1,19 @@ -// Copyright 2024 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* eslint @typescript-eslint/no-explicit-any: 0 */ diff --git a/packages/firestore/src/lite-api/pipeline_impl.ts b/packages/firestore/src/lite-api/pipeline_impl.ts index 30ccc04cbd4..cd490d31871 100644 --- a/packages/firestore/src/lite-api/pipeline_impl.ts +++ b/packages/firestore/src/lite-api/pipeline_impl.ts @@ -1,3 +1,20 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import { Pipeline } from './pipeline'; import { PipelineResult } from './pipeline-result'; diff --git a/packages/firestore/src/lite-api/stage.ts b/packages/firestore/src/lite-api/stage.ts index 9f4c7735f03..b4fe237f79c 100644 --- a/packages/firestore/src/lite-api/stage.ts +++ b/packages/firestore/src/lite-api/stage.ts @@ -1,16 +1,19 @@ -// Copyright 2024 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { ObjectValue } from '../model/object_value'; import { diff --git a/packages/firestore/src/model/pipeline_stream_element.ts b/packages/firestore/src/model/pipeline_stream_element.ts index 9ec4c765993..efa27e2cc44 100644 --- a/packages/firestore/src/model/pipeline_stream_element.ts +++ b/packages/firestore/src/model/pipeline_stream_element.ts @@ -1,3 +1,20 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import { SnapshotVersion } from '../core/snapshot_version'; import { DocumentKey } from './document_key'; diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index aa68528d124..8b107a7ea65 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -1,16 +1,19 @@ -// Copyright 2024 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { expect, use } from 'chai'; import chaiAsPromised from 'chai-as-promised'; From 1aef450d38337d2cf2c0c330d594da1ab0320d3c Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 13 Nov 2024 14:35:54 -0700 Subject: [PATCH 33/59] docgen --- common/api-review/firestore-lite.api.md | 8 ++++---- common/api-review/firestore.api.md | 8 ++++---- docs-devsite/firestore_.md | 10 +++++++++- docs-devsite/firestore_lite.md | 10 +++++++++- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 1d32a0b466a..8b7e4612dd9 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -2146,7 +2146,7 @@ export function updateDoc(refere // @public export function updateDoc(reference: DocumentReference, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise; -// @public (undocumented) +// @public export function useFirestorePipelines(): void; // @public @@ -2214,8 +2214,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9243:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9244:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9273:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9243:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9244:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9273:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index bafcf704778..c1106de776c 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -2419,7 +2419,7 @@ export function updateDoc(refere // @public export function updateDoc(reference: DocumentReference, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise; -// @public (undocumented) +// @public export function useFirestorePipelines(): void; // @public @@ -2490,8 +2490,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10106:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10106:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10133:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10106:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10106:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10133:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/docs-devsite/firestore_.md b/docs-devsite/firestore_.md index 78db4044e17..4393d8999dc 100644 --- a/docs-devsite/firestore_.md +++ b/docs-devsite/firestore_.md @@ -56,7 +56,7 @@ countAll().as("totalUsers"); | [memoryEagerGarbageCollector()](./firestore_.md#memoryeagergarbagecollector) | Creates an instance of MemoryEagerGarbageCollector. This is also the default garbage collector unless it is explicitly specified otherwise. | | [persistentMultipleTabManager()](./firestore_.md#persistentmultipletabmanager) | Creates an instance of PersistentMultipleTabManager. | | [serverTimestamp()](./firestore_.md#servertimestamp) | Returns a sentinel used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) to include a server-generated timestamp in the written data. | -| [useFirestorePipelines()](./firestore_.md#usefirestorepipelines) | | +| [useFirestorePipelines()](./firestore_.md#usefirestorepipelines) | Copyright 2024 Google LLCLicensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | | function(array, ...) | | [arrayConcat(array, elements)](./firestore_.md#arrayconcat_0b3ddb9) | (BETA) Creates an expression that concatenates an array expression with other arrays. ```typescript @@ -2432,6 +2432,14 @@ export declare function serverTimestamp(): FieldValue; ### useFirestorePipelines() {:#usefirestorepipelines} + Copyright 2024 Google LLC + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + Signature: ```typescript diff --git a/docs-devsite/firestore_lite.md b/docs-devsite/firestore_lite.md index 59abff098db..2a9a2c55801 100644 --- a/docs-devsite/firestore_lite.md +++ b/docs-devsite/firestore_lite.md @@ -42,7 +42,7 @@ countAll().as("totalUsers"); | [documentId()](./firestore_lite.md#documentid) | Returns a special sentinel FieldPath to refer to the ID of a document. It can be used in queries to sort or filter by the document ID. | | [getFirestore()](./firestore_lite.md#getfirestore) | Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. | | [serverTimestamp()](./firestore_lite.md#servertimestamp) | Returns a sentinel used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) to include a server-generated timestamp in the written data. | -| [useFirestorePipelines()](./firestore_lite.md#usefirestorepipelines) | | +| [useFirestorePipelines()](./firestore_lite.md#usefirestorepipelines) | Copyright 2024 Google LLCLicensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | | function(array, ...) | | [arrayConcat(array, elements)](./firestore_lite.md#arrayconcat_0b3ddb9) | (BETA) Creates an expression that concatenates an array expression with other arrays. ```typescript @@ -1976,6 +1976,14 @@ export declare function serverTimestamp(): FieldValue; ### useFirestorePipelines() {:#usefirestorepipelines} + Copyright 2024 Google LLC + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + Signature: ```typescript From b20afe6e65c762a4be19f6c4d1830796045a6a09 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 13 Nov 2024 14:48:08 -0700 Subject: [PATCH 34/59] docs-devsite fix --- docs-devsite/_toc.yaml | 127 +++--- docs-devsite/index.md | 2 +- docs-devsite/vertexai-preview.chatsession.md | 138 ------ ...texai-preview.functiondeclarationschema.md | 70 --- ...eview.functiondeclarationschemaproperty.md | 125 ------ ...rtexai-preview.functiondeclarationstool.md | 35 -- ...rtexai-preview.generatecontentcandidate.md | 87 ---- .../vertexai-preview.generationconfig.md | 107 ----- .../vertexai-preview.generativemodel.md | 201 --------- docs-devsite/vertexai-preview.md | 397 ----------------- docs-devsite/vertexai.arrayschema.md | 57 +++ ...w.baseparams.md => vertexai.baseparams.md} | 4 +- docs-devsite/vertexai.booleanschema.md | 43 ++ docs-devsite/vertexai.chatsession.md | 138 ++++++ ...eview.citation.md => vertexai.citation.md} | 12 +- ...tadata.md => vertexai.citationmetadata.md} | 4 +- ...preview.content.md => vertexai.content.md} | 4 +- ...uest.md => vertexai.counttokensrequest.md} | 4 +- ...nse.md => vertexai.counttokensresponse.md} | 6 +- ...rordata.md => vertexai.customerrordata.md} | 10 +- ...i-preview.date_2.md => vertexai.date_2.md} | 6 +- ...rtexai.enhancedgeneratecontentresponse.md} | 6 +- ...rordetails.md => vertexai.errordetails.md} | 8 +- ...eview.filedata.md => vertexai.filedata.md} | 4 +- ...ledatapart.md => vertexai.filedatapart.md} | 12 +- ...nctioncall.md => vertexai.functioncall.md} | 6 +- ...g.md => vertexai.functioncallingconfig.md} | 4 +- ...llpart.md => vertexai.functioncallpart.md} | 10 +- ...ion.md => vertexai.functiondeclaration.md} | 12 +- .../vertexai.functiondeclarationstool.md | 35 ++ ...sponse.md => vertexai.functionresponse.md} | 6 +- ...rt.md => vertexai.functionresponsepart.md} | 10 +- .../vertexai.generatecontentcandidate.md | 87 ++++ ....md => vertexai.generatecontentrequest.md} | 12 +- ...md => vertexai.generatecontentresponse.md} | 8 +- ...t.md => vertexai.generatecontentresult.md} | 4 +- ...> vertexai.generatecontentstreamresult.md} | 6 +- docs-devsite/vertexai.generationconfig.md | 118 +++++ ...b.md => vertexai.generativecontentblob.md} | 4 +- docs-devsite/vertexai.generativemodel.md | 201 +++++++++ ...on.md => vertexai.groundingattribution.md} | 8 +- ...adata.md => vertexai.groundingmetadata.md} | 6 +- ...datapart.md => vertexai.inlinedatapart.md} | 10 +- docs-devsite/vertexai.integerschema.md | 43 ++ docs-devsite/vertexai.md | 412 ++++++++++++++++++ ...modelparams.md => vertexai.modelparams.md} | 12 +- docs-devsite/vertexai.numberschema.md | 43 ++ docs-devsite/vertexai.objectschema.md | 71 +++ .../vertexai.objectschemainterface.md | 43 ++ ...feedback.md => vertexai.promptfeedback.md} | 8 +- ...toptions.md => vertexai.requestoptions.md} | 10 +- ...> vertexai.retrievedcontextattribution.md} | 4 +- ...fetyrating.md => vertexai.safetyrating.md} | 14 +- ...tysetting.md => vertexai.safetysetting.md} | 8 +- docs-devsite/vertexai.schema.md | 250 +++++++++++ docs-devsite/vertexai.schemainterface.md | 36 ++ docs-devsite/vertexai.schemaparams.md | 21 + docs-devsite/vertexai.schemarequest.md | 47 ++ docs-devsite/vertexai.schemashared.md | 103 +++++ ...preview.segment.md => vertexai.segment.md} | 6 +- ...tparams.md => vertexai.startchatparams.md} | 12 +- docs-devsite/vertexai.stringschema.md | 57 +++ ...eview.textpart.md => vertexai.textpart.md} | 8 +- ...w.toolconfig.md => vertexai.toolconfig.md} | 4 +- ...emetadata.md => vertexai.usagemetadata.md} | 8 +- ...eview.vertexai.md => vertexai.vertexai.md} | 8 +- ...exaierror.md => vertexai.vertexaierror.md} | 21 +- ...options.md => vertexai.vertexaioptions.md} | 4 +- ...ometadata.md => vertexai.videometadata.md} | 4 +- ...ribution.md => vertexai.webattribution.md} | 4 +- 70 files changed, 2035 insertions(+), 1380 deletions(-) delete mode 100644 docs-devsite/vertexai-preview.chatsession.md delete mode 100644 docs-devsite/vertexai-preview.functiondeclarationschema.md delete mode 100644 docs-devsite/vertexai-preview.functiondeclarationschemaproperty.md delete mode 100644 docs-devsite/vertexai-preview.functiondeclarationstool.md delete mode 100644 docs-devsite/vertexai-preview.generatecontentcandidate.md delete mode 100644 docs-devsite/vertexai-preview.generationconfig.md delete mode 100644 docs-devsite/vertexai-preview.generativemodel.md delete mode 100644 docs-devsite/vertexai-preview.md create mode 100644 docs-devsite/vertexai.arrayschema.md rename docs-devsite/{vertexai-preview.baseparams.md => vertexai.baseparams.md} (67%) create mode 100644 docs-devsite/vertexai.booleanschema.md create mode 100644 docs-devsite/vertexai.chatsession.md rename docs-devsite/{vertexai-preview.citation.md => vertexai.citation.md} (68%) rename docs-devsite/{vertexai-preview.citationmetadata.md => vertexai.citationmetadata.md} (64%) rename docs-devsite/{vertexai-preview.content.md => vertexai.content.md} (76%) rename docs-devsite/{vertexai-preview.counttokensrequest.md => vertexai.counttokensrequest.md} (68%) rename docs-devsite/{vertexai-preview.counttokensresponse.md => vertexai.counttokensresponse.md} (67%) rename docs-devsite/{vertexai-preview.customerrordata.md => vertexai.customerrordata.md} (54%) rename docs-devsite/{vertexai-preview.date_2.md => vertexai.date_2.md} (78%) rename docs-devsite/{vertexai-preview.enhancedgeneratecontentresponse.md => vertexai.enhancedgeneratecontentresponse.md} (61%) rename docs-devsite/{vertexai-preview.errordetails.md => vertexai.errordetails.md} (68%) rename docs-devsite/{vertexai-preview.filedata.md => vertexai.filedata.md} (81%) rename docs-devsite/{vertexai-preview.filedatapart.md => vertexai.filedatapart.md} (60%) rename docs-devsite/{vertexai-preview.functioncall.md => vertexai.functioncall.md} (57%) rename docs-devsite/{vertexai-preview.functioncallingconfig.md => vertexai.functioncallingconfig.md} (71%) rename docs-devsite/{vertexai-preview.functioncallpart.md => vertexai.functioncallpart.md} (59%) rename docs-devsite/{vertexai-preview.functiondeclaration.md => vertexai.functiondeclaration.md} (57%) create mode 100644 docs-devsite/vertexai.functiondeclarationstool.md rename docs-devsite/{vertexai-preview.functionresponse.md => vertexai.functionresponse.md} (50%) rename docs-devsite/{vertexai-preview.functionresponsepart.md => vertexai.functionresponsepart.md} (58%) create mode 100644 docs-devsite/vertexai.generatecontentcandidate.md rename docs-devsite/{vertexai-preview.generatecontentrequest.md => vertexai.generatecontentrequest.md} (54%) rename docs-devsite/{vertexai-preview.generatecontentresponse.md => vertexai.generatecontentresponse.md} (50%) rename docs-devsite/{vertexai-preview.generatecontentresult.md => vertexai.generatecontentresult.md} (69%) rename docs-devsite/{vertexai-preview.generatecontentstreamresult.md => vertexai.generatecontentstreamresult.md} (52%) create mode 100644 docs-devsite/vertexai.generationconfig.md rename docs-devsite/{vertexai-preview.generativecontentblob.md => vertexai.generativecontentblob.md} (76%) create mode 100644 docs-devsite/vertexai.generativemodel.md rename docs-devsite/{vertexai-preview.groundingattribution.md => vertexai.groundingattribution.md} (58%) rename docs-devsite/{vertexai-preview.groundingmetadata.md => vertexai.groundingmetadata.md} (66%) rename docs-devsite/{vertexai-preview.inlinedatapart.md => vertexai.inlinedatapart.md} (60%) create mode 100644 docs-devsite/vertexai.integerschema.md create mode 100644 docs-devsite/vertexai.md rename docs-devsite/{vertexai-preview.modelparams.md => vertexai.modelparams.md} (54%) create mode 100644 docs-devsite/vertexai.numberschema.md create mode 100644 docs-devsite/vertexai.objectschema.md create mode 100644 docs-devsite/vertexai.objectschemainterface.md rename docs-devsite/{vertexai-preview.promptfeedback.md => vertexai.promptfeedback.md} (66%) rename docs-devsite/{vertexai-preview.requestoptions.md => vertexai.requestoptions.md} (55%) rename docs-devsite/{vertexai-preview.retrievedcontextattribution.md => vertexai.retrievedcontextattribution.md} (76%) rename docs-devsite/{vertexai-preview.safetyrating.md => vertexai.safetyrating.md} (55%) rename docs-devsite/{vertexai-preview.safetysetting.md => vertexai.safetysetting.md} (64%) create mode 100644 docs-devsite/vertexai.schema.md create mode 100644 docs-devsite/vertexai.schemainterface.md create mode 100644 docs-devsite/vertexai.schemaparams.md create mode 100644 docs-devsite/vertexai.schemarequest.md create mode 100644 docs-devsite/vertexai.schemashared.md rename docs-devsite/{vertexai-preview.segment.md => vertexai.segment.md} (75%) rename docs-devsite/{vertexai-preview.startchatparams.md => vertexai.startchatparams.md} (51%) create mode 100644 docs-devsite/vertexai.stringschema.md rename docs-devsite/{vertexai-preview.textpart.md => vertexai.textpart.md} (72%) rename docs-devsite/{vertexai-preview.toolconfig.md => vertexai.toolconfig.md} (71%) rename docs-devsite/{vertexai-preview.usagemetadata.md => vertexai.usagemetadata.md} (63%) rename docs-devsite/{vertexai-preview.vertexai.md => vertexai.vertexai.md} (58%) rename docs-devsite/{vertexai-preview.vertexaierror.md => vertexai.vertexaierror.md} (55%) rename docs-devsite/{vertexai-preview.vertexaioptions.md => vertexai.vertexaioptions.md} (79%) rename docs-devsite/{vertexai-preview.videometadata.md => vertexai.videometadata.md} (66%) rename docs-devsite/{vertexai-preview.webattribution.md => vertexai.webattribution.md} (79%) diff --git a/docs-devsite/_toc.yaml b/docs-devsite/_toc.yaml index 569c436a053..26c520a12ba 100644 --- a/docs-devsite/_toc.yaml +++ b/docs-devsite/_toc.yaml @@ -811,105 +811,124 @@ toc: path: /docs/reference/js/storage.uploadtask.md - title: UploadTaskSnapshot path: /docs/reference/js/storage.uploadtasksnapshot.md - - title: vertexai-preview - path: /docs/reference/js/vertexai-preview.md + - title: vertexai + path: /docs/reference/js/vertexai.md section: + - title: ArraySchema + path: /docs/reference/js/vertexai.arrayschema.md - title: BaseParams - path: /docs/reference/js/vertexai-preview.baseparams.md + path: /docs/reference/js/vertexai.baseparams.md + - title: BooleanSchema + path: /docs/reference/js/vertexai.booleanschema.md - title: ChatSession - path: /docs/reference/js/vertexai-preview.chatsession.md + path: /docs/reference/js/vertexai.chatsession.md - title: Citation - path: /docs/reference/js/vertexai-preview.citation.md + path: /docs/reference/js/vertexai.citation.md - title: CitationMetadata - path: /docs/reference/js/vertexai-preview.citationmetadata.md + path: /docs/reference/js/vertexai.citationmetadata.md - title: Content - path: /docs/reference/js/vertexai-preview.content.md + path: /docs/reference/js/vertexai.content.md - title: CountTokensRequest - path: /docs/reference/js/vertexai-preview.counttokensrequest.md + path: /docs/reference/js/vertexai.counttokensrequest.md - title: CountTokensResponse - path: /docs/reference/js/vertexai-preview.counttokensresponse.md + path: /docs/reference/js/vertexai.counttokensresponse.md - title: CustomErrorData - path: /docs/reference/js/vertexai-preview.customerrordata.md + path: /docs/reference/js/vertexai.customerrordata.md - title: Date_2 - path: /docs/reference/js/vertexai-preview.date_2.md + path: /docs/reference/js/vertexai.date_2.md - title: EnhancedGenerateContentResponse - path: /docs/reference/js/vertexai-preview.enhancedgeneratecontentresponse.md + path: /docs/reference/js/vertexai.enhancedgeneratecontentresponse.md - title: ErrorDetails - path: /docs/reference/js/vertexai-preview.errordetails.md + path: /docs/reference/js/vertexai.errordetails.md - title: FileData - path: /docs/reference/js/vertexai-preview.filedata.md + path: /docs/reference/js/vertexai.filedata.md - title: FileDataPart - path: /docs/reference/js/vertexai-preview.filedatapart.md + path: /docs/reference/js/vertexai.filedatapart.md - title: FunctionCall - path: /docs/reference/js/vertexai-preview.functioncall.md + path: /docs/reference/js/vertexai.functioncall.md - title: FunctionCallingConfig - path: /docs/reference/js/vertexai-preview.functioncallingconfig.md + path: /docs/reference/js/vertexai.functioncallingconfig.md - title: FunctionCallPart - path: /docs/reference/js/vertexai-preview.functioncallpart.md + path: /docs/reference/js/vertexai.functioncallpart.md - title: FunctionDeclaration - path: /docs/reference/js/vertexai-preview.functiondeclaration.md - - title: FunctionDeclarationSchema - path: /docs/reference/js/vertexai-preview.functiondeclarationschema.md - - title: FunctionDeclarationSchemaProperty - path: >- - /docs/reference/js/vertexai-preview.functiondeclarationschemaproperty.md + path: /docs/reference/js/vertexai.functiondeclaration.md - title: FunctionDeclarationsTool - path: /docs/reference/js/vertexai-preview.functiondeclarationstool.md + path: /docs/reference/js/vertexai.functiondeclarationstool.md - title: FunctionResponse - path: /docs/reference/js/vertexai-preview.functionresponse.md + path: /docs/reference/js/vertexai.functionresponse.md - title: FunctionResponsePart - path: /docs/reference/js/vertexai-preview.functionresponsepart.md + path: /docs/reference/js/vertexai.functionresponsepart.md - title: GenerateContentCandidate - path: /docs/reference/js/vertexai-preview.generatecontentcandidate.md + path: /docs/reference/js/vertexai.generatecontentcandidate.md - title: GenerateContentRequest - path: /docs/reference/js/vertexai-preview.generatecontentrequest.md + path: /docs/reference/js/vertexai.generatecontentrequest.md - title: GenerateContentResponse - path: /docs/reference/js/vertexai-preview.generatecontentresponse.md + path: /docs/reference/js/vertexai.generatecontentresponse.md - title: GenerateContentResult - path: /docs/reference/js/vertexai-preview.generatecontentresult.md + path: /docs/reference/js/vertexai.generatecontentresult.md - title: GenerateContentStreamResult - path: /docs/reference/js/vertexai-preview.generatecontentstreamresult.md + path: /docs/reference/js/vertexai.generatecontentstreamresult.md - title: GenerationConfig - path: /docs/reference/js/vertexai-preview.generationconfig.md + path: /docs/reference/js/vertexai.generationconfig.md - title: GenerativeContentBlob - path: /docs/reference/js/vertexai-preview.generativecontentblob.md + path: /docs/reference/js/vertexai.generativecontentblob.md - title: GenerativeModel - path: /docs/reference/js/vertexai-preview.generativemodel.md + path: /docs/reference/js/vertexai.generativemodel.md - title: GroundingAttribution - path: /docs/reference/js/vertexai-preview.groundingattribution.md + path: /docs/reference/js/vertexai.groundingattribution.md - title: GroundingMetadata - path: /docs/reference/js/vertexai-preview.groundingmetadata.md + path: /docs/reference/js/vertexai.groundingmetadata.md - title: InlineDataPart - path: /docs/reference/js/vertexai-preview.inlinedatapart.md + path: /docs/reference/js/vertexai.inlinedatapart.md + - title: IntegerSchema + path: /docs/reference/js/vertexai.integerschema.md - title: ModelParams - path: /docs/reference/js/vertexai-preview.modelparams.md + path: /docs/reference/js/vertexai.modelparams.md + - title: NumberSchema + path: /docs/reference/js/vertexai.numberschema.md + - title: ObjectSchema + path: /docs/reference/js/vertexai.objectschema.md + - title: ObjectSchemaInterface + path: /docs/reference/js/vertexai.objectschemainterface.md - title: PromptFeedback - path: /docs/reference/js/vertexai-preview.promptfeedback.md + path: /docs/reference/js/vertexai.promptfeedback.md - title: RequestOptions - path: /docs/reference/js/vertexai-preview.requestoptions.md + path: /docs/reference/js/vertexai.requestoptions.md - title: RetrievedContextAttribution - path: /docs/reference/js/vertexai-preview.retrievedcontextattribution.md + path: /docs/reference/js/vertexai.retrievedcontextattribution.md - title: SafetyRating - path: /docs/reference/js/vertexai-preview.safetyrating.md + path: /docs/reference/js/vertexai.safetyrating.md - title: SafetySetting - path: /docs/reference/js/vertexai-preview.safetysetting.md + path: /docs/reference/js/vertexai.safetysetting.md + - title: Schema + path: /docs/reference/js/vertexai.schema.md + - title: SchemaInterface + path: /docs/reference/js/vertexai.schemainterface.md + - title: SchemaParams + path: /docs/reference/js/vertexai.schemaparams.md + - title: SchemaRequest + path: /docs/reference/js/vertexai.schemarequest.md + - title: SchemaShared + path: /docs/reference/js/vertexai.schemashared.md - title: Segment - path: /docs/reference/js/vertexai-preview.segment.md + path: /docs/reference/js/vertexai.segment.md - title: StartChatParams - path: /docs/reference/js/vertexai-preview.startchatparams.md + path: /docs/reference/js/vertexai.startchatparams.md + - title: StringSchema + path: /docs/reference/js/vertexai.stringschema.md - title: TextPart - path: /docs/reference/js/vertexai-preview.textpart.md + path: /docs/reference/js/vertexai.textpart.md - title: ToolConfig - path: /docs/reference/js/vertexai-preview.toolconfig.md + path: /docs/reference/js/vertexai.toolconfig.md - title: UsageMetadata - path: /docs/reference/js/vertexai-preview.usagemetadata.md + path: /docs/reference/js/vertexai.usagemetadata.md - title: VertexAI - path: /docs/reference/js/vertexai-preview.vertexai.md + path: /docs/reference/js/vertexai.vertexai.md - title: VertexAIError - path: /docs/reference/js/vertexai-preview.vertexaierror.md + path: /docs/reference/js/vertexai.vertexaierror.md - title: VertexAIOptions - path: /docs/reference/js/vertexai-preview.vertexaioptions.md + path: /docs/reference/js/vertexai.vertexaioptions.md - title: VideoMetadata - path: /docs/reference/js/vertexai-preview.videometadata.md + path: /docs/reference/js/vertexai.videometadata.md - title: WebAttribution - path: /docs/reference/js/vertexai-preview.webattribution.md + path: /docs/reference/js/vertexai.webattribution.md diff --git a/docs-devsite/index.md b/docs-devsite/index.md index 2c22b58d80c..82fdb36f076 100644 --- a/docs-devsite/index.md +++ b/docs-devsite/index.md @@ -27,5 +27,5 @@ https://github.com/firebase/firebase-js-sdk | [@firebase/performance](./performance.md#performance_package) | The Firebase Performance Monitoring Web SDK. This SDK does not work in a Node.js environment. | | [@firebase/remote-config](./remote-config.md#remote-config_package) | The Firebase Remote Config Web SDK. This SDK does not work in a Node.js environment. | | [@firebase/storage](./storage.md#storage_package) | Cloud Storage for Firebase | -| [@firebase/vertexai-preview](./vertexai-preview.md#vertexai-preview_package) | The Vertex AI For Firebase Web SDK. | +| [@firebase/vertexai](./vertexai.md#vertexai_package) | The Vertex AI in Firebase Web SDK. | diff --git a/docs-devsite/vertexai-preview.chatsession.md b/docs-devsite/vertexai-preview.chatsession.md deleted file mode 100644 index d8dc691d186..00000000000 --- a/docs-devsite/vertexai-preview.chatsession.md +++ /dev/null @@ -1,138 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ChatSession class -ChatSession class that enables sending chat messages and stores history of sent and received messages so far. - -Signature: - -```typescript -export declare class ChatSession -``` - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(apiSettings, model, params, requestOptions)](./vertexai-preview.chatsession.md#chatsessionconstructor) | | Constructs a new instance of the ChatSession class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [model](./vertexai-preview.chatsession.md#chatsessionmodel) | | string | | -| [params](./vertexai-preview.chatsession.md#chatsessionparams) | | [StartChatParams](./vertexai-preview.startchatparams.md#startchatparams_interface) \| undefined | | -| [requestOptions](./vertexai-preview.chatsession.md#chatsessionrequestoptions) | | [RequestOptions](./vertexai-preview.requestoptions.md#requestoptions_interface) \| undefined | | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [getHistory()](./vertexai-preview.chatsession.md#chatsessiongethistory) | | Gets the chat history so far. Blocked prompts are not added to history. Neither blocked candidates nor the prompts that generated them are added to history. | -| [sendMessage(request)](./vertexai-preview.chatsession.md#chatsessionsendmessage) | | Sends a chat message and receives a non-streaming [GenerateContentResult](./vertexai-preview.generatecontentresult.md#generatecontentresult_interface) | -| [sendMessageStream(request)](./vertexai-preview.chatsession.md#chatsessionsendmessagestream) | | Sends a chat message and receives the response as a [GenerateContentStreamResult](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresult_interface) containing an iterable stream and a response promise. | - -## ChatSession.(constructor) - -Constructs a new instance of the `ChatSession` class - -Signature: - -```typescript -constructor(apiSettings: ApiSettings, model: string, params?: StartChatParams | undefined, requestOptions?: RequestOptions | undefined); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| apiSettings | ApiSettings | | -| model | string | | -| params | [StartChatParams](./vertexai-preview.startchatparams.md#startchatparams_interface) \| undefined | | -| requestOptions | [RequestOptions](./vertexai-preview.requestoptions.md#requestoptions_interface) \| undefined | | - -## ChatSession.model - -Signature: - -```typescript -model: string; -``` - -## ChatSession.params - -Signature: - -```typescript -params?: StartChatParams | undefined; -``` - -## ChatSession.requestOptions - -Signature: - -```typescript -requestOptions?: RequestOptions | undefined; -``` - -## ChatSession.getHistory() - -Gets the chat history so far. Blocked prompts are not added to history. Neither blocked candidates nor the prompts that generated them are added to history. - -Signature: - -```typescript -getHistory(): Promise; -``` -Returns: - -Promise<[Content](./vertexai-preview.content.md#content_interface)\[\]> - -## ChatSession.sendMessage() - -Sends a chat message and receives a non-streaming [GenerateContentResult](./vertexai-preview.generatecontentresult.md#generatecontentresult_interface) - -Signature: - -```typescript -sendMessage(request: string | Array): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| request | string \| Array<string \| [Part](./vertexai-preview.md#part)> | | - -Returns: - -Promise<[GenerateContentResult](./vertexai-preview.generatecontentresult.md#generatecontentresult_interface)> - -## ChatSession.sendMessageStream() - -Sends a chat message and receives the response as a [GenerateContentStreamResult](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresult_interface) containing an iterable stream and a response promise. - -Signature: - -```typescript -sendMessageStream(request: string | Array): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| request | string \| Array<string \| [Part](./vertexai-preview.md#part)> | | - -Returns: - -Promise<[GenerateContentStreamResult](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresult_interface)> - diff --git a/docs-devsite/vertexai-preview.functiondeclarationschema.md b/docs-devsite/vertexai-preview.functiondeclarationschema.md deleted file mode 100644 index 7d0e5809d41..00000000000 --- a/docs-devsite/vertexai-preview.functiondeclarationschema.md +++ /dev/null @@ -1,70 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# FunctionDeclarationSchema interface -Schema for parameters passed to [FunctionDeclaration.parameters](./vertexai-preview.functiondeclaration.md#functiondeclarationparameters). - -Signature: - -```typescript -export interface FunctionDeclarationSchema -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [description](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschemadescription) | string | Optional. Description of the parameter. | -| [properties](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschemaproperties) | { \[k: string\]: [FunctionDeclarationSchemaProperty](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemaproperty_interface); } | The format of the parameter. | -| [required](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschemarequired) | string\[\] | Optional. Array of required parameters. | -| [type](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschematype) | [FunctionDeclarationSchemaType](./vertexai-preview.md#functiondeclarationschematype) | The type of the parameter. | - -## FunctionDeclarationSchema.description - -Optional. Description of the parameter. - -Signature: - -```typescript -description?: string; -``` - -## FunctionDeclarationSchema.properties - -The format of the parameter. - -Signature: - -```typescript -properties: { - [k: string]: FunctionDeclarationSchemaProperty; - }; -``` - -## FunctionDeclarationSchema.required - -Optional. Array of required parameters. - -Signature: - -```typescript -required?: string[]; -``` - -## FunctionDeclarationSchema.type - -The type of the parameter. - -Signature: - -```typescript -type: FunctionDeclarationSchemaType; -``` diff --git a/docs-devsite/vertexai-preview.functiondeclarationschemaproperty.md b/docs-devsite/vertexai-preview.functiondeclarationschemaproperty.md deleted file mode 100644 index ac2e1262dd0..00000000000 --- a/docs-devsite/vertexai-preview.functiondeclarationschemaproperty.md +++ /dev/null @@ -1,125 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# FunctionDeclarationSchemaProperty interface -Schema is used to define the format of input/output data. Represents a select subset of an OpenAPI 3.0 schema object. More fields may be added in the future as needed. - -Signature: - -```typescript -export interface FunctionDeclarationSchemaProperty -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [description](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertydescription) | string | Optional. The description of the property. | -| [enum](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertyenum) | string\[\] | Optional. The enum of the property. | -| [example](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertyexample) | unknown | Optional. The example of the property. | -| [format](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertyformat) | string | Optional. The format of the property. | -| [items](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertyitems) | [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface) | Optional. The items of the property. [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface) | -| [nullable](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertynullable) | boolean | Optional. Whether the property is nullable. | -| [properties](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertyproperties) | { \[k: string\]: [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface); } | Optional. Map of [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface). | -| [required](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertyrequired) | string\[\] | Optional. Array of required property. | -| [type](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertytype) | [FunctionDeclarationSchemaType](./vertexai-preview.md#functiondeclarationschematype) | Optional. The type of the property. [FunctionDeclarationSchemaType](./vertexai-preview.md#functiondeclarationschematype). | - -## FunctionDeclarationSchemaProperty.description - -Optional. The description of the property. - -Signature: - -```typescript -description?: string; -``` - -## FunctionDeclarationSchemaProperty.enum - -Optional. The enum of the property. - -Signature: - -```typescript -enum?: string[]; -``` - -## FunctionDeclarationSchemaProperty.example - -Optional. The example of the property. - -Signature: - -```typescript -example?: unknown; -``` - -## FunctionDeclarationSchemaProperty.format - -Optional. The format of the property. - -Signature: - -```typescript -format?: string; -``` - -## FunctionDeclarationSchemaProperty.items - -Optional. The items of the property. [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface) - -Signature: - -```typescript -items?: FunctionDeclarationSchema; -``` - -## FunctionDeclarationSchemaProperty.nullable - -Optional. Whether the property is nullable. - -Signature: - -```typescript -nullable?: boolean; -``` - -## FunctionDeclarationSchemaProperty.properties - -Optional. Map of [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface). - -Signature: - -```typescript -properties?: { - [k: string]: FunctionDeclarationSchema; - }; -``` - -## FunctionDeclarationSchemaProperty.required - -Optional. Array of required property. - -Signature: - -```typescript -required?: string[]; -``` - -## FunctionDeclarationSchemaProperty.type - -Optional. The type of the property. [FunctionDeclarationSchemaType](./vertexai-preview.md#functiondeclarationschematype). - -Signature: - -```typescript -type?: FunctionDeclarationSchemaType; -``` diff --git a/docs-devsite/vertexai-preview.functiondeclarationstool.md b/docs-devsite/vertexai-preview.functiondeclarationstool.md deleted file mode 100644 index d1af4351a23..00000000000 --- a/docs-devsite/vertexai-preview.functiondeclarationstool.md +++ /dev/null @@ -1,35 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# FunctionDeclarationsTool interface -A `FunctionDeclarationsTool` is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. - -Signature: - -```typescript -export declare interface FunctionDeclarationsTool -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [functionDeclarations](./vertexai-preview.functiondeclarationstool.md#functiondeclarationstoolfunctiondeclarations) | [FunctionDeclaration](./vertexai-preview.functiondeclaration.md#functiondeclaration_interface)\[\] | Optional. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) in the response. User should provide a [FunctionResponse](./vertexai-preview.functionresponse.md#functionresponse_interface) for each function call in the next turn. Based on the function responses, the model will generate the final response back to the user. Maximum 64 function declarations can be provided. | - -## FunctionDeclarationsTool.functionDeclarations - -Optional. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) in the response. User should provide a [FunctionResponse](./vertexai-preview.functionresponse.md#functionresponse_interface) for each function call in the next turn. Based on the function responses, the model will generate the final response back to the user. Maximum 64 function declarations can be provided. - -Signature: - -```typescript -functionDeclarations?: FunctionDeclaration[]; -``` diff --git a/docs-devsite/vertexai-preview.generatecontentcandidate.md b/docs-devsite/vertexai-preview.generatecontentcandidate.md deleted file mode 100644 index 9f36fab1e87..00000000000 --- a/docs-devsite/vertexai-preview.generatecontentcandidate.md +++ /dev/null @@ -1,87 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# GenerateContentCandidate interface -A candidate returned as part of a [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface). - -Signature: - -```typescript -export interface GenerateContentCandidate -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [citationMetadata](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidatecitationmetadata) | [CitationMetadata](./vertexai-preview.citationmetadata.md#citationmetadata_interface) | | -| [content](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidatecontent) | [Content](./vertexai-preview.content.md#content_interface) | | -| [finishMessage](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidatefinishmessage) | string | | -| [finishReason](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidatefinishreason) | [FinishReason](./vertexai-preview.md#finishreason) | | -| [groundingMetadata](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidategroundingmetadata) | [GroundingMetadata](./vertexai-preview.groundingmetadata.md#groundingmetadata_interface) | | -| [index](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidateindex) | number | | -| [safetyRatings](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidatesafetyratings) | [SafetyRating](./vertexai-preview.safetyrating.md#safetyrating_interface)\[\] | | - -## GenerateContentCandidate.citationMetadata - -Signature: - -```typescript -citationMetadata?: CitationMetadata; -``` - -## GenerateContentCandidate.content - -Signature: - -```typescript -content: Content; -``` - -## GenerateContentCandidate.finishMessage - -Signature: - -```typescript -finishMessage?: string; -``` - -## GenerateContentCandidate.finishReason - -Signature: - -```typescript -finishReason?: FinishReason; -``` - -## GenerateContentCandidate.groundingMetadata - -Signature: - -```typescript -groundingMetadata?: GroundingMetadata; -``` - -## GenerateContentCandidate.index - -Signature: - -```typescript -index: number; -``` - -## GenerateContentCandidate.safetyRatings - -Signature: - -```typescript -safetyRatings?: SafetyRating[]; -``` diff --git a/docs-devsite/vertexai-preview.generationconfig.md b/docs-devsite/vertexai-preview.generationconfig.md deleted file mode 100644 index b14dfea053b..00000000000 --- a/docs-devsite/vertexai-preview.generationconfig.md +++ /dev/null @@ -1,107 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# GenerationConfig interface -Config options for content-related requests - -Signature: - -```typescript -export interface GenerationConfig -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [candidateCount](./vertexai-preview.generationconfig.md#generationconfigcandidatecount) | number | | -| [frequencyPenalty](./vertexai-preview.generationconfig.md#generationconfigfrequencypenalty) | number | | -| [maxOutputTokens](./vertexai-preview.generationconfig.md#generationconfigmaxoutputtokens) | number | | -| [presencePenalty](./vertexai-preview.generationconfig.md#generationconfigpresencepenalty) | number | | -| [responseMimeType](./vertexai-preview.generationconfig.md#generationconfigresponsemimetype) | string | Output response mimetype of the generated candidate text. Supported mimetypes are text/plain (default, text output) and application/json (JSON response in the candidates). The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined. This is a preview feature. | -| [stopSequences](./vertexai-preview.generationconfig.md#generationconfigstopsequences) | string\[\] | | -| [temperature](./vertexai-preview.generationconfig.md#generationconfigtemperature) | number | | -| [topK](./vertexai-preview.generationconfig.md#generationconfigtopk) | number | | -| [topP](./vertexai-preview.generationconfig.md#generationconfigtopp) | number | | - -## GenerationConfig.candidateCount - -Signature: - -```typescript -candidateCount?: number; -``` - -## GenerationConfig.frequencyPenalty - -Signature: - -```typescript -frequencyPenalty?: number; -``` - -## GenerationConfig.maxOutputTokens - -Signature: - -```typescript -maxOutputTokens?: number; -``` - -## GenerationConfig.presencePenalty - -Signature: - -```typescript -presencePenalty?: number; -``` - -## GenerationConfig.responseMimeType - -Output response mimetype of the generated candidate text. Supported mimetypes are `text/plain` (default, text output) and `application/json` (JSON response in the candidates). The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined. This is a preview feature. - -Signature: - -```typescript -responseMimeType?: string; -``` - -## GenerationConfig.stopSequences - -Signature: - -```typescript -stopSequences?: string[]; -``` - -## GenerationConfig.temperature - -Signature: - -```typescript -temperature?: number; -``` - -## GenerationConfig.topK - -Signature: - -```typescript -topK?: number; -``` - -## GenerationConfig.topP - -Signature: - -```typescript -topP?: number; -``` diff --git a/docs-devsite/vertexai-preview.generativemodel.md b/docs-devsite/vertexai-preview.generativemodel.md deleted file mode 100644 index a50fac631cc..00000000000 --- a/docs-devsite/vertexai-preview.generativemodel.md +++ /dev/null @@ -1,201 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# GenerativeModel class -Class for generative model APIs. - -Signature: - -```typescript -export declare class GenerativeModel -``` - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(vertexAI, modelParams, requestOptions)](./vertexai-preview.generativemodel.md#generativemodelconstructor) | | Constructs a new instance of the GenerativeModel class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [generationConfig](./vertexai-preview.generativemodel.md#generativemodelgenerationconfig) | | [GenerationConfig](./vertexai-preview.generationconfig.md#generationconfig_interface) | | -| [model](./vertexai-preview.generativemodel.md#generativemodelmodel) | | string | | -| [requestOptions](./vertexai-preview.generativemodel.md#generativemodelrequestoptions) | | [RequestOptions](./vertexai-preview.requestoptions.md#requestoptions_interface) | | -| [safetySettings](./vertexai-preview.generativemodel.md#generativemodelsafetysettings) | | [SafetySetting](./vertexai-preview.safetysetting.md#safetysetting_interface)\[\] | | -| [systemInstruction](./vertexai-preview.generativemodel.md#generativemodelsysteminstruction) | | [Content](./vertexai-preview.content.md#content_interface) | | -| [toolConfig](./vertexai-preview.generativemodel.md#generativemodeltoolconfig) | | [ToolConfig](./vertexai-preview.toolconfig.md#toolconfig_interface) | | -| [tools](./vertexai-preview.generativemodel.md#generativemodeltools) | | [Tool](./vertexai-preview.md#tool)\[\] | | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [countTokens(request)](./vertexai-preview.generativemodel.md#generativemodelcounttokens) | | Counts the tokens in the provided request. | -| [generateContent(request)](./vertexai-preview.generativemodel.md#generativemodelgeneratecontent) | | Makes a single non-streaming call to the model and returns an object containing a single [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface). | -| [generateContentStream(request)](./vertexai-preview.generativemodel.md#generativemodelgeneratecontentstream) | | Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response. | -| [startChat(startChatParams)](./vertexai-preview.generativemodel.md#generativemodelstartchat) | | Gets a new [ChatSession](./vertexai-preview.chatsession.md#chatsession_class) instance which can be used for multi-turn chats. | - -## GenerativeModel.(constructor) - -Constructs a new instance of the `GenerativeModel` class - -Signature: - -```typescript -constructor(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| vertexAI | [VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) | | -| modelParams | [ModelParams](./vertexai-preview.modelparams.md#modelparams_interface) | | -| requestOptions | [RequestOptions](./vertexai-preview.requestoptions.md#requestoptions_interface) | | - -## GenerativeModel.generationConfig - -Signature: - -```typescript -generationConfig: GenerationConfig; -``` - -## GenerativeModel.model - -Signature: - -```typescript -model: string; -``` - -## GenerativeModel.requestOptions - -Signature: - -```typescript -requestOptions?: RequestOptions; -``` - -## GenerativeModel.safetySettings - -Signature: - -```typescript -safetySettings: SafetySetting[]; -``` - -## GenerativeModel.systemInstruction - -Signature: - -```typescript -systemInstruction?: Content; -``` - -## GenerativeModel.toolConfig - -Signature: - -```typescript -toolConfig?: ToolConfig; -``` - -## GenerativeModel.tools - -Signature: - -```typescript -tools?: Tool[]; -``` - -## GenerativeModel.countTokens() - -Counts the tokens in the provided request. - -Signature: - -```typescript -countTokens(request: CountTokensRequest | string | Array): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| request | [CountTokensRequest](./vertexai-preview.counttokensrequest.md#counttokensrequest_interface) \| string \| Array<string \| [Part](./vertexai-preview.md#part)> | | - -Returns: - -Promise<[CountTokensResponse](./vertexai-preview.counttokensresponse.md#counttokensresponse_interface)> - -## GenerativeModel.generateContent() - -Makes a single non-streaming call to the model and returns an object containing a single [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface). - -Signature: - -```typescript -generateContent(request: GenerateContentRequest | string | Array): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| request | [GenerateContentRequest](./vertexai-preview.generatecontentrequest.md#generatecontentrequest_interface) \| string \| Array<string \| [Part](./vertexai-preview.md#part)> | | - -Returns: - -Promise<[GenerateContentResult](./vertexai-preview.generatecontentresult.md#generatecontentresult_interface)> - -## GenerativeModel.generateContentStream() - -Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response. - -Signature: - -```typescript -generateContentStream(request: GenerateContentRequest | string | Array): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| request | [GenerateContentRequest](./vertexai-preview.generatecontentrequest.md#generatecontentrequest_interface) \| string \| Array<string \| [Part](./vertexai-preview.md#part)> | | - -Returns: - -Promise<[GenerateContentStreamResult](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresult_interface)> - -## GenerativeModel.startChat() - -Gets a new [ChatSession](./vertexai-preview.chatsession.md#chatsession_class) instance which can be used for multi-turn chats. - -Signature: - -```typescript -startChat(startChatParams?: StartChatParams): ChatSession; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| startChatParams | [StartChatParams](./vertexai-preview.startchatparams.md#startchatparams_interface) | | - -Returns: - -[ChatSession](./vertexai-preview.chatsession.md#chatsession_class) - diff --git a/docs-devsite/vertexai-preview.md b/docs-devsite/vertexai-preview.md deleted file mode 100644 index 57fbab35909..00000000000 --- a/docs-devsite/vertexai-preview.md +++ /dev/null @@ -1,397 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# vertexai-preview package -The Vertex AI For Firebase Web SDK. - -## Functions - -| Function | Description | -| --- | --- | -| function(app, ...) | -| [getVertexAI(app, options)](./vertexai-preview.md#getvertexai_04094cf) | Returns a [VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) instance for the given app. | -| function(vertexAI, ...) | -| [getGenerativeModel(vertexAI, modelParams, requestOptions)](./vertexai-preview.md#getgenerativemodel_e3037c9) | Returns a [GenerativeModel](./vertexai-preview.generativemodel.md#generativemodel_class) class with methods for inference and other functionality. | - -## Classes - -| Class | Description | -| --- | --- | -| [ChatSession](./vertexai-preview.chatsession.md#chatsession_class) | ChatSession class that enables sending chat messages and stores history of sent and received messages so far. | -| [GenerativeModel](./vertexai-preview.generativemodel.md#generativemodel_class) | Class for generative model APIs. | -| [VertexAIError](./vertexai-preview.vertexaierror.md#vertexaierror_class) | Error class for the Vertex AI for Firebase SDK. | - -## Enumerations - -| Enumeration | Description | -| --- | --- | -| [BlockReason](./vertexai-preview.md#blockreason) | Reason that a prompt was blocked. | -| [FinishReason](./vertexai-preview.md#finishreason) | Reason that a candidate finished. | -| [FunctionCallingMode](./vertexai-preview.md#functioncallingmode) | | -| [FunctionDeclarationSchemaType](./vertexai-preview.md#functiondeclarationschematype) | Contains the list of OpenAPI data types as defined by https://swagger.io/docs/specification/data-models/data-types/ | -| [HarmBlockMethod](./vertexai-preview.md#harmblockmethod) | | -| [HarmBlockThreshold](./vertexai-preview.md#harmblockthreshold) | Threshold above which a prompt or candidate will be blocked. | -| [HarmCategory](./vertexai-preview.md#harmcategory) | Harm categories that would cause prompts or candidates to be blocked. | -| [HarmProbability](./vertexai-preview.md#harmprobability) | Probability that a prompt or candidate matches a harm category. | -| [HarmSeverity](./vertexai-preview.md#harmseverity) | Harm severity levels. | -| [VertexAIErrorCode](./vertexai-preview.md#vertexaierrorcode) | Standardized error codes that [VertexAIError](./vertexai-preview.vertexaierror.md#vertexaierror_class) can have. | - -## Interfaces - -| Interface | Description | -| --- | --- | -| [BaseParams](./vertexai-preview.baseparams.md#baseparams_interface) | Base parameters for a number of methods. | -| [Citation](./vertexai-preview.citation.md#citation_interface) | A single citation. | -| [CitationMetadata](./vertexai-preview.citationmetadata.md#citationmetadata_interface) | Citation metadata that may be found on a [GenerateContentCandidate](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidate_interface). | -| [Content](./vertexai-preview.content.md#content_interface) | Content type for both prompts and response candidates. | -| [CountTokensRequest](./vertexai-preview.counttokensrequest.md#counttokensrequest_interface) | Params for calling [GenerativeModel.countTokens()](./vertexai-preview.generativemodel.md#generativemodelcounttokens) | -| [CountTokensResponse](./vertexai-preview.counttokensresponse.md#counttokensresponse_interface) | Response from calling [GenerativeModel.countTokens()](./vertexai-preview.generativemodel.md#generativemodelcounttokens). | -| [CustomErrorData](./vertexai-preview.customerrordata.md#customerrordata_interface) | Details object that contains data originating from a bad HTTP response. | -| [Date\_2](./vertexai-preview.date_2.md#date_2_interface) | Protobuf google.type.Date | -| [EnhancedGenerateContentResponse](./vertexai-preview.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface) | Response object wrapped with helper methods. | -| [ErrorDetails](./vertexai-preview.errordetails.md#errordetails_interface) | Details object that may be included in an error response. | -| [FileData](./vertexai-preview.filedata.md#filedata_interface) | Data pointing to a file uploaded on Google Cloud Storage. | -| [FileDataPart](./vertexai-preview.filedatapart.md#filedatapart_interface) | Content part interface if the part represents [FileData](./vertexai-preview.filedata.md#filedata_interface) | -| [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) | A predicted [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) returned from the model that contains a string representing the [FunctionDeclaration.name](./vertexai-preview.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing the parameters and their values. | -| [FunctionCallingConfig](./vertexai-preview.functioncallingconfig.md#functioncallingconfig_interface) | | -| [FunctionCallPart](./vertexai-preview.functioncallpart.md#functioncallpart_interface) | Content part interface if the part represents a [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface). | -| [FunctionDeclaration](./vertexai-preview.functiondeclaration.md#functiondeclaration_interface) | Structured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3). Included in this declaration are the function name and parameters. This FunctionDeclaration is a representation of a block of code that can be used as a Tool by the model and executed by the client. | -| [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface) | Schema for parameters passed to [FunctionDeclaration.parameters](./vertexai-preview.functiondeclaration.md#functiondeclarationparameters). | -| [FunctionDeclarationSchemaProperty](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemaproperty_interface) | Schema is used to define the format of input/output data. Represents a select subset of an OpenAPI 3.0 schema object. More fields may be added in the future as needed. | -| [FunctionDeclarationsTool](./vertexai-preview.functiondeclarationstool.md#functiondeclarationstool_interface) | A FunctionDeclarationsTool is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. | -| [FunctionResponse](./vertexai-preview.functionresponse.md#functionresponse_interface) | The result output from a [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) that contains a string representing the [FunctionDeclaration.name](./vertexai-preview.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) made based on model prediction. | -| [FunctionResponsePart](./vertexai-preview.functionresponsepart.md#functionresponsepart_interface) | Content part interface if the part represents [FunctionResponse](./vertexai-preview.functionresponse.md#functionresponse_interface). | -| [GenerateContentCandidate](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidate_interface) | A candidate returned as part of a [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface). | -| [GenerateContentRequest](./vertexai-preview.generatecontentrequest.md#generatecontentrequest_interface) | Request sent through [GenerativeModel.generateContent()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontent) | -| [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface) | Individual response from [GenerativeModel.generateContent()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontent) and [GenerativeModel.generateContentStream()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontentstream). generateContentStream() will return one in each chunk until the stream is done. | -| [GenerateContentResult](./vertexai-preview.generatecontentresult.md#generatecontentresult_interface) | Result object returned from [GenerativeModel.generateContent()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontent) call. | -| [GenerateContentStreamResult](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresult_interface) | Result object returned from [GenerativeModel.generateContentStream()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontentstream) call. Iterate over stream to get chunks as they come in and/or use the response promise to get the aggregated response when the stream is done. | -| [GenerationConfig](./vertexai-preview.generationconfig.md#generationconfig_interface) | Config options for content-related requests | -| [GenerativeContentBlob](./vertexai-preview.generativecontentblob.md#generativecontentblob_interface) | Interface for sending an image. | -| [GroundingAttribution](./vertexai-preview.groundingattribution.md#groundingattribution_interface) | | -| [GroundingMetadata](./vertexai-preview.groundingmetadata.md#groundingmetadata_interface) | Metadata returned to client when grounding is enabled. | -| [InlineDataPart](./vertexai-preview.inlinedatapart.md#inlinedatapart_interface) | Content part interface if the part represents an image. | -| [ModelParams](./vertexai-preview.modelparams.md#modelparams_interface) | Params passed to [getGenerativeModel()](./vertexai-preview.md#getgenerativemodel_e3037c9). | -| [PromptFeedback](./vertexai-preview.promptfeedback.md#promptfeedback_interface) | If the prompt was blocked, this will be populated with blockReason and the relevant safetyRatings. | -| [RequestOptions](./vertexai-preview.requestoptions.md#requestoptions_interface) | Params passed to [getGenerativeModel()](./vertexai-preview.md#getgenerativemodel_e3037c9). | -| [RetrievedContextAttribution](./vertexai-preview.retrievedcontextattribution.md#retrievedcontextattribution_interface) | | -| [SafetyRating](./vertexai-preview.safetyrating.md#safetyrating_interface) | A safety rating associated with a [GenerateContentCandidate](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidate_interface) | -| [SafetySetting](./vertexai-preview.safetysetting.md#safetysetting_interface) | Safety setting that can be sent as part of request parameters. | -| [Segment](./vertexai-preview.segment.md#segment_interface) | | -| [StartChatParams](./vertexai-preview.startchatparams.md#startchatparams_interface) | Params for [GenerativeModel.startChat()](./vertexai-preview.generativemodel.md#generativemodelstartchat). | -| [TextPart](./vertexai-preview.textpart.md#textpart_interface) | Content part interface if the part represents a text string. | -| [ToolConfig](./vertexai-preview.toolconfig.md#toolconfig_interface) | Tool config. This config is shared for all tools provided in the request. | -| [UsageMetadata](./vertexai-preview.usagemetadata.md#usagemetadata_interface) | Usage metadata about a [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface). | -| [VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) | An instance of the Vertex AI for Firebase SDK. | -| [VertexAIOptions](./vertexai-preview.vertexaioptions.md#vertexaioptions_interface) | Options when initializing the Vertex AI for Firebase SDK. | -| [VideoMetadata](./vertexai-preview.videometadata.md#videometadata_interface) | Describes the input video content. | -| [WebAttribution](./vertexai-preview.webattribution.md#webattribution_interface) | | - -## Variables - -| Variable | Description | -| --- | --- | -| [POSSIBLE\_ROLES](./vertexai-preview.md#possible_roles) | Possible roles. | - -## Type Aliases - -| Type Alias | Description | -| --- | --- | -| [Part](./vertexai-preview.md#part) | Content part - includes text, image/video, or function call/response part types. | -| [Role](./vertexai-preview.md#role) | Role is the producer of the content. | -| [Tool](./vertexai-preview.md#tool) | Defines a tool that model can call to access external knowledge. | - -## function(app, ...) - -### getVertexAI(app, options) {:#getvertexai_04094cf} - -Returns a [VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) instance for the given app. - -Signature: - -```typescript -export declare function getVertexAI(app?: FirebaseApp, options?: VertexAIOptions): VertexAI; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) to use. | -| options | [VertexAIOptions](./vertexai-preview.vertexaioptions.md#vertexaioptions_interface) | | - -Returns: - -[VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) - -## function(vertexAI, ...) - -### getGenerativeModel(vertexAI, modelParams, requestOptions) {:#getgenerativemodel_e3037c9} - -Returns a [GenerativeModel](./vertexai-preview.generativemodel.md#generativemodel_class) class with methods for inference and other functionality. - -Signature: - -```typescript -export declare function getGenerativeModel(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| vertexAI | [VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) | | -| modelParams | [ModelParams](./vertexai-preview.modelparams.md#modelparams_interface) | | -| requestOptions | [RequestOptions](./vertexai-preview.requestoptions.md#requestoptions_interface) | | - -Returns: - -[GenerativeModel](./vertexai-preview.generativemodel.md#generativemodel_class) - -## POSSIBLE\_ROLES - -Possible roles. - -Signature: - -```typescript -POSSIBLE_ROLES: readonly ["user", "model", "function", "system"] -``` - -## Part - -Content part - includes text, image/video, or function call/response part types. - -Signature: - -```typescript -export declare type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart; -``` - -## Role - -Role is the producer of the content. - -Signature: - -```typescript -export declare type Role = (typeof POSSIBLE_ROLES)[number]; -``` - -## Tool - -Defines a tool that model can call to access external knowledge. - -Signature: - -```typescript -export declare type Tool = FunctionDeclarationsTool; -``` - -## BlockReason - -Reason that a prompt was blocked. - -Signature: - -```typescript -export declare enum BlockReason -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| BLOCKED\_REASON\_UNSPECIFIED | "BLOCKED_REASON_UNSPECIFIED" | | -| OTHER | "OTHER" | | -| SAFETY | "SAFETY" | | - -## FinishReason - -Reason that a candidate finished. - -Signature: - -```typescript -export declare enum FinishReason -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| FINISH\_REASON\_UNSPECIFIED | "FINISH_REASON_UNSPECIFIED" | | -| MAX\_TOKENS | "MAX_TOKENS" | | -| OTHER | "OTHER" | | -| RECITATION | "RECITATION" | | -| SAFETY | "SAFETY" | | -| STOP | "STOP" | | - -## FunctionCallingMode - - -Signature: - -```typescript -export declare enum FunctionCallingMode -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| ANY | "ANY" | | -| AUTO | "AUTO" | | -| MODE\_UNSPECIFIED | "MODE_UNSPECIFIED" | | -| NONE | "NONE" | | - -## FunctionDeclarationSchemaType - -Contains the list of OpenAPI data types as defined by https://swagger.io/docs/specification/data-models/data-types/ - -Signature: - -```typescript -export declare enum FunctionDeclarationSchemaType -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| ARRAY | "ARRAY" | Array type. | -| BOOLEAN | "BOOLEAN" | Boolean type. | -| INTEGER | "INTEGER" | Integer type. | -| NUMBER | "NUMBER" | Number type. | -| OBJECT | "OBJECT" | Object type. | -| STRING | "STRING" | String type. | - -## HarmBlockMethod - - -Signature: - -```typescript -export declare enum HarmBlockMethod -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| HARM\_BLOCK\_METHOD\_UNSPECIFIED | "HARM_BLOCK_METHOD_UNSPECIFIED" | | -| PROBABILITY | "PROBABILITY" | | -| SEVERITY | "SEVERITY" | | - -## HarmBlockThreshold - -Threshold above which a prompt or candidate will be blocked. - -Signature: - -```typescript -export declare enum HarmBlockThreshold -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| BLOCK\_LOW\_AND\_ABOVE | "BLOCK_LOW_AND_ABOVE" | | -| BLOCK\_MEDIUM\_AND\_ABOVE | "BLOCK_MEDIUM_AND_ABOVE" | | -| BLOCK\_NONE | "BLOCK_NONE" | | -| BLOCK\_ONLY\_HIGH | "BLOCK_ONLY_HIGH" | | -| HARM\_BLOCK\_THRESHOLD\_UNSPECIFIED | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | | - -## HarmCategory - -Harm categories that would cause prompts or candidates to be blocked. - -Signature: - -```typescript -export declare enum HarmCategory -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| HARM\_CATEGORY\_DANGEROUS\_CONTENT | "HARM_CATEGORY_DANGEROUS_CONTENT" | | -| HARM\_CATEGORY\_HARASSMENT | "HARM_CATEGORY_HARASSMENT" | | -| HARM\_CATEGORY\_HATE\_SPEECH | "HARM_CATEGORY_HATE_SPEECH" | | -| HARM\_CATEGORY\_SEXUALLY\_EXPLICIT | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | | -| HARM\_CATEGORY\_UNSPECIFIED | "HARM_CATEGORY_UNSPECIFIED" | | - -## HarmProbability - -Probability that a prompt or candidate matches a harm category. - -Signature: - -```typescript -export declare enum HarmProbability -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| HARM\_PROBABILITY\_UNSPECIFIED | "HARM_PROBABILITY_UNSPECIFIED" | | -| HIGH | "HIGH" | | -| LOW | "LOW" | | -| MEDIUM | "MEDIUM" | | -| NEGLIGIBLE | "NEGLIGIBLE" | | - -## HarmSeverity - -Harm severity levels. - -Signature: - -```typescript -export declare enum HarmSeverity -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| HARM\_SEVERITY\_HIGH | "HARM_SEVERITY_HIGH" | | -| HARM\_SEVERITY\_LOW | "HARM_SEVERITY_LOW" | | -| HARM\_SEVERITY\_MEDIUM | "HARM_SEVERITY_MEDIUM" | | -| HARM\_SEVERITY\_NEGLIGIBLE | "HARM_SEVERITY_NEGLIGIBLE" | | -| HARM\_SEVERITY\_UNSPECIFIED | "HARM_SEVERITY_UNSPECIFIED" | | - -## VertexAIErrorCode - -Standardized error codes that [VertexAIError](./vertexai-preview.vertexaierror.md#vertexaierror_class) can have. - -Signature: - -```typescript -export declare const enum VertexAIErrorCode -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| ERROR | "error" | A generic error occurred. | -| FETCH\_ERROR | "fetch-error" | An error occurred while performing a fetch. | -| INVALID\_CONTENT | "invalid-content" | An error associated with a Content object. | -| NO\_API\_KEY | "no-api-key" | An error occurred due to a missing Firebase API key. | -| NO\_MODEL | "no-model" | An error occurred due to a model name not being specified during initialization. | -| NO\_PROJECT\_ID | "no-project-id" | An error occurred due to a missing project ID. | -| PARSE\_FAILED | "parse-failed" | An error occurred while parsing. | -| REQUEST\_ERROR | "request-error" | An error occurred in a request. | -| RESPONSE\_ERROR | "response-error" | An error occurred in a response. | - diff --git a/docs-devsite/vertexai.arrayschema.md b/docs-devsite/vertexai.arrayschema.md new file mode 100644 index 00000000000..8f228baf9e8 --- /dev/null +++ b/docs-devsite/vertexai.arrayschema.md @@ -0,0 +1,57 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ArraySchema class +Schema class for "array" types. The `items` param should refer to the type of item that can be a member of the array. + +Signature: + +```typescript +export declare class ArraySchema extends Schema +``` +Extends: [Schema](./vertexai.schema.md#schema_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(schemaParams, items)](./vertexai.arrayschema.md#arrayschemaconstructor) | | Constructs a new instance of the ArraySchema class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [items](./vertexai.arrayschema.md#arrayschemaitems) | | [TypedSchema](./vertexai.md#typedschema) | | + +## ArraySchema.(constructor) + +Constructs a new instance of the `ArraySchema` class + +Signature: + +```typescript +constructor(schemaParams: SchemaParams, items: TypedSchema); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| schemaParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | +| items | [TypedSchema](./vertexai.md#typedschema) | | + +## ArraySchema.items + +Signature: + +```typescript +items: TypedSchema; +``` diff --git a/docs-devsite/vertexai-preview.baseparams.md b/docs-devsite/vertexai.baseparams.md similarity index 67% rename from docs-devsite/vertexai-preview.baseparams.md rename to docs-devsite/vertexai.baseparams.md index 6756c919ccc..382ec825210 100644 --- a/docs-devsite/vertexai-preview.baseparams.md +++ b/docs-devsite/vertexai.baseparams.md @@ -22,8 +22,8 @@ export interface BaseParams | Property | Type | Description | | --- | --- | --- | -| [generationConfig](./vertexai-preview.baseparams.md#baseparamsgenerationconfig) | [GenerationConfig](./vertexai-preview.generationconfig.md#generationconfig_interface) | | -| [safetySettings](./vertexai-preview.baseparams.md#baseparamssafetysettings) | [SafetySetting](./vertexai-preview.safetysetting.md#safetysetting_interface)\[\] | | +| [generationConfig](./vertexai.baseparams.md#baseparamsgenerationconfig) | [GenerationConfig](./vertexai.generationconfig.md#generationconfig_interface) | | +| [safetySettings](./vertexai.baseparams.md#baseparamssafetysettings) | [SafetySetting](./vertexai.safetysetting.md#safetysetting_interface)\[\] | | ## BaseParams.generationConfig diff --git a/docs-devsite/vertexai.booleanschema.md b/docs-devsite/vertexai.booleanschema.md new file mode 100644 index 00000000000..89449f26142 --- /dev/null +++ b/docs-devsite/vertexai.booleanschema.md @@ -0,0 +1,43 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# BooleanSchema class +Schema class for "boolean" types. + +Signature: + +```typescript +export declare class BooleanSchema extends Schema +``` +Extends: [Schema](./vertexai.schema.md#schema_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(schemaParams)](./vertexai.booleanschema.md#booleanschemaconstructor) | | Constructs a new instance of the BooleanSchema class | + +## BooleanSchema.(constructor) + +Constructs a new instance of the `BooleanSchema` class + +Signature: + +```typescript +constructor(schemaParams?: SchemaParams); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| schemaParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | + diff --git a/docs-devsite/vertexai.chatsession.md b/docs-devsite/vertexai.chatsession.md new file mode 100644 index 00000000000..cc5a75ace16 --- /dev/null +++ b/docs-devsite/vertexai.chatsession.md @@ -0,0 +1,138 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ChatSession class +ChatSession class that enables sending chat messages and stores history of sent and received messages so far. + +Signature: + +```typescript +export declare class ChatSession +``` + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(apiSettings, model, params, requestOptions)](./vertexai.chatsession.md#chatsessionconstructor) | | Constructs a new instance of the ChatSession class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [model](./vertexai.chatsession.md#chatsessionmodel) | | string | | +| [params](./vertexai.chatsession.md#chatsessionparams) | | [StartChatParams](./vertexai.startchatparams.md#startchatparams_interface) \| undefined | | +| [requestOptions](./vertexai.chatsession.md#chatsessionrequestoptions) | | [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) \| undefined | | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [getHistory()](./vertexai.chatsession.md#chatsessiongethistory) | | Gets the chat history so far. Blocked prompts are not added to history. Neither blocked candidates nor the prompts that generated them are added to history. | +| [sendMessage(request)](./vertexai.chatsession.md#chatsessionsendmessage) | | Sends a chat message and receives a non-streaming [GenerateContentResult](./vertexai.generatecontentresult.md#generatecontentresult_interface) | +| [sendMessageStream(request)](./vertexai.chatsession.md#chatsessionsendmessagestream) | | Sends a chat message and receives the response as a [GenerateContentStreamResult](./vertexai.generatecontentstreamresult.md#generatecontentstreamresult_interface) containing an iterable stream and a response promise. | + +## ChatSession.(constructor) + +Constructs a new instance of the `ChatSession` class + +Signature: + +```typescript +constructor(apiSettings: ApiSettings, model: string, params?: StartChatParams | undefined, requestOptions?: RequestOptions | undefined); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| apiSettings | ApiSettings | | +| model | string | | +| params | [StartChatParams](./vertexai.startchatparams.md#startchatparams_interface) \| undefined | | +| requestOptions | [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) \| undefined | | + +## ChatSession.model + +Signature: + +```typescript +model: string; +``` + +## ChatSession.params + +Signature: + +```typescript +params?: StartChatParams | undefined; +``` + +## ChatSession.requestOptions + +Signature: + +```typescript +requestOptions?: RequestOptions | undefined; +``` + +## ChatSession.getHistory() + +Gets the chat history so far. Blocked prompts are not added to history. Neither blocked candidates nor the prompts that generated them are added to history. + +Signature: + +```typescript +getHistory(): Promise; +``` +Returns: + +Promise<[Content](./vertexai.content.md#content_interface)\[\]> + +## ChatSession.sendMessage() + +Sends a chat message and receives a non-streaming [GenerateContentResult](./vertexai.generatecontentresult.md#generatecontentresult_interface) + +Signature: + +```typescript +sendMessage(request: string | Array): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| request | string \| Array<string \| [Part](./vertexai.md#part)> | | + +Returns: + +Promise<[GenerateContentResult](./vertexai.generatecontentresult.md#generatecontentresult_interface)> + +## ChatSession.sendMessageStream() + +Sends a chat message and receives the response as a [GenerateContentStreamResult](./vertexai.generatecontentstreamresult.md#generatecontentstreamresult_interface) containing an iterable stream and a response promise. + +Signature: + +```typescript +sendMessageStream(request: string | Array): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| request | string \| Array<string \| [Part](./vertexai.md#part)> | | + +Returns: + +Promise<[GenerateContentStreamResult](./vertexai.generatecontentstreamresult.md#generatecontentstreamresult_interface)> + diff --git a/docs-devsite/vertexai-preview.citation.md b/docs-devsite/vertexai.citation.md similarity index 68% rename from docs-devsite/vertexai-preview.citation.md rename to docs-devsite/vertexai.citation.md index 10a615ee247..b5f5a19f231 100644 --- a/docs-devsite/vertexai-preview.citation.md +++ b/docs-devsite/vertexai.citation.md @@ -22,12 +22,12 @@ export interface Citation | Property | Type | Description | | --- | --- | --- | -| [endIndex](./vertexai-preview.citation.md#citationendindex) | number | | -| [license](./vertexai-preview.citation.md#citationlicense) | string | | -| [publicationDate](./vertexai-preview.citation.md#citationpublicationdate) | Date | | -| [startIndex](./vertexai-preview.citation.md#citationstartindex) | number | | -| [title](./vertexai-preview.citation.md#citationtitle) | string | | -| [uri](./vertexai-preview.citation.md#citationuri) | string | | +| [endIndex](./vertexai.citation.md#citationendindex) | number | | +| [license](./vertexai.citation.md#citationlicense) | string | | +| [publicationDate](./vertexai.citation.md#citationpublicationdate) | Date | | +| [startIndex](./vertexai.citation.md#citationstartindex) | number | | +| [title](./vertexai.citation.md#citationtitle) | string | | +| [uri](./vertexai.citation.md#citationuri) | string | | ## Citation.endIndex diff --git a/docs-devsite/vertexai-preview.citationmetadata.md b/docs-devsite/vertexai.citationmetadata.md similarity index 64% rename from docs-devsite/vertexai-preview.citationmetadata.md rename to docs-devsite/vertexai.citationmetadata.md index fa740ca1af7..e3d41a37d98 100644 --- a/docs-devsite/vertexai-preview.citationmetadata.md +++ b/docs-devsite/vertexai.citationmetadata.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # CitationMetadata interface -Citation metadata that may be found on a [GenerateContentCandidate](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidate_interface). +Citation metadata that may be found on a [GenerateContentCandidate](./vertexai.generatecontentcandidate.md#generatecontentcandidate_interface). Signature: @@ -22,7 +22,7 @@ export interface CitationMetadata | Property | Type | Description | | --- | --- | --- | -| [citations](./vertexai-preview.citationmetadata.md#citationmetadatacitations) | [Citation](./vertexai-preview.citation.md#citation_interface)\[\] | | +| [citations](./vertexai.citationmetadata.md#citationmetadatacitations) | [Citation](./vertexai.citation.md#citation_interface)\[\] | | ## CitationMetadata.citations diff --git a/docs-devsite/vertexai-preview.content.md b/docs-devsite/vertexai.content.md similarity index 76% rename from docs-devsite/vertexai-preview.content.md rename to docs-devsite/vertexai.content.md index 26198a3951f..7a4634a62bc 100644 --- a/docs-devsite/vertexai-preview.content.md +++ b/docs-devsite/vertexai.content.md @@ -22,8 +22,8 @@ export interface Content | Property | Type | Description | | --- | --- | --- | -| [parts](./vertexai-preview.content.md#contentparts) | [Part](./vertexai-preview.md#part)\[\] | | -| [role](./vertexai-preview.content.md#contentrole) | [Role](./vertexai-preview.md#role) | | +| [parts](./vertexai.content.md#contentparts) | [Part](./vertexai.md#part)\[\] | | +| [role](./vertexai.content.md#contentrole) | [Role](./vertexai.md#role) | | ## Content.parts diff --git a/docs-devsite/vertexai-preview.counttokensrequest.md b/docs-devsite/vertexai.counttokensrequest.md similarity index 68% rename from docs-devsite/vertexai-preview.counttokensrequest.md rename to docs-devsite/vertexai.counttokensrequest.md index 07e5f0d85f3..db519b7eb11 100644 --- a/docs-devsite/vertexai-preview.counttokensrequest.md +++ b/docs-devsite/vertexai.counttokensrequest.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # CountTokensRequest interface -Params for calling [GenerativeModel.countTokens()](./vertexai-preview.generativemodel.md#generativemodelcounttokens) +Params for calling [GenerativeModel.countTokens()](./vertexai.generativemodel.md#generativemodelcounttokens) Signature: @@ -22,7 +22,7 @@ export interface CountTokensRequest | Property | Type | Description | | --- | --- | --- | -| [contents](./vertexai-preview.counttokensrequest.md#counttokensrequestcontents) | [Content](./vertexai-preview.content.md#content_interface)\[\] | | +| [contents](./vertexai.counttokensrequest.md#counttokensrequestcontents) | [Content](./vertexai.content.md#content_interface)\[\] | | ## CountTokensRequest.contents diff --git a/docs-devsite/vertexai-preview.counttokensresponse.md b/docs-devsite/vertexai.counttokensresponse.md similarity index 67% rename from docs-devsite/vertexai-preview.counttokensresponse.md rename to docs-devsite/vertexai.counttokensresponse.md index d097d5aacff..2978f9a45bb 100644 --- a/docs-devsite/vertexai-preview.counttokensresponse.md +++ b/docs-devsite/vertexai.counttokensresponse.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # CountTokensResponse interface -Response from calling [GenerativeModel.countTokens()](./vertexai-preview.generativemodel.md#generativemodelcounttokens). +Response from calling [GenerativeModel.countTokens()](./vertexai.generativemodel.md#generativemodelcounttokens). Signature: @@ -22,8 +22,8 @@ export interface CountTokensResponse | Property | Type | Description | | --- | --- | --- | -| [totalBillableCharacters](./vertexai-preview.counttokensresponse.md#counttokensresponsetotalbillablecharacters) | number | The total number of billable characters counted across all instances from the request. | -| [totalTokens](./vertexai-preview.counttokensresponse.md#counttokensresponsetotaltokens) | number | The total number of tokens counted across all instances from the request. | +| [totalBillableCharacters](./vertexai.counttokensresponse.md#counttokensresponsetotalbillablecharacters) | number | The total number of billable characters counted across all instances from the request. | +| [totalTokens](./vertexai.counttokensresponse.md#counttokensresponsetotaltokens) | number | The total number of tokens counted across all instances from the request. | ## CountTokensResponse.totalBillableCharacters diff --git a/docs-devsite/vertexai-preview.customerrordata.md b/docs-devsite/vertexai.customerrordata.md similarity index 54% rename from docs-devsite/vertexai-preview.customerrordata.md rename to docs-devsite/vertexai.customerrordata.md index f0af0574161..701b1b84c49 100644 --- a/docs-devsite/vertexai-preview.customerrordata.md +++ b/docs-devsite/vertexai.customerrordata.md @@ -22,10 +22,10 @@ export interface CustomErrorData | Property | Type | Description | | --- | --- | --- | -| [errorDetails](./vertexai-preview.customerrordata.md#customerrordataerrordetails) | [ErrorDetails](./vertexai-preview.errordetails.md#errordetails_interface)\[\] | Optional additional details about the error. | -| [response](./vertexai-preview.customerrordata.md#customerrordataresponse) | [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface) | Response from a [GenerateContentRequest](./vertexai-preview.generatecontentrequest.md#generatecontentrequest_interface) | -| [status](./vertexai-preview.customerrordata.md#customerrordatastatus) | number | HTTP status code of the error response. | -| [statusText](./vertexai-preview.customerrordata.md#customerrordatastatustext) | string | HTTP status text of the error response. | +| [errorDetails](./vertexai.customerrordata.md#customerrordataerrordetails) | [ErrorDetails](./vertexai.errordetails.md#errordetails_interface)\[\] | Optional additional details about the error. | +| [response](./vertexai.customerrordata.md#customerrordataresponse) | [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface) | Response from a [GenerateContentRequest](./vertexai.generatecontentrequest.md#generatecontentrequest_interface) | +| [status](./vertexai.customerrordata.md#customerrordatastatus) | number | HTTP status code of the error response. | +| [statusText](./vertexai.customerrordata.md#customerrordatastatustext) | string | HTTP status text of the error response. | ## CustomErrorData.errorDetails @@ -39,7 +39,7 @@ errorDetails?: ErrorDetails[]; ## CustomErrorData.response -Response from a [GenerateContentRequest](./vertexai-preview.generatecontentrequest.md#generatecontentrequest_interface) +Response from a [GenerateContentRequest](./vertexai.generatecontentrequest.md#generatecontentrequest_interface) Signature: diff --git a/docs-devsite/vertexai-preview.date_2.md b/docs-devsite/vertexai.date_2.md similarity index 78% rename from docs-devsite/vertexai-preview.date_2.md rename to docs-devsite/vertexai.date_2.md index 5af031447c4..cf073bb86fe 100644 --- a/docs-devsite/vertexai-preview.date_2.md +++ b/docs-devsite/vertexai.date_2.md @@ -22,9 +22,9 @@ export interface Date | Property | Type | Description | | --- | --- | --- | -| [day](./vertexai-preview.date_2.md#date_2day) | number | | -| [month](./vertexai-preview.date_2.md#date_2month) | number | | -| [year](./vertexai-preview.date_2.md#date_2year) | number | | +| [day](./vertexai.date_2.md#date_2day) | number | | +| [month](./vertexai.date_2.md#date_2month) | number | | +| [year](./vertexai.date_2.md#date_2year) | number | | ## Date\_2.day diff --git a/docs-devsite/vertexai-preview.enhancedgeneratecontentresponse.md b/docs-devsite/vertexai.enhancedgeneratecontentresponse.md similarity index 61% rename from docs-devsite/vertexai-preview.enhancedgeneratecontentresponse.md rename to docs-devsite/vertexai.enhancedgeneratecontentresponse.md index 132c5ed0be2..535fb9def8f 100644 --- a/docs-devsite/vertexai-preview.enhancedgeneratecontentresponse.md +++ b/docs-devsite/vertexai.enhancedgeneratecontentresponse.md @@ -17,14 +17,14 @@ Response object wrapped with helper methods. ```typescript export interface EnhancedGenerateContentResponse extends GenerateContentResponse ``` -Extends: [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface) +Extends: [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface) ## Properties | Property | Type | Description | | --- | --- | --- | -| [functionCalls](./vertexai-preview.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponsefunctioncalls) | () => [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface)\[\] \| undefined | | -| [text](./vertexai-preview.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponsetext) | () => string | Returns the text string from the response, if available. Throws if the prompt or candidate was blocked. | +| [functionCalls](./vertexai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponsefunctioncalls) | () => [FunctionCall](./vertexai.functioncall.md#functioncall_interface)\[\] \| undefined | | +| [text](./vertexai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponsetext) | () => string | Returns the text string from the response, if available. Throws if the prompt or candidate was blocked. | ## EnhancedGenerateContentResponse.functionCalls diff --git a/docs-devsite/vertexai-preview.errordetails.md b/docs-devsite/vertexai.errordetails.md similarity index 68% rename from docs-devsite/vertexai-preview.errordetails.md rename to docs-devsite/vertexai.errordetails.md index 45e84a618ab..68959343439 100644 --- a/docs-devsite/vertexai-preview.errordetails.md +++ b/docs-devsite/vertexai.errordetails.md @@ -22,10 +22,10 @@ export interface ErrorDetails | Property | Type | Description | | --- | --- | --- | -| ["@type"](./vertexai-preview.errordetails.md#errordetails"@type") | string | | -| [domain](./vertexai-preview.errordetails.md#errordetailsdomain) | string | The domain where the error occurred. | -| [metadata](./vertexai-preview.errordetails.md#errordetailsmetadata) | Record<string, unknown> | Additional metadata about the error. | -| [reason](./vertexai-preview.errordetails.md#errordetailsreason) | string | The reason for the error. | +| ["@type"](./vertexai.errordetails.md#errordetails"@type") | string | | +| [domain](./vertexai.errordetails.md#errordetailsdomain) | string | The domain where the error occurred. | +| [metadata](./vertexai.errordetails.md#errordetailsmetadata) | Record<string, unknown> | Additional metadata about the error. | +| [reason](./vertexai.errordetails.md#errordetailsreason) | string | The reason for the error. | ## ErrorDetails."@type" diff --git a/docs-devsite/vertexai-preview.filedata.md b/docs-devsite/vertexai.filedata.md similarity index 81% rename from docs-devsite/vertexai-preview.filedata.md rename to docs-devsite/vertexai.filedata.md index 577b4b1910d..7e000174692 100644 --- a/docs-devsite/vertexai-preview.filedata.md +++ b/docs-devsite/vertexai.filedata.md @@ -22,8 +22,8 @@ export interface FileData | Property | Type | Description | | --- | --- | --- | -| [fileUri](./vertexai-preview.filedata.md#filedatafileuri) | string | | -| [mimeType](./vertexai-preview.filedata.md#filedatamimetype) | string | | +| [fileUri](./vertexai.filedata.md#filedatafileuri) | string | | +| [mimeType](./vertexai.filedata.md#filedatamimetype) | string | | ## FileData.fileUri diff --git a/docs-devsite/vertexai-preview.filedatapart.md b/docs-devsite/vertexai.filedatapart.md similarity index 60% rename from docs-devsite/vertexai-preview.filedatapart.md rename to docs-devsite/vertexai.filedatapart.md index e03c056f588..74512fa6d29 100644 --- a/docs-devsite/vertexai-preview.filedatapart.md +++ b/docs-devsite/vertexai.filedatapart.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # FileDataPart interface -Content part interface if the part represents [FileData](./vertexai-preview.filedata.md#filedata_interface) +Content part interface if the part represents [FileData](./vertexai.filedata.md#filedata_interface) Signature: @@ -22,11 +22,11 @@ export interface FileDataPart | Property | Type | Description | | --- | --- | --- | -| [fileData](./vertexai-preview.filedatapart.md#filedatapartfiledata) | [FileData](./vertexai-preview.filedata.md#filedata_interface) | | -| [functionCall](./vertexai-preview.filedatapart.md#filedatapartfunctioncall) | never | | -| [functionResponse](./vertexai-preview.filedatapart.md#filedatapartfunctionresponse) | never | | -| [inlineData](./vertexai-preview.filedatapart.md#filedatapartinlinedata) | never | | -| [text](./vertexai-preview.filedatapart.md#filedataparttext) | never | | +| [fileData](./vertexai.filedatapart.md#filedatapartfiledata) | [FileData](./vertexai.filedata.md#filedata_interface) | | +| [functionCall](./vertexai.filedatapart.md#filedatapartfunctioncall) | never | | +| [functionResponse](./vertexai.filedatapart.md#filedatapartfunctionresponse) | never | | +| [inlineData](./vertexai.filedatapart.md#filedatapartinlinedata) | never | | +| [text](./vertexai.filedatapart.md#filedataparttext) | never | | ## FileDataPart.fileData diff --git a/docs-devsite/vertexai-preview.functioncall.md b/docs-devsite/vertexai.functioncall.md similarity index 57% rename from docs-devsite/vertexai-preview.functioncall.md rename to docs-devsite/vertexai.functioncall.md index 60e0ea50dc4..ca7bc015438 100644 --- a/docs-devsite/vertexai-preview.functioncall.md +++ b/docs-devsite/vertexai.functioncall.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # FunctionCall interface -A predicted [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) returned from the model that contains a string representing the [FunctionDeclaration.name](./vertexai-preview.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing the parameters and their values. +A predicted [FunctionCall](./vertexai.functioncall.md#functioncall_interface) returned from the model that contains a string representing the [FunctionDeclaration.name](./vertexai.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing the parameters and their values. Signature: @@ -22,8 +22,8 @@ export interface FunctionCall | Property | Type | Description | | --- | --- | --- | -| [args](./vertexai-preview.functioncall.md#functioncallargs) | object | | -| [name](./vertexai-preview.functioncall.md#functioncallname) | string | | +| [args](./vertexai.functioncall.md#functioncallargs) | object | | +| [name](./vertexai.functioncall.md#functioncallname) | string | | ## FunctionCall.args diff --git a/docs-devsite/vertexai-preview.functioncallingconfig.md b/docs-devsite/vertexai.functioncallingconfig.md similarity index 71% rename from docs-devsite/vertexai-preview.functioncallingconfig.md rename to docs-devsite/vertexai.functioncallingconfig.md index 1965fb76e95..3724fec5bf7 100644 --- a/docs-devsite/vertexai-preview.functioncallingconfig.md +++ b/docs-devsite/vertexai.functioncallingconfig.md @@ -21,8 +21,8 @@ export interface FunctionCallingConfig | Property | Type | Description | | --- | --- | --- | -| [allowedFunctionNames](./vertexai-preview.functioncallingconfig.md#functioncallingconfigallowedfunctionnames) | string\[\] | | -| [mode](./vertexai-preview.functioncallingconfig.md#functioncallingconfigmode) | [FunctionCallingMode](./vertexai-preview.md#functioncallingmode) | | +| [allowedFunctionNames](./vertexai.functioncallingconfig.md#functioncallingconfigallowedfunctionnames) | string\[\] | | +| [mode](./vertexai.functioncallingconfig.md#functioncallingconfigmode) | [FunctionCallingMode](./vertexai.md#functioncallingmode) | | ## FunctionCallingConfig.allowedFunctionNames diff --git a/docs-devsite/vertexai-preview.functioncallpart.md b/docs-devsite/vertexai.functioncallpart.md similarity index 59% rename from docs-devsite/vertexai-preview.functioncallpart.md rename to docs-devsite/vertexai.functioncallpart.md index 5da204692f9..af8ccf1109a 100644 --- a/docs-devsite/vertexai-preview.functioncallpart.md +++ b/docs-devsite/vertexai.functioncallpart.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # FunctionCallPart interface -Content part interface if the part represents a [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface). +Content part interface if the part represents a [FunctionCall](./vertexai.functioncall.md#functioncall_interface). Signature: @@ -22,10 +22,10 @@ export interface FunctionCallPart | Property | Type | Description | | --- | --- | --- | -| [functionCall](./vertexai-preview.functioncallpart.md#functioncallpartfunctioncall) | [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) | | -| [functionResponse](./vertexai-preview.functioncallpart.md#functioncallpartfunctionresponse) | never | | -| [inlineData](./vertexai-preview.functioncallpart.md#functioncallpartinlinedata) | never | | -| [text](./vertexai-preview.functioncallpart.md#functioncallparttext) | never | | +| [functionCall](./vertexai.functioncallpart.md#functioncallpartfunctioncall) | [FunctionCall](./vertexai.functioncall.md#functioncall_interface) | | +| [functionResponse](./vertexai.functioncallpart.md#functioncallpartfunctionresponse) | never | | +| [inlineData](./vertexai.functioncallpart.md#functioncallpartinlinedata) | never | | +| [text](./vertexai.functioncallpart.md#functioncallparttext) | never | | ## FunctionCallPart.functionCall diff --git a/docs-devsite/vertexai-preview.functiondeclaration.md b/docs-devsite/vertexai.functiondeclaration.md similarity index 57% rename from docs-devsite/vertexai-preview.functiondeclaration.md rename to docs-devsite/vertexai.functiondeclaration.md index e178c7e8bc3..211c1dd868d 100644 --- a/docs-devsite/vertexai-preview.functiondeclaration.md +++ b/docs-devsite/vertexai.functiondeclaration.md @@ -22,18 +22,18 @@ export declare interface FunctionDeclaration | Property | Type | Description | | --- | --- | --- | -| [description](./vertexai-preview.functiondeclaration.md#functiondeclarationdescription) | string | Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function. | -| [name](./vertexai-preview.functiondeclaration.md#functiondeclarationname) | string | The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a max length of 64. | -| [parameters](./vertexai-preview.functiondeclaration.md#functiondeclarationparameters) | [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface) | Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. Parameter names are case-sensitive. For a function with no parameters, this can be left unset. | +| [description](./vertexai.functiondeclaration.md#functiondeclarationdescription) | string | Description and purpose of the function. Model uses it to decide how and whether to call the function. | +| [name](./vertexai.functiondeclaration.md#functiondeclarationname) | string | The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a max length of 64. | +| [parameters](./vertexai.functiondeclaration.md#functiondeclarationparameters) | [ObjectSchemaInterface](./vertexai.objectschemainterface.md#objectschemainterface_interface) | Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. Parameter names are case-sensitive. For a function with no parameters, this can be left unset. | ## FunctionDeclaration.description -Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function. +Description and purpose of the function. Model uses it to decide how and whether to call the function. Signature: ```typescript -description?: string; +description: string; ``` ## FunctionDeclaration.name @@ -53,5 +53,5 @@ Optional. Describes the parameters to this function in JSON Schema Object format Signature: ```typescript -parameters?: FunctionDeclarationSchema; +parameters?: ObjectSchemaInterface; ``` diff --git a/docs-devsite/vertexai.functiondeclarationstool.md b/docs-devsite/vertexai.functiondeclarationstool.md new file mode 100644 index 00000000000..5e728046639 --- /dev/null +++ b/docs-devsite/vertexai.functiondeclarationstool.md @@ -0,0 +1,35 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# FunctionDeclarationsTool interface +A `FunctionDeclarationsTool` is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. + +Signature: + +```typescript +export declare interface FunctionDeclarationsTool +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [functionDeclarations](./vertexai.functiondeclarationstool.md#functiondeclarationstoolfunctiondeclarations) | [FunctionDeclaration](./vertexai.functiondeclaration.md#functiondeclaration_interface)\[\] | Optional. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating [FunctionCall](./vertexai.functioncall.md#functioncall_interface) in the response. User should provide a [FunctionResponse](./vertexai.functionresponse.md#functionresponse_interface) for each function call in the next turn. Based on the function responses, the model will generate the final response back to the user. Maximum 64 function declarations can be provided. | + +## FunctionDeclarationsTool.functionDeclarations + +Optional. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating [FunctionCall](./vertexai.functioncall.md#functioncall_interface) in the response. User should provide a [FunctionResponse](./vertexai.functionresponse.md#functionresponse_interface) for each function call in the next turn. Based on the function responses, the model will generate the final response back to the user. Maximum 64 function declarations can be provided. + +Signature: + +```typescript +functionDeclarations?: FunctionDeclaration[]; +``` diff --git a/docs-devsite/vertexai-preview.functionresponse.md b/docs-devsite/vertexai.functionresponse.md similarity index 50% rename from docs-devsite/vertexai-preview.functionresponse.md rename to docs-devsite/vertexai.functionresponse.md index d89ace08df1..0ca553e0e6b 100644 --- a/docs-devsite/vertexai-preview.functionresponse.md +++ b/docs-devsite/vertexai.functionresponse.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # FunctionResponse interface -The result output from a [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) that contains a string representing the [FunctionDeclaration.name](./vertexai-preview.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) made based on model prediction. +The result output from a [FunctionCall](./vertexai.functioncall.md#functioncall_interface) that contains a string representing the [FunctionDeclaration.name](./vertexai.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a [FunctionCall](./vertexai.functioncall.md#functioncall_interface) made based on model prediction. Signature: @@ -22,8 +22,8 @@ export interface FunctionResponse | Property | Type | Description | | --- | --- | --- | -| [name](./vertexai-preview.functionresponse.md#functionresponsename) | string | | -| [response](./vertexai-preview.functionresponse.md#functionresponseresponse) | object | | +| [name](./vertexai.functionresponse.md#functionresponsename) | string | | +| [response](./vertexai.functionresponse.md#functionresponseresponse) | object | | ## FunctionResponse.name diff --git a/docs-devsite/vertexai-preview.functionresponsepart.md b/docs-devsite/vertexai.functionresponsepart.md similarity index 58% rename from docs-devsite/vertexai-preview.functionresponsepart.md rename to docs-devsite/vertexai.functionresponsepart.md index 4e246d625f6..1905c98cdc7 100644 --- a/docs-devsite/vertexai-preview.functionresponsepart.md +++ b/docs-devsite/vertexai.functionresponsepart.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # FunctionResponsePart interface -Content part interface if the part represents [FunctionResponse](./vertexai-preview.functionresponse.md#functionresponse_interface). +Content part interface if the part represents [FunctionResponse](./vertexai.functionresponse.md#functionresponse_interface). Signature: @@ -22,10 +22,10 @@ export interface FunctionResponsePart | Property | Type | Description | | --- | --- | --- | -| [functionCall](./vertexai-preview.functionresponsepart.md#functionresponsepartfunctioncall) | never | | -| [functionResponse](./vertexai-preview.functionresponsepart.md#functionresponsepartfunctionresponse) | [FunctionResponse](./vertexai-preview.functionresponse.md#functionresponse_interface) | | -| [inlineData](./vertexai-preview.functionresponsepart.md#functionresponsepartinlinedata) | never | | -| [text](./vertexai-preview.functionresponsepart.md#functionresponseparttext) | never | | +| [functionCall](./vertexai.functionresponsepart.md#functionresponsepartfunctioncall) | never | | +| [functionResponse](./vertexai.functionresponsepart.md#functionresponsepartfunctionresponse) | [FunctionResponse](./vertexai.functionresponse.md#functionresponse_interface) | | +| [inlineData](./vertexai.functionresponsepart.md#functionresponsepartinlinedata) | never | | +| [text](./vertexai.functionresponsepart.md#functionresponseparttext) | never | | ## FunctionResponsePart.functionCall diff --git a/docs-devsite/vertexai.generatecontentcandidate.md b/docs-devsite/vertexai.generatecontentcandidate.md new file mode 100644 index 00000000000..a30eef55485 --- /dev/null +++ b/docs-devsite/vertexai.generatecontentcandidate.md @@ -0,0 +1,87 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# GenerateContentCandidate interface +A candidate returned as part of a [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface). + +Signature: + +```typescript +export interface GenerateContentCandidate +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [citationMetadata](./vertexai.generatecontentcandidate.md#generatecontentcandidatecitationmetadata) | [CitationMetadata](./vertexai.citationmetadata.md#citationmetadata_interface) | | +| [content](./vertexai.generatecontentcandidate.md#generatecontentcandidatecontent) | [Content](./vertexai.content.md#content_interface) | | +| [finishMessage](./vertexai.generatecontentcandidate.md#generatecontentcandidatefinishmessage) | string | | +| [finishReason](./vertexai.generatecontentcandidate.md#generatecontentcandidatefinishreason) | [FinishReason](./vertexai.md#finishreason) | | +| [groundingMetadata](./vertexai.generatecontentcandidate.md#generatecontentcandidategroundingmetadata) | [GroundingMetadata](./vertexai.groundingmetadata.md#groundingmetadata_interface) | | +| [index](./vertexai.generatecontentcandidate.md#generatecontentcandidateindex) | number | | +| [safetyRatings](./vertexai.generatecontentcandidate.md#generatecontentcandidatesafetyratings) | [SafetyRating](./vertexai.safetyrating.md#safetyrating_interface)\[\] | | + +## GenerateContentCandidate.citationMetadata + +Signature: + +```typescript +citationMetadata?: CitationMetadata; +``` + +## GenerateContentCandidate.content + +Signature: + +```typescript +content: Content; +``` + +## GenerateContentCandidate.finishMessage + +Signature: + +```typescript +finishMessage?: string; +``` + +## GenerateContentCandidate.finishReason + +Signature: + +```typescript +finishReason?: FinishReason; +``` + +## GenerateContentCandidate.groundingMetadata + +Signature: + +```typescript +groundingMetadata?: GroundingMetadata; +``` + +## GenerateContentCandidate.index + +Signature: + +```typescript +index: number; +``` + +## GenerateContentCandidate.safetyRatings + +Signature: + +```typescript +safetyRatings?: SafetyRating[]; +``` diff --git a/docs-devsite/vertexai-preview.generatecontentrequest.md b/docs-devsite/vertexai.generatecontentrequest.md similarity index 54% rename from docs-devsite/vertexai-preview.generatecontentrequest.md rename to docs-devsite/vertexai.generatecontentrequest.md index 68ce52340e8..31f1103a2e2 100644 --- a/docs-devsite/vertexai-preview.generatecontentrequest.md +++ b/docs-devsite/vertexai.generatecontentrequest.md @@ -10,23 +10,23 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # GenerateContentRequest interface -Request sent through [GenerativeModel.generateContent()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontent) +Request sent through [GenerativeModel.generateContent()](./vertexai.generativemodel.md#generativemodelgeneratecontent) Signature: ```typescript export interface GenerateContentRequest extends BaseParams ``` -Extends: [BaseParams](./vertexai-preview.baseparams.md#baseparams_interface) +Extends: [BaseParams](./vertexai.baseparams.md#baseparams_interface) ## Properties | Property | Type | Description | | --- | --- | --- | -| [contents](./vertexai-preview.generatecontentrequest.md#generatecontentrequestcontents) | [Content](./vertexai-preview.content.md#content_interface)\[\] | | -| [systemInstruction](./vertexai-preview.generatecontentrequest.md#generatecontentrequestsysteminstruction) | string \| [Part](./vertexai-preview.md#part) \| [Content](./vertexai-preview.content.md#content_interface) | | -| [toolConfig](./vertexai-preview.generatecontentrequest.md#generatecontentrequesttoolconfig) | [ToolConfig](./vertexai-preview.toolconfig.md#toolconfig_interface) | | -| [tools](./vertexai-preview.generatecontentrequest.md#generatecontentrequesttools) | [Tool](./vertexai-preview.md#tool)\[\] | | +| [contents](./vertexai.generatecontentrequest.md#generatecontentrequestcontents) | [Content](./vertexai.content.md#content_interface)\[\] | | +| [systemInstruction](./vertexai.generatecontentrequest.md#generatecontentrequestsysteminstruction) | string \| [Part](./vertexai.md#part) \| [Content](./vertexai.content.md#content_interface) | | +| [toolConfig](./vertexai.generatecontentrequest.md#generatecontentrequesttoolconfig) | [ToolConfig](./vertexai.toolconfig.md#toolconfig_interface) | | +| [tools](./vertexai.generatecontentrequest.md#generatecontentrequesttools) | [Tool](./vertexai.md#tool)\[\] | | ## GenerateContentRequest.contents diff --git a/docs-devsite/vertexai-preview.generatecontentresponse.md b/docs-devsite/vertexai.generatecontentresponse.md similarity index 50% rename from docs-devsite/vertexai-preview.generatecontentresponse.md rename to docs-devsite/vertexai.generatecontentresponse.md index cb0fb0e3209..304674c9b6f 100644 --- a/docs-devsite/vertexai-preview.generatecontentresponse.md +++ b/docs-devsite/vertexai.generatecontentresponse.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # GenerateContentResponse interface -Individual response from [GenerativeModel.generateContent()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontent) and [GenerativeModel.generateContentStream()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontentstream). `generateContentStream()` will return one in each chunk until the stream is done. +Individual response from [GenerativeModel.generateContent()](./vertexai.generativemodel.md#generativemodelgeneratecontent) and [GenerativeModel.generateContentStream()](./vertexai.generativemodel.md#generativemodelgeneratecontentstream). `generateContentStream()` will return one in each chunk until the stream is done. Signature: @@ -22,9 +22,9 @@ export interface GenerateContentResponse | Property | Type | Description | | --- | --- | --- | -| [candidates](./vertexai-preview.generatecontentresponse.md#generatecontentresponsecandidates) | [GenerateContentCandidate](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidate_interface)\[\] | | -| [promptFeedback](./vertexai-preview.generatecontentresponse.md#generatecontentresponsepromptfeedback) | [PromptFeedback](./vertexai-preview.promptfeedback.md#promptfeedback_interface) | | -| [usageMetadata](./vertexai-preview.generatecontentresponse.md#generatecontentresponseusagemetadata) | [UsageMetadata](./vertexai-preview.usagemetadata.md#usagemetadata_interface) | | +| [candidates](./vertexai.generatecontentresponse.md#generatecontentresponsecandidates) | [GenerateContentCandidate](./vertexai.generatecontentcandidate.md#generatecontentcandidate_interface)\[\] | | +| [promptFeedback](./vertexai.generatecontentresponse.md#generatecontentresponsepromptfeedback) | [PromptFeedback](./vertexai.promptfeedback.md#promptfeedback_interface) | | +| [usageMetadata](./vertexai.generatecontentresponse.md#generatecontentresponseusagemetadata) | [UsageMetadata](./vertexai.usagemetadata.md#usagemetadata_interface) | | ## GenerateContentResponse.candidates diff --git a/docs-devsite/vertexai-preview.generatecontentresult.md b/docs-devsite/vertexai.generatecontentresult.md similarity index 69% rename from docs-devsite/vertexai-preview.generatecontentresult.md rename to docs-devsite/vertexai.generatecontentresult.md index 87249a5bc55..3e162f9ebb2 100644 --- a/docs-devsite/vertexai-preview.generatecontentresult.md +++ b/docs-devsite/vertexai.generatecontentresult.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # GenerateContentResult interface -Result object returned from [GenerativeModel.generateContent()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontent) call. +Result object returned from [GenerativeModel.generateContent()](./vertexai.generativemodel.md#generativemodelgeneratecontent) call. Signature: @@ -22,7 +22,7 @@ export interface GenerateContentResult | Property | Type | Description | | --- | --- | --- | -| [response](./vertexai-preview.generatecontentresult.md#generatecontentresultresponse) | [EnhancedGenerateContentResponse](./vertexai-preview.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface) | | +| [response](./vertexai.generatecontentresult.md#generatecontentresultresponse) | [EnhancedGenerateContentResponse](./vertexai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface) | | ## GenerateContentResult.response diff --git a/docs-devsite/vertexai-preview.generatecontentstreamresult.md b/docs-devsite/vertexai.generatecontentstreamresult.md similarity index 52% rename from docs-devsite/vertexai-preview.generatecontentstreamresult.md rename to docs-devsite/vertexai.generatecontentstreamresult.md index 6fd46600079..340abb1d0bd 100644 --- a/docs-devsite/vertexai-preview.generatecontentstreamresult.md +++ b/docs-devsite/vertexai.generatecontentstreamresult.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # GenerateContentStreamResult interface -Result object returned from [GenerativeModel.generateContentStream()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontentstream) call. Iterate over `stream` to get chunks as they come in and/or use the `response` promise to get the aggregated response when the stream is done. +Result object returned from [GenerativeModel.generateContentStream()](./vertexai.generativemodel.md#generativemodelgeneratecontentstream) call. Iterate over `stream` to get chunks as they come in and/or use the `response` promise to get the aggregated response when the stream is done. Signature: @@ -22,8 +22,8 @@ export interface GenerateContentStreamResult | Property | Type | Description | | --- | --- | --- | -| [response](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresultresponse) | Promise<[EnhancedGenerateContentResponse](./vertexai-preview.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface)> | | -| [stream](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresultstream) | AsyncGenerator<[EnhancedGenerateContentResponse](./vertexai-preview.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface)> | | +| [response](./vertexai.generatecontentstreamresult.md#generatecontentstreamresultresponse) | Promise<[EnhancedGenerateContentResponse](./vertexai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface)> | | +| [stream](./vertexai.generatecontentstreamresult.md#generatecontentstreamresultstream) | AsyncGenerator<[EnhancedGenerateContentResponse](./vertexai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface)> | | ## GenerateContentStreamResult.response diff --git a/docs-devsite/vertexai.generationconfig.md b/docs-devsite/vertexai.generationconfig.md new file mode 100644 index 00000000000..3c3d0a14ffa --- /dev/null +++ b/docs-devsite/vertexai.generationconfig.md @@ -0,0 +1,118 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# GenerationConfig interface +Config options for content-related requests + +Signature: + +```typescript +export interface GenerationConfig +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [candidateCount](./vertexai.generationconfig.md#generationconfigcandidatecount) | number | | +| [frequencyPenalty](./vertexai.generationconfig.md#generationconfigfrequencypenalty) | number | | +| [maxOutputTokens](./vertexai.generationconfig.md#generationconfigmaxoutputtokens) | number | | +| [presencePenalty](./vertexai.generationconfig.md#generationconfigpresencepenalty) | number | | +| [responseMimeType](./vertexai.generationconfig.md#generationconfigresponsemimetype) | string | Output response MIME type of the generated candidate text. Supported MIME types are text/plain (default, text output), application/json (JSON response in the candidates), and text/x.enum. | +| [responseSchema](./vertexai.generationconfig.md#generationconfigresponseschema) | [TypedSchema](./vertexai.md#typedschema) \| [SchemaRequest](./vertexai.schemarequest.md#schemarequest_interface) | Output response schema of the generated candidate text. This value can be a class generated with a [Schema](./vertexai.schema.md#schema_class) static method like Schema.string() or Schema.object() or it can be a plain JS object matching the [SchemaRequest](./vertexai.schemarequest.md#schemarequest_interface) interface.
Note: This only applies when the specified responseMIMEType supports a schema; currently this is limited to application/json and text/x.enum. | +| [stopSequences](./vertexai.generationconfig.md#generationconfigstopsequences) | string\[\] | | +| [temperature](./vertexai.generationconfig.md#generationconfigtemperature) | number | | +| [topK](./vertexai.generationconfig.md#generationconfigtopk) | number | | +| [topP](./vertexai.generationconfig.md#generationconfigtopp) | number | | + +## GenerationConfig.candidateCount + +Signature: + +```typescript +candidateCount?: number; +``` + +## GenerationConfig.frequencyPenalty + +Signature: + +```typescript +frequencyPenalty?: number; +``` + +## GenerationConfig.maxOutputTokens + +Signature: + +```typescript +maxOutputTokens?: number; +``` + +## GenerationConfig.presencePenalty + +Signature: + +```typescript +presencePenalty?: number; +``` + +## GenerationConfig.responseMimeType + +Output response MIME type of the generated candidate text. Supported MIME types are `text/plain` (default, text output), `application/json` (JSON response in the candidates), and `text/x.enum`. + +Signature: + +```typescript +responseMimeType?: string; +``` + +## GenerationConfig.responseSchema + +Output response schema of the generated candidate text. This value can be a class generated with a [Schema](./vertexai.schema.md#schema_class) static method like `Schema.string()` or `Schema.object()` or it can be a plain JS object matching the [SchemaRequest](./vertexai.schemarequest.md#schemarequest_interface) interface.
Note: This only applies when the specified `responseMIMEType` supports a schema; currently this is limited to `application/json` and `text/x.enum`. + +Signature: + +```typescript +responseSchema?: TypedSchema | SchemaRequest; +``` + +## GenerationConfig.stopSequences + +Signature: + +```typescript +stopSequences?: string[]; +``` + +## GenerationConfig.temperature + +Signature: + +```typescript +temperature?: number; +``` + +## GenerationConfig.topK + +Signature: + +```typescript +topK?: number; +``` + +## GenerationConfig.topP + +Signature: + +```typescript +topP?: number; +``` diff --git a/docs-devsite/vertexai-preview.generativecontentblob.md b/docs-devsite/vertexai.generativecontentblob.md similarity index 76% rename from docs-devsite/vertexai-preview.generativecontentblob.md rename to docs-devsite/vertexai.generativecontentblob.md index b5dcb272027..dfcd098291f 100644 --- a/docs-devsite/vertexai-preview.generativecontentblob.md +++ b/docs-devsite/vertexai.generativecontentblob.md @@ -22,8 +22,8 @@ export interface GenerativeContentBlob | Property | Type | Description | | --- | --- | --- | -| [data](./vertexai-preview.generativecontentblob.md#generativecontentblobdata) | string | Image as a base64 string. | -| [mimeType](./vertexai-preview.generativecontentblob.md#generativecontentblobmimetype) | string | | +| [data](./vertexai.generativecontentblob.md#generativecontentblobdata) | string | Image as a base64 string. | +| [mimeType](./vertexai.generativecontentblob.md#generativecontentblobmimetype) | string | | ## GenerativeContentBlob.data diff --git a/docs-devsite/vertexai.generativemodel.md b/docs-devsite/vertexai.generativemodel.md new file mode 100644 index 00000000000..7105f9c100b --- /dev/null +++ b/docs-devsite/vertexai.generativemodel.md @@ -0,0 +1,201 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# GenerativeModel class +Class for generative model APIs. + +Signature: + +```typescript +export declare class GenerativeModel +``` + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(vertexAI, modelParams, requestOptions)](./vertexai.generativemodel.md#generativemodelconstructor) | | Constructs a new instance of the GenerativeModel class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [generationConfig](./vertexai.generativemodel.md#generativemodelgenerationconfig) | | [GenerationConfig](./vertexai.generationconfig.md#generationconfig_interface) | | +| [model](./vertexai.generativemodel.md#generativemodelmodel) | | string | | +| [requestOptions](./vertexai.generativemodel.md#generativemodelrequestoptions) | | [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) | | +| [safetySettings](./vertexai.generativemodel.md#generativemodelsafetysettings) | | [SafetySetting](./vertexai.safetysetting.md#safetysetting_interface)\[\] | | +| [systemInstruction](./vertexai.generativemodel.md#generativemodelsysteminstruction) | | [Content](./vertexai.content.md#content_interface) | | +| [toolConfig](./vertexai.generativemodel.md#generativemodeltoolconfig) | | [ToolConfig](./vertexai.toolconfig.md#toolconfig_interface) | | +| [tools](./vertexai.generativemodel.md#generativemodeltools) | | [Tool](./vertexai.md#tool)\[\] | | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [countTokens(request)](./vertexai.generativemodel.md#generativemodelcounttokens) | | Counts the tokens in the provided request. | +| [generateContent(request)](./vertexai.generativemodel.md#generativemodelgeneratecontent) | | Makes a single non-streaming call to the model and returns an object containing a single [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface). | +| [generateContentStream(request)](./vertexai.generativemodel.md#generativemodelgeneratecontentstream) | | Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response. | +| [startChat(startChatParams)](./vertexai.generativemodel.md#generativemodelstartchat) | | Gets a new [ChatSession](./vertexai.chatsession.md#chatsession_class) instance which can be used for multi-turn chats. | + +## GenerativeModel.(constructor) + +Constructs a new instance of the `GenerativeModel` class + +Signature: + +```typescript +constructor(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| vertexAI | [VertexAI](./vertexai.vertexai.md#vertexai_interface) | | +| modelParams | [ModelParams](./vertexai.modelparams.md#modelparams_interface) | | +| requestOptions | [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) | | + +## GenerativeModel.generationConfig + +Signature: + +```typescript +generationConfig: GenerationConfig; +``` + +## GenerativeModel.model + +Signature: + +```typescript +model: string; +``` + +## GenerativeModel.requestOptions + +Signature: + +```typescript +requestOptions?: RequestOptions; +``` + +## GenerativeModel.safetySettings + +Signature: + +```typescript +safetySettings: SafetySetting[]; +``` + +## GenerativeModel.systemInstruction + +Signature: + +```typescript +systemInstruction?: Content; +``` + +## GenerativeModel.toolConfig + +Signature: + +```typescript +toolConfig?: ToolConfig; +``` + +## GenerativeModel.tools + +Signature: + +```typescript +tools?: Tool[]; +``` + +## GenerativeModel.countTokens() + +Counts the tokens in the provided request. + +Signature: + +```typescript +countTokens(request: CountTokensRequest | string | Array): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| request | [CountTokensRequest](./vertexai.counttokensrequest.md#counttokensrequest_interface) \| string \| Array<string \| [Part](./vertexai.md#part)> | | + +Returns: + +Promise<[CountTokensResponse](./vertexai.counttokensresponse.md#counttokensresponse_interface)> + +## GenerativeModel.generateContent() + +Makes a single non-streaming call to the model and returns an object containing a single [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface). + +Signature: + +```typescript +generateContent(request: GenerateContentRequest | string | Array): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| request | [GenerateContentRequest](./vertexai.generatecontentrequest.md#generatecontentrequest_interface) \| string \| Array<string \| [Part](./vertexai.md#part)> | | + +Returns: + +Promise<[GenerateContentResult](./vertexai.generatecontentresult.md#generatecontentresult_interface)> + +## GenerativeModel.generateContentStream() + +Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response. + +Signature: + +```typescript +generateContentStream(request: GenerateContentRequest | string | Array): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| request | [GenerateContentRequest](./vertexai.generatecontentrequest.md#generatecontentrequest_interface) \| string \| Array<string \| [Part](./vertexai.md#part)> | | + +Returns: + +Promise<[GenerateContentStreamResult](./vertexai.generatecontentstreamresult.md#generatecontentstreamresult_interface)> + +## GenerativeModel.startChat() + +Gets a new [ChatSession](./vertexai.chatsession.md#chatsession_class) instance which can be used for multi-turn chats. + +Signature: + +```typescript +startChat(startChatParams?: StartChatParams): ChatSession; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| startChatParams | [StartChatParams](./vertexai.startchatparams.md#startchatparams_interface) | | + +Returns: + +[ChatSession](./vertexai.chatsession.md#chatsession_class) + diff --git a/docs-devsite/vertexai-preview.groundingattribution.md b/docs-devsite/vertexai.groundingattribution.md similarity index 58% rename from docs-devsite/vertexai-preview.groundingattribution.md rename to docs-devsite/vertexai.groundingattribution.md index 2c7d2f09e0b..b72d8150635 100644 --- a/docs-devsite/vertexai-preview.groundingattribution.md +++ b/docs-devsite/vertexai.groundingattribution.md @@ -21,10 +21,10 @@ export interface GroundingAttribution | Property | Type | Description | | --- | --- | --- | -| [confidenceScore](./vertexai-preview.groundingattribution.md#groundingattributionconfidencescore) | number | | -| [retrievedContext](./vertexai-preview.groundingattribution.md#groundingattributionretrievedcontext) | [RetrievedContextAttribution](./vertexai-preview.retrievedcontextattribution.md#retrievedcontextattribution_interface) | | -| [segment](./vertexai-preview.groundingattribution.md#groundingattributionsegment) | [Segment](./vertexai-preview.segment.md#segment_interface) | | -| [web](./vertexai-preview.groundingattribution.md#groundingattributionweb) | [WebAttribution](./vertexai-preview.webattribution.md#webattribution_interface) | | +| [confidenceScore](./vertexai.groundingattribution.md#groundingattributionconfidencescore) | number | | +| [retrievedContext](./vertexai.groundingattribution.md#groundingattributionretrievedcontext) | [RetrievedContextAttribution](./vertexai.retrievedcontextattribution.md#retrievedcontextattribution_interface) | | +| [segment](./vertexai.groundingattribution.md#groundingattributionsegment) | [Segment](./vertexai.segment.md#segment_interface) | | +| [web](./vertexai.groundingattribution.md#groundingattributionweb) | [WebAttribution](./vertexai.webattribution.md#webattribution_interface) | | ## GroundingAttribution.confidenceScore diff --git a/docs-devsite/vertexai-preview.groundingmetadata.md b/docs-devsite/vertexai.groundingmetadata.md similarity index 66% rename from docs-devsite/vertexai-preview.groundingmetadata.md rename to docs-devsite/vertexai.groundingmetadata.md index 5f40a00457d..186f00d29a7 100644 --- a/docs-devsite/vertexai-preview.groundingmetadata.md +++ b/docs-devsite/vertexai.groundingmetadata.md @@ -22,9 +22,9 @@ export interface GroundingMetadata | Property | Type | Description | | --- | --- | --- | -| [groundingAttributions](./vertexai-preview.groundingmetadata.md#groundingmetadatagroundingattributions) | [GroundingAttribution](./vertexai-preview.groundingattribution.md#groundingattribution_interface)\[\] | | -| [retrievalQueries](./vertexai-preview.groundingmetadata.md#groundingmetadataretrievalqueries) | string\[\] | | -| [webSearchQueries](./vertexai-preview.groundingmetadata.md#groundingmetadatawebsearchqueries) | string\[\] | | +| [groundingAttributions](./vertexai.groundingmetadata.md#groundingmetadatagroundingattributions) | [GroundingAttribution](./vertexai.groundingattribution.md#groundingattribution_interface)\[\] | | +| [retrievalQueries](./vertexai.groundingmetadata.md#groundingmetadataretrievalqueries) | string\[\] | | +| [webSearchQueries](./vertexai.groundingmetadata.md#groundingmetadatawebsearchqueries) | string\[\] | | ## GroundingMetadata.groundingAttributions diff --git a/docs-devsite/vertexai-preview.inlinedatapart.md b/docs-devsite/vertexai.inlinedatapart.md similarity index 60% rename from docs-devsite/vertexai-preview.inlinedatapart.md rename to docs-devsite/vertexai.inlinedatapart.md index ae05f80ddb7..0cb064fc357 100644 --- a/docs-devsite/vertexai-preview.inlinedatapart.md +++ b/docs-devsite/vertexai.inlinedatapart.md @@ -22,11 +22,11 @@ export interface InlineDataPart | Property | Type | Description | | --- | --- | --- | -| [functionCall](./vertexai-preview.inlinedatapart.md#inlinedatapartfunctioncall) | never | | -| [functionResponse](./vertexai-preview.inlinedatapart.md#inlinedatapartfunctionresponse) | never | | -| [inlineData](./vertexai-preview.inlinedatapart.md#inlinedatapartinlinedata) | [GenerativeContentBlob](./vertexai-preview.generativecontentblob.md#generativecontentblob_interface) | | -| [text](./vertexai-preview.inlinedatapart.md#inlinedataparttext) | never | | -| [videoMetadata](./vertexai-preview.inlinedatapart.md#inlinedatapartvideometadata) | [VideoMetadata](./vertexai-preview.videometadata.md#videometadata_interface) | Applicable if inlineData is a video. | +| [functionCall](./vertexai.inlinedatapart.md#inlinedatapartfunctioncall) | never | | +| [functionResponse](./vertexai.inlinedatapart.md#inlinedatapartfunctionresponse) | never | | +| [inlineData](./vertexai.inlinedatapart.md#inlinedatapartinlinedata) | [GenerativeContentBlob](./vertexai.generativecontentblob.md#generativecontentblob_interface) | | +| [text](./vertexai.inlinedatapart.md#inlinedataparttext) | never | | +| [videoMetadata](./vertexai.inlinedatapart.md#inlinedatapartvideometadata) | [VideoMetadata](./vertexai.videometadata.md#videometadata_interface) | Applicable if inlineData is a video. | ## InlineDataPart.functionCall diff --git a/docs-devsite/vertexai.integerschema.md b/docs-devsite/vertexai.integerschema.md new file mode 100644 index 00000000000..4822bdd618b --- /dev/null +++ b/docs-devsite/vertexai.integerschema.md @@ -0,0 +1,43 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# IntegerSchema class +Schema class for "integer" types. + +Signature: + +```typescript +export declare class IntegerSchema extends Schema +``` +Extends: [Schema](./vertexai.schema.md#schema_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(schemaParams)](./vertexai.integerschema.md#integerschemaconstructor) | | Constructs a new instance of the IntegerSchema class | + +## IntegerSchema.(constructor) + +Constructs a new instance of the `IntegerSchema` class + +Signature: + +```typescript +constructor(schemaParams?: SchemaParams); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| schemaParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | + diff --git a/docs-devsite/vertexai.md b/docs-devsite/vertexai.md new file mode 100644 index 00000000000..d9e26eabc5d --- /dev/null +++ b/docs-devsite/vertexai.md @@ -0,0 +1,412 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# vertexai package +The Vertex AI in Firebase Web SDK. + +## Functions + +| Function | Description | +| --- | --- | +| function(app, ...) | +| [getVertexAI(app, options)](./vertexai.md#getvertexai_04094cf) | Returns a [VertexAI](./vertexai.vertexai.md#vertexai_interface) instance for the given app. | +| function(vertexAI, ...) | +| [getGenerativeModel(vertexAI, modelParams, requestOptions)](./vertexai.md#getgenerativemodel_e3037c9) | Returns a [GenerativeModel](./vertexai.generativemodel.md#generativemodel_class) class with methods for inference and other functionality. | + +## Classes + +| Class | Description | +| --- | --- | +| [ArraySchema](./vertexai.arrayschema.md#arrayschema_class) | Schema class for "array" types. The items param should refer to the type of item that can be a member of the array. | +| [BooleanSchema](./vertexai.booleanschema.md#booleanschema_class) | Schema class for "boolean" types. | +| [ChatSession](./vertexai.chatsession.md#chatsession_class) | ChatSession class that enables sending chat messages and stores history of sent and received messages so far. | +| [GenerativeModel](./vertexai.generativemodel.md#generativemodel_class) | Class for generative model APIs. | +| [IntegerSchema](./vertexai.integerschema.md#integerschema_class) | Schema class for "integer" types. | +| [NumberSchema](./vertexai.numberschema.md#numberschema_class) | Schema class for "number" types. | +| [ObjectSchema](./vertexai.objectschema.md#objectschema_class) | Schema class for "object" types. The properties param must be a map of Schema objects. | +| [Schema](./vertexai.schema.md#schema_class) | Parent class encompassing all Schema types, with static methods that allow building specific Schema types. This class can be converted with JSON.stringify() into a JSON string accepted by Vertex AI REST endpoints. (This string conversion is automatically done when calling SDK methods.) | +| [StringSchema](./vertexai.stringschema.md#stringschema_class) | Schema class for "string" types. Can be used with or without enum values. | +| [VertexAIError](./vertexai.vertexaierror.md#vertexaierror_class) | Error class for the Vertex AI in Firebase SDK. | + +## Enumerations + +| Enumeration | Description | +| --- | --- | +| [BlockReason](./vertexai.md#blockreason) | Reason that a prompt was blocked. | +| [FinishReason](./vertexai.md#finishreason) | Reason that a candidate finished. | +| [FunctionCallingMode](./vertexai.md#functioncallingmode) | | +| [HarmBlockMethod](./vertexai.md#harmblockmethod) | | +| [HarmBlockThreshold](./vertexai.md#harmblockthreshold) | Threshold above which a prompt or candidate will be blocked. | +| [HarmCategory](./vertexai.md#harmcategory) | Harm categories that would cause prompts or candidates to be blocked. | +| [HarmProbability](./vertexai.md#harmprobability) | Probability that a prompt or candidate matches a harm category. | +| [HarmSeverity](./vertexai.md#harmseverity) | Harm severity levels. | +| [SchemaType](./vertexai.md#schematype) | Contains the list of OpenAPI data types as defined by the [OpenAPI specification](https://swagger.io/docs/specification/data-models/data-types/) | +| [VertexAIErrorCode](./vertexai.md#vertexaierrorcode) | Standardized error codes that [VertexAIError](./vertexai.vertexaierror.md#vertexaierror_class) can have. | + +## Interfaces + +| Interface | Description | +| --- | --- | +| [BaseParams](./vertexai.baseparams.md#baseparams_interface) | Base parameters for a number of methods. | +| [Citation](./vertexai.citation.md#citation_interface) | A single citation. | +| [CitationMetadata](./vertexai.citationmetadata.md#citationmetadata_interface) | Citation metadata that may be found on a [GenerateContentCandidate](./vertexai.generatecontentcandidate.md#generatecontentcandidate_interface). | +| [Content](./vertexai.content.md#content_interface) | Content type for both prompts and response candidates. | +| [CountTokensRequest](./vertexai.counttokensrequest.md#counttokensrequest_interface) | Params for calling [GenerativeModel.countTokens()](./vertexai.generativemodel.md#generativemodelcounttokens) | +| [CountTokensResponse](./vertexai.counttokensresponse.md#counttokensresponse_interface) | Response from calling [GenerativeModel.countTokens()](./vertexai.generativemodel.md#generativemodelcounttokens). | +| [CustomErrorData](./vertexai.customerrordata.md#customerrordata_interface) | Details object that contains data originating from a bad HTTP response. | +| [Date\_2](./vertexai.date_2.md#date_2_interface) | Protobuf google.type.Date | +| [EnhancedGenerateContentResponse](./vertexai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface) | Response object wrapped with helper methods. | +| [ErrorDetails](./vertexai.errordetails.md#errordetails_interface) | Details object that may be included in an error response. | +| [FileData](./vertexai.filedata.md#filedata_interface) | Data pointing to a file uploaded on Google Cloud Storage. | +| [FileDataPart](./vertexai.filedatapart.md#filedatapart_interface) | Content part interface if the part represents [FileData](./vertexai.filedata.md#filedata_interface) | +| [FunctionCall](./vertexai.functioncall.md#functioncall_interface) | A predicted [FunctionCall](./vertexai.functioncall.md#functioncall_interface) returned from the model that contains a string representing the [FunctionDeclaration.name](./vertexai.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing the parameters and their values. | +| [FunctionCallingConfig](./vertexai.functioncallingconfig.md#functioncallingconfig_interface) | | +| [FunctionCallPart](./vertexai.functioncallpart.md#functioncallpart_interface) | Content part interface if the part represents a [FunctionCall](./vertexai.functioncall.md#functioncall_interface). | +| [FunctionDeclaration](./vertexai.functiondeclaration.md#functiondeclaration_interface) | Structured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3). Included in this declaration are the function name and parameters. This FunctionDeclaration is a representation of a block of code that can be used as a Tool by the model and executed by the client. | +| [FunctionDeclarationsTool](./vertexai.functiondeclarationstool.md#functiondeclarationstool_interface) | A FunctionDeclarationsTool is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. | +| [FunctionResponse](./vertexai.functionresponse.md#functionresponse_interface) | The result output from a [FunctionCall](./vertexai.functioncall.md#functioncall_interface) that contains a string representing the [FunctionDeclaration.name](./vertexai.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a [FunctionCall](./vertexai.functioncall.md#functioncall_interface) made based on model prediction. | +| [FunctionResponsePart](./vertexai.functionresponsepart.md#functionresponsepart_interface) | Content part interface if the part represents [FunctionResponse](./vertexai.functionresponse.md#functionresponse_interface). | +| [GenerateContentCandidate](./vertexai.generatecontentcandidate.md#generatecontentcandidate_interface) | A candidate returned as part of a [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface). | +| [GenerateContentRequest](./vertexai.generatecontentrequest.md#generatecontentrequest_interface) | Request sent through [GenerativeModel.generateContent()](./vertexai.generativemodel.md#generativemodelgeneratecontent) | +| [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface) | Individual response from [GenerativeModel.generateContent()](./vertexai.generativemodel.md#generativemodelgeneratecontent) and [GenerativeModel.generateContentStream()](./vertexai.generativemodel.md#generativemodelgeneratecontentstream). generateContentStream() will return one in each chunk until the stream is done. | +| [GenerateContentResult](./vertexai.generatecontentresult.md#generatecontentresult_interface) | Result object returned from [GenerativeModel.generateContent()](./vertexai.generativemodel.md#generativemodelgeneratecontent) call. | +| [GenerateContentStreamResult](./vertexai.generatecontentstreamresult.md#generatecontentstreamresult_interface) | Result object returned from [GenerativeModel.generateContentStream()](./vertexai.generativemodel.md#generativemodelgeneratecontentstream) call. Iterate over stream to get chunks as they come in and/or use the response promise to get the aggregated response when the stream is done. | +| [GenerationConfig](./vertexai.generationconfig.md#generationconfig_interface) | Config options for content-related requests | +| [GenerativeContentBlob](./vertexai.generativecontentblob.md#generativecontentblob_interface) | Interface for sending an image. | +| [GroundingAttribution](./vertexai.groundingattribution.md#groundingattribution_interface) | | +| [GroundingMetadata](./vertexai.groundingmetadata.md#groundingmetadata_interface) | Metadata returned to client when grounding is enabled. | +| [InlineDataPart](./vertexai.inlinedatapart.md#inlinedatapart_interface) | Content part interface if the part represents an image. | +| [ModelParams](./vertexai.modelparams.md#modelparams_interface) | Params passed to [getGenerativeModel()](./vertexai.md#getgenerativemodel_e3037c9). | +| [ObjectSchemaInterface](./vertexai.objectschemainterface.md#objectschemainterface_interface) | Interface for [ObjectSchema](./vertexai.objectschema.md#objectschema_class) class. | +| [PromptFeedback](./vertexai.promptfeedback.md#promptfeedback_interface) | If the prompt was blocked, this will be populated with blockReason and the relevant safetyRatings. | +| [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) | Params passed to [getGenerativeModel()](./vertexai.md#getgenerativemodel_e3037c9). | +| [RetrievedContextAttribution](./vertexai.retrievedcontextattribution.md#retrievedcontextattribution_interface) | | +| [SafetyRating](./vertexai.safetyrating.md#safetyrating_interface) | A safety rating associated with a [GenerateContentCandidate](./vertexai.generatecontentcandidate.md#generatecontentcandidate_interface) | +| [SafetySetting](./vertexai.safetysetting.md#safetysetting_interface) | Safety setting that can be sent as part of request parameters. | +| [SchemaInterface](./vertexai.schemainterface.md#schemainterface_interface) | Interface for [Schema](./vertexai.schema.md#schema_class) class. | +| [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | Params passed to [Schema](./vertexai.schema.md#schema_class) static methods to create specific [Schema](./vertexai.schema.md#schema_class) classes. | +| [SchemaRequest](./vertexai.schemarequest.md#schemarequest_interface) | Final format for [Schema](./vertexai.schema.md#schema_class) params passed to backend requests. | +| [SchemaShared](./vertexai.schemashared.md#schemashared_interface) | Basic [Schema](./vertexai.schema.md#schema_class) properties shared across several Schema-related types. | +| [Segment](./vertexai.segment.md#segment_interface) | | +| [StartChatParams](./vertexai.startchatparams.md#startchatparams_interface) | Params for [GenerativeModel.startChat()](./vertexai.generativemodel.md#generativemodelstartchat). | +| [TextPart](./vertexai.textpart.md#textpart_interface) | Content part interface if the part represents a text string. | +| [ToolConfig](./vertexai.toolconfig.md#toolconfig_interface) | Tool config. This config is shared for all tools provided in the request. | +| [UsageMetadata](./vertexai.usagemetadata.md#usagemetadata_interface) | Usage metadata about a [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface). | +| [VertexAI](./vertexai.vertexai.md#vertexai_interface) | An instance of the Vertex AI in Firebase SDK. | +| [VertexAIOptions](./vertexai.vertexaioptions.md#vertexaioptions_interface) | Options when initializing the Vertex AI in Firebase SDK. | +| [VideoMetadata](./vertexai.videometadata.md#videometadata_interface) | Describes the input video content. | +| [WebAttribution](./vertexai.webattribution.md#webattribution_interface) | | + +## Variables + +| Variable | Description | +| --- | --- | +| [POSSIBLE\_ROLES](./vertexai.md#possible_roles) | Possible roles. | + +## Type Aliases + +| Type Alias | Description | +| --- | --- | +| [Part](./vertexai.md#part) | Content part - includes text, image/video, or function call/response part types. | +| [Role](./vertexai.md#role) | Role is the producer of the content. | +| [Tool](./vertexai.md#tool) | Defines a tool that model can call to access external knowledge. | +| [TypedSchema](./vertexai.md#typedschema) | A type that includes all specific Schema types. | + +## function(app, ...) + +### getVertexAI(app, options) {:#getvertexai_04094cf} + +Returns a [VertexAI](./vertexai.vertexai.md#vertexai_interface) instance for the given app. + +Signature: + +```typescript +export declare function getVertexAI(app?: FirebaseApp, options?: VertexAIOptions): VertexAI; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) to use. | +| options | [VertexAIOptions](./vertexai.vertexaioptions.md#vertexaioptions_interface) | | + +Returns: + +[VertexAI](./vertexai.vertexai.md#vertexai_interface) + +## function(vertexAI, ...) + +### getGenerativeModel(vertexAI, modelParams, requestOptions) {:#getgenerativemodel_e3037c9} + +Returns a [GenerativeModel](./vertexai.generativemodel.md#generativemodel_class) class with methods for inference and other functionality. + +Signature: + +```typescript +export declare function getGenerativeModel(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| vertexAI | [VertexAI](./vertexai.vertexai.md#vertexai_interface) | | +| modelParams | [ModelParams](./vertexai.modelparams.md#modelparams_interface) | | +| requestOptions | [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) | | + +Returns: + +[GenerativeModel](./vertexai.generativemodel.md#generativemodel_class) + +## POSSIBLE\_ROLES + +Possible roles. + +Signature: + +```typescript +POSSIBLE_ROLES: readonly ["user", "model", "function", "system"] +``` + +## Part + +Content part - includes text, image/video, or function call/response part types. + +Signature: + +```typescript +export type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart; +``` + +## Role + +Role is the producer of the content. + +Signature: + +```typescript +export type Role = (typeof POSSIBLE_ROLES)[number]; +``` + +## Tool + +Defines a tool that model can call to access external knowledge. + +Signature: + +```typescript +export declare type Tool = FunctionDeclarationsTool; +``` + +## TypedSchema + +A type that includes all specific Schema types. + +Signature: + +```typescript +export type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema; +``` + +## BlockReason + +Reason that a prompt was blocked. + +Signature: + +```typescript +export declare enum BlockReason +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| OTHER | "OTHER" | | +| SAFETY | "SAFETY" | | + +## FinishReason + +Reason that a candidate finished. + +Signature: + +```typescript +export declare enum FinishReason +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| MAX\_TOKENS | "MAX_TOKENS" | | +| OTHER | "OTHER" | | +| RECITATION | "RECITATION" | | +| SAFETY | "SAFETY" | | +| STOP | "STOP" | | + +## FunctionCallingMode + + +Signature: + +```typescript +export declare enum FunctionCallingMode +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| ANY | "ANY" | | +| AUTO | "AUTO" | | +| NONE | "NONE" | | + +## HarmBlockMethod + + +Signature: + +```typescript +export declare enum HarmBlockMethod +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| PROBABILITY | "PROBABILITY" | | +| SEVERITY | "SEVERITY" | | + +## HarmBlockThreshold + +Threshold above which a prompt or candidate will be blocked. + +Signature: + +```typescript +export declare enum HarmBlockThreshold +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| BLOCK\_LOW\_AND\_ABOVE | "BLOCK_LOW_AND_ABOVE" | | +| BLOCK\_MEDIUM\_AND\_ABOVE | "BLOCK_MEDIUM_AND_ABOVE" | | +| BLOCK\_NONE | "BLOCK_NONE" | | +| BLOCK\_ONLY\_HIGH | "BLOCK_ONLY_HIGH" | | + +## HarmCategory + +Harm categories that would cause prompts or candidates to be blocked. + +Signature: + +```typescript +export declare enum HarmCategory +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| HARM\_CATEGORY\_DANGEROUS\_CONTENT | "HARM_CATEGORY_DANGEROUS_CONTENT" | | +| HARM\_CATEGORY\_HARASSMENT | "HARM_CATEGORY_HARASSMENT" | | +| HARM\_CATEGORY\_HATE\_SPEECH | "HARM_CATEGORY_HATE_SPEECH" | | +| HARM\_CATEGORY\_SEXUALLY\_EXPLICIT | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | | + +## HarmProbability + +Probability that a prompt or candidate matches a harm category. + +Signature: + +```typescript +export declare enum HarmProbability +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| HIGH | "HIGH" | | +| LOW | "LOW" | | +| MEDIUM | "MEDIUM" | | +| NEGLIGIBLE | "NEGLIGIBLE" | | + +## HarmSeverity + +Harm severity levels. + +Signature: + +```typescript +export declare enum HarmSeverity +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| HARM\_SEVERITY\_HIGH | "HARM_SEVERITY_HIGH" | | +| HARM\_SEVERITY\_LOW | "HARM_SEVERITY_LOW" | | +| HARM\_SEVERITY\_MEDIUM | "HARM_SEVERITY_MEDIUM" | | +| HARM\_SEVERITY\_NEGLIGIBLE | "HARM_SEVERITY_NEGLIGIBLE" | | + +## SchemaType + +Contains the list of OpenAPI data types as defined by the [OpenAPI specification](https://swagger.io/docs/specification/data-models/data-types/) + +Signature: + +```typescript +export declare enum SchemaType +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| ARRAY | "array" | Array type. | +| BOOLEAN | "boolean" | Boolean type. | +| INTEGER | "integer" | Integer type. | +| NUMBER | "number" | Number type. | +| OBJECT | "object" | Object type. | +| STRING | "string" | String type. | + +## VertexAIErrorCode + +Standardized error codes that [VertexAIError](./vertexai.vertexaierror.md#vertexaierror_class) can have. + +Signature: + +```typescript +export declare const enum VertexAIErrorCode +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| API\_NOT\_ENABLED | "api-not-enabled" | An error due to the Firebase API not being enabled in the Console. | +| ERROR | "error" | A generic error occurred. | +| FETCH\_ERROR | "fetch-error" | An error occurred while performing a fetch. | +| INVALID\_CONTENT | "invalid-content" | An error associated with a Content object. | +| INVALID\_SCHEMA | "invalid-schema" | An error due to invalid Schema input. | +| NO\_API\_KEY | "no-api-key" | An error occurred due to a missing Firebase API key. | +| NO\_MODEL | "no-model" | An error occurred due to a model name not being specified during initialization. | +| NO\_PROJECT\_ID | "no-project-id" | An error occurred due to a missing project ID. | +| PARSE\_FAILED | "parse-failed" | An error occurred while parsing. | +| REQUEST\_ERROR | "request-error" | An error occurred in a request. | +| RESPONSE\_ERROR | "response-error" | An error occurred in a response. | + diff --git a/docs-devsite/vertexai-preview.modelparams.md b/docs-devsite/vertexai.modelparams.md similarity index 54% rename from docs-devsite/vertexai-preview.modelparams.md rename to docs-devsite/vertexai.modelparams.md index 34d68f86714..590bc14e435 100644 --- a/docs-devsite/vertexai-preview.modelparams.md +++ b/docs-devsite/vertexai.modelparams.md @@ -10,23 +10,23 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # ModelParams interface -Params passed to [getGenerativeModel()](./vertexai-preview.md#getgenerativemodel_e3037c9). +Params passed to [getGenerativeModel()](./vertexai.md#getgenerativemodel_e3037c9). Signature: ```typescript export interface ModelParams extends BaseParams ``` -Extends: [BaseParams](./vertexai-preview.baseparams.md#baseparams_interface) +Extends: [BaseParams](./vertexai.baseparams.md#baseparams_interface) ## Properties | Property | Type | Description | | --- | --- | --- | -| [model](./vertexai-preview.modelparams.md#modelparamsmodel) | string | | -| [systemInstruction](./vertexai-preview.modelparams.md#modelparamssysteminstruction) | string \| [Part](./vertexai-preview.md#part) \| [Content](./vertexai-preview.content.md#content_interface) | | -| [toolConfig](./vertexai-preview.modelparams.md#modelparamstoolconfig) | [ToolConfig](./vertexai-preview.toolconfig.md#toolconfig_interface) | | -| [tools](./vertexai-preview.modelparams.md#modelparamstools) | [Tool](./vertexai-preview.md#tool)\[\] | | +| [model](./vertexai.modelparams.md#modelparamsmodel) | string | | +| [systemInstruction](./vertexai.modelparams.md#modelparamssysteminstruction) | string \| [Part](./vertexai.md#part) \| [Content](./vertexai.content.md#content_interface) | | +| [toolConfig](./vertexai.modelparams.md#modelparamstoolconfig) | [ToolConfig](./vertexai.toolconfig.md#toolconfig_interface) | | +| [tools](./vertexai.modelparams.md#modelparamstools) | [Tool](./vertexai.md#tool)\[\] | | ## ModelParams.model diff --git a/docs-devsite/vertexai.numberschema.md b/docs-devsite/vertexai.numberschema.md new file mode 100644 index 00000000000..8fdd9374652 --- /dev/null +++ b/docs-devsite/vertexai.numberschema.md @@ -0,0 +1,43 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# NumberSchema class +Schema class for "number" types. + +Signature: + +```typescript +export declare class NumberSchema extends Schema +``` +Extends: [Schema](./vertexai.schema.md#schema_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(schemaParams)](./vertexai.numberschema.md#numberschemaconstructor) | | Constructs a new instance of the NumberSchema class | + +## NumberSchema.(constructor) + +Constructs a new instance of the `NumberSchema` class + +Signature: + +```typescript +constructor(schemaParams?: SchemaParams); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| schemaParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | + diff --git a/docs-devsite/vertexai.objectschema.md b/docs-devsite/vertexai.objectschema.md new file mode 100644 index 00000000000..8731960b220 --- /dev/null +++ b/docs-devsite/vertexai.objectschema.md @@ -0,0 +1,71 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ObjectSchema class +Schema class for "object" types. The `properties` param must be a map of `Schema` objects. + +Signature: + +```typescript +export declare class ObjectSchema extends Schema +``` +Extends: [Schema](./vertexai.schema.md#schema_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(schemaParams, properties, optionalProperties)](./vertexai.objectschema.md#objectschemaconstructor) | | Constructs a new instance of the ObjectSchema class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [optionalProperties](./vertexai.objectschema.md#objectschemaoptionalproperties) | | string\[\] | | +| [properties](./vertexai.objectschema.md#objectschemaproperties) | | { \[k: string\]: [TypedSchema](./vertexai.md#typedschema); } | | + +## ObjectSchema.(constructor) + +Constructs a new instance of the `ObjectSchema` class + +Signature: + +```typescript +constructor(schemaParams: SchemaParams, properties: { + [k: string]: TypedSchema; + }, optionalProperties?: string[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| schemaParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | +| properties | { \[k: string\]: [TypedSchema](./vertexai.md#typedschema); } | | +| optionalProperties | string\[\] | | + +## ObjectSchema.optionalProperties + +Signature: + +```typescript +optionalProperties: string[]; +``` + +## ObjectSchema.properties + +Signature: + +```typescript +properties: { + [k: string]: TypedSchema; + }; +``` diff --git a/docs-devsite/vertexai.objectschemainterface.md b/docs-devsite/vertexai.objectschemainterface.md new file mode 100644 index 00000000000..6a4e052d183 --- /dev/null +++ b/docs-devsite/vertexai.objectschemainterface.md @@ -0,0 +1,43 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ObjectSchemaInterface interface +Interface for [ObjectSchema](./vertexai.objectschema.md#objectschema_class) class. + +Signature: + +```typescript +export interface ObjectSchemaInterface extends SchemaInterface +``` +Extends: [SchemaInterface](./vertexai.schemainterface.md#schemainterface_interface) + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [optionalProperties](./vertexai.objectschemainterface.md#objectschemainterfaceoptionalproperties) | string\[\] | | +| [type](./vertexai.objectschemainterface.md#objectschemainterfacetype) | [SchemaType.OBJECT](./vertexai.md#schematypeobject_enummember) | | + +## ObjectSchemaInterface.optionalProperties + +Signature: + +```typescript +optionalProperties?: string[]; +``` + +## ObjectSchemaInterface.type + +Signature: + +```typescript +type: SchemaType.OBJECT; +``` diff --git a/docs-devsite/vertexai-preview.promptfeedback.md b/docs-devsite/vertexai.promptfeedback.md similarity index 66% rename from docs-devsite/vertexai-preview.promptfeedback.md rename to docs-devsite/vertexai.promptfeedback.md index cb27f10c8c3..369ef02051d 100644 --- a/docs-devsite/vertexai-preview.promptfeedback.md +++ b/docs-devsite/vertexai.promptfeedback.md @@ -22,16 +22,16 @@ export interface PromptFeedback | Property | Type | Description | | --- | --- | --- | -| [blockReason](./vertexai-preview.promptfeedback.md#promptfeedbackblockreason) | [BlockReason](./vertexai-preview.md#blockreason) | | -| [blockReasonMessage](./vertexai-preview.promptfeedback.md#promptfeedbackblockreasonmessage) | string | | -| [safetyRatings](./vertexai-preview.promptfeedback.md#promptfeedbacksafetyratings) | [SafetyRating](./vertexai-preview.safetyrating.md#safetyrating_interface)\[\] | | +| [blockReason](./vertexai.promptfeedback.md#promptfeedbackblockreason) | [BlockReason](./vertexai.md#blockreason) | | +| [blockReasonMessage](./vertexai.promptfeedback.md#promptfeedbackblockreasonmessage) | string | | +| [safetyRatings](./vertexai.promptfeedback.md#promptfeedbacksafetyratings) | [SafetyRating](./vertexai.safetyrating.md#safetyrating_interface)\[\] | | ## PromptFeedback.blockReason Signature: ```typescript -blockReason: BlockReason; +blockReason?: BlockReason; ``` ## PromptFeedback.blockReasonMessage diff --git a/docs-devsite/vertexai-preview.requestoptions.md b/docs-devsite/vertexai.requestoptions.md similarity index 55% rename from docs-devsite/vertexai-preview.requestoptions.md rename to docs-devsite/vertexai.requestoptions.md index 550ec44ce96..6d074775520 100644 --- a/docs-devsite/vertexai-preview.requestoptions.md +++ b/docs-devsite/vertexai.requestoptions.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # RequestOptions interface -Params passed to [getGenerativeModel()](./vertexai-preview.md#getgenerativemodel_e3037c9). +Params passed to [getGenerativeModel()](./vertexai.md#getgenerativemodel_e3037c9). Signature: @@ -22,12 +22,12 @@ export interface RequestOptions | Property | Type | Description | | --- | --- | --- | -| [baseUrl](./vertexai-preview.requestoptions.md#requestoptionsbaseurl) | string | Base url for endpoint. Defaults to https://firebaseml.googleapis.com | -| [timeout](./vertexai-preview.requestoptions.md#requestoptionstimeout) | number | Request timeout in milliseconds. | +| [baseUrl](./vertexai.requestoptions.md#requestoptionsbaseurl) | string | Base url for endpoint. Defaults to https://firebasevertexai.googleapis.com | +| [timeout](./vertexai.requestoptions.md#requestoptionstimeout) | number | Request timeout in milliseconds. Defaults to 180 seconds (180000ms). | ## RequestOptions.baseUrl -Base url for endpoint. Defaults to https://firebaseml.googleapis.com +Base url for endpoint. Defaults to https://firebasevertexai.googleapis.com Signature: @@ -37,7 +37,7 @@ baseUrl?: string; ## RequestOptions.timeout -Request timeout in milliseconds. +Request timeout in milliseconds. Defaults to 180 seconds (180000ms). Signature: diff --git a/docs-devsite/vertexai-preview.retrievedcontextattribution.md b/docs-devsite/vertexai.retrievedcontextattribution.md similarity index 76% rename from docs-devsite/vertexai-preview.retrievedcontextattribution.md rename to docs-devsite/vertexai.retrievedcontextattribution.md index 0a121cdc004..e36bfacb3ec 100644 --- a/docs-devsite/vertexai-preview.retrievedcontextattribution.md +++ b/docs-devsite/vertexai.retrievedcontextattribution.md @@ -21,8 +21,8 @@ export interface RetrievedContextAttribution | Property | Type | Description | | --- | --- | --- | -| [title](./vertexai-preview.retrievedcontextattribution.md#retrievedcontextattributiontitle) | string | | -| [uri](./vertexai-preview.retrievedcontextattribution.md#retrievedcontextattributionuri) | string | | +| [title](./vertexai.retrievedcontextattribution.md#retrievedcontextattributiontitle) | string | | +| [uri](./vertexai.retrievedcontextattribution.md#retrievedcontextattributionuri) | string | | ## RetrievedContextAttribution.title diff --git a/docs-devsite/vertexai-preview.safetyrating.md b/docs-devsite/vertexai.safetyrating.md similarity index 55% rename from docs-devsite/vertexai-preview.safetyrating.md rename to docs-devsite/vertexai.safetyrating.md index 65b1bc8fb42..b5f204bef2c 100644 --- a/docs-devsite/vertexai-preview.safetyrating.md +++ b/docs-devsite/vertexai.safetyrating.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # SafetyRating interface -A safety rating associated with a [GenerateContentCandidate](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidate_interface) +A safety rating associated with a [GenerateContentCandidate](./vertexai.generatecontentcandidate.md#generatecontentcandidate_interface) Signature: @@ -22,12 +22,12 @@ export interface SafetyRating | Property | Type | Description | | --- | --- | --- | -| [blocked](./vertexai-preview.safetyrating.md#safetyratingblocked) | boolean | | -| [category](./vertexai-preview.safetyrating.md#safetyratingcategory) | [HarmCategory](./vertexai-preview.md#harmcategory) | | -| [probability](./vertexai-preview.safetyrating.md#safetyratingprobability) | [HarmProbability](./vertexai-preview.md#harmprobability) | | -| [probabilityScore](./vertexai-preview.safetyrating.md#safetyratingprobabilityscore) | number | | -| [severity](./vertexai-preview.safetyrating.md#safetyratingseverity) | [HarmSeverity](./vertexai-preview.md#harmseverity) | | -| [severityScore](./vertexai-preview.safetyrating.md#safetyratingseverityscore) | number | | +| [blocked](./vertexai.safetyrating.md#safetyratingblocked) | boolean | | +| [category](./vertexai.safetyrating.md#safetyratingcategory) | [HarmCategory](./vertexai.md#harmcategory) | | +| [probability](./vertexai.safetyrating.md#safetyratingprobability) | [HarmProbability](./vertexai.md#harmprobability) | | +| [probabilityScore](./vertexai.safetyrating.md#safetyratingprobabilityscore) | number | | +| [severity](./vertexai.safetyrating.md#safetyratingseverity) | [HarmSeverity](./vertexai.md#harmseverity) | | +| [severityScore](./vertexai.safetyrating.md#safetyratingseverityscore) | number | | ## SafetyRating.blocked diff --git a/docs-devsite/vertexai-preview.safetysetting.md b/docs-devsite/vertexai.safetysetting.md similarity index 64% rename from docs-devsite/vertexai-preview.safetysetting.md rename to docs-devsite/vertexai.safetysetting.md index 78678315805..17fa1cff839 100644 --- a/docs-devsite/vertexai-preview.safetysetting.md +++ b/docs-devsite/vertexai.safetysetting.md @@ -22,9 +22,9 @@ export interface SafetySetting | Property | Type | Description | | --- | --- | --- | -| [category](./vertexai-preview.safetysetting.md#safetysettingcategory) | [HarmCategory](./vertexai-preview.md#harmcategory) | | -| [method](./vertexai-preview.safetysetting.md#safetysettingmethod) | [HarmBlockMethod](./vertexai-preview.md#harmblockmethod) | | -| [threshold](./vertexai-preview.safetysetting.md#safetysettingthreshold) | [HarmBlockThreshold](./vertexai-preview.md#harmblockthreshold) | | +| [category](./vertexai.safetysetting.md#safetysettingcategory) | [HarmCategory](./vertexai.md#harmcategory) | | +| [method](./vertexai.safetysetting.md#safetysettingmethod) | [HarmBlockMethod](./vertexai.md#harmblockmethod) | | +| [threshold](./vertexai.safetysetting.md#safetysettingthreshold) | [HarmBlockThreshold](./vertexai.md#harmblockthreshold) | | ## SafetySetting.category @@ -39,7 +39,7 @@ category: HarmCategory; Signature: ```typescript -method: HarmBlockMethod; +method?: HarmBlockMethod; ``` ## SafetySetting.threshold diff --git a/docs-devsite/vertexai.schema.md b/docs-devsite/vertexai.schema.md new file mode 100644 index 00000000000..f4a36c3c506 --- /dev/null +++ b/docs-devsite/vertexai.schema.md @@ -0,0 +1,250 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Schema class +Parent class encompassing all Schema types, with static methods that allow building specific Schema types. This class can be converted with `JSON.stringify()` into a JSON string accepted by Vertex AI REST endpoints. (This string conversion is automatically done when calling SDK methods.) + +Signature: + +```typescript +export declare abstract class Schema implements SchemaInterface +``` +Implements: [SchemaInterface](./vertexai.schemainterface.md#schemainterface_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(schemaParams)](./vertexai.schema.md#schemaconstructor) | | Constructs a new instance of the Schema class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [description](./vertexai.schema.md#schemadescription) | | string | Optional. The description of the property. | +| [example](./vertexai.schema.md#schemaexample) | | unknown | Optional. The example of the property. | +| [format](./vertexai.schema.md#schemaformat) | | string | Optional. The format of the property. Supported formats:
  • for NUMBER type: "float", "double"
  • for INTEGER type: "int32", "int64"
  • for STRING type: "email", "byte", etc
| +| [nullable](./vertexai.schema.md#schemanullable) | | boolean | Optional. Whether the property is nullable. Defaults to false. | +| [type](./vertexai.schema.md#schematype) | | [SchemaType](./vertexai.md#schematype) | Optional. The type of the property. [SchemaType](./vertexai.md#schematype). | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [array(arrayParams)](./vertexai.schema.md#schemaarray) | static | | +| [boolean(booleanParams)](./vertexai.schema.md#schemaboolean) | static | | +| [enumString(stringParams)](./vertexai.schema.md#schemaenumstring) | static | | +| [integer(integerParams)](./vertexai.schema.md#schemainteger) | static | | +| [number(numberParams)](./vertexai.schema.md#schemanumber) | static | | +| [object(objectParams)](./vertexai.schema.md#schemaobject) | static | | +| [string(stringParams)](./vertexai.schema.md#schemastring) | static | | + +## Schema.(constructor) + +Constructs a new instance of the `Schema` class + +Signature: + +```typescript +constructor(schemaParams: SchemaInterface); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| schemaParams | [SchemaInterface](./vertexai.schemainterface.md#schemainterface_interface) | | + +## Schema.description + +Optional. The description of the property. + +Signature: + +```typescript +description?: string; +``` + +## Schema.example + +Optional. The example of the property. + +Signature: + +```typescript +example?: unknown; +``` + +## Schema.format + +Optional. The format of the property. Supported formats:
  • for NUMBER type: "float", "double"
  • for INTEGER type: "int32", "int64"
  • for STRING type: "email", "byte", etc
+ +Signature: + +```typescript +format?: string; +``` + +## Schema.nullable + +Optional. Whether the property is nullable. Defaults to false. + +Signature: + +```typescript +nullable: boolean; +``` + +## Schema.type + +Optional. The type of the property. [SchemaType](./vertexai.md#schematype). + +Signature: + +```typescript +type: SchemaType; +``` + +## Schema.array() + +Signature: + +```typescript +static array(arrayParams: SchemaParams & { + items: Schema; + }): ArraySchema; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrayParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) & { items: [Schema](./vertexai.schema.md#schema_class); } | | + +Returns: + +[ArraySchema](./vertexai.arrayschema.md#arrayschema_class) + +## Schema.boolean() + +Signature: + +```typescript +static boolean(booleanParams?: SchemaParams): BooleanSchema; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| booleanParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | + +Returns: + +[BooleanSchema](./vertexai.booleanschema.md#booleanschema_class) + +## Schema.enumString() + +Signature: + +```typescript +static enumString(stringParams: SchemaParams & { + enum: string[]; + }): StringSchema; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| stringParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) & { enum: string\[\]; } | | + +Returns: + +[StringSchema](./vertexai.stringschema.md#stringschema_class) + +## Schema.integer() + +Signature: + +```typescript +static integer(integerParams?: SchemaParams): IntegerSchema; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| integerParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | + +Returns: + +[IntegerSchema](./vertexai.integerschema.md#integerschema_class) + +## Schema.number() + +Signature: + +```typescript +static number(numberParams?: SchemaParams): NumberSchema; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| numberParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | + +Returns: + +[NumberSchema](./vertexai.numberschema.md#numberschema_class) + +## Schema.object() + +Signature: + +```typescript +static object(objectParams: SchemaParams & { + properties: { + [k: string]: Schema; + }; + optionalProperties?: string[]; + }): ObjectSchema; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| objectParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) & { properties: { \[k: string\]: [Schema](./vertexai.schema.md#schema_class); }; optionalProperties?: string\[\]; } | | + +Returns: + +[ObjectSchema](./vertexai.objectschema.md#objectschema_class) + +## Schema.string() + +Signature: + +```typescript +static string(stringParams?: SchemaParams): StringSchema; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| stringParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | + +Returns: + +[StringSchema](./vertexai.stringschema.md#stringschema_class) + diff --git a/docs-devsite/vertexai.schemainterface.md b/docs-devsite/vertexai.schemainterface.md new file mode 100644 index 00000000000..3992c9e5116 --- /dev/null +++ b/docs-devsite/vertexai.schemainterface.md @@ -0,0 +1,36 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# SchemaInterface interface +Interface for [Schema](./vertexai.schema.md#schema_class) class. + +Signature: + +```typescript +export interface SchemaInterface extends SchemaShared +``` +Extends: [SchemaShared](./vertexai.schemashared.md#schemashared_interface)<[SchemaInterface](./vertexai.schemainterface.md#schemainterface_interface)> + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [type](./vertexai.schemainterface.md#schemainterfacetype) | [SchemaType](./vertexai.md#schematype) | The type of the property. [SchemaType](./vertexai.md#schematype). | + +## SchemaInterface.type + +The type of the property. [SchemaType](./vertexai.md#schematype). + +Signature: + +```typescript +type: SchemaType; +``` diff --git a/docs-devsite/vertexai.schemaparams.md b/docs-devsite/vertexai.schemaparams.md new file mode 100644 index 00000000000..3c6d9f385fd --- /dev/null +++ b/docs-devsite/vertexai.schemaparams.md @@ -0,0 +1,21 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# SchemaParams interface +Params passed to [Schema](./vertexai.schema.md#schema_class) static methods to create specific [Schema](./vertexai.schema.md#schema_class) classes. + +Signature: + +```typescript +export interface SchemaParams extends SchemaShared +``` +Extends: [SchemaShared](./vertexai.schemashared.md#schemashared_interface)<[SchemaInterface](./vertexai.schemainterface.md#schemainterface_interface)> + diff --git a/docs-devsite/vertexai.schemarequest.md b/docs-devsite/vertexai.schemarequest.md new file mode 100644 index 00000000000..f12259b1608 --- /dev/null +++ b/docs-devsite/vertexai.schemarequest.md @@ -0,0 +1,47 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# SchemaRequest interface +Final format for [Schema](./vertexai.schema.md#schema_class) params passed to backend requests. + +Signature: + +```typescript +export interface SchemaRequest extends SchemaShared +``` +Extends: [SchemaShared](./vertexai.schemashared.md#schemashared_interface)<[SchemaRequest](./vertexai.schemarequest.md#schemarequest_interface)> + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [required](./vertexai.schemarequest.md#schemarequestrequired) | string\[\] | Optional. Array of required property. | +| [type](./vertexai.schemarequest.md#schemarequesttype) | [SchemaType](./vertexai.md#schematype) | The type of the property. [SchemaType](./vertexai.md#schematype). | + +## SchemaRequest.required + +Optional. Array of required property. + +Signature: + +```typescript +required?: string[]; +``` + +## SchemaRequest.type + +The type of the property. [SchemaType](./vertexai.md#schematype). + +Signature: + +```typescript +type: SchemaType; +``` diff --git a/docs-devsite/vertexai.schemashared.md b/docs-devsite/vertexai.schemashared.md new file mode 100644 index 00000000000..50cc6464ecf --- /dev/null +++ b/docs-devsite/vertexai.schemashared.md @@ -0,0 +1,103 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# SchemaShared interface +Basic [Schema](./vertexai.schema.md#schema_class) properties shared across several Schema-related types. + +Signature: + +```typescript +export interface SchemaShared +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [description](./vertexai.schemashared.md#schemashareddescription) | string | Optional. The description of the property. | +| [enum](./vertexai.schemashared.md#schemasharedenum) | string\[\] | Optional. The enum of the property. | +| [example](./vertexai.schemashared.md#schemasharedexample) | unknown | Optional. The example of the property. | +| [format](./vertexai.schemashared.md#schemasharedformat) | string | Optional. The format of the property. | +| [items](./vertexai.schemashared.md#schemashareditems) | T | Optional. The items of the property. | +| [nullable](./vertexai.schemashared.md#schemasharednullable) | boolean | Optional. Whether the property is nullable. | +| [properties](./vertexai.schemashared.md#schemasharedproperties) | { \[k: string\]: T; } | Optional. Map of Schema objects. | + +## SchemaShared.description + +Optional. The description of the property. + +Signature: + +```typescript +description?: string; +``` + +## SchemaShared.enum + +Optional. The enum of the property. + +Signature: + +```typescript +enum?: string[]; +``` + +## SchemaShared.example + +Optional. The example of the property. + +Signature: + +```typescript +example?: unknown; +``` + +## SchemaShared.format + +Optional. The format of the property. + +Signature: + +```typescript +format?: string; +``` + +## SchemaShared.items + +Optional. The items of the property. + +Signature: + +```typescript +items?: T; +``` + +## SchemaShared.nullable + +Optional. Whether the property is nullable. + +Signature: + +```typescript +nullable?: boolean; +``` + +## SchemaShared.properties + +Optional. Map of `Schema` objects. + +Signature: + +```typescript +properties?: { + [k: string]: T; + }; +``` diff --git a/docs-devsite/vertexai-preview.segment.md b/docs-devsite/vertexai.segment.md similarity index 75% rename from docs-devsite/vertexai-preview.segment.md rename to docs-devsite/vertexai.segment.md index c64bc3ffcda..db61f00a149 100644 --- a/docs-devsite/vertexai-preview.segment.md +++ b/docs-devsite/vertexai.segment.md @@ -21,9 +21,9 @@ export interface Segment | Property | Type | Description | | --- | --- | --- | -| [endIndex](./vertexai-preview.segment.md#segmentendindex) | number | | -| [partIndex](./vertexai-preview.segment.md#segmentpartindex) | number | | -| [startIndex](./vertexai-preview.segment.md#segmentstartindex) | number | | +| [endIndex](./vertexai.segment.md#segmentendindex) | number | | +| [partIndex](./vertexai.segment.md#segmentpartindex) | number | | +| [startIndex](./vertexai.segment.md#segmentstartindex) | number | | ## Segment.endIndex diff --git a/docs-devsite/vertexai-preview.startchatparams.md b/docs-devsite/vertexai.startchatparams.md similarity index 51% rename from docs-devsite/vertexai-preview.startchatparams.md rename to docs-devsite/vertexai.startchatparams.md index f422f7a1ff0..e07bbd91d82 100644 --- a/docs-devsite/vertexai-preview.startchatparams.md +++ b/docs-devsite/vertexai.startchatparams.md @@ -10,23 +10,23 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # StartChatParams interface -Params for [GenerativeModel.startChat()](./vertexai-preview.generativemodel.md#generativemodelstartchat). +Params for [GenerativeModel.startChat()](./vertexai.generativemodel.md#generativemodelstartchat). Signature: ```typescript export interface StartChatParams extends BaseParams ``` -Extends: [BaseParams](./vertexai-preview.baseparams.md#baseparams_interface) +Extends: [BaseParams](./vertexai.baseparams.md#baseparams_interface) ## Properties | Property | Type | Description | | --- | --- | --- | -| [history](./vertexai-preview.startchatparams.md#startchatparamshistory) | [Content](./vertexai-preview.content.md#content_interface)\[\] | | -| [systemInstruction](./vertexai-preview.startchatparams.md#startchatparamssysteminstruction) | string \| [Part](./vertexai-preview.md#part) \| [Content](./vertexai-preview.content.md#content_interface) | | -| [toolConfig](./vertexai-preview.startchatparams.md#startchatparamstoolconfig) | [ToolConfig](./vertexai-preview.toolconfig.md#toolconfig_interface) | | -| [tools](./vertexai-preview.startchatparams.md#startchatparamstools) | [Tool](./vertexai-preview.md#tool)\[\] | | +| [history](./vertexai.startchatparams.md#startchatparamshistory) | [Content](./vertexai.content.md#content_interface)\[\] | | +| [systemInstruction](./vertexai.startchatparams.md#startchatparamssysteminstruction) | string \| [Part](./vertexai.md#part) \| [Content](./vertexai.content.md#content_interface) | | +| [toolConfig](./vertexai.startchatparams.md#startchatparamstoolconfig) | [ToolConfig](./vertexai.toolconfig.md#toolconfig_interface) | | +| [tools](./vertexai.startchatparams.md#startchatparamstools) | [Tool](./vertexai.md#tool)\[\] | | ## StartChatParams.history diff --git a/docs-devsite/vertexai.stringschema.md b/docs-devsite/vertexai.stringschema.md new file mode 100644 index 00000000000..bfafe0fe9df --- /dev/null +++ b/docs-devsite/vertexai.stringschema.md @@ -0,0 +1,57 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# StringSchema class +Schema class for "string" types. Can be used with or without enum values. + +Signature: + +```typescript +export declare class StringSchema extends Schema +``` +Extends: [Schema](./vertexai.schema.md#schema_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(schemaParams, enumValues)](./vertexai.stringschema.md#stringschemaconstructor) | | Constructs a new instance of the StringSchema class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [enum](./vertexai.stringschema.md#stringschemaenum) | | string\[\] | | + +## StringSchema.(constructor) + +Constructs a new instance of the `StringSchema` class + +Signature: + +```typescript +constructor(schemaParams?: SchemaParams, enumValues?: string[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| schemaParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | +| enumValues | string\[\] | | + +## StringSchema.enum + +Signature: + +```typescript +enum?: string[]; +``` diff --git a/docs-devsite/vertexai-preview.textpart.md b/docs-devsite/vertexai.textpart.md similarity index 72% rename from docs-devsite/vertexai-preview.textpart.md rename to docs-devsite/vertexai.textpart.md index 206168180b2..afee40a369d 100644 --- a/docs-devsite/vertexai-preview.textpart.md +++ b/docs-devsite/vertexai.textpart.md @@ -22,10 +22,10 @@ export interface TextPart | Property | Type | Description | | --- | --- | --- | -| [functionCall](./vertexai-preview.textpart.md#textpartfunctioncall) | never | | -| [functionResponse](./vertexai-preview.textpart.md#textpartfunctionresponse) | never | | -| [inlineData](./vertexai-preview.textpart.md#textpartinlinedata) | never | | -| [text](./vertexai-preview.textpart.md#textparttext) | string | | +| [functionCall](./vertexai.textpart.md#textpartfunctioncall) | never | | +| [functionResponse](./vertexai.textpart.md#textpartfunctionresponse) | never | | +| [inlineData](./vertexai.textpart.md#textpartinlinedata) | never | | +| [text](./vertexai.textpart.md#textparttext) | string | | ## TextPart.functionCall diff --git a/docs-devsite/vertexai-preview.toolconfig.md b/docs-devsite/vertexai.toolconfig.md similarity index 71% rename from docs-devsite/vertexai-preview.toolconfig.md rename to docs-devsite/vertexai.toolconfig.md index 4278eef509b..30c62c17c01 100644 --- a/docs-devsite/vertexai-preview.toolconfig.md +++ b/docs-devsite/vertexai.toolconfig.md @@ -22,12 +22,12 @@ export interface ToolConfig | Property | Type | Description | | --- | --- | --- | -| [functionCallingConfig](./vertexai-preview.toolconfig.md#toolconfigfunctioncallingconfig) | [FunctionCallingConfig](./vertexai-preview.functioncallingconfig.md#functioncallingconfig_interface) | | +| [functionCallingConfig](./vertexai.toolconfig.md#toolconfigfunctioncallingconfig) | [FunctionCallingConfig](./vertexai.functioncallingconfig.md#functioncallingconfig_interface) | | ## ToolConfig.functionCallingConfig Signature: ```typescript -functionCallingConfig: FunctionCallingConfig; +functionCallingConfig?: FunctionCallingConfig; ``` diff --git a/docs-devsite/vertexai-preview.usagemetadata.md b/docs-devsite/vertexai.usagemetadata.md similarity index 63% rename from docs-devsite/vertexai-preview.usagemetadata.md rename to docs-devsite/vertexai.usagemetadata.md index 2829c9dbd5d..d254f34335f 100644 --- a/docs-devsite/vertexai-preview.usagemetadata.md +++ b/docs-devsite/vertexai.usagemetadata.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # UsageMetadata interface -Usage metadata about a [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface). +Usage metadata about a [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface). Signature: @@ -22,9 +22,9 @@ export interface UsageMetadata | Property | Type | Description | | --- | --- | --- | -| [candidatesTokenCount](./vertexai-preview.usagemetadata.md#usagemetadatacandidatestokencount) | number | | -| [promptTokenCount](./vertexai-preview.usagemetadata.md#usagemetadataprompttokencount) | number | | -| [totalTokenCount](./vertexai-preview.usagemetadata.md#usagemetadatatotaltokencount) | number | | +| [candidatesTokenCount](./vertexai.usagemetadata.md#usagemetadatacandidatestokencount) | number | | +| [promptTokenCount](./vertexai.usagemetadata.md#usagemetadataprompttokencount) | number | | +| [totalTokenCount](./vertexai.usagemetadata.md#usagemetadatatotaltokencount) | number | | ## UsageMetadata.candidatesTokenCount diff --git a/docs-devsite/vertexai-preview.vertexai.md b/docs-devsite/vertexai.vertexai.md similarity index 58% rename from docs-devsite/vertexai-preview.vertexai.md rename to docs-devsite/vertexai.vertexai.md index 35991f2be12..4797bf8bada 100644 --- a/docs-devsite/vertexai-preview.vertexai.md +++ b/docs-devsite/vertexai.vertexai.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # VertexAI interface -An instance of the Vertex AI for Firebase SDK. +An instance of the Vertex AI in Firebase SDK. Signature: @@ -22,12 +22,12 @@ export interface VertexAI | Property | Type | Description | | --- | --- | --- | -| [app](./vertexai-preview.vertexai.md#vertexaiapp) | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) this [VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) instance is associated with. | -| [location](./vertexai-preview.vertexai.md#vertexailocation) | string | | +| [app](./vertexai.vertexai.md#vertexaiapp) | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) this [VertexAI](./vertexai.vertexai.md#vertexai_interface) instance is associated with. | +| [location](./vertexai.vertexai.md#vertexailocation) | string | | ## VertexAI.app -The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) this [VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) instance is associated with. +The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) this [VertexAI](./vertexai.vertexai.md#vertexai_interface) instance is associated with. Signature: diff --git a/docs-devsite/vertexai-preview.vertexaierror.md b/docs-devsite/vertexai.vertexaierror.md similarity index 55% rename from docs-devsite/vertexai-preview.vertexaierror.md rename to docs-devsite/vertexai.vertexaierror.md index 05a12c62b8e..86532ac6018 100644 --- a/docs-devsite/vertexai-preview.vertexaierror.md +++ b/docs-devsite/vertexai.vertexaierror.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # VertexAIError class -Error class for the Vertex AI for Firebase SDK. +Error class for the Vertex AI in Firebase SDK. Signature: @@ -23,15 +23,14 @@ export declare class VertexAIError extends FirebaseError | Constructor | Modifiers | Description | | --- | --- | --- | -| [(constructor)(code, message, customErrorData)](./vertexai-preview.vertexaierror.md#vertexaierrorconstructor) | | Constructs a new instance of the VertexAIError class. | +| [(constructor)(code, message, customErrorData)](./vertexai.vertexaierror.md#vertexaierrorconstructor) | | Constructs a new instance of the VertexAIError class. | ## Properties | Property | Modifiers | Type | Description | | --- | --- | --- | --- | -| [code](./vertexai-preview.vertexaierror.md#vertexaierrorcode) | | [VertexAIErrorCode](./vertexai-preview.md#vertexaierrorcode) | | -| [customErrorData](./vertexai-preview.vertexaierror.md#vertexaierrorcustomerrordata) | | [CustomErrorData](./vertexai-preview.customerrordata.md#customerrordata_interface) \| undefined | | -| [message](./vertexai-preview.vertexaierror.md#vertexaierrormessage) | | string | | +| [code](./vertexai.vertexaierror.md#vertexaierrorcode) | | [VertexAIErrorCode](./vertexai.md#vertexaierrorcode) | | +| [customErrorData](./vertexai.vertexaierror.md#vertexaierrorcustomerrordata) | | [CustomErrorData](./vertexai.customerrordata.md#customerrordata_interface) \| undefined | | ## VertexAIError.(constructor) @@ -47,9 +46,9 @@ constructor(code: VertexAIErrorCode, message: string, customErrorData?: CustomEr | Parameter | Type | Description | | --- | --- | --- | -| code | [VertexAIErrorCode](./vertexai-preview.md#vertexaierrorcode) | The error code from [VertexAIErrorCode](./vertexai-preview.md#vertexaierrorcode). | +| code | [VertexAIErrorCode](./vertexai.md#vertexaierrorcode) | The error code from [VertexAIErrorCode](./vertexai.md#vertexaierrorcode). | | message | string | A human-readable message describing the error. | -| customErrorData | [CustomErrorData](./vertexai-preview.customerrordata.md#customerrordata_interface) \| undefined | Optional error data. | +| customErrorData | [CustomErrorData](./vertexai.customerrordata.md#customerrordata_interface) \| undefined | Optional error data. | ## VertexAIError.code @@ -66,11 +65,3 @@ readonly code: VertexAIErrorCode; ```typescript readonly customErrorData?: CustomErrorData | undefined; ``` - -## VertexAIError.message - -Signature: - -```typescript -readonly message: string; -``` diff --git a/docs-devsite/vertexai-preview.vertexaioptions.md b/docs-devsite/vertexai.vertexaioptions.md similarity index 79% rename from docs-devsite/vertexai-preview.vertexaioptions.md rename to docs-devsite/vertexai.vertexaioptions.md index 320132c22f9..e15b525bfed 100644 --- a/docs-devsite/vertexai-preview.vertexaioptions.md +++ b/docs-devsite/vertexai.vertexaioptions.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # VertexAIOptions interface -Options when initializing the Vertex AI for Firebase SDK. +Options when initializing the Vertex AI in Firebase SDK. Signature: @@ -22,7 +22,7 @@ export interface VertexAIOptions | Property | Type | Description | | --- | --- | --- | -| [location](./vertexai-preview.vertexaioptions.md#vertexaioptionslocation) | string | | +| [location](./vertexai.vertexaioptions.md#vertexaioptionslocation) | string | | ## VertexAIOptions.location diff --git a/docs-devsite/vertexai-preview.videometadata.md b/docs-devsite/vertexai.videometadata.md similarity index 66% rename from docs-devsite/vertexai-preview.videometadata.md rename to docs-devsite/vertexai.videometadata.md index 04d8883bae9..b4f872c4e3d 100644 --- a/docs-devsite/vertexai-preview.videometadata.md +++ b/docs-devsite/vertexai.videometadata.md @@ -22,8 +22,8 @@ export interface VideoMetadata | Property | Type | Description | | --- | --- | --- | -| [endOffset](./vertexai-preview.videometadata.md#videometadataendoffset) | string | The end offset of the video in protobuf [Duration](https://cloud.google.com/ruby/docs/reference/google-cloud-workflows-v1/latest/Google-Protobuf-Duration#json-mapping) format. | -| [startOffset](./vertexai-preview.videometadata.md#videometadatastartoffset) | string | The start offset of the video in protobuf [Duration](https://cloud.google.com/ruby/docs/reference/google-cloud-workflows-v1/latest/Google-Protobuf-Duration#json-mapping) format. | +| [endOffset](./vertexai.videometadata.md#videometadataendoffset) | string | The end offset of the video in protobuf [Duration](https://cloud.google.com/ruby/docs/reference/google-cloud-workflows-v1/latest/Google-Protobuf-Duration#json-mapping) format. | +| [startOffset](./vertexai.videometadata.md#videometadatastartoffset) | string | The start offset of the video in protobuf [Duration](https://cloud.google.com/ruby/docs/reference/google-cloud-workflows-v1/latest/Google-Protobuf-Duration#json-mapping) format. | ## VideoMetadata.endOffset diff --git a/docs-devsite/vertexai-preview.webattribution.md b/docs-devsite/vertexai.webattribution.md similarity index 79% rename from docs-devsite/vertexai-preview.webattribution.md rename to docs-devsite/vertexai.webattribution.md index 5db6f94b82e..bb4fecf874d 100644 --- a/docs-devsite/vertexai-preview.webattribution.md +++ b/docs-devsite/vertexai.webattribution.md @@ -21,8 +21,8 @@ export interface WebAttribution | Property | Type | Description | | --- | --- | --- | -| [title](./vertexai-preview.webattribution.md#webattributiontitle) | string | | -| [uri](./vertexai-preview.webattribution.md#webattributionuri) | string | | +| [title](./vertexai.webattribution.md#webattributiontitle) | string | | +| [uri](./vertexai.webattribution.md#webattributionuri) | string | | ## WebAttribution.title From 877bf3c43f3cf12c8e9a6caeaa9124e51af6ea01 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 13 Nov 2024 14:53:44 -0700 Subject: [PATCH 35/59] Skipping pipeline tests for CI --- packages/firestore/test/integration/api/pipeline.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index 8b107a7ea65..9bdb35251d0 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -62,7 +62,7 @@ import { apiDescribe, withTestCollection } from '../util/helpers'; use(chaiAsPromised); useFirestorePipelines(); -apiDescribe('Pipelines', persistence => { +apiDescribe.skip('Pipelines', persistence => { addEqualityMatcher(); let firestore: Firestore; let randomCol: CollectionReference; From 1f7b0718a7e6d822d1cb376843b8061501ab83f3 Mon Sep 17 00:00:00 2001 From: MarkDuckworth Date: Wed, 13 Nov 2024 22:08:32 +0000 Subject: [PATCH 36/59] Update API reports --- common/api-review/firestore-lite.api.md | 6 +++--- common/api-review/firestore.api.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 8b7e4612dd9..165385bf890 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -2214,8 +2214,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9243:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9244:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9273:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9243:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9244:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9273:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index c1106de776c..d8beb999ddd 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -2490,8 +2490,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10106:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10106:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10133:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10106:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10106:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10133:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` From d9b6e9a8bec774d64e1174565415b8b19f939d18 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 13 Nov 2024 15:45:41 -0700 Subject: [PATCH 37/59] reverting changes to docs-devsite --- docs-devsite/_toc.yaml | 356 - docs-devsite/firestore_.accumulator.md | 39 - docs-devsite/firestore_.add.md | 49 - docs-devsite/firestore_.addfields.md | 64 - docs-devsite/firestore_.aggregate.md | 65 - docs-devsite/firestore_.and.md | 17 - docs-devsite/firestore_.arrayconcat.md | 49 - docs-devsite/firestore_.arraycontains.md | 67 - docs-devsite/firestore_.arraycontainsall.md | 67 - docs-devsite/firestore_.arraycontainsany.md | 67 - docs-devsite/firestore_.arrayelement.md | 41 - docs-devsite/firestore_.arraylength.md | 48 - docs-devsite/firestore_.arrayreverse.md | 48 - docs-devsite/firestore_.avg.md | 67 - docs-devsite/firestore_.bytelength.md | 48 - docs-devsite/firestore_.charlength.md | 48 - .../firestore_.collectiongroupsource.md | 64 - docs-devsite/firestore_.collectionsource.md | 64 - docs-devsite/firestore_.constant.md | 3504 ------- docs-devsite/firestore_.cosinedistance.md | 49 - docs-devsite/firestore_.count.md | 67 - docs-devsite/firestore_.databasesource.md | 39 - docs-devsite/firestore_.distinct.md | 64 - docs-devsite/firestore_.divide.md | 49 - docs-devsite/firestore_.documentssource.md | 92 - docs-devsite/firestore_.dotproduct.md | 49 - docs-devsite/firestore_.endswith.md | 67 - docs-devsite/firestore_.eq.md | 67 - docs-devsite/firestore_.euclideandistance.md | 49 - docs-devsite/firestore_.exists.md | 66 - docs-devsite/firestore_.exprwithalias.md | 3207 ------ docs-devsite/firestore_.field.md | 3275 ------ docs-devsite/firestore_.fields.md | 3210 ------ docs-devsite/firestore_.filtercondition.md | 39 - docs-devsite/firestore_.findnearest.md | 39 - docs-devsite/firestore_.findnearestoptions.md | 86 - docs-devsite/firestore_.firestore.md | 14 - docs-devsite/firestore_.firestorefunction.md | 3173 ------ docs-devsite/firestore_.genericstage.md | 65 - docs-devsite/firestore_.gt.md | 67 - docs-devsite/firestore_.gte.md | 67 - docs-devsite/firestore_.if.md | 68 - docs-devsite/firestore_.in.md | 67 - docs-devsite/firestore_.isnan.md | 66 - docs-devsite/firestore_.like.md | 67 - docs-devsite/firestore_.limit.md | 64 - docs-devsite/firestore_.logicalmax.md | 49 - docs-devsite/firestore_.logicalmin.md | 49 - docs-devsite/firestore_.lt.md | 67 - docs-devsite/firestore_.lte.md | 67 - docs-devsite/firestore_.mapget.md | 49 - docs-devsite/firestore_.max.md | 67 - docs-devsite/firestore_.md | 8980 ++--------------- docs-devsite/firestore_.min.md | 67 - docs-devsite/firestore_.mod.md | 49 - docs-devsite/firestore_.multiply.md | 49 - docs-devsite/firestore_.neq.md | 67 - docs-devsite/firestore_.not.md | 66 - docs-devsite/firestore_.offset.md | 64 - docs-devsite/firestore_.or.md | 17 - docs-devsite/firestore_.ordering.md | 51 - docs-devsite/firestore_.pipeline.md | 609 -- docs-devsite/firestore_.pipelineresult.md | 184 - docs-devsite/firestore_.pipelinesource.md | 109 - docs-devsite/firestore_.query.md | 14 - ...restore_.querycompositefilterconstraint.md | 2 +- docs-devsite/firestore_.regexcontains.md | 67 - docs-devsite/firestore_.regexmatch.md | 67 - docs-devsite/firestore_.replaceall.md | 50 - docs-devsite/firestore_.replacefirst.md | 50 - docs-devsite/firestore_.reverse.md | 48 - docs-devsite/firestore_.select.md | 64 - docs-devsite/firestore_.selectable.md | 39 - docs-devsite/firestore_.sort.md | 64 - docs-devsite/firestore_.stage.md | 38 - docs-devsite/firestore_.startswith.md | 67 - docs-devsite/firestore_.strconcat.md | 49 - docs-devsite/firestore_.strcontains.md | 67 - docs-devsite/firestore_.subtract.md | 49 - docs-devsite/firestore_.sum.md | 67 - docs-devsite/firestore_.timestampadd.md | 50 - docs-devsite/firestore_.timestampsub.md | 50 - .../firestore_.timestamptounixmicros.md | 48 - .../firestore_.timestamptounixmillis.md | 48 - .../firestore_.timestamptounixseconds.md | 48 - docs-devsite/firestore_.tolower.md | 48 - docs-devsite/firestore_.toupper.md | 48 - docs-devsite/firestore_.trim.md | 48 - .../firestore_.unixmicrostotimestamp.md | 48 - .../firestore_.unixmillistotimestamp.md | 48 - .../firestore_.unixsecondstotimestamp.md | 48 - docs-devsite/firestore_.vectorlength.md | 48 - docs-devsite/firestore_.where.md | 64 - docs-devsite/firestore_.xor.md | 66 - docs-devsite/firestore_lite.accumulator.md | 39 - docs-devsite/firestore_lite.add.md | 49 - docs-devsite/firestore_lite.addfields.md | 64 - docs-devsite/firestore_lite.aggregate.md | 65 - docs-devsite/firestore_lite.and.md | 17 - docs-devsite/firestore_lite.arrayconcat.md | 49 - docs-devsite/firestore_lite.arraycontains.md | 67 - .../firestore_lite.arraycontainsall.md | 67 - .../firestore_lite.arraycontainsany.md | 67 - docs-devsite/firestore_lite.arrayelement.md | 41 - docs-devsite/firestore_lite.arraylength.md | 48 - docs-devsite/firestore_lite.arrayreverse.md | 48 - docs-devsite/firestore_lite.avg.md | 67 - docs-devsite/firestore_lite.bytelength.md | 48 - docs-devsite/firestore_lite.charlength.md | 48 - .../firestore_lite.collectiongroupsource.md | 64 - .../firestore_lite.collectionsource.md | 64 - docs-devsite/firestore_lite.constant.md | 3504 ------- docs-devsite/firestore_lite.cosinedistance.md | 49 - docs-devsite/firestore_lite.count.md | 67 - docs-devsite/firestore_lite.databasesource.md | 39 - docs-devsite/firestore_lite.distinct.md | 64 - docs-devsite/firestore_lite.divide.md | 49 - .../firestore_lite.documentssource.md | 92 - docs-devsite/firestore_lite.dotproduct.md | 49 - docs-devsite/firestore_lite.endswith.md | 67 - docs-devsite/firestore_lite.eq.md | 67 - .../firestore_lite.euclideandistance.md | 49 - docs-devsite/firestore_lite.exists.md | 66 - docs-devsite/firestore_lite.exprwithalias.md | 3207 ------ docs-devsite/firestore_lite.field.md | 3275 ------ docs-devsite/firestore_lite.fields.md | 3210 ------ .../firestore_lite.filtercondition.md | 39 - docs-devsite/firestore_lite.findnearest.md | 39 - .../firestore_lite.findnearestoptions.md | 86 - docs-devsite/firestore_lite.firestore.md | 14 - .../firestore_lite.firestorefunction.md | 3173 ------ docs-devsite/firestore_lite.genericstage.md | 65 - docs-devsite/firestore_lite.gt.md | 67 - docs-devsite/firestore_lite.gte.md | 67 - docs-devsite/firestore_lite.if.md | 68 - docs-devsite/firestore_lite.in.md | 67 - docs-devsite/firestore_lite.isnan.md | 66 - docs-devsite/firestore_lite.like.md | 67 - docs-devsite/firestore_lite.limit.md | 64 - docs-devsite/firestore_lite.logicalmax.md | 49 - docs-devsite/firestore_lite.logicalmin.md | 49 - docs-devsite/firestore_lite.lt.md | 67 - docs-devsite/firestore_lite.lte.md | 67 - docs-devsite/firestore_lite.mapget.md | 49 - docs-devsite/firestore_lite.max.md | 67 - docs-devsite/firestore_lite.md | 8091 +-------------- docs-devsite/firestore_lite.min.md | 67 - docs-devsite/firestore_lite.mod.md | 49 - docs-devsite/firestore_lite.multiply.md | 49 - docs-devsite/firestore_lite.neq.md | 67 - docs-devsite/firestore_lite.not.md | 66 - docs-devsite/firestore_lite.offset.md | 64 - docs-devsite/firestore_lite.or.md | 17 - docs-devsite/firestore_lite.ordering.md | 51 - docs-devsite/firestore_lite.pipeline.md | 564 -- docs-devsite/firestore_lite.pipelineresult.md | 184 - docs-devsite/firestore_lite.pipelinesource.md | 109 - docs-devsite/firestore_lite.query.md | 14 - ...ore_lite.querycompositefilterconstraint.md | 2 +- docs-devsite/firestore_lite.regexcontains.md | 67 - docs-devsite/firestore_lite.regexmatch.md | 67 - docs-devsite/firestore_lite.replaceall.md | 50 - docs-devsite/firestore_lite.replacefirst.md | 50 - docs-devsite/firestore_lite.reverse.md | 48 - docs-devsite/firestore_lite.select.md | 64 - docs-devsite/firestore_lite.selectable.md | 39 - docs-devsite/firestore_lite.sort.md | 64 - docs-devsite/firestore_lite.stage.md | 38 - docs-devsite/firestore_lite.startswith.md | 67 - docs-devsite/firestore_lite.strconcat.md | 49 - docs-devsite/firestore_lite.strcontains.md | 67 - docs-devsite/firestore_lite.subtract.md | 49 - docs-devsite/firestore_lite.sum.md | 67 - docs-devsite/firestore_lite.timestampadd.md | 50 - docs-devsite/firestore_lite.timestampsub.md | 50 - .../firestore_lite.timestamptounixmicros.md | 48 - .../firestore_lite.timestamptounixmillis.md | 48 - .../firestore_lite.timestamptounixseconds.md | 48 - docs-devsite/firestore_lite.tolower.md | 48 - docs-devsite/firestore_lite.toupper.md | 48 - docs-devsite/firestore_lite.trim.md | 48 - .../firestore_lite.unixmicrostotimestamp.md | 48 - .../firestore_lite.unixmillistotimestamp.md | 48 - .../firestore_lite.unixsecondstotimestamp.md | 48 - docs-devsite/firestore_lite.vectorlength.md | 48 - docs-devsite/firestore_lite.where.md | 64 - docs-devsite/firestore_lite.xor.md | 66 - 187 files changed, 1490 insertions(+), 59572 deletions(-) delete mode 100644 docs-devsite/firestore_.accumulator.md delete mode 100644 docs-devsite/firestore_.add.md delete mode 100644 docs-devsite/firestore_.addfields.md delete mode 100644 docs-devsite/firestore_.aggregate.md delete mode 100644 docs-devsite/firestore_.and.md delete mode 100644 docs-devsite/firestore_.arrayconcat.md delete mode 100644 docs-devsite/firestore_.arraycontains.md delete mode 100644 docs-devsite/firestore_.arraycontainsall.md delete mode 100644 docs-devsite/firestore_.arraycontainsany.md delete mode 100644 docs-devsite/firestore_.arrayelement.md delete mode 100644 docs-devsite/firestore_.arraylength.md delete mode 100644 docs-devsite/firestore_.arrayreverse.md delete mode 100644 docs-devsite/firestore_.avg.md delete mode 100644 docs-devsite/firestore_.bytelength.md delete mode 100644 docs-devsite/firestore_.charlength.md delete mode 100644 docs-devsite/firestore_.collectiongroupsource.md delete mode 100644 docs-devsite/firestore_.collectionsource.md delete mode 100644 docs-devsite/firestore_.constant.md delete mode 100644 docs-devsite/firestore_.cosinedistance.md delete mode 100644 docs-devsite/firestore_.count.md delete mode 100644 docs-devsite/firestore_.databasesource.md delete mode 100644 docs-devsite/firestore_.distinct.md delete mode 100644 docs-devsite/firestore_.divide.md delete mode 100644 docs-devsite/firestore_.documentssource.md delete mode 100644 docs-devsite/firestore_.dotproduct.md delete mode 100644 docs-devsite/firestore_.endswith.md delete mode 100644 docs-devsite/firestore_.eq.md delete mode 100644 docs-devsite/firestore_.euclideandistance.md delete mode 100644 docs-devsite/firestore_.exists.md delete mode 100644 docs-devsite/firestore_.exprwithalias.md delete mode 100644 docs-devsite/firestore_.field.md delete mode 100644 docs-devsite/firestore_.fields.md delete mode 100644 docs-devsite/firestore_.filtercondition.md delete mode 100644 docs-devsite/firestore_.findnearest.md delete mode 100644 docs-devsite/firestore_.findnearestoptions.md delete mode 100644 docs-devsite/firestore_.firestorefunction.md delete mode 100644 docs-devsite/firestore_.genericstage.md delete mode 100644 docs-devsite/firestore_.gt.md delete mode 100644 docs-devsite/firestore_.gte.md delete mode 100644 docs-devsite/firestore_.if.md delete mode 100644 docs-devsite/firestore_.in.md delete mode 100644 docs-devsite/firestore_.isnan.md delete mode 100644 docs-devsite/firestore_.like.md delete mode 100644 docs-devsite/firestore_.limit.md delete mode 100644 docs-devsite/firestore_.logicalmax.md delete mode 100644 docs-devsite/firestore_.logicalmin.md delete mode 100644 docs-devsite/firestore_.lt.md delete mode 100644 docs-devsite/firestore_.lte.md delete mode 100644 docs-devsite/firestore_.mapget.md delete mode 100644 docs-devsite/firestore_.max.md delete mode 100644 docs-devsite/firestore_.min.md delete mode 100644 docs-devsite/firestore_.mod.md delete mode 100644 docs-devsite/firestore_.multiply.md delete mode 100644 docs-devsite/firestore_.neq.md delete mode 100644 docs-devsite/firestore_.not.md delete mode 100644 docs-devsite/firestore_.offset.md delete mode 100644 docs-devsite/firestore_.or.md delete mode 100644 docs-devsite/firestore_.ordering.md delete mode 100644 docs-devsite/firestore_.pipeline.md delete mode 100644 docs-devsite/firestore_.pipelineresult.md delete mode 100644 docs-devsite/firestore_.pipelinesource.md delete mode 100644 docs-devsite/firestore_.regexcontains.md delete mode 100644 docs-devsite/firestore_.regexmatch.md delete mode 100644 docs-devsite/firestore_.replaceall.md delete mode 100644 docs-devsite/firestore_.replacefirst.md delete mode 100644 docs-devsite/firestore_.reverse.md delete mode 100644 docs-devsite/firestore_.select.md delete mode 100644 docs-devsite/firestore_.selectable.md delete mode 100644 docs-devsite/firestore_.sort.md delete mode 100644 docs-devsite/firestore_.stage.md delete mode 100644 docs-devsite/firestore_.startswith.md delete mode 100644 docs-devsite/firestore_.strconcat.md delete mode 100644 docs-devsite/firestore_.strcontains.md delete mode 100644 docs-devsite/firestore_.subtract.md delete mode 100644 docs-devsite/firestore_.sum.md delete mode 100644 docs-devsite/firestore_.timestampadd.md delete mode 100644 docs-devsite/firestore_.timestampsub.md delete mode 100644 docs-devsite/firestore_.timestamptounixmicros.md delete mode 100644 docs-devsite/firestore_.timestamptounixmillis.md delete mode 100644 docs-devsite/firestore_.timestamptounixseconds.md delete mode 100644 docs-devsite/firestore_.tolower.md delete mode 100644 docs-devsite/firestore_.toupper.md delete mode 100644 docs-devsite/firestore_.trim.md delete mode 100644 docs-devsite/firestore_.unixmicrostotimestamp.md delete mode 100644 docs-devsite/firestore_.unixmillistotimestamp.md delete mode 100644 docs-devsite/firestore_.unixsecondstotimestamp.md delete mode 100644 docs-devsite/firestore_.vectorlength.md delete mode 100644 docs-devsite/firestore_.where.md delete mode 100644 docs-devsite/firestore_.xor.md delete mode 100644 docs-devsite/firestore_lite.accumulator.md delete mode 100644 docs-devsite/firestore_lite.add.md delete mode 100644 docs-devsite/firestore_lite.addfields.md delete mode 100644 docs-devsite/firestore_lite.aggregate.md delete mode 100644 docs-devsite/firestore_lite.and.md delete mode 100644 docs-devsite/firestore_lite.arrayconcat.md delete mode 100644 docs-devsite/firestore_lite.arraycontains.md delete mode 100644 docs-devsite/firestore_lite.arraycontainsall.md delete mode 100644 docs-devsite/firestore_lite.arraycontainsany.md delete mode 100644 docs-devsite/firestore_lite.arrayelement.md delete mode 100644 docs-devsite/firestore_lite.arraylength.md delete mode 100644 docs-devsite/firestore_lite.arrayreverse.md delete mode 100644 docs-devsite/firestore_lite.avg.md delete mode 100644 docs-devsite/firestore_lite.bytelength.md delete mode 100644 docs-devsite/firestore_lite.charlength.md delete mode 100644 docs-devsite/firestore_lite.collectiongroupsource.md delete mode 100644 docs-devsite/firestore_lite.collectionsource.md delete mode 100644 docs-devsite/firestore_lite.constant.md delete mode 100644 docs-devsite/firestore_lite.cosinedistance.md delete mode 100644 docs-devsite/firestore_lite.count.md delete mode 100644 docs-devsite/firestore_lite.databasesource.md delete mode 100644 docs-devsite/firestore_lite.distinct.md delete mode 100644 docs-devsite/firestore_lite.divide.md delete mode 100644 docs-devsite/firestore_lite.documentssource.md delete mode 100644 docs-devsite/firestore_lite.dotproduct.md delete mode 100644 docs-devsite/firestore_lite.endswith.md delete mode 100644 docs-devsite/firestore_lite.eq.md delete mode 100644 docs-devsite/firestore_lite.euclideandistance.md delete mode 100644 docs-devsite/firestore_lite.exists.md delete mode 100644 docs-devsite/firestore_lite.exprwithalias.md delete mode 100644 docs-devsite/firestore_lite.field.md delete mode 100644 docs-devsite/firestore_lite.fields.md delete mode 100644 docs-devsite/firestore_lite.filtercondition.md delete mode 100644 docs-devsite/firestore_lite.findnearest.md delete mode 100644 docs-devsite/firestore_lite.findnearestoptions.md delete mode 100644 docs-devsite/firestore_lite.firestorefunction.md delete mode 100644 docs-devsite/firestore_lite.genericstage.md delete mode 100644 docs-devsite/firestore_lite.gt.md delete mode 100644 docs-devsite/firestore_lite.gte.md delete mode 100644 docs-devsite/firestore_lite.if.md delete mode 100644 docs-devsite/firestore_lite.in.md delete mode 100644 docs-devsite/firestore_lite.isnan.md delete mode 100644 docs-devsite/firestore_lite.like.md delete mode 100644 docs-devsite/firestore_lite.limit.md delete mode 100644 docs-devsite/firestore_lite.logicalmax.md delete mode 100644 docs-devsite/firestore_lite.logicalmin.md delete mode 100644 docs-devsite/firestore_lite.lt.md delete mode 100644 docs-devsite/firestore_lite.lte.md delete mode 100644 docs-devsite/firestore_lite.mapget.md delete mode 100644 docs-devsite/firestore_lite.max.md delete mode 100644 docs-devsite/firestore_lite.min.md delete mode 100644 docs-devsite/firestore_lite.mod.md delete mode 100644 docs-devsite/firestore_lite.multiply.md delete mode 100644 docs-devsite/firestore_lite.neq.md delete mode 100644 docs-devsite/firestore_lite.not.md delete mode 100644 docs-devsite/firestore_lite.offset.md delete mode 100644 docs-devsite/firestore_lite.or.md delete mode 100644 docs-devsite/firestore_lite.ordering.md delete mode 100644 docs-devsite/firestore_lite.pipeline.md delete mode 100644 docs-devsite/firestore_lite.pipelineresult.md delete mode 100644 docs-devsite/firestore_lite.pipelinesource.md delete mode 100644 docs-devsite/firestore_lite.regexcontains.md delete mode 100644 docs-devsite/firestore_lite.regexmatch.md delete mode 100644 docs-devsite/firestore_lite.replaceall.md delete mode 100644 docs-devsite/firestore_lite.replacefirst.md delete mode 100644 docs-devsite/firestore_lite.reverse.md delete mode 100644 docs-devsite/firestore_lite.select.md delete mode 100644 docs-devsite/firestore_lite.selectable.md delete mode 100644 docs-devsite/firestore_lite.sort.md delete mode 100644 docs-devsite/firestore_lite.stage.md delete mode 100644 docs-devsite/firestore_lite.startswith.md delete mode 100644 docs-devsite/firestore_lite.strconcat.md delete mode 100644 docs-devsite/firestore_lite.strcontains.md delete mode 100644 docs-devsite/firestore_lite.subtract.md delete mode 100644 docs-devsite/firestore_lite.sum.md delete mode 100644 docs-devsite/firestore_lite.timestampadd.md delete mode 100644 docs-devsite/firestore_lite.timestampsub.md delete mode 100644 docs-devsite/firestore_lite.timestamptounixmicros.md delete mode 100644 docs-devsite/firestore_lite.timestamptounixmillis.md delete mode 100644 docs-devsite/firestore_lite.timestamptounixseconds.md delete mode 100644 docs-devsite/firestore_lite.tolower.md delete mode 100644 docs-devsite/firestore_lite.toupper.md delete mode 100644 docs-devsite/firestore_lite.trim.md delete mode 100644 docs-devsite/firestore_lite.unixmicrostotimestamp.md delete mode 100644 docs-devsite/firestore_lite.unixmillistotimestamp.md delete mode 100644 docs-devsite/firestore_lite.unixsecondstotimestamp.md delete mode 100644 docs-devsite/firestore_lite.vectorlength.md delete mode 100644 docs-devsite/firestore_lite.where.md delete mode 100644 docs-devsite/firestore_lite.xor.md diff --git a/docs-devsite/_toc.yaml b/docs-devsite/_toc.yaml index 26c520a12ba..a27f2832eb7 100644 --- a/docs-devsite/_toc.yaml +++ b/docs-devsite/_toc.yaml @@ -201,62 +201,16 @@ toc: - title: firestore path: /docs/reference/js/firestore_.md section: - - title: Accumulator - path: /docs/reference/js/firestore_.accumulator.md - - title: Add - path: /docs/reference/js/firestore_.add.md - - title: AddFields - path: /docs/reference/js/firestore_.addfields.md - - title: Aggregate - path: /docs/reference/js/firestore_.aggregate.md - title: AggregateField path: /docs/reference/js/firestore_.aggregatefield.md - title: AggregateQuerySnapshot path: /docs/reference/js/firestore_.aggregatequerysnapshot.md - title: AggregateSpec path: /docs/reference/js/firestore_.aggregatespec.md - - title: And - path: /docs/reference/js/firestore_.and.md - - title: ArrayConcat - path: /docs/reference/js/firestore_.arrayconcat.md - - title: ArrayContains - path: /docs/reference/js/firestore_.arraycontains.md - - title: ArrayContainsAll - path: /docs/reference/js/firestore_.arraycontainsall.md - - title: ArrayContainsAny - path: /docs/reference/js/firestore_.arraycontainsany.md - - title: ArrayElement - path: /docs/reference/js/firestore_.arrayelement.md - - title: ArrayLength - path: /docs/reference/js/firestore_.arraylength.md - - title: ArrayReverse - path: /docs/reference/js/firestore_.arrayreverse.md - - title: Avg - path: /docs/reference/js/firestore_.avg.md - - title: ByteLength - path: /docs/reference/js/firestore_.bytelength.md - title: Bytes path: /docs/reference/js/firestore_.bytes.md - - title: CharLength - path: /docs/reference/js/firestore_.charlength.md - - title: CollectionGroupSource - path: /docs/reference/js/firestore_.collectiongroupsource.md - title: CollectionReference path: /docs/reference/js/firestore_.collectionreference.md - - title: CollectionSource - path: /docs/reference/js/firestore_.collectionsource.md - - title: Constant - path: /docs/reference/js/firestore_.constant.md - - title: CosineDistance - path: /docs/reference/js/firestore_.cosinedistance.md - - title: Count - path: /docs/reference/js/firestore_.count.md - - title: DatabaseSource - path: /docs/reference/js/firestore_.databasesource.md - - title: Distinct - path: /docs/reference/js/firestore_.distinct.md - - title: Divide - path: /docs/reference/js/firestore_.divide.md - title: DocumentChange path: /docs/reference/js/firestore_.documentchange.md - title: DocumentData @@ -265,86 +219,32 @@ toc: path: /docs/reference/js/firestore_.documentreference.md - title: DocumentSnapshot path: /docs/reference/js/firestore_.documentsnapshot.md - - title: DocumentsSource - path: /docs/reference/js/firestore_.documentssource.md - - title: DotProduct - path: /docs/reference/js/firestore_.dotproduct.md - - title: EndsWith - path: /docs/reference/js/firestore_.endswith.md - - title: Eq - path: /docs/reference/js/firestore_.eq.md - - title: EuclideanDistance - path: /docs/reference/js/firestore_.euclideandistance.md - - title: Exists - path: /docs/reference/js/firestore_.exists.md - title: ExperimentalLongPollingOptions path: /docs/reference/js/firestore_.experimentallongpollingoptions.md - - title: ExprWithAlias - path: /docs/reference/js/firestore_.exprwithalias.md - - title: Field - path: /docs/reference/js/firestore_.field.md - title: FieldPath path: /docs/reference/js/firestore_.fieldpath.md - - title: Fields - path: /docs/reference/js/firestore_.fields.md - title: FieldValue path: /docs/reference/js/firestore_.fieldvalue.md - - title: FilterCondition - path: /docs/reference/js/firestore_.filtercondition.md - - title: FindNearest - path: /docs/reference/js/firestore_.findnearest.md - - title: FindNearestOptions - path: /docs/reference/js/firestore_.findnearestoptions.md - title: Firestore path: /docs/reference/js/firestore_.firestore.md - title: FirestoreDataConverter path: /docs/reference/js/firestore_.firestoredataconverter.md - title: FirestoreError path: /docs/reference/js/firestore_.firestoreerror.md - - title: FirestoreFunction - path: /docs/reference/js/firestore_.firestorefunction.md - title: FirestoreSettings path: /docs/reference/js/firestore_.firestoresettings.md - - title: GenericStage - path: /docs/reference/js/firestore_.genericstage.md - title: GeoPoint path: /docs/reference/js/firestore_.geopoint.md - - title: Gt - path: /docs/reference/js/firestore_.gt.md - - title: Gte - path: /docs/reference/js/firestore_.gte.md - - title: If - path: /docs/reference/js/firestore_.if.md - - title: In - path: /docs/reference/js/firestore_.in.md - title: Index path: /docs/reference/js/firestore_.index.md - title: IndexConfiguration path: /docs/reference/js/firestore_.indexconfiguration.md - title: IndexField path: /docs/reference/js/firestore_.indexfield.md - - title: IsNan - path: /docs/reference/js/firestore_.isnan.md - - title: Like - path: /docs/reference/js/firestore_.like.md - - title: Limit - path: /docs/reference/js/firestore_.limit.md - title: LoadBundleTask path: /docs/reference/js/firestore_.loadbundletask.md - title: LoadBundleTaskProgress path: /docs/reference/js/firestore_.loadbundletaskprogress.md - - title: LogicalMax - path: /docs/reference/js/firestore_.logicalmax.md - - title: LogicalMin - path: /docs/reference/js/firestore_.logicalmin.md - - title: Lt - path: /docs/reference/js/firestore_.lt.md - - title: Lte - path: /docs/reference/js/firestore_.lte.md - - title: MapGet - path: /docs/reference/js/firestore_.mapget.md - - title: Max - path: /docs/reference/js/firestore_.max.md - title: MemoryCacheSettings path: /docs/reference/js/firestore_.memorycachesettings.md - title: MemoryEagerGarbageCollector @@ -353,22 +253,6 @@ toc: path: /docs/reference/js/firestore_.memorylocalcache.md - title: MemoryLruGarbageCollector path: /docs/reference/js/firestore_.memorylrugarbagecollector.md - - title: Min - path: /docs/reference/js/firestore_.min.md - - title: Mod - path: /docs/reference/js/firestore_.mod.md - - title: Multiply - path: /docs/reference/js/firestore_.multiply.md - - title: Neq - path: /docs/reference/js/firestore_.neq.md - - title: Not - path: /docs/reference/js/firestore_.not.md - - title: Offset - path: /docs/reference/js/firestore_.offset.md - - title: Or - path: /docs/reference/js/firestore_.or.md - - title: Ordering - path: /docs/reference/js/firestore_.ordering.md - title: PersistenceSettings path: /docs/reference/js/firestore_.persistencesettings.md - title: PersistentCacheIndexManager @@ -383,12 +267,6 @@ toc: path: /docs/reference/js/firestore_.persistentsingletabmanager.md - title: PersistentSingleTabManagerSettings path: /docs/reference/js/firestore_.persistentsingletabmanagersettings.md - - title: Pipeline - path: /docs/reference/js/firestore_.pipeline.md - - title: PipelineResult - path: /docs/reference/js/firestore_.pipelineresult.md - - title: PipelineSource - path: /docs/reference/js/firestore_.pipelinesource.md - title: Query path: /docs/reference/js/firestore_.query.md - title: QueryCompositeFilterConstraint @@ -409,233 +287,55 @@ toc: path: /docs/reference/js/firestore_.querysnapshot.md - title: QueryStartAtConstraint path: /docs/reference/js/firestore_.querystartatconstraint.md - - title: RegexContains - path: /docs/reference/js/firestore_.regexcontains.md - - title: RegexMatch - path: /docs/reference/js/firestore_.regexmatch.md - - title: ReplaceAll - path: /docs/reference/js/firestore_.replaceall.md - - title: ReplaceFirst - path: /docs/reference/js/firestore_.replacefirst.md - - title: Reverse - path: /docs/reference/js/firestore_.reverse.md - - title: Select - path: /docs/reference/js/firestore_.select.md - - title: Selectable - path: /docs/reference/js/firestore_.selectable.md - title: SnapshotListenOptions path: /docs/reference/js/firestore_.snapshotlistenoptions.md - title: SnapshotMetadata path: /docs/reference/js/firestore_.snapshotmetadata.md - title: SnapshotOptions path: /docs/reference/js/firestore_.snapshotoptions.md - - title: Sort - path: /docs/reference/js/firestore_.sort.md - - title: Stage - path: /docs/reference/js/firestore_.stage.md - - title: StartsWith - path: /docs/reference/js/firestore_.startswith.md - - title: StrConcat - path: /docs/reference/js/firestore_.strconcat.md - - title: StrContains - path: /docs/reference/js/firestore_.strcontains.md - - title: Subtract - path: /docs/reference/js/firestore_.subtract.md - - title: Sum - path: /docs/reference/js/firestore_.sum.md - title: Timestamp path: /docs/reference/js/firestore_.timestamp.md - - title: TimestampAdd - path: /docs/reference/js/firestore_.timestampadd.md - - title: TimestampSub - path: /docs/reference/js/firestore_.timestampsub.md - - title: TimestampToUnixMicros - path: /docs/reference/js/firestore_.timestamptounixmicros.md - - title: TimestampToUnixMillis - path: /docs/reference/js/firestore_.timestamptounixmillis.md - - title: TimestampToUnixSeconds - path: /docs/reference/js/firestore_.timestamptounixseconds.md - - title: ToLower - path: /docs/reference/js/firestore_.tolower.md - - title: ToUpper - path: /docs/reference/js/firestore_.toupper.md - title: Transaction path: /docs/reference/js/firestore_.transaction.md - title: TransactionOptions path: /docs/reference/js/firestore_.transactionoptions.md - - title: Trim - path: /docs/reference/js/firestore_.trim.md - - title: UnixMicrosToTimestamp - path: /docs/reference/js/firestore_.unixmicrostotimestamp.md - - title: UnixMillisToTimestamp - path: /docs/reference/js/firestore_.unixmillistotimestamp.md - - title: UnixSecondsToTimestamp - path: /docs/reference/js/firestore_.unixsecondstotimestamp.md - title: Unsubscribe path: /docs/reference/js/firestore_.unsubscribe.md - - title: VectorLength - path: /docs/reference/js/firestore_.vectorlength.md - title: VectorValue path: /docs/reference/js/firestore_.vectorvalue.md - - title: Where - path: /docs/reference/js/firestore_.where.md - title: WriteBatch path: /docs/reference/js/firestore_.writebatch.md - - title: Xor - path: /docs/reference/js/firestore_.xor.md - title: firestore/lite path: /docs/reference/js/firestore_lite.md section: - - title: Accumulator - path: /docs/reference/js/firestore_lite.accumulator.md - - title: Add - path: /docs/reference/js/firestore_lite.add.md - - title: AddFields - path: /docs/reference/js/firestore_lite.addfields.md - - title: Aggregate - path: /docs/reference/js/firestore_lite.aggregate.md - title: AggregateField path: /docs/reference/js/firestore_lite.aggregatefield.md - title: AggregateQuerySnapshot path: /docs/reference/js/firestore_lite.aggregatequerysnapshot.md - title: AggregateSpec path: /docs/reference/js/firestore_lite.aggregatespec.md - - title: And - path: /docs/reference/js/firestore_lite.and.md - - title: ArrayConcat - path: /docs/reference/js/firestore_lite.arrayconcat.md - - title: ArrayContains - path: /docs/reference/js/firestore_lite.arraycontains.md - - title: ArrayContainsAll - path: /docs/reference/js/firestore_lite.arraycontainsall.md - - title: ArrayContainsAny - path: /docs/reference/js/firestore_lite.arraycontainsany.md - - title: ArrayElement - path: /docs/reference/js/firestore_lite.arrayelement.md - - title: ArrayLength - path: /docs/reference/js/firestore_lite.arraylength.md - - title: ArrayReverse - path: /docs/reference/js/firestore_lite.arrayreverse.md - - title: Avg - path: /docs/reference/js/firestore_lite.avg.md - - title: ByteLength - path: /docs/reference/js/firestore_lite.bytelength.md - title: Bytes path: /docs/reference/js/firestore_lite.bytes.md - - title: CharLength - path: /docs/reference/js/firestore_lite.charlength.md - - title: CollectionGroupSource - path: /docs/reference/js/firestore_lite.collectiongroupsource.md - title: CollectionReference path: /docs/reference/js/firestore_lite.collectionreference.md - - title: CollectionSource - path: /docs/reference/js/firestore_lite.collectionsource.md - - title: Constant - path: /docs/reference/js/firestore_lite.constant.md - - title: CosineDistance - path: /docs/reference/js/firestore_lite.cosinedistance.md - - title: Count - path: /docs/reference/js/firestore_lite.count.md - - title: DatabaseSource - path: /docs/reference/js/firestore_lite.databasesource.md - - title: Distinct - path: /docs/reference/js/firestore_lite.distinct.md - - title: Divide - path: /docs/reference/js/firestore_lite.divide.md - title: DocumentData path: /docs/reference/js/firestore_lite.documentdata.md - title: DocumentReference path: /docs/reference/js/firestore_lite.documentreference.md - title: DocumentSnapshot path: /docs/reference/js/firestore_lite.documentsnapshot.md - - title: DocumentsSource - path: /docs/reference/js/firestore_lite.documentssource.md - - title: DotProduct - path: /docs/reference/js/firestore_lite.dotproduct.md - - title: EndsWith - path: /docs/reference/js/firestore_lite.endswith.md - - title: Eq - path: /docs/reference/js/firestore_lite.eq.md - - title: EuclideanDistance - path: /docs/reference/js/firestore_lite.euclideandistance.md - - title: Exists - path: /docs/reference/js/firestore_lite.exists.md - - title: ExprWithAlias - path: /docs/reference/js/firestore_lite.exprwithalias.md - - title: Field - path: /docs/reference/js/firestore_lite.field.md - title: FieldPath path: /docs/reference/js/firestore_lite.fieldpath.md - - title: Fields - path: /docs/reference/js/firestore_lite.fields.md - title: FieldValue path: /docs/reference/js/firestore_lite.fieldvalue.md - - title: FilterCondition - path: /docs/reference/js/firestore_lite.filtercondition.md - - title: FindNearest - path: /docs/reference/js/firestore_lite.findnearest.md - - title: FindNearestOptions - path: /docs/reference/js/firestore_lite.findnearestoptions.md - title: Firestore path: /docs/reference/js/firestore_lite.firestore.md - title: FirestoreDataConverter path: /docs/reference/js/firestore_lite.firestoredataconverter.md - title: FirestoreError path: /docs/reference/js/firestore_lite.firestoreerror.md - - title: FirestoreFunction - path: /docs/reference/js/firestore_lite.firestorefunction.md - - title: GenericStage - path: /docs/reference/js/firestore_lite.genericstage.md - title: GeoPoint path: /docs/reference/js/firestore_lite.geopoint.md - - title: Gt - path: /docs/reference/js/firestore_lite.gt.md - - title: Gte - path: /docs/reference/js/firestore_lite.gte.md - - title: If - path: /docs/reference/js/firestore_lite.if.md - - title: In - path: /docs/reference/js/firestore_lite.in.md - - title: IsNan - path: /docs/reference/js/firestore_lite.isnan.md - - title: Like - path: /docs/reference/js/firestore_lite.like.md - - title: Limit - path: /docs/reference/js/firestore_lite.limit.md - - title: LogicalMax - path: /docs/reference/js/firestore_lite.logicalmax.md - - title: LogicalMin - path: /docs/reference/js/firestore_lite.logicalmin.md - - title: Lt - path: /docs/reference/js/firestore_lite.lt.md - - title: Lte - path: /docs/reference/js/firestore_lite.lte.md - - title: MapGet - path: /docs/reference/js/firestore_lite.mapget.md - - title: Max - path: /docs/reference/js/firestore_lite.max.md - - title: Min - path: /docs/reference/js/firestore_lite.min.md - - title: Mod - path: /docs/reference/js/firestore_lite.mod.md - - title: Multiply - path: /docs/reference/js/firestore_lite.multiply.md - - title: Neq - path: /docs/reference/js/firestore_lite.neq.md - - title: Not - path: /docs/reference/js/firestore_lite.not.md - - title: Offset - path: /docs/reference/js/firestore_lite.offset.md - - title: Or - path: /docs/reference/js/firestore_lite.or.md - - title: Ordering - path: /docs/reference/js/firestore_lite.ordering.md - - title: Pipeline - path: /docs/reference/js/firestore_lite.pipeline.md - - title: PipelineResult - path: /docs/reference/js/firestore_lite.pipelineresult.md - - title: PipelineSource - path: /docs/reference/js/firestore_lite.pipelinesource.md - title: Query path: /docs/reference/js/firestore_lite.query.md - title: QueryCompositeFilterConstraint @@ -656,74 +356,18 @@ toc: path: /docs/reference/js/firestore_lite.querysnapshot.md - title: QueryStartAtConstraint path: /docs/reference/js/firestore_lite.querystartatconstraint.md - - title: RegexContains - path: /docs/reference/js/firestore_lite.regexcontains.md - - title: RegexMatch - path: /docs/reference/js/firestore_lite.regexmatch.md - - title: ReplaceAll - path: /docs/reference/js/firestore_lite.replaceall.md - - title: ReplaceFirst - path: /docs/reference/js/firestore_lite.replacefirst.md - - title: Reverse - path: /docs/reference/js/firestore_lite.reverse.md - - title: Select - path: /docs/reference/js/firestore_lite.select.md - - title: Selectable - path: /docs/reference/js/firestore_lite.selectable.md - title: Settings path: /docs/reference/js/firestore_lite.settings.md - - title: Sort - path: /docs/reference/js/firestore_lite.sort.md - - title: Stage - path: /docs/reference/js/firestore_lite.stage.md - - title: StartsWith - path: /docs/reference/js/firestore_lite.startswith.md - - title: StrConcat - path: /docs/reference/js/firestore_lite.strconcat.md - - title: StrContains - path: /docs/reference/js/firestore_lite.strcontains.md - - title: Subtract - path: /docs/reference/js/firestore_lite.subtract.md - - title: Sum - path: /docs/reference/js/firestore_lite.sum.md - title: Timestamp path: /docs/reference/js/firestore_lite.timestamp.md - - title: TimestampAdd - path: /docs/reference/js/firestore_lite.timestampadd.md - - title: TimestampSub - path: /docs/reference/js/firestore_lite.timestampsub.md - - title: TimestampToUnixMicros - path: /docs/reference/js/firestore_lite.timestamptounixmicros.md - - title: TimestampToUnixMillis - path: /docs/reference/js/firestore_lite.timestamptounixmillis.md - - title: TimestampToUnixSeconds - path: /docs/reference/js/firestore_lite.timestamptounixseconds.md - - title: ToLower - path: /docs/reference/js/firestore_lite.tolower.md - - title: ToUpper - path: /docs/reference/js/firestore_lite.toupper.md - title: Transaction path: /docs/reference/js/firestore_lite.transaction.md - title: TransactionOptions path: /docs/reference/js/firestore_lite.transactionoptions.md - - title: Trim - path: /docs/reference/js/firestore_lite.trim.md - - title: UnixMicrosToTimestamp - path: /docs/reference/js/firestore_lite.unixmicrostotimestamp.md - - title: UnixMillisToTimestamp - path: /docs/reference/js/firestore_lite.unixmillistotimestamp.md - - title: UnixSecondsToTimestamp - path: /docs/reference/js/firestore_lite.unixsecondstotimestamp.md - - title: VectorLength - path: /docs/reference/js/firestore_lite.vectorlength.md - title: VectorValue path: /docs/reference/js/firestore_lite.vectorvalue.md - - title: Where - path: /docs/reference/js/firestore_lite.where.md - title: WriteBatch path: /docs/reference/js/firestore_lite.writebatch.md - - title: Xor - path: /docs/reference/js/firestore_lite.xor.md - title: functions path: /docs/reference/js/functions.md section: diff --git a/docs-devsite/firestore_.accumulator.md b/docs-devsite/firestore_.accumulator.md deleted file mode 100644 index 540bb3da217..00000000000 --- a/docs-devsite/firestore_.accumulator.md +++ /dev/null @@ -1,39 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Accumulator interface -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -An interface that represents an accumulator. - -Signature: - -```typescript -export declare interface Accumulator -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [accumulator](./firestore_.accumulator.md#accumulatoraccumulator) | true | (BETA) | - -## Accumulator.accumulator - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -accumulator: true; -``` diff --git a/docs-devsite/firestore_.add.md b/docs-devsite/firestore_.add.md deleted file mode 100644 index 5fa68c68d84..00000000000 --- a/docs-devsite/firestore_.add.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Add class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Add extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_.add.md#addconstructor) | | (BETA) Constructs a new instance of the Add class | - -## Add.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Add` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | | -| right | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.addfields.md b/docs-devsite/firestore_.addfields.md deleted file mode 100644 index 23cf88da2d0..00000000000 --- a/docs-devsite/firestore_.addfields.md +++ /dev/null @@ -1,64 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# AddFields class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class AddFields implements Stage -``` -Implements: [Stage](./firestore_.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(fields)](./firestore_.addfields.md#addfieldsconstructor) | | (BETA) Constructs a new instance of the AddFields class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_.addfields.md#addfieldsname) | | string | (BETA) | - -## AddFields.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `AddFields` class - -Signature: - -```typescript -constructor(fields: Map); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| fields | Map<string, [Constant](./firestore_.constant.md#constant_class)> | | - -## AddFields.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_.aggregate.md b/docs-devsite/firestore_.aggregate.md deleted file mode 100644 index 0868c5edc95..00000000000 --- a/docs-devsite/firestore_.aggregate.md +++ /dev/null @@ -1,65 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Aggregate class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Aggregate implements Stage -``` -Implements: [Stage](./firestore_.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(accumulators, groups)](./firestore_.aggregate.md#aggregateconstructor) | | (BETA) Constructs a new instance of the Aggregate class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_.aggregate.md#aggregatename) | | string | (BETA) | - -## Aggregate.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Aggregate` class - -Signature: - -```typescript -constructor(accumulators: Map, groups: Map); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| accumulators | Map<string, [Accumulator](./firestore_.accumulator.md#accumulator_interface)> | | -| groups | Map<string, [Constant](./firestore_.constant.md#constant_class)> | | - -## Aggregate.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_.and.md b/docs-devsite/firestore_.and.md deleted file mode 100644 index 59b0a32b25d..00000000000 --- a/docs-devsite/firestore_.and.md +++ /dev/null @@ -1,17 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# and namespace -Signature: - -```typescript -export declare namespace and -``` diff --git a/docs-devsite/firestore_.arrayconcat.md b/docs-devsite/firestore_.arrayconcat.md deleted file mode 100644 index d7f104b6954..00000000000 --- a/docs-devsite/firestore_.arrayconcat.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ArrayConcat class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ArrayConcat extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(array, elements)](./firestore_.arrayconcat.md#arrayconcatconstructor) | | (BETA) Constructs a new instance of the ArrayConcat class | - -## ArrayConcat.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ArrayConcat` class - -Signature: - -```typescript -constructor(array: Constant, elements: Constant[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_.constant.md#constant_class) | | -| elements | [Constant](./firestore_.constant.md#constant_class)\[\] | | - diff --git a/docs-devsite/firestore_.arraycontains.md b/docs-devsite/firestore_.arraycontains.md deleted file mode 100644 index c56ae8b281d..00000000000 --- a/docs-devsite/firestore_.arraycontains.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ArrayContains class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ArrayContains extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(array, element)](./firestore_.arraycontains.md#arraycontainsconstructor) | | (BETA) Constructs a new instance of the ArrayContains class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_.arraycontains.md#arraycontainsfilterable) | | true | (BETA) | - -## ArrayContains.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ArrayContains` class - -Signature: - -```typescript -constructor(array: Constant, element: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_.constant.md#constant_class) | | -| element | [Constant](./firestore_.constant.md#constant_class) | | - -## ArrayContains.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_.arraycontainsall.md b/docs-devsite/firestore_.arraycontainsall.md deleted file mode 100644 index 0509d2ee79d..00000000000 --- a/docs-devsite/firestore_.arraycontainsall.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ArrayContainsAll class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ArrayContainsAll extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(array, values)](./firestore_.arraycontainsall.md#arraycontainsallconstructor) | | (BETA) Constructs a new instance of the ArrayContainsAll class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_.arraycontainsall.md#arraycontainsallfilterable) | | true | (BETA) | - -## ArrayContainsAll.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ArrayContainsAll` class - -Signature: - -```typescript -constructor(array: Constant, values: Constant[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_.constant.md#constant_class) | | -| values | [Constant](./firestore_.constant.md#constant_class)\[\] | | - -## ArrayContainsAll.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_.arraycontainsany.md b/docs-devsite/firestore_.arraycontainsany.md deleted file mode 100644 index 0736b7b198b..00000000000 --- a/docs-devsite/firestore_.arraycontainsany.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ArrayContainsAny class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ArrayContainsAny extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(array, values)](./firestore_.arraycontainsany.md#arraycontainsanyconstructor) | | (BETA) Constructs a new instance of the ArrayContainsAny class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_.arraycontainsany.md#arraycontainsanyfilterable) | | true | (BETA) | - -## ArrayContainsAny.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ArrayContainsAny` class - -Signature: - -```typescript -constructor(array: Constant, values: Constant[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_.constant.md#constant_class) | | -| values | [Constant](./firestore_.constant.md#constant_class)\[\] | | - -## ArrayContainsAny.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_.arrayelement.md b/docs-devsite/firestore_.arrayelement.md deleted file mode 100644 index e8dcd7e04b7..00000000000 --- a/docs-devsite/firestore_.arrayelement.md +++ /dev/null @@ -1,41 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ArrayElement class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ArrayElement extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)()](./firestore_.arrayelement.md#arrayelementconstructor) | | (BETA) Constructs a new instance of the ArrayElement class | - -## ArrayElement.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ArrayElement` class - -Signature: - -```typescript -constructor(); -``` diff --git a/docs-devsite/firestore_.arraylength.md b/docs-devsite/firestore_.arraylength.md deleted file mode 100644 index 88b3b3fa624..00000000000 --- a/docs-devsite/firestore_.arraylength.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ArrayLength class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ArrayLength extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(array)](./firestore_.arraylength.md#arraylengthconstructor) | | (BETA) Constructs a new instance of the ArrayLength class | - -## ArrayLength.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ArrayLength` class - -Signature: - -```typescript -constructor(array: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.arrayreverse.md b/docs-devsite/firestore_.arrayreverse.md deleted file mode 100644 index bc7e06c72a7..00000000000 --- a/docs-devsite/firestore_.arrayreverse.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ArrayReverse class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ArrayReverse extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(array)](./firestore_.arrayreverse.md#arrayreverseconstructor) | | (BETA) Constructs a new instance of the ArrayReverse class | - -## ArrayReverse.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ArrayReverse` class - -Signature: - -```typescript -constructor(array: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.avg.md b/docs-devsite/firestore_.avg.md deleted file mode 100644 index e93ade31d62..00000000000 --- a/docs-devsite/firestore_.avg.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Avg class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Avg extends FirestoreFunction implements Accumulator -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [Accumulator](./firestore_.accumulator.md#accumulator_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value, distinct)](./firestore_.avg.md#avgconstructor) | | (BETA) Constructs a new instance of the Avg class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [accumulator](./firestore_.avg.md#avgaccumulator) | | true | (BETA) | - -## Avg.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Avg` class - -Signature: - -```typescript -constructor(value: Constant, distinct: boolean); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) | | -| distinct | boolean | | - -## Avg.accumulator - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -accumulator: true; -``` diff --git a/docs-devsite/firestore_.bytelength.md b/docs-devsite/firestore_.bytelength.md deleted file mode 100644 index 7b7055b2951..00000000000 --- a/docs-devsite/firestore_.bytelength.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ByteLength class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ByteLength extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value)](./firestore_.bytelength.md#bytelengthconstructor) | | (BETA) Constructs a new instance of the ByteLength class | - -## ByteLength.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ByteLength` class - -Signature: - -```typescript -constructor(value: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.charlength.md b/docs-devsite/firestore_.charlength.md deleted file mode 100644 index cb978a4675f..00000000000 --- a/docs-devsite/firestore_.charlength.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# CharLength class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class CharLength extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value)](./firestore_.charlength.md#charlengthconstructor) | | (BETA) Constructs a new instance of the CharLength class | - -## CharLength.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `CharLength` class - -Signature: - -```typescript -constructor(value: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.collectiongroupsource.md b/docs-devsite/firestore_.collectiongroupsource.md deleted file mode 100644 index 58d0d7e9b25..00000000000 --- a/docs-devsite/firestore_.collectiongroupsource.md +++ /dev/null @@ -1,64 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# CollectionGroupSource class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class CollectionGroupSource implements Stage -``` -Implements: [Stage](./firestore_.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(collectionId)](./firestore_.collectiongroupsource.md#collectiongroupsourceconstructor) | | (BETA) Constructs a new instance of the CollectionGroupSource class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_.collectiongroupsource.md#collectiongroupsourcename) | | string | (BETA) | - -## CollectionGroupSource.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `CollectionGroupSource` class - -Signature: - -```typescript -constructor(collectionId: string); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| collectionId | string | | - -## CollectionGroupSource.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_.collectionsource.md b/docs-devsite/firestore_.collectionsource.md deleted file mode 100644 index d5b485ea610..00000000000 --- a/docs-devsite/firestore_.collectionsource.md +++ /dev/null @@ -1,64 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# CollectionSource class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class CollectionSource implements Stage -``` -Implements: [Stage](./firestore_.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(collectionPath)](./firestore_.collectionsource.md#collectionsourceconstructor) | | (BETA) Constructs a new instance of the CollectionSource class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_.collectionsource.md#collectionsourcename) | | string | (BETA) | - -## CollectionSource.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `CollectionSource` class - -Signature: - -```typescript -constructor(collectionPath: string); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| collectionPath | string | | - -## CollectionSource.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_.constant.md b/docs-devsite/firestore_.constant.md deleted file mode 100644 index 42463dbc01d..00000000000 --- a/docs-devsite/firestore_.constant.md +++ /dev/null @@ -1,3504 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Constant class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Represents a constant value that can be used in a Firestore pipeline expression. - -You can create a `Constant` instance using the static method: - -```typescript -// Create a Constant instance for the number 10 -const ten = Constant.of(10); - -// Create a Constant instance for the string "hello" -const hello = Constant.of("hello"); - -``` - -Signature: - -```typescript -export declare class Constant -``` - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [exprType](./firestore_.constant.md#constantexprtype) | | [ExprType](./firestore_.md#exprtype) | (BETA) | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [add(other)](./firestore_.constant.md#constantadd) | | (BETA) Creates an expression that adds this expression to another expression. -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -Field.of("quantity").add(Field.of("reserve")); - -``` - | -| [add(other)](./firestore_.constant.md#constantadd) | | (BETA) Creates an expression that adds this expression to a constant value. -```typescript -// Add 5 to the value of the 'age' field -Field.of("age").add(5); - -``` - | -| [arrayConcat(arrays)](./firestore_.constant.md#constantarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. -```typescript -// Combine the 'items' array with another array field. -Field.of("items").arrayConcat(Field.of("otherItems")); - -``` - | -| [arrayConcat(arrays)](./firestore_.constant.md#constantarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. -```typescript -// Combine the 'tags' array with a new array and an array field -Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); - -``` - | -| [arrayContains(element)](./firestore_.constant.md#constantarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific element. -```typescript -// Check if the 'sizes' array contains the value from the 'selectedSize' field -Field.of("sizes").arrayContains(Field.of("selectedSize")); - -``` - | -| [arrayContains(element)](./firestore_.constant.md#constantarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific value. -```typescript -// Check if the 'colors' array contains "red" -Field.of("colors").arrayContains("red"); - -``` - | -| [arrayContainsAll(values)](./firestore_.constant.md#constantarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. -```typescript -// Check if the 'tags' array contains both "news" and "sports" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - | -| [arrayContainsAll(values)](./firestore_.constant.md#constantarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - | -| [arrayContainsAny(values)](./firestore_.constant.md#constantarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "cate2" -Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); - -``` - | -| [arrayContainsAny(values)](./firestore_.constant.md#constantarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); - -``` - | -| [arrayLength()](./firestore_.constant.md#constantarraylength) | | (BETA) Creates an expression that calculates the length of an array. -```typescript -// Get the number of items in the 'cart' array -Field.of("cart").arrayLength(); - -``` - A new Expr representing the length of the array. | -| [as(name)](./firestore_.constant.md#constantas) | | (BETA) Assigns an alias to this expression.Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. -```typescript -// Calculate the total price and assign it the alias "totalPrice" and add it to the output. -firestore.pipeline().collection("items") -.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); - -``` - | -| [ascending()](./firestore_.constant.md#constantascending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. -```typescript -// Sort documents by the 'name' field in ascending order -pipeline().collection("users") -.sort(Field.of("name").ascending()); - -``` - A new Ordering for ascending sorting. | -| [avg()](./firestore_.constant.md#constantavg) | | (BETA) Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. -```typescript -// Calculate the average age of users -Field.of("age").avg().as("averageAge"); - -``` - A new Accumulator representing the 'avg' aggregation. | -| [byteLength()](./firestore_.constant.md#constantbytelength) | | (BETA) Creates an expression that calculates the length of this string expression in bytes. -```typescript -// Calculate the length of the 'myString' field in bytes. -Field.of("myString").byteLength(); - -``` - A new representing the length of the string in bytes. | -| [charLength()](./firestore_.constant.md#constantcharlength) | | (BETA) Creates an expression that calculates the character length of a string in UTF-8. -```typescript -// Get the character length of the 'name' field in its UTF-8 form. -Field.of("name").charLength(); - -``` - A new Expr representing the length of the string. | -| [cosineDistance(other)](./firestore_.constant.md#constantcosinedistance) | | (BETA) Calculates the cosine distance between two vectors. -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -Field.of("userVector").cosineDistance(Field.of("itemVector")); - -``` - | -| [cosineDistance(other)](./firestore_.constant.md#constantcosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); - -``` - | -| [cosineDistance(other)](./firestore_.constant.md#constantcosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance([37.7749, -122.4194]); - -``` - | -| [count()](./firestore_.constant.md#constantcount) | | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. -```typescript -// Count the total number of products -Field.of("productId").count().as("totalProducts"); - -``` - A new Accumulator representing the 'count' aggregation. | -| [descending()](./firestore_.constant.md#constantdescending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") -.sort(Field.of("createdAt").descending()); - -``` - A new Ordering for descending sorting. | -| [divide(other)](./firestore_.constant.md#constantdivide) | | (BETA) Creates an expression that divides this expression by another expression. -```typescript -// Divide the 'total' field by the 'count' field -Field.of("total").divide(Field.of("count")); - -``` - | -| [divide(other)](./firestore_.constant.md#constantdivide) | | (BETA) Creates an expression that divides this expression by a constant value. -```typescript -// Divide the 'value' field by 10 -Field.of("value").divide(10); - -``` - | -| [dotProduct(other)](./firestore_.constant.md#constantdotproduct) | | (BETA) Calculates the dot product between two vectors. -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct([0.5, 0.8, 0.2]); - -``` - | -| [dotProduct(other)](./firestore_.constant.md#constantdotproduct) | | (BETA) Calculates the dot product between two vectors. -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); - -``` - | -| [dotProduct(other)](./firestore_.constant.md#constantdotproduct) | | (BETA) | -| [endsWith(suffix)](./firestore_.constant.md#constantendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix. -```typescript -// Check if the 'filename' field ends with ".txt" -Field.of("filename").endsWith(".txt"); - -``` - | -| [endsWith(suffix)](./firestore_.constant.md#constantendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix (represented as an expression). -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -Field.of("url").endsWith(Field.of("extension")); - -``` - | -| [eq(other)](./firestore_.constant.md#constanteq) | | (BETA) Creates an expression that checks if this expression is equal to another expression. -```typescript -// Check if the 'age' field is equal to 21 -Field.of("age").eq(21); - -``` - | -| [eq(other)](./firestore_.constant.md#constanteq) | | (BETA) Creates an expression that checks if this expression is equal to a constant value. -```typescript -// Check if the 'city' field is equal to "London" -Field.of("city").eq("London"); - -``` - | -| [euclideanDistance(other)](./firestore_.constant.md#constanteuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance([37.7749, -122.4194]); - -``` - | -| [euclideanDistance(other)](./firestore_.constant.md#constanteuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); - -``` - | -| [euclideanDistance(other)](./firestore_.constant.md#constanteuclideandistance) | | (BETA) | -| [exists()](./firestore_.constant.md#constantexists) | | (BETA) Creates an expression that checks if a field exists in the document. -```typescript -// Check if the document has a field named "phoneNumber" -Field.of("phoneNumber").exists(); - -``` - A new Expr representing the 'exists' check. | -| [gt(other)](./firestore_.constant.md#constantgt) | | (BETA) Creates an expression that checks if this expression is greater than another expression. -```typescript -// Check if the 'age' field is greater than the 'limit' field -Field.of("age").gt(Field.of("limit")); - -``` - | -| [gt(other)](./firestore_.constant.md#constantgt) | | (BETA) Creates an expression that checks if this expression is greater than a constant value. -```typescript -// Check if the 'price' field is greater than 100 -Field.of("price").gt(100); - -``` - | -| [gte(other)](./firestore_.constant.md#constantgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to another expression. -```typescript -// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 -Field.of("quantity").gte(Field.of('requirement').add(1)); - -``` - | -| [gte(other)](./firestore_.constant.md#constantgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to a constant value. -```typescript -// Check if the 'score' field is greater than or equal to 80 -Field.of("score").gte(80); - -``` - | -| [in(others)](./firestore_.constant.md#constantin) | | (BETA) Creates an expression that checks if this expression is equal to any of the provided values or expressions. -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -Field.of("category").in("Electronics", Field.of("primaryType")); - -``` - | -| [in(others)](./firestore_.constant.md#constantin) | | (BETA) | -| [isNaN()](./firestore_.constant.md#constantisnan) | | (BETA) Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). -```typescript -// Check if the result of a calculation is NaN -Field.of("value").divide(0).isNaN(); - -``` - A new Expr representing the 'isNaN' check. | -| [like(pattern)](./firestore_.constant.md#constantlike) | | (BETA) Creates an expression that performs a case-sensitive string comparison. -```typescript -// Check if the 'title' field contains the word "guide" (case-sensitive) -Field.of("title").like("%guide%"); - -``` - | -| [like(pattern)](./firestore_.constant.md#constantlike) | | (BETA) | -| [logicalMax(other)](./firestore_.constant.md#constantlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMax(Function.currentTimestamp()); - -``` - | -| [logicalMax(other)](./firestore_.constant.md#constantlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'value' field and 10. -Field.of("value").logicalMax(10); - -``` - | -| [logicalMin(other)](./firestore_.constant.md#constantlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMin(Function.currentTimestamp()); - -``` - | -| [logicalMin(other)](./firestore_.constant.md#constantlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'value' field and 10. -Field.of("value").logicalMin(10); - -``` - | -| [lt(other)](./firestore_.constant.md#constantlt) | | (BETA) Creates an expression that checks if this expression is less than another expression. -```typescript -// Check if the 'age' field is less than 'limit' -Field.of("age").lt(Field.of('limit')); - -``` - | -| [lt(other)](./firestore_.constant.md#constantlt) | | (BETA) Creates an expression that checks if this expression is less than a constant value. -```typescript -// Check if the 'price' field is less than 50 -Field.of("price").lt(50); - -``` - | -| [lte(other)](./firestore_.constant.md#constantlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to another expression. -```typescript -// Check if the 'quantity' field is less than or equal to 20 -Field.of("quantity").lte(Constant.of(20)); - -``` - | -| [lte(other)](./firestore_.constant.md#constantlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to a constant value. -```typescript -// Check if the 'score' field is less than or equal to 70 -Field.of("score").lte(70); - -``` - | -| [mapGet(subfield)](./firestore_.constant.md#constantmapget) | | (BETA) Accesses a value from a map (object) field using the provided key. -```typescript -// Get the 'city' value from the 'address' map field -Field.of("address").mapGet("city"); - -``` - | -| [max()](./firestore_.constant.md#constantmax) | | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. -```typescript -// Find the highest score in a leaderboard -Field.of("score").max().as("highestScore"); - -``` - A new Accumulator representing the 'max' aggregation. | -| [min()](./firestore_.constant.md#constantmin) | | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. -```typescript -// Find the lowest price of all products -Field.of("price").min().as("lowestPrice"); - -``` - A new Accumulator representing the 'min' aggregation. | -| [mod(other)](./firestore_.constant.md#constantmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. -```typescript -// Calculate the remainder of dividing the 'value' field by the 'divisor' field -Field.of("value").mod(Field.of("divisor")); - -``` - | -| [mod(other)](./firestore_.constant.md#constantmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. -```typescript -// Calculate the remainder of dividing the 'value' field by 10 -Field.of("value").mod(10); - -``` - | -| [multiply(other)](./firestore_.constant.md#constantmultiply) | | (BETA) Creates an expression that multiplies this expression by another expression. -```typescript -// Multiply the 'quantity' field by the 'price' field -Field.of("quantity").multiply(Field.of("price")); - -``` - | -| [multiply(other)](./firestore_.constant.md#constantmultiply) | | (BETA) Creates an expression that multiplies this expression by a constant value. -```typescript -// Multiply the 'value' field by 2 -Field.of("value").multiply(2); - -``` - | -| [neq(other)](./firestore_.constant.md#constantneq) | | (BETA) Creates an expression that checks if this expression is not equal to another expression. -```typescript -// Check if the 'status' field is not equal to "completed" -Field.of("status").neq("completed"); - -``` - | -| [neq(other)](./firestore_.constant.md#constantneq) | | (BETA) Creates an expression that checks if this expression is not equal to a constant value. -```typescript -// Check if the 'country' field is not equal to "USA" -Field.of("country").neq("USA"); - -``` - | -| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a number value. | -| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a DocumentReference value. | -| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for an array value. | -| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a map value. | -| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a VectorValue value. | -| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a string value. | -| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a boolean value. | -| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a null value. | -| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for an undefined value. | -| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a GeoPoint value. | -| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a Timestamp value. | -| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a Date value. | -| [of(value)](./firestore_.constant.md#constantof) | static | (BETA) Creates a Constant instance for a Uint8Array value. | -| [regexContains(pattern)](./firestore_.constant.md#constantregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -Field.of("description").regexContains("(?i)example"); - -``` - | -| [regexContains(pattern)](./firestore_.constant.md#constantregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains the regular expression stored in field 'regex' -Field.of("description").regexContains(Field.of("regex")); - -``` - | -| [regexMatch(pattern)](./firestore_.constant.md#constantregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. -```typescript -// Check if the 'email' field matches a valid email pattern -Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - | -| [regexMatch(pattern)](./firestore_.constant.md#constantregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. -```typescript -// Check if the 'email' field matches a regular expression stored in field 'regex' -Field.of("email").regexMatch(Field.of("regex")); - -``` - | -| [replaceAll(find, replace)](./firestore_.constant.md#constantreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring. -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field -Field.of("message").replaceAll("hello", "hi"); - -``` - | -| [replaceAll(find, replace)](./firestore_.constant.md#constantreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); - -``` - | -| [replaceFirst(find, replace)](./firestore_.constant.md#constantreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field -Field.of("message").replaceFirst("hello", "hi"); - -``` - | -| [replaceFirst(find, replace)](./firestore_.constant.md#constantreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); - -``` - | -| [reverse()](./firestore_.constant.md#constantreverse) | | (BETA) Creates an expression that reverses this string expression. -```typescript -// Reverse the value of the 'myString' field. -Field.of("myString").reverse(); - -``` - A new representing the reversed string. | -| [startsWith(prefix)](./firestore_.constant.md#constantstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix. -```typescript -// Check if the 'name' field starts with "Mr." -Field.of("name").startsWith("Mr."); - -``` - | -| [startsWith(prefix)](./firestore_.constant.md#constantstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix (represented as an expression). -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -Field.of("fullName").startsWith(Field.of("firstName")); - -``` - | -| [strConcat(elements)](./firestore_.constant.md#constantstrconcat) | | (BETA) Creates an expression that concatenates string expressions together. -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); - -``` - | -| [strContains(substring)](./firestore_.constant.md#constantstrcontains) | | (BETA) Creates an expression that checks if a string contains a specified substring. -```typescript -// Check if the 'description' field contains "example". -Field.of("description").strContains("example"); - -``` - | -| [strContains(expr)](./firestore_.constant.md#constantstrcontains) | | (BETA) Creates an expression that checks if a string contains the string represented by another expression. -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -Field.of("description").strContains(Field.of("keyword")); - -``` - | -| [subtract(other)](./firestore_.constant.md#constantsubtract) | | (BETA) Creates an expression that subtracts another expression from this expression. -```typescript -// Subtract the 'discount' field from the 'price' field -Field.of("price").subtract(Field.of("discount")); - -``` - | -| [subtract(other)](./firestore_.constant.md#constantsubtract) | | (BETA) Creates an expression that subtracts a constant value from this expression. -```typescript -// Subtract 20 from the value of the 'total' field -Field.of("total").subtract(20); - -``` - | -| [sum()](./firestore_.constant.md#constantsum) | | (BETA) Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. -```typescript -// Calculate the total revenue from a set of orders -Field.of("orderAmount").sum().as("totalRevenue"); - -``` - A new Accumulator representing the 'sum' aggregation. | -| [timestampAdd(unit, amount)](./firestore_.constant.md#constanttimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampAdd(unit, amount)](./firestore_.constant.md#constanttimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. -```typescript -// Add 1 day to the 'timestamp' field. -Field.of("timestamp").timestampAdd("day", 1); - -``` - | -| [timestampSub(unit, amount)](./firestore_.constant.md#constanttimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampSub(unit, amount)](./firestore_.constant.md#constanttimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. -```typescript -// Subtract 1 day from the 'timestamp' field. -Field.of("timestamp").timestampSub("day", 1); - -``` - | -| [timestampToUnixMicros()](./firestore_.constant.md#constanttimestamptounixmicros) | | (BETA) Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -Field.of("timestamp").timestampToUnixMicros(); - -``` - A new representing the number of microseconds since epoch. | -| [timestampToUnixMillis()](./firestore_.constant.md#constanttimestamptounixmillis) | | (BETA) Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -Field.of("timestamp").timestampToUnixMillis(); - -``` - A new representing the number of milliseconds since epoch. | -| [timestampToUnixSeconds()](./firestore_.constant.md#constanttimestamptounixseconds) | | (BETA) Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to seconds since epoch. -Field.of("timestamp").timestampToUnixSeconds(); - -``` - A new representing the number of seconds since epoch. | -| [toLower()](./firestore_.constant.md#constanttolower) | | (BETA) Creates an expression that converts a string to lowercase. -```typescript -// Convert the 'name' field to lowercase -Field.of("name").toLower(); - -``` - A new Expr representing the lowercase string. | -| [toUpper()](./firestore_.constant.md#constanttoupper) | | (BETA) Creates an expression that converts a string to uppercase. -```typescript -// Convert the 'title' field to uppercase -Field.of("title").toUpper(); - -``` - A new Expr representing the uppercase string. | -| [trim()](./firestore_.constant.md#constanttrim) | | (BETA) Creates an expression that removes leading and trailing whitespace from a string. -```typescript -// Trim whitespace from the 'userInput' field -Field.of("userInput").trim(); - -``` - A new Expr representing the trimmed string. | -| [unixMicrosToTimestamp()](./firestore_.constant.md#constantunixmicrostotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -Field.of("microseconds").unixMicrosToTimestamp(); - -``` - A new representing the timestamp. | -| [unixMillisToTimestamp()](./firestore_.constant.md#constantunixmillistotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -Field.of("milliseconds").unixMillisToTimestamp(); - -``` - A new representing the timestamp. | -| [unixSecondsToTimestamp()](./firestore_.constant.md#constantunixsecondstotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'seconds' field as seconds since epoch. -Field.of("seconds").unixSecondsToTimestamp(); - -``` - A new representing the timestamp. | -| [vector(value)](./firestore_.constant.md#constantvector) | static | (BETA) Creates a Constant instance for a VectorValue value. -```typescript -// Create a Constant instance for a vector value -const vectorConstant = Constant.ofVector([1, 2, 3]); - -``` - | -| [vectorLength()](./firestore_.constant.md#constantvectorlength) | | (BETA) Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. -```typescript -// Get the vector length (dimension) of the field 'embedding'. -Field.of("embedding").vectorLength(); - -``` - A new representing the length of the vector. | - -## Constant.exprType - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -exprType: ExprType; -``` - -## Constant.add() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds this expression to another expression. - -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -Field.of("quantity").add(Field.of("reserve")); - -``` - -Signature: - -```typescript -add(other: Constant): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to add to this expression. A new Expr representing the addition operation. | - -Returns: - -[Add](./firestore_.add.md#add_class) - -## Constant.add() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds this expression to a constant value. - -```typescript -// Add 5 to the value of the 'age' field -Field.of("age").add(5); - -``` - -Signature: - -```typescript -add(other: any): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to add. A new Expr representing the addition operation. | - -Returns: - -[Add](./firestore_.add.md#add_class) - -## Constant.arrayConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with one or more other arrays. - -```typescript -// Combine the 'items' array with another array field. -Field.of("items").arrayConcat(Field.of("otherItems")); - -``` - -Signature: - -```typescript -arrayConcat(arrays: Constant[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| arrays | [Constant](./firestore_.constant.md#constant_class)\[\] | The array expressions to concatenate. A new Expr representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) - -## Constant.arrayConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with one or more other arrays. - -```typescript -// Combine the 'tags' array with a new array and an array field -Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); - -``` - -Signature: - -```typescript -arrayConcat(arrays: any[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| arrays | any\[\] | The array expressions or values to concatenate. A new Expr representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) - -## Constant.arrayContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains a specific element. - -```typescript -// Check if the 'sizes' array contains the value from the 'selectedSize' field -Field.of("sizes").arrayContains(Field.of("selectedSize")); - -``` - -Signature: - -```typescript -arrayContains(element: Constant): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | [Constant](./firestore_.constant.md#constant_class) | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) - -## Constant.arrayContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains a specific value. - -```typescript -// Check if the 'colors' array contains "red" -Field.of("colors").arrayContains("red"); - -``` - -Signature: - -```typescript -arrayContains(element: any): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | any | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) - -## Constant.arrayContainsAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both "news" and "sports" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - -Signature: - -```typescript -arrayContainsAll(...values: Constant[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) - -## Constant.arrayContainsAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - -Signature: - -```typescript -arrayContainsAll(...values: any[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) - -## Constant.arrayContainsAny() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains any of the specified elements. - -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "cate2" -Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); - -``` - -Signature: - -```typescript -arrayContainsAny(...values: Constant[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) - -## Constant.arrayContainsAny() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains any of the specified elements. - -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); - -``` - -Signature: - -```typescript -arrayContainsAny(...values: any[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) - -## Constant.arrayLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of an array. - -```typescript -// Get the number of items in the 'cart' array -Field.of("cart").arrayLength(); - -``` - A new `Expr` representing the length of the array. - -Signature: - -```typescript -arrayLength(): ArrayLength; -``` -Returns: - -[ArrayLength](./firestore_.arraylength.md#arraylength_class) - -## Constant.as() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Assigns an alias to this expression. - -Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. - -```typescript -// Calculate the total price and assign it the alias "totalPrice" and add it to the output. -firestore.pipeline().collection("items") -.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); - -``` - -Signature: - -```typescript -as(name: string): ExprWithAlias; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | The alias to assign to this expression. A new [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) that wraps this expression and associates it with the provided alias. | - -Returns: - -[ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class)<this> - -## Constant.ascending() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. - -```typescript -// Sort documents by the 'name' field in ascending order -pipeline().collection("users") -.sort(Field.of("name").ascending()); - -``` - A new `Ordering` for ascending sorting. - -Signature: - -```typescript -ascending(): Ordering; -``` -Returns: - -[Ordering](./firestore_.ordering.md#ordering_class) - -## Constant.avg() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. - -```typescript -// Calculate the average age of users -Field.of("age").avg().as("averageAge"); - -``` - A new `Accumulator` representing the 'avg' aggregation. - -Signature: - -```typescript -avg(): Avg; -``` -Returns: - -[Avg](./firestore_.avg.md#avg_class) - -## Constant.byteLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of this string expression in bytes. - -```typescript -// Calculate the length of the 'myString' field in bytes. -Field.of("myString").byteLength(); - -``` - A new representing the length of the string in bytes. - -Signature: - -```typescript -byteLength(): ByteLength; -``` -Returns: - -[ByteLength](./firestore_.bytelength.md#bytelength_class) - -## Constant.charLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the character length of a string in UTF-8. - -```typescript -// Get the character length of the 'name' field in its UTF-8 form. -Field.of("name").charLength(); - -``` - A new `Expr` representing the length of the string. - -Signature: - -```typescript -charLength(): CharLength; -``` -Returns: - -[CharLength](./firestore_.charlength.md#charlength_class) - -## Constant.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the cosine distance between two vectors. - -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -Field.of("userVector").cosineDistance(Field.of("itemVector")); - -``` - -Signature: - -```typescript -cosineDistance(other: Constant): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new Expr representing the cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) - -## Constant.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vectors. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -cosineDistance(other: VectorValue): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) - -## Constant.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vectors. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance([37.7749, -122.4194]); - -``` - -Signature: - -```typescript -cosineDistance(other: number[]): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | The other vector (as an array of numbers) to compare against. A new Expr representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) - -## Constant.count() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. - -```typescript -// Count the total number of products -Field.of("productId").count().as("totalProducts"); - -``` - A new `Accumulator` representing the 'count' aggregation. - -Signature: - -```typescript -count(): Count; -``` -Returns: - -[Count](./firestore_.count.md#count_class) - -## Constant.descending() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. - -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") -.sort(Field.of("createdAt").descending()); - -``` - A new `Ordering` for descending sorting. - -Signature: - -```typescript -descending(): Ordering; -``` -Returns: - -[Ordering](./firestore_.ordering.md#ordering_class) - -## Constant.divide() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides this expression by another expression. - -```typescript -// Divide the 'total' field by the 'count' field -Field.of("total").divide(Field.of("count")); - -``` - -Signature: - -```typescript -divide(other: Constant): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new Expr representing the division operation. | - -Returns: - -[Divide](./firestore_.divide.md#divide_class) - -## Constant.divide() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides this expression by a constant value. - -```typescript -// Divide the 'value' field by 10 -Field.of("value").divide(10); - -``` - -Signature: - -```typescript -divide(other: any): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to divide by. A new Expr representing the division operation. | - -Returns: - -[Divide](./firestore_.divide.md#divide_class) - -## Constant.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vectors. - -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct([0.5, 0.8, 0.2]); - -``` - -Signature: - -```typescript -dotProduct(other: Constant): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_.dotproduct.md#dotproduct_class) - -## Constant.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vectors. - -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); - -``` - -Signature: - -```typescript -dotProduct(other: VectorValue): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_.dotproduct.md#dotproduct_class) - -## Constant.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -dotProduct(other: number[]): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | | - -Returns: - -[DotProduct](./firestore_.dotproduct.md#dotproduct_class) - -## Constant.endsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string ends with a given postfix. - -```typescript -// Check if the 'filename' field ends with ".txt" -Field.of("filename").endsWith(".txt"); - -``` - -Signature: - -```typescript -endsWith(suffix: string): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| suffix | string | The postfix to check for. A new Expr representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_.endswith.md#endswith_class) - -## Constant.endsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string ends with a given postfix (represented as an expression). - -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -Field.of("url").endsWith(Field.of("extension")); - -``` - -Signature: - -```typescript -endsWith(suffix: Constant): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| suffix | [Constant](./firestore_.constant.md#constant_class) | The postfix expression to check for. A new Expr representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_.endswith.md#endswith_class) - -## Constant.eq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to another expression. - -```typescript -// Check if the 'age' field is equal to 21 -Field.of("age").eq(21); - -``` - -Signature: - -```typescript -eq(other: Constant): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for equality. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_.eq.md#eq_class) - -## Constant.eq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to a constant value. - -```typescript -// Check if the 'city' field is equal to "London" -Field.of("city").eq("London"); - -``` - -Signature: - -```typescript -eq(other: any): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for equality. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_.eq.md#eq_class) - -## Constant.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vectors. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance([37.7749, -122.4194]); - -``` - -Signature: - -```typescript -euclideanDistance(other: Constant): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) - -## Constant.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vectors. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -euclideanDistance(other: VectorValue): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) - -## Constant.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -euclideanDistance(other: number[]): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | | - -Returns: - -[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) - -## Constant.exists() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field exists in the document. - -```typescript -// Check if the document has a field named "phoneNumber" -Field.of("phoneNumber").exists(); - -``` - A new `Expr` representing the 'exists' check. - -Signature: - -```typescript -exists(): Exists; -``` -Returns: - -[Exists](./firestore_.exists.md#exists_class) - -## Constant.gt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than another expression. - -```typescript -// Check if the 'age' field is greater than the 'limit' field -Field.of("age").gt(Field.of("limit")); - -``` - -Signature: - -```typescript -gt(other: Constant): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for greater than. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_.gt.md#gt_class) - -## Constant.gt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than a constant value. - -```typescript -// Check if the 'price' field is greater than 100 -Field.of("price").gt(100); - -``` - -Signature: - -```typescript -gt(other: any): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for greater than. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_.gt.md#gt_class) - -## Constant.gte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than or equal to another expression. - -```typescript -// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 -Field.of("quantity").gte(Field.of('requirement').add(1)); - -``` - -Signature: - -```typescript -gte(other: Constant): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_.gte.md#gte_class) - -## Constant.gte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than or equal to a constant value. - -```typescript -// Check if the 'score' field is greater than or equal to 80 -Field.of("score").gte(80); - -``` - -Signature: - -```typescript -gte(other: any): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_.gte.md#gte_class) - -## Constant.in() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to any of the provided values or expressions. - -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -Field.of("category").in("Electronics", Field.of("primaryType")); - -``` - -Signature: - -```typescript -in(...others: Constant[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| others | [Constant](./firestore_.constant.md#constant_class)\[\] | The values or expressions to check against. A new Expr representing the 'IN' comparison. | - -Returns: - -[In](./firestore_.in.md#in_class) - -## Constant.in() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -in(...others: any[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| others | any\[\] | | - -Returns: - -[In](./firestore_.in.md#in_class) - -## Constant.isNaN() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). - -```typescript -// Check if the result of a calculation is NaN -Field.of("value").divide(0).isNaN(); - -``` - A new `Expr` representing the 'isNaN' check. - -Signature: - -```typescript -isNaN(): IsNan; -``` -Returns: - -[IsNan](./firestore_.isnan.md#isnan_class) - -## Constant.like() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that performs a case-sensitive string comparison. - -```typescript -// Check if the 'title' field contains the word "guide" (case-sensitive) -Field.of("title").like("%guide%"); - -``` - -Signature: - -```typescript -like(pattern: string): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new Expr representing the 'like' comparison. | - -Returns: - -[Like](./firestore_.like.md#like_class) - -## Constant.like() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -like(pattern: Constant): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_.constant.md#constant_class) | | - -Returns: - -[Like](./firestore_.like.md#like_class) - -## Constant.logicalMax() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMax(Function.currentTimestamp()); - -``` - -Signature: - -```typescript -logicalMax(other: Constant): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare with. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) - -## Constant.logicalMax() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'value' field and 10. -Field.of("value").logicalMax(10); - -``` - -Signature: - -```typescript -logicalMax(other: any): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare with. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) - -## Constant.logicalMin() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMin(Function.currentTimestamp()); - -``` - -Signature: - -```typescript -logicalMin(other: Constant): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare with. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) - -## Constant.logicalMin() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'value' field and 10. -Field.of("value").logicalMin(10); - -``` - -Signature: - -```typescript -logicalMin(other: any): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare with. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) - -## Constant.lt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than another expression. - -```typescript -// Check if the 'age' field is less than 'limit' -Field.of("age").lt(Field.of('limit')); - -``` - -Signature: - -```typescript -lt(other: Constant): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for less than. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_.lt.md#lt_class) - -## Constant.lt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than a constant value. - -```typescript -// Check if the 'price' field is less than 50 -Field.of("price").lt(50); - -``` - -Signature: - -```typescript -lt(other: any): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for less than. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_.lt.md#lt_class) - -## Constant.lte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than or equal to another expression. - -```typescript -// Check if the 'quantity' field is less than or equal to 20 -Field.of("quantity").lte(Constant.of(20)); - -``` - -Signature: - -```typescript -lte(other: Constant): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_.lte.md#lte_class) - -## Constant.lte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than or equal to a constant value. - -```typescript -// Check if the 'score' field is less than or equal to 70 -Field.of("score").lte(70); - -``` - -Signature: - -```typescript -lte(other: any): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_.lte.md#lte_class) - -## Constant.mapGet() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Accesses a value from a map (object) field using the provided key. - -```typescript -// Get the 'city' value from the 'address' map field -Field.of("address").mapGet("city"); - -``` - -Signature: - -```typescript -mapGet(subfield: string): MapGet; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| subfield | string | The key to access in the map. A new Expr representing the value associated with the given key in the map. | - -Returns: - -[MapGet](./firestore_.mapget.md#mapget_class) - -## Constant.max() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that finds the maximum value of a field across multiple stage inputs. - -```typescript -// Find the highest score in a leaderboard -Field.of("score").max().as("highestScore"); - -``` - A new `Accumulator` representing the 'max' aggregation. - -Signature: - -```typescript -max(): Max; -``` -Returns: - -[Max](./firestore_.max.md#max_class) - -## Constant.min() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that finds the minimum value of a field across multiple stage inputs. - -```typescript -// Find the lowest price of all products -Field.of("price").min().as("lowestPrice"); - -``` - A new `Accumulator` representing the 'min' aggregation. - -Signature: - -```typescript -min(): Min; -``` -Returns: - -[Min](./firestore_.min.md#min_class) - -## Constant.mod() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. - -```typescript -// Calculate the remainder of dividing the 'value' field by the 'divisor' field -Field.of("value").mod(Field.of("divisor")); - -``` - -Signature: - -```typescript -mod(other: Constant): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new Expr representing the modulo operation. | - -Returns: - -[Mod](./firestore_.mod.md#mod_class) - -## Constant.mod() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. - -```typescript -// Calculate the remainder of dividing the 'value' field by 10 -Field.of("value").mod(10); - -``` - -Signature: - -```typescript -mod(other: any): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to divide by. A new Expr representing the modulo operation. | - -Returns: - -[Mod](./firestore_.mod.md#mod_class) - -## Constant.multiply() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies this expression by another expression. - -```typescript -// Multiply the 'quantity' field by the 'price' field -Field.of("quantity").multiply(Field.of("price")); - -``` - -Signature: - -```typescript -multiply(other: Constant): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to multiply by. A new Expr representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_.multiply.md#multiply_class) - -## Constant.multiply() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies this expression by a constant value. - -```typescript -// Multiply the 'value' field by 2 -Field.of("value").multiply(2); - -``` - -Signature: - -```typescript -multiply(other: any): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to multiply by. A new Expr representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_.multiply.md#multiply_class) - -## Constant.neq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is not equal to another expression. - -```typescript -// Check if the 'status' field is not equal to "completed" -Field.of("status").neq("completed"); - -``` - -Signature: - -```typescript -neq(other: Constant): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for inequality. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_.neq.md#neq_class) - -## Constant.neq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is not equal to a constant value. - -```typescript -// Check if the 'country' field is not equal to "USA" -Field.of("country").neq("USA"); - -``` - -Signature: - -```typescript -neq(other: any): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for inequality. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_.neq.md#neq_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a number value. - -Signature: - -```typescript -static of(value: number): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | number | The number value. A new Constant instance. | - -Returns: - -[Constant](./firestore_.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a DocumentReference value. - -Signature: - -```typescript -static of(value: DocumentReference): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [DocumentReference](./firestore_.documentreference.md#documentreference_class) | The DocumentReference value. A new Constant instance. | - -Returns: - -[Constant](./firestore_.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for an array value. - -Signature: - -```typescript -static of(value: any[]): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | any\[\] | The array value. A new Constant instance. | - -Returns: - -[Constant](./firestore_.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a map value. - -Signature: - -```typescript -static of(value: Map): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | Map<string, any> | The map value. A new Constant instance. | - -Returns: - -[Constant](./firestore_.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a VectorValue value. - -Signature: - -```typescript -static of(value: VectorValue): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The VectorValue value. A new Constant instance. | - -Returns: - -[Constant](./firestore_.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a string value. - -Signature: - -```typescript -static of(value: string): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | string | The string value. A new Constant instance. | - -Returns: - -[Constant](./firestore_.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a boolean value. - -Signature: - -```typescript -static of(value: boolean): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | boolean | The boolean value. A new Constant instance. | - -Returns: - -[Constant](./firestore_.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a null value. - -Signature: - -```typescript -static of(value: null): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | null | The null value. A new Constant instance. | - -Returns: - -[Constant](./firestore_.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for an undefined value. - -Signature: - -```typescript -static of(value: undefined): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | undefined | The undefined value. A new Constant instance. | - -Returns: - -[Constant](./firestore_.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a GeoPoint value. - -Signature: - -```typescript -static of(value: GeoPoint): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [GeoPoint](./firestore_.geopoint.md#geopoint_class) | The GeoPoint value. A new Constant instance. | - -Returns: - -[Constant](./firestore_.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a Timestamp value. - -Signature: - -```typescript -static of(value: Timestamp): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Timestamp](./firestore_.timestamp.md#timestamp_class) | The Timestamp value. A new Constant instance. | - -Returns: - -[Constant](./firestore_.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a Date value. - -Signature: - -```typescript -static of(value: Date): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | Date | The Date value. A new Constant instance. | - -Returns: - -[Constant](./firestore_.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a Uint8Array value. - -Signature: - -```typescript -static of(value: Uint8Array): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | Uint8Array | The Uint8Array value. A new Constant instance. | - -Returns: - -[Constant](./firestore_.constant.md#constant_class) - -## Constant.regexContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -Field.of("description").regexContains("(?i)example"); - -``` - -Signature: - -```typescript -regexContains(pattern: string): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_.regexcontains.md#regexcontains_class) - -## Constant.regexContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains the regular expression stored in field 'regex' -Field.of("description").regexContains(Field.of("regex")); - -``` - -Signature: - -```typescript -regexContains(pattern: Constant): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_.regexcontains.md#regexcontains_class) - -## Constant.regexMatch() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a valid email pattern -Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - -Signature: - -```typescript -regexMatch(pattern: string): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The regular expression to use for the match. A new Expr representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) - -## Constant.regexMatch() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a regular expression stored in field 'regex' -Field.of("email").regexMatch(Field.of("regex")); - -``` - -Signature: - -```typescript -regexMatch(pattern: Constant): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the match. A new Expr representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) - -## Constant.replaceAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within this string expression with another substring. - -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field -Field.of("message").replaceAll("hello", "hi"); - -``` - -Signature: - -```typescript -replaceAll(find: string, replace: string): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | string | The substring to search for. | -| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_.replaceall.md#replaceall_class) - -## Constant.replaceAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. - -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); - -``` - -Signature: - -```typescript -replaceAll(find: Constant, replace: Constant): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_.replaceall.md#replaceall_class) - -## Constant.replaceFirst() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. - -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field -Field.of("message").replaceFirst("hello", "hi"); - -``` - -Signature: - -```typescript -replaceFirst(find: string, replace: string): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | string | The substring to search for. | -| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) - -## Constant.replaceFirst() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. - -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); - -``` - -Signature: - -```typescript -replaceFirst(find: Constant, replace: Constant): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) - -## Constant.reverse() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that reverses this string expression. - -```typescript -// Reverse the value of the 'myString' field. -Field.of("myString").reverse(); - -``` - A new representing the reversed string. - -Signature: - -```typescript -reverse(): Reverse; -``` -Returns: - -[Reverse](./firestore_.reverse.md#reverse_class) - -## Constant.startsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string starts with a given prefix. - -```typescript -// Check if the 'name' field starts with "Mr." -Field.of("name").startsWith("Mr."); - -``` - -Signature: - -```typescript -startsWith(prefix: string): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| prefix | string | The prefix to check for. A new Expr representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_.startswith.md#startswith_class) - -## Constant.startsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string starts with a given prefix (represented as an expression). - -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -Field.of("fullName").startsWith(Field.of("firstName")); - -``` - -Signature: - -```typescript -startsWith(prefix: Constant): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| prefix | [Constant](./firestore_.constant.md#constant_class) | The prefix expression to check for. A new Expr representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_.startswith.md#startswith_class) - -## Constant.strConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates string expressions together. - -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); - -``` - -Signature: - -```typescript -strConcat(...elements: Array): StrConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| elements | Array<string \| [Constant](./firestore_.constant.md#constant_class)> | The expressions (typically strings) to concatenate. A new Expr representing the concatenated string. | - -Returns: - -[StrConcat](./firestore_.strconcat.md#strconcat_class) - -## Constant.strContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified substring. - -```typescript -// Check if the 'description' field contains "example". -Field.of("description").strContains("example"); - -``` - -Signature: - -```typescript -strContains(substring: string): StrContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| substring | string | The substring to search for. A new Expr representing the 'contains' comparison. | - -Returns: - -[StrContains](./firestore_.strcontains.md#strcontains_class) - -## Constant.strContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains the string represented by another expression. - -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -Field.of("description").strContains(Field.of("keyword")); - -``` - -Signature: - -```typescript -strContains(expr: Constant): StrContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. A new Expr representing the 'contains' comparison. | - -Returns: - -[StrContains](./firestore_.strcontains.md#strcontains_class) - -## Constant.subtract() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts another expression from this expression. - -```typescript -// Subtract the 'discount' field from the 'price' field -Field.of("price").subtract(Field.of("discount")); - -``` - -Signature: - -```typescript -subtract(other: Constant): Subtract; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to subtract from this expression. A new Expr representing the subtraction operation. | - -Returns: - -[Subtract](./firestore_.subtract.md#subtract_class) - -## Constant.subtract() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a constant value from this expression. - -```typescript -// Subtract 20 from the value of the 'total' field -Field.of("total").subtract(20); - -``` - -Signature: - -```typescript -subtract(other: any): Subtract; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to subtract. A new Expr representing the subtraction operation. | - -Returns: - -[Subtract](./firestore_.subtract.md#subtract_class) - -## Constant.sum() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. - -```typescript -// Calculate the total revenue from a set of orders -Field.of("orderAmount").sum().as("totalRevenue"); - -``` - A new `Accumulator` representing the 'sum' aggregation. - -Signature: - -```typescript -sum(): Sum; -``` -Returns: - -[Sum](./firestore_.sum.md#sum_class) - -## Constant.timestampAdd() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to this timestamp expression. - -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); - -``` - -Signature: - -```typescript -timestampAdd(unit: Constant, amount: Constant): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) - -## Constant.timestampAdd() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to this timestamp expression. - -```typescript -// Add 1 day to the 'timestamp' field. -Field.of("timestamp").timestampAdd("day", 1); - -``` - -Signature: - -```typescript -timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | -| amount | number | The amount of time to add. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) - -## Constant.timestampSub() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from this timestamp expression. - -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); - -``` - -Signature: - -```typescript -timestampSub(unit: Constant, amount: Constant): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) - -## Constant.timestampSub() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from this timestamp expression. - -```typescript -// Subtract 1 day from the 'timestamp' field. -Field.of("timestamp").timestampSub("day", 1); - -``` - -Signature: - -```typescript -timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | -| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) - -## Constant.timestampToUnixMicros() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -Field.of("timestamp").timestampToUnixMicros(); - -``` - A new representing the number of microseconds since epoch. - -Signature: - -```typescript -timestampToUnixMicros(): TimestampToUnixMicros; -``` -Returns: - -[TimestampToUnixMicros](./firestore_.timestamptounixmicros.md#timestamptounixmicros_class) - -## Constant.timestampToUnixMillis() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -Field.of("timestamp").timestampToUnixMillis(); - -``` - A new representing the number of milliseconds since epoch. - -Signature: - -```typescript -timestampToUnixMillis(): TimestampToUnixMillis; -``` -Returns: - -[TimestampToUnixMillis](./firestore_.timestamptounixmillis.md#timestamptounixmillis_class) - -## Constant.timestampToUnixSeconds() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to seconds since epoch. -Field.of("timestamp").timestampToUnixSeconds(); - -``` - A new representing the number of seconds since epoch. - -Signature: - -```typescript -timestampToUnixSeconds(): TimestampToUnixSeconds; -``` -Returns: - -[TimestampToUnixSeconds](./firestore_.timestamptounixseconds.md#timestamptounixseconds_class) - -## Constant.toLower() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string to lowercase. - -```typescript -// Convert the 'name' field to lowercase -Field.of("name").toLower(); - -``` - A new `Expr` representing the lowercase string. - -Signature: - -```typescript -toLower(): ToLower; -``` -Returns: - -[ToLower](./firestore_.tolower.md#tolower_class) - -## Constant.toUpper() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string to uppercase. - -```typescript -// Convert the 'title' field to uppercase -Field.of("title").toUpper(); - -``` - A new `Expr` representing the uppercase string. - -Signature: - -```typescript -toUpper(): ToUpper; -``` -Returns: - -[ToUpper](./firestore_.toupper.md#toupper_class) - -## Constant.trim() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that removes leading and trailing whitespace from a string. - -```typescript -// Trim whitespace from the 'userInput' field -Field.of("userInput").trim(); - -``` - A new `Expr` representing the trimmed string. - -Signature: - -```typescript -trim(): Trim; -``` -Returns: - -[Trim](./firestore_.trim.md#trim_class) - -## Constant.unixMicrosToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -Field.of("microseconds").unixMicrosToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixMicrosToTimestamp(): UnixMicrosToTimestamp; -``` -Returns: - -[UnixMicrosToTimestamp](./firestore_.unixmicrostotimestamp.md#unixmicrostotimestamp_class) - -## Constant.unixMillisToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -Field.of("milliseconds").unixMillisToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixMillisToTimestamp(): UnixMillisToTimestamp; -``` -Returns: - -[UnixMillisToTimestamp](./firestore_.unixmillistotimestamp.md#unixmillistotimestamp_class) - -## Constant.unixSecondsToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'seconds' field as seconds since epoch. -Field.of("seconds").unixSecondsToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixSecondsToTimestamp(): UnixSecondsToTimestamp; -``` -Returns: - -[UnixSecondsToTimestamp](./firestore_.unixsecondstotimestamp.md#unixsecondstotimestamp_class) - -## Constant.vector() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a VectorValue value. - -```typescript -// Create a Constant instance for a vector value -const vectorConstant = Constant.ofVector([1, 2, 3]); - -``` - -Signature: - -```typescript -static vector(value: number[] | VectorValue): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | number\[\] \| [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The VectorValue value. A new Constant instance. | - -Returns: - -[Constant](./firestore_.constant.md#constant_class) - -## Constant.vectorLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. - -```typescript -// Get the vector length (dimension) of the field 'embedding'. -Field.of("embedding").vectorLength(); - -``` - A new representing the length of the vector. - -Signature: - -```typescript -vectorLength(): VectorLength; -``` -Returns: - -[VectorLength](./firestore_.vectorlength.md#vectorlength_class) - diff --git a/docs-devsite/firestore_.cosinedistance.md b/docs-devsite/firestore_.cosinedistance.md deleted file mode 100644 index 794d99c6d34..00000000000 --- a/docs-devsite/firestore_.cosinedistance.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# CosineDistance class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class CosineDistance extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(vector1, vector2)](./firestore_.cosinedistance.md#cosinedistanceconstructor) | | (BETA) Constructs a new instance of the CosineDistance class | - -## CosineDistance.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `CosineDistance` class - -Signature: - -```typescript -constructor(vector1: Constant, vector2: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| vector1 | [Constant](./firestore_.constant.md#constant_class) | | -| vector2 | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.count.md b/docs-devsite/firestore_.count.md deleted file mode 100644 index be4c3a37c57..00000000000 --- a/docs-devsite/firestore_.count.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Count class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Count extends FirestoreFunction implements Accumulator -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [Accumulator](./firestore_.accumulator.md#accumulator_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value, distinct)](./firestore_.count.md#countconstructor) | | (BETA) Constructs a new instance of the Count class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [accumulator](./firestore_.count.md#countaccumulator) | | true | (BETA) | - -## Count.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Count` class - -Signature: - -```typescript -constructor(value: Constant | undefined, distinct: boolean); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) \| undefined | | -| distinct | boolean | | - -## Count.accumulator - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -accumulator: true; -``` diff --git a/docs-devsite/firestore_.databasesource.md b/docs-devsite/firestore_.databasesource.md deleted file mode 100644 index 0989b69042c..00000000000 --- a/docs-devsite/firestore_.databasesource.md +++ /dev/null @@ -1,39 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# DatabaseSource class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class DatabaseSource implements Stage -``` -Implements: [Stage](./firestore_.stage.md#stage_interface) - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_.databasesource.md#databasesourcename) | | string | (BETA) | - -## DatabaseSource.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_.distinct.md b/docs-devsite/firestore_.distinct.md deleted file mode 100644 index a893d3f7e47..00000000000 --- a/docs-devsite/firestore_.distinct.md +++ /dev/null @@ -1,64 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Distinct class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Distinct implements Stage -``` -Implements: [Stage](./firestore_.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(groups)](./firestore_.distinct.md#distinctconstructor) | | (BETA) Constructs a new instance of the Distinct class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_.distinct.md#distinctname) | | string | (BETA) | - -## Distinct.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Distinct` class - -Signature: - -```typescript -constructor(groups: Map); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| groups | Map<string, [Constant](./firestore_.constant.md#constant_class)> | | - -## Distinct.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_.divide.md b/docs-devsite/firestore_.divide.md deleted file mode 100644 index ac77d7916d8..00000000000 --- a/docs-devsite/firestore_.divide.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Divide class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Divide extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_.divide.md#divideconstructor) | | (BETA) Constructs a new instance of the Divide class | - -## Divide.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Divide` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | | -| right | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.documentssource.md b/docs-devsite/firestore_.documentssource.md deleted file mode 100644 index 18ea01c0517..00000000000 --- a/docs-devsite/firestore_.documentssource.md +++ /dev/null @@ -1,92 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# DocumentsSource class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class DocumentsSource implements Stage -``` -Implements: [Stage](./firestore_.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(docPaths)](./firestore_.documentssource.md#documentssourceconstructor) | | (BETA) Constructs a new instance of the DocumentsSource class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_.documentssource.md#documentssourcename) | | string | (BETA) | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [of(refs)](./firestore_.documentssource.md#documentssourceof) | static | (BETA) | - -## DocumentsSource.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `DocumentsSource` class - -Signature: - -```typescript -constructor(docPaths: string[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| docPaths | string\[\] | | - -## DocumentsSource.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` - -## DocumentsSource.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -static of(refs: DocumentReference[]): DocumentsSource; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| refs | [DocumentReference](./firestore_.documentreference.md#documentreference_class)\[\] | | - -Returns: - -[DocumentsSource](./firestore_.documentssource.md#documentssource_class) - diff --git a/docs-devsite/firestore_.dotproduct.md b/docs-devsite/firestore_.dotproduct.md deleted file mode 100644 index 2e1a21700ad..00000000000 --- a/docs-devsite/firestore_.dotproduct.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# DotProduct class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class DotProduct extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(vector1, vector2)](./firestore_.dotproduct.md#dotproductconstructor) | | (BETA) Constructs a new instance of the DotProduct class | - -## DotProduct.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `DotProduct` class - -Signature: - -```typescript -constructor(vector1: Constant, vector2: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| vector1 | [Constant](./firestore_.constant.md#constant_class) | | -| vector2 | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.endswith.md b/docs-devsite/firestore_.endswith.md deleted file mode 100644 index 85f67657c50..00000000000 --- a/docs-devsite/firestore_.endswith.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# EndsWith class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class EndsWith extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr, suffix)](./firestore_.endswith.md#endswithconstructor) | | (BETA) Constructs a new instance of the EndsWith class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_.endswith.md#endswithfilterable) | | true | (BETA) | - -## EndsWith.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `EndsWith` class - -Signature: - -```typescript -constructor(expr: Constant, suffix: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | | -| suffix | [Constant](./firestore_.constant.md#constant_class) | | - -## EndsWith.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_.eq.md b/docs-devsite/firestore_.eq.md deleted file mode 100644 index 15cc19e3c2b..00000000000 --- a/docs-devsite/firestore_.eq.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Eq class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Eq extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_.eq.md#eqconstructor) | | (BETA) Constructs a new instance of the Eq class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_.eq.md#eqfilterable) | | true | (BETA) | - -## Eq.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Eq` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | | -| right | [Constant](./firestore_.constant.md#constant_class) | | - -## Eq.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_.euclideandistance.md b/docs-devsite/firestore_.euclideandistance.md deleted file mode 100644 index 240f048f42e..00000000000 --- a/docs-devsite/firestore_.euclideandistance.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# EuclideanDistance class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class EuclideanDistance extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(vector1, vector2)](./firestore_.euclideandistance.md#euclideandistanceconstructor) | | (BETA) Constructs a new instance of the EuclideanDistance class | - -## EuclideanDistance.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `EuclideanDistance` class - -Signature: - -```typescript -constructor(vector1: Constant, vector2: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| vector1 | [Constant](./firestore_.constant.md#constant_class) | | -| vector2 | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.exists.md b/docs-devsite/firestore_.exists.md deleted file mode 100644 index 459196066d4..00000000000 --- a/docs-devsite/firestore_.exists.md +++ /dev/null @@ -1,66 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Exists class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Exists extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr)](./firestore_.exists.md#existsconstructor) | | (BETA) Constructs a new instance of the Exists class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_.exists.md#existsfilterable) | | true | (BETA) | - -## Exists.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Exists` class - -Signature: - -```typescript -constructor(expr: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | | - -## Exists.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_.exprwithalias.md b/docs-devsite/firestore_.exprwithalias.md deleted file mode 100644 index 7d92f0e46fa..00000000000 --- a/docs-devsite/firestore_.exprwithalias.md +++ /dev/null @@ -1,3207 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ExprWithAlias class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ExprWithAlias implements Selectable -``` -Implements: [Selectable](./firestore_.selectable.md#selectable_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr, alias)](./firestore_.exprwithalias.md#exprwithaliasconstructor) | | (BETA) Constructs a new instance of the ExprWithAlias class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [alias](./firestore_.exprwithalias.md#exprwithaliasalias) | | string | (BETA) | -| [expr](./firestore_.exprwithalias.md#exprwithaliasexpr) | | T | (BETA) | -| [exprType](./firestore_.exprwithalias.md#exprwithaliasexprtype) | | [ExprType](./firestore_.md#exprtype) | (BETA) | -| [selectable](./firestore_.exprwithalias.md#exprwithaliasselectable) | | true | (BETA) | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [add(other)](./firestore_.exprwithalias.md#exprwithaliasadd) | | (BETA) Creates an expression that adds this expression to another expression. -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -Field.of("quantity").add(Field.of("reserve")); - -``` - | -| [add(other)](./firestore_.exprwithalias.md#exprwithaliasadd) | | (BETA) Creates an expression that adds this expression to a constant value. -```typescript -// Add 5 to the value of the 'age' field -Field.of("age").add(5); - -``` - | -| [arrayConcat(arrays)](./firestore_.exprwithalias.md#exprwithaliasarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. -```typescript -// Combine the 'items' array with another array field. -Field.of("items").arrayConcat(Field.of("otherItems")); - -``` - | -| [arrayConcat(arrays)](./firestore_.exprwithalias.md#exprwithaliasarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. -```typescript -// Combine the 'tags' array with a new array and an array field -Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); - -``` - | -| [arrayContains(element)](./firestore_.exprwithalias.md#exprwithaliasarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific element. -```typescript -// Check if the 'sizes' array contains the value from the 'selectedSize' field -Field.of("sizes").arrayContains(Field.of("selectedSize")); - -``` - | -| [arrayContains(element)](./firestore_.exprwithalias.md#exprwithaliasarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific value. -```typescript -// Check if the 'colors' array contains "red" -Field.of("colors").arrayContains("red"); - -``` - | -| [arrayContainsAll(values)](./firestore_.exprwithalias.md#exprwithaliasarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. -```typescript -// Check if the 'tags' array contains both "news" and "sports" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - | -| [arrayContainsAll(values)](./firestore_.exprwithalias.md#exprwithaliasarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - | -| [arrayContainsAny(values)](./firestore_.exprwithalias.md#exprwithaliasarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "cate2" -Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); - -``` - | -| [arrayContainsAny(values)](./firestore_.exprwithalias.md#exprwithaliasarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); - -``` - | -| [arrayLength()](./firestore_.exprwithalias.md#exprwithaliasarraylength) | | (BETA) Creates an expression that calculates the length of an array. -```typescript -// Get the number of items in the 'cart' array -Field.of("cart").arrayLength(); - -``` - A new Expr representing the length of the array. | -| [as(name)](./firestore_.exprwithalias.md#exprwithaliasas) | | (BETA) Assigns an alias to this expression.Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. -```typescript -// Calculate the total price and assign it the alias "totalPrice" and add it to the output. -firestore.pipeline().collection("items") -.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); - -``` - | -| [ascending()](./firestore_.exprwithalias.md#exprwithaliasascending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. -```typescript -// Sort documents by the 'name' field in ascending order -pipeline().collection("users") -.sort(Field.of("name").ascending()); - -``` - A new Ordering for ascending sorting. | -| [avg()](./firestore_.exprwithalias.md#exprwithaliasavg) | | (BETA) Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. -```typescript -// Calculate the average age of users -Field.of("age").avg().as("averageAge"); - -``` - A new Accumulator representing the 'avg' aggregation. | -| [byteLength()](./firestore_.exprwithalias.md#exprwithaliasbytelength) | | (BETA) Creates an expression that calculates the length of this string expression in bytes. -```typescript -// Calculate the length of the 'myString' field in bytes. -Field.of("myString").byteLength(); - -``` - A new representing the length of the string in bytes. | -| [charLength()](./firestore_.exprwithalias.md#exprwithaliascharlength) | | (BETA) Creates an expression that calculates the character length of a string in UTF-8. -```typescript -// Get the character length of the 'name' field in its UTF-8 form. -Field.of("name").charLength(); - -``` - A new Expr representing the length of the string. | -| [cosineDistance(other)](./firestore_.exprwithalias.md#exprwithaliascosinedistance) | | (BETA) Calculates the cosine distance between two vectors. -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -Field.of("userVector").cosineDistance(Field.of("itemVector")); - -``` - | -| [cosineDistance(other)](./firestore_.exprwithalias.md#exprwithaliascosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); - -``` - | -| [cosineDistance(other)](./firestore_.exprwithalias.md#exprwithaliascosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance([37.7749, -122.4194]); - -``` - | -| [count()](./firestore_.exprwithalias.md#exprwithaliascount) | | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. -```typescript -// Count the total number of products -Field.of("productId").count().as("totalProducts"); - -``` - A new Accumulator representing the 'count' aggregation. | -| [descending()](./firestore_.exprwithalias.md#exprwithaliasdescending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") -.sort(Field.of("createdAt").descending()); - -``` - A new Ordering for descending sorting. | -| [divide(other)](./firestore_.exprwithalias.md#exprwithaliasdivide) | | (BETA) Creates an expression that divides this expression by another expression. -```typescript -// Divide the 'total' field by the 'count' field -Field.of("total").divide(Field.of("count")); - -``` - | -| [divide(other)](./firestore_.exprwithalias.md#exprwithaliasdivide) | | (BETA) Creates an expression that divides this expression by a constant value. -```typescript -// Divide the 'value' field by 10 -Field.of("value").divide(10); - -``` - | -| [dotProduct(other)](./firestore_.exprwithalias.md#exprwithaliasdotproduct) | | (BETA) Calculates the dot product between two vectors. -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct([0.5, 0.8, 0.2]); - -``` - | -| [dotProduct(other)](./firestore_.exprwithalias.md#exprwithaliasdotproduct) | | (BETA) Calculates the dot product between two vectors. -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); - -``` - | -| [dotProduct(other)](./firestore_.exprwithalias.md#exprwithaliasdotproduct) | | (BETA) | -| [endsWith(suffix)](./firestore_.exprwithalias.md#exprwithaliasendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix. -```typescript -// Check if the 'filename' field ends with ".txt" -Field.of("filename").endsWith(".txt"); - -``` - | -| [endsWith(suffix)](./firestore_.exprwithalias.md#exprwithaliasendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix (represented as an expression). -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -Field.of("url").endsWith(Field.of("extension")); - -``` - | -| [eq(other)](./firestore_.exprwithalias.md#exprwithaliaseq) | | (BETA) Creates an expression that checks if this expression is equal to another expression. -```typescript -// Check if the 'age' field is equal to 21 -Field.of("age").eq(21); - -``` - | -| [eq(other)](./firestore_.exprwithalias.md#exprwithaliaseq) | | (BETA) Creates an expression that checks if this expression is equal to a constant value. -```typescript -// Check if the 'city' field is equal to "London" -Field.of("city").eq("London"); - -``` - | -| [euclideanDistance(other)](./firestore_.exprwithalias.md#exprwithaliaseuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance([37.7749, -122.4194]); - -``` - | -| [euclideanDistance(other)](./firestore_.exprwithalias.md#exprwithaliaseuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); - -``` - | -| [euclideanDistance(other)](./firestore_.exprwithalias.md#exprwithaliaseuclideandistance) | | (BETA) | -| [exists()](./firestore_.exprwithalias.md#exprwithaliasexists) | | (BETA) Creates an expression that checks if a field exists in the document. -```typescript -// Check if the document has a field named "phoneNumber" -Field.of("phoneNumber").exists(); - -``` - A new Expr representing the 'exists' check. | -| [gt(other)](./firestore_.exprwithalias.md#exprwithaliasgt) | | (BETA) Creates an expression that checks if this expression is greater than another expression. -```typescript -// Check if the 'age' field is greater than the 'limit' field -Field.of("age").gt(Field.of("limit")); - -``` - | -| [gt(other)](./firestore_.exprwithalias.md#exprwithaliasgt) | | (BETA) Creates an expression that checks if this expression is greater than a constant value. -```typescript -// Check if the 'price' field is greater than 100 -Field.of("price").gt(100); - -``` - | -| [gte(other)](./firestore_.exprwithalias.md#exprwithaliasgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to another expression. -```typescript -// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 -Field.of("quantity").gte(Field.of('requirement').add(1)); - -``` - | -| [gte(other)](./firestore_.exprwithalias.md#exprwithaliasgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to a constant value. -```typescript -// Check if the 'score' field is greater than or equal to 80 -Field.of("score").gte(80); - -``` - | -| [in(others)](./firestore_.exprwithalias.md#exprwithaliasin) | | (BETA) Creates an expression that checks if this expression is equal to any of the provided values or expressions. -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -Field.of("category").in("Electronics", Field.of("primaryType")); - -``` - | -| [in(others)](./firestore_.exprwithalias.md#exprwithaliasin) | | (BETA) | -| [isNaN()](./firestore_.exprwithalias.md#exprwithaliasisnan) | | (BETA) Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). -```typescript -// Check if the result of a calculation is NaN -Field.of("value").divide(0).isNaN(); - -``` - A new Expr representing the 'isNaN' check. | -| [like(pattern)](./firestore_.exprwithalias.md#exprwithaliaslike) | | (BETA) Creates an expression that performs a case-sensitive string comparison. -```typescript -// Check if the 'title' field contains the word "guide" (case-sensitive) -Field.of("title").like("%guide%"); - -``` - | -| [like(pattern)](./firestore_.exprwithalias.md#exprwithaliaslike) | | (BETA) | -| [logicalMax(other)](./firestore_.exprwithalias.md#exprwithaliaslogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMax(Function.currentTimestamp()); - -``` - | -| [logicalMax(other)](./firestore_.exprwithalias.md#exprwithaliaslogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'value' field and 10. -Field.of("value").logicalMax(10); - -``` - | -| [logicalMin(other)](./firestore_.exprwithalias.md#exprwithaliaslogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMin(Function.currentTimestamp()); - -``` - | -| [logicalMin(other)](./firestore_.exprwithalias.md#exprwithaliaslogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'value' field and 10. -Field.of("value").logicalMin(10); - -``` - | -| [lt(other)](./firestore_.exprwithalias.md#exprwithaliaslt) | | (BETA) Creates an expression that checks if this expression is less than another expression. -```typescript -// Check if the 'age' field is less than 'limit' -Field.of("age").lt(Field.of('limit')); - -``` - | -| [lt(other)](./firestore_.exprwithalias.md#exprwithaliaslt) | | (BETA) Creates an expression that checks if this expression is less than a constant value. -```typescript -// Check if the 'price' field is less than 50 -Field.of("price").lt(50); - -``` - | -| [lte(other)](./firestore_.exprwithalias.md#exprwithaliaslte) | | (BETA) Creates an expression that checks if this expression is less than or equal to another expression. -```typescript -// Check if the 'quantity' field is less than or equal to 20 -Field.of("quantity").lte(Constant.of(20)); - -``` - | -| [lte(other)](./firestore_.exprwithalias.md#exprwithaliaslte) | | (BETA) Creates an expression that checks if this expression is less than or equal to a constant value. -```typescript -// Check if the 'score' field is less than or equal to 70 -Field.of("score").lte(70); - -``` - | -| [mapGet(subfield)](./firestore_.exprwithalias.md#exprwithaliasmapget) | | (BETA) Accesses a value from a map (object) field using the provided key. -```typescript -// Get the 'city' value from the 'address' map field -Field.of("address").mapGet("city"); - -``` - | -| [max()](./firestore_.exprwithalias.md#exprwithaliasmax) | | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. -```typescript -// Find the highest score in a leaderboard -Field.of("score").max().as("highestScore"); - -``` - A new Accumulator representing the 'max' aggregation. | -| [min()](./firestore_.exprwithalias.md#exprwithaliasmin) | | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. -```typescript -// Find the lowest price of all products -Field.of("price").min().as("lowestPrice"); - -``` - A new Accumulator representing the 'min' aggregation. | -| [mod(other)](./firestore_.exprwithalias.md#exprwithaliasmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. -```typescript -// Calculate the remainder of dividing the 'value' field by the 'divisor' field -Field.of("value").mod(Field.of("divisor")); - -``` - | -| [mod(other)](./firestore_.exprwithalias.md#exprwithaliasmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. -```typescript -// Calculate the remainder of dividing the 'value' field by 10 -Field.of("value").mod(10); - -``` - | -| [multiply(other)](./firestore_.exprwithalias.md#exprwithaliasmultiply) | | (BETA) Creates an expression that multiplies this expression by another expression. -```typescript -// Multiply the 'quantity' field by the 'price' field -Field.of("quantity").multiply(Field.of("price")); - -``` - | -| [multiply(other)](./firestore_.exprwithalias.md#exprwithaliasmultiply) | | (BETA) Creates an expression that multiplies this expression by a constant value. -```typescript -// Multiply the 'value' field by 2 -Field.of("value").multiply(2); - -``` - | -| [neq(other)](./firestore_.exprwithalias.md#exprwithaliasneq) | | (BETA) Creates an expression that checks if this expression is not equal to another expression. -```typescript -// Check if the 'status' field is not equal to "completed" -Field.of("status").neq("completed"); - -``` - | -| [neq(other)](./firestore_.exprwithalias.md#exprwithaliasneq) | | (BETA) Creates an expression that checks if this expression is not equal to a constant value. -```typescript -// Check if the 'country' field is not equal to "USA" -Field.of("country").neq("USA"); - -``` - | -| [regexContains(pattern)](./firestore_.exprwithalias.md#exprwithaliasregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -Field.of("description").regexContains("(?i)example"); - -``` - | -| [regexContains(pattern)](./firestore_.exprwithalias.md#exprwithaliasregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains the regular expression stored in field 'regex' -Field.of("description").regexContains(Field.of("regex")); - -``` - | -| [regexMatch(pattern)](./firestore_.exprwithalias.md#exprwithaliasregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. -```typescript -// Check if the 'email' field matches a valid email pattern -Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - | -| [regexMatch(pattern)](./firestore_.exprwithalias.md#exprwithaliasregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. -```typescript -// Check if the 'email' field matches a regular expression stored in field 'regex' -Field.of("email").regexMatch(Field.of("regex")); - -``` - | -| [replaceAll(find, replace)](./firestore_.exprwithalias.md#exprwithaliasreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring. -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field -Field.of("message").replaceAll("hello", "hi"); - -``` - | -| [replaceAll(find, replace)](./firestore_.exprwithalias.md#exprwithaliasreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); - -``` - | -| [replaceFirst(find, replace)](./firestore_.exprwithalias.md#exprwithaliasreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field -Field.of("message").replaceFirst("hello", "hi"); - -``` - | -| [replaceFirst(find, replace)](./firestore_.exprwithalias.md#exprwithaliasreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); - -``` - | -| [reverse()](./firestore_.exprwithalias.md#exprwithaliasreverse) | | (BETA) Creates an expression that reverses this string expression. -```typescript -// Reverse the value of the 'myString' field. -Field.of("myString").reverse(); - -``` - A new representing the reversed string. | -| [startsWith(prefix)](./firestore_.exprwithalias.md#exprwithaliasstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix. -```typescript -// Check if the 'name' field starts with "Mr." -Field.of("name").startsWith("Mr."); - -``` - | -| [startsWith(prefix)](./firestore_.exprwithalias.md#exprwithaliasstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix (represented as an expression). -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -Field.of("fullName").startsWith(Field.of("firstName")); - -``` - | -| [strConcat(elements)](./firestore_.exprwithalias.md#exprwithaliasstrconcat) | | (BETA) Creates an expression that concatenates string expressions together. -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); - -``` - | -| [strContains(substring)](./firestore_.exprwithalias.md#exprwithaliasstrcontains) | | (BETA) Creates an expression that checks if a string contains a specified substring. -```typescript -// Check if the 'description' field contains "example". -Field.of("description").strContains("example"); - -``` - | -| [strContains(expr)](./firestore_.exprwithalias.md#exprwithaliasstrcontains) | | (BETA) Creates an expression that checks if a string contains the string represented by another expression. -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -Field.of("description").strContains(Field.of("keyword")); - -``` - | -| [subtract(other)](./firestore_.exprwithalias.md#exprwithaliassubtract) | | (BETA) Creates an expression that subtracts another expression from this expression. -```typescript -// Subtract the 'discount' field from the 'price' field -Field.of("price").subtract(Field.of("discount")); - -``` - | -| [subtract(other)](./firestore_.exprwithalias.md#exprwithaliassubtract) | | (BETA) Creates an expression that subtracts a constant value from this expression. -```typescript -// Subtract 20 from the value of the 'total' field -Field.of("total").subtract(20); - -``` - | -| [sum()](./firestore_.exprwithalias.md#exprwithaliassum) | | (BETA) Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. -```typescript -// Calculate the total revenue from a set of orders -Field.of("orderAmount").sum().as("totalRevenue"); - -``` - A new Accumulator representing the 'sum' aggregation. | -| [timestampAdd(unit, amount)](./firestore_.exprwithalias.md#exprwithaliastimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampAdd(unit, amount)](./firestore_.exprwithalias.md#exprwithaliastimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. -```typescript -// Add 1 day to the 'timestamp' field. -Field.of("timestamp").timestampAdd("day", 1); - -``` - | -| [timestampSub(unit, amount)](./firestore_.exprwithalias.md#exprwithaliastimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampSub(unit, amount)](./firestore_.exprwithalias.md#exprwithaliastimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. -```typescript -// Subtract 1 day from the 'timestamp' field. -Field.of("timestamp").timestampSub("day", 1); - -``` - | -| [timestampToUnixMicros()](./firestore_.exprwithalias.md#exprwithaliastimestamptounixmicros) | | (BETA) Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -Field.of("timestamp").timestampToUnixMicros(); - -``` - A new representing the number of microseconds since epoch. | -| [timestampToUnixMillis()](./firestore_.exprwithalias.md#exprwithaliastimestamptounixmillis) | | (BETA) Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -Field.of("timestamp").timestampToUnixMillis(); - -``` - A new representing the number of milliseconds since epoch. | -| [timestampToUnixSeconds()](./firestore_.exprwithalias.md#exprwithaliastimestamptounixseconds) | | (BETA) Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to seconds since epoch. -Field.of("timestamp").timestampToUnixSeconds(); - -``` - A new representing the number of seconds since epoch. | -| [toLower()](./firestore_.exprwithalias.md#exprwithaliastolower) | | (BETA) Creates an expression that converts a string to lowercase. -```typescript -// Convert the 'name' field to lowercase -Field.of("name").toLower(); - -``` - A new Expr representing the lowercase string. | -| [toUpper()](./firestore_.exprwithalias.md#exprwithaliastoupper) | | (BETA) Creates an expression that converts a string to uppercase. -```typescript -// Convert the 'title' field to uppercase -Field.of("title").toUpper(); - -``` - A new Expr representing the uppercase string. | -| [trim()](./firestore_.exprwithalias.md#exprwithaliastrim) | | (BETA) Creates an expression that removes leading and trailing whitespace from a string. -```typescript -// Trim whitespace from the 'userInput' field -Field.of("userInput").trim(); - -``` - A new Expr representing the trimmed string. | -| [unixMicrosToTimestamp()](./firestore_.exprwithalias.md#exprwithaliasunixmicrostotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -Field.of("microseconds").unixMicrosToTimestamp(); - -``` - A new representing the timestamp. | -| [unixMillisToTimestamp()](./firestore_.exprwithalias.md#exprwithaliasunixmillistotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -Field.of("milliseconds").unixMillisToTimestamp(); - -``` - A new representing the timestamp. | -| [unixSecondsToTimestamp()](./firestore_.exprwithalias.md#exprwithaliasunixsecondstotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'seconds' field as seconds since epoch. -Field.of("seconds").unixSecondsToTimestamp(); - -``` - A new representing the timestamp. | -| [vectorLength()](./firestore_.exprwithalias.md#exprwithaliasvectorlength) | | (BETA) Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. -```typescript -// Get the vector length (dimension) of the field 'embedding'. -Field.of("embedding").vectorLength(); - -``` - A new representing the length of the vector. | - -## ExprWithAlias.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ExprWithAlias` class - -Signature: - -```typescript -constructor(expr: T, alias: string); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | T | | -| alias | string | | - -## ExprWithAlias.alias - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -alias: string; -``` - -## ExprWithAlias.expr - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -expr: T; -``` - -## ExprWithAlias.exprType - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -exprType: ExprType; -``` - -## ExprWithAlias.selectable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -selectable: true; -``` - -## ExprWithAlias.add() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds this expression to another expression. - -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -Field.of("quantity").add(Field.of("reserve")); - -``` - -Signature: - -```typescript -add(other: Constant): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to add to this expression. A new Expr representing the addition operation. | - -Returns: - -[Add](./firestore_.add.md#add_class) - -## ExprWithAlias.add() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds this expression to a constant value. - -```typescript -// Add 5 to the value of the 'age' field -Field.of("age").add(5); - -``` - -Signature: - -```typescript -add(other: any): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to add. A new Expr representing the addition operation. | - -Returns: - -[Add](./firestore_.add.md#add_class) - -## ExprWithAlias.arrayConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with one or more other arrays. - -```typescript -// Combine the 'items' array with another array field. -Field.of("items").arrayConcat(Field.of("otherItems")); - -``` - -Signature: - -```typescript -arrayConcat(arrays: Constant[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| arrays | [Constant](./firestore_.constant.md#constant_class)\[\] | The array expressions to concatenate. A new Expr representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) - -## ExprWithAlias.arrayConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with one or more other arrays. - -```typescript -// Combine the 'tags' array with a new array and an array field -Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); - -``` - -Signature: - -```typescript -arrayConcat(arrays: any[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| arrays | any\[\] | The array expressions or values to concatenate. A new Expr representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) - -## ExprWithAlias.arrayContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains a specific element. - -```typescript -// Check if the 'sizes' array contains the value from the 'selectedSize' field -Field.of("sizes").arrayContains(Field.of("selectedSize")); - -``` - -Signature: - -```typescript -arrayContains(element: Constant): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | [Constant](./firestore_.constant.md#constant_class) | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) - -## ExprWithAlias.arrayContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains a specific value. - -```typescript -// Check if the 'colors' array contains "red" -Field.of("colors").arrayContains("red"); - -``` - -Signature: - -```typescript -arrayContains(element: any): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | any | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) - -## ExprWithAlias.arrayContainsAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both "news" and "sports" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - -Signature: - -```typescript -arrayContainsAll(...values: Constant[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) - -## ExprWithAlias.arrayContainsAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - -Signature: - -```typescript -arrayContainsAll(...values: any[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) - -## ExprWithAlias.arrayContainsAny() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains any of the specified elements. - -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "cate2" -Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); - -``` - -Signature: - -```typescript -arrayContainsAny(...values: Constant[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) - -## ExprWithAlias.arrayContainsAny() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains any of the specified elements. - -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); - -``` - -Signature: - -```typescript -arrayContainsAny(...values: any[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) - -## ExprWithAlias.arrayLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of an array. - -```typescript -// Get the number of items in the 'cart' array -Field.of("cart").arrayLength(); - -``` - A new `Expr` representing the length of the array. - -Signature: - -```typescript -arrayLength(): ArrayLength; -``` -Returns: - -[ArrayLength](./firestore_.arraylength.md#arraylength_class) - -## ExprWithAlias.as() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Assigns an alias to this expression. - -Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. - -```typescript -// Calculate the total price and assign it the alias "totalPrice" and add it to the output. -firestore.pipeline().collection("items") -.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); - -``` - -Signature: - -```typescript -as(name: string): ExprWithAlias; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | The alias to assign to this expression. A new [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) that wraps this expression and associates it with the provided alias. | - -Returns: - -[ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class)<this> - -## ExprWithAlias.ascending() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. - -```typescript -// Sort documents by the 'name' field in ascending order -pipeline().collection("users") -.sort(Field.of("name").ascending()); - -``` - A new `Ordering` for ascending sorting. - -Signature: - -```typescript -ascending(): Ordering; -``` -Returns: - -[Ordering](./firestore_.ordering.md#ordering_class) - -## ExprWithAlias.avg() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. - -```typescript -// Calculate the average age of users -Field.of("age").avg().as("averageAge"); - -``` - A new `Accumulator` representing the 'avg' aggregation. - -Signature: - -```typescript -avg(): Avg; -``` -Returns: - -[Avg](./firestore_.avg.md#avg_class) - -## ExprWithAlias.byteLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of this string expression in bytes. - -```typescript -// Calculate the length of the 'myString' field in bytes. -Field.of("myString").byteLength(); - -``` - A new representing the length of the string in bytes. - -Signature: - -```typescript -byteLength(): ByteLength; -``` -Returns: - -[ByteLength](./firestore_.bytelength.md#bytelength_class) - -## ExprWithAlias.charLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the character length of a string in UTF-8. - -```typescript -// Get the character length of the 'name' field in its UTF-8 form. -Field.of("name").charLength(); - -``` - A new `Expr` representing the length of the string. - -Signature: - -```typescript -charLength(): CharLength; -``` -Returns: - -[CharLength](./firestore_.charlength.md#charlength_class) - -## ExprWithAlias.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the cosine distance between two vectors. - -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -Field.of("userVector").cosineDistance(Field.of("itemVector")); - -``` - -Signature: - -```typescript -cosineDistance(other: Constant): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new Expr representing the cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) - -## ExprWithAlias.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vectors. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -cosineDistance(other: VectorValue): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) - -## ExprWithAlias.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vectors. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance([37.7749, -122.4194]); - -``` - -Signature: - -```typescript -cosineDistance(other: number[]): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | The other vector (as an array of numbers) to compare against. A new Expr representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) - -## ExprWithAlias.count() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. - -```typescript -// Count the total number of products -Field.of("productId").count().as("totalProducts"); - -``` - A new `Accumulator` representing the 'count' aggregation. - -Signature: - -```typescript -count(): Count; -``` -Returns: - -[Count](./firestore_.count.md#count_class) - -## ExprWithAlias.descending() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. - -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") -.sort(Field.of("createdAt").descending()); - -``` - A new `Ordering` for descending sorting. - -Signature: - -```typescript -descending(): Ordering; -``` -Returns: - -[Ordering](./firestore_.ordering.md#ordering_class) - -## ExprWithAlias.divide() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides this expression by another expression. - -```typescript -// Divide the 'total' field by the 'count' field -Field.of("total").divide(Field.of("count")); - -``` - -Signature: - -```typescript -divide(other: Constant): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new Expr representing the division operation. | - -Returns: - -[Divide](./firestore_.divide.md#divide_class) - -## ExprWithAlias.divide() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides this expression by a constant value. - -```typescript -// Divide the 'value' field by 10 -Field.of("value").divide(10); - -``` - -Signature: - -```typescript -divide(other: any): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to divide by. A new Expr representing the division operation. | - -Returns: - -[Divide](./firestore_.divide.md#divide_class) - -## ExprWithAlias.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vectors. - -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct([0.5, 0.8, 0.2]); - -``` - -Signature: - -```typescript -dotProduct(other: Constant): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_.dotproduct.md#dotproduct_class) - -## ExprWithAlias.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vectors. - -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); - -``` - -Signature: - -```typescript -dotProduct(other: VectorValue): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_.dotproduct.md#dotproduct_class) - -## ExprWithAlias.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -dotProduct(other: number[]): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | | - -Returns: - -[DotProduct](./firestore_.dotproduct.md#dotproduct_class) - -## ExprWithAlias.endsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string ends with a given postfix. - -```typescript -// Check if the 'filename' field ends with ".txt" -Field.of("filename").endsWith(".txt"); - -``` - -Signature: - -```typescript -endsWith(suffix: string): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| suffix | string | The postfix to check for. A new Expr representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_.endswith.md#endswith_class) - -## ExprWithAlias.endsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string ends with a given postfix (represented as an expression). - -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -Field.of("url").endsWith(Field.of("extension")); - -``` - -Signature: - -```typescript -endsWith(suffix: Constant): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| suffix | [Constant](./firestore_.constant.md#constant_class) | The postfix expression to check for. A new Expr representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_.endswith.md#endswith_class) - -## ExprWithAlias.eq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to another expression. - -```typescript -// Check if the 'age' field is equal to 21 -Field.of("age").eq(21); - -``` - -Signature: - -```typescript -eq(other: Constant): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for equality. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_.eq.md#eq_class) - -## ExprWithAlias.eq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to a constant value. - -```typescript -// Check if the 'city' field is equal to "London" -Field.of("city").eq("London"); - -``` - -Signature: - -```typescript -eq(other: any): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for equality. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_.eq.md#eq_class) - -## ExprWithAlias.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vectors. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance([37.7749, -122.4194]); - -``` - -Signature: - -```typescript -euclideanDistance(other: Constant): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) - -## ExprWithAlias.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vectors. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -euclideanDistance(other: VectorValue): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) - -## ExprWithAlias.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -euclideanDistance(other: number[]): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | | - -Returns: - -[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) - -## ExprWithAlias.exists() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field exists in the document. - -```typescript -// Check if the document has a field named "phoneNumber" -Field.of("phoneNumber").exists(); - -``` - A new `Expr` representing the 'exists' check. - -Signature: - -```typescript -exists(): Exists; -``` -Returns: - -[Exists](./firestore_.exists.md#exists_class) - -## ExprWithAlias.gt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than another expression. - -```typescript -// Check if the 'age' field is greater than the 'limit' field -Field.of("age").gt(Field.of("limit")); - -``` - -Signature: - -```typescript -gt(other: Constant): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for greater than. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_.gt.md#gt_class) - -## ExprWithAlias.gt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than a constant value. - -```typescript -// Check if the 'price' field is greater than 100 -Field.of("price").gt(100); - -``` - -Signature: - -```typescript -gt(other: any): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for greater than. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_.gt.md#gt_class) - -## ExprWithAlias.gte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than or equal to another expression. - -```typescript -// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 -Field.of("quantity").gte(Field.of('requirement').add(1)); - -``` - -Signature: - -```typescript -gte(other: Constant): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_.gte.md#gte_class) - -## ExprWithAlias.gte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than or equal to a constant value. - -```typescript -// Check if the 'score' field is greater than or equal to 80 -Field.of("score").gte(80); - -``` - -Signature: - -```typescript -gte(other: any): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_.gte.md#gte_class) - -## ExprWithAlias.in() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to any of the provided values or expressions. - -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -Field.of("category").in("Electronics", Field.of("primaryType")); - -``` - -Signature: - -```typescript -in(...others: Constant[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| others | [Constant](./firestore_.constant.md#constant_class)\[\] | The values or expressions to check against. A new Expr representing the 'IN' comparison. | - -Returns: - -[In](./firestore_.in.md#in_class) - -## ExprWithAlias.in() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -in(...others: any[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| others | any\[\] | | - -Returns: - -[In](./firestore_.in.md#in_class) - -## ExprWithAlias.isNaN() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). - -```typescript -// Check if the result of a calculation is NaN -Field.of("value").divide(0).isNaN(); - -``` - A new `Expr` representing the 'isNaN' check. - -Signature: - -```typescript -isNaN(): IsNan; -``` -Returns: - -[IsNan](./firestore_.isnan.md#isnan_class) - -## ExprWithAlias.like() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that performs a case-sensitive string comparison. - -```typescript -// Check if the 'title' field contains the word "guide" (case-sensitive) -Field.of("title").like("%guide%"); - -``` - -Signature: - -```typescript -like(pattern: string): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new Expr representing the 'like' comparison. | - -Returns: - -[Like](./firestore_.like.md#like_class) - -## ExprWithAlias.like() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -like(pattern: Constant): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_.constant.md#constant_class) | | - -Returns: - -[Like](./firestore_.like.md#like_class) - -## ExprWithAlias.logicalMax() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMax(Function.currentTimestamp()); - -``` - -Signature: - -```typescript -logicalMax(other: Constant): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare with. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) - -## ExprWithAlias.logicalMax() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'value' field and 10. -Field.of("value").logicalMax(10); - -``` - -Signature: - -```typescript -logicalMax(other: any): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare with. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) - -## ExprWithAlias.logicalMin() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMin(Function.currentTimestamp()); - -``` - -Signature: - -```typescript -logicalMin(other: Constant): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare with. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) - -## ExprWithAlias.logicalMin() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'value' field and 10. -Field.of("value").logicalMin(10); - -``` - -Signature: - -```typescript -logicalMin(other: any): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare with. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) - -## ExprWithAlias.lt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than another expression. - -```typescript -// Check if the 'age' field is less than 'limit' -Field.of("age").lt(Field.of('limit')); - -``` - -Signature: - -```typescript -lt(other: Constant): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for less than. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_.lt.md#lt_class) - -## ExprWithAlias.lt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than a constant value. - -```typescript -// Check if the 'price' field is less than 50 -Field.of("price").lt(50); - -``` - -Signature: - -```typescript -lt(other: any): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for less than. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_.lt.md#lt_class) - -## ExprWithAlias.lte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than or equal to another expression. - -```typescript -// Check if the 'quantity' field is less than or equal to 20 -Field.of("quantity").lte(Constant.of(20)); - -``` - -Signature: - -```typescript -lte(other: Constant): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_.lte.md#lte_class) - -## ExprWithAlias.lte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than or equal to a constant value. - -```typescript -// Check if the 'score' field is less than or equal to 70 -Field.of("score").lte(70); - -``` - -Signature: - -```typescript -lte(other: any): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_.lte.md#lte_class) - -## ExprWithAlias.mapGet() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Accesses a value from a map (object) field using the provided key. - -```typescript -// Get the 'city' value from the 'address' map field -Field.of("address").mapGet("city"); - -``` - -Signature: - -```typescript -mapGet(subfield: string): MapGet; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| subfield | string | The key to access in the map. A new Expr representing the value associated with the given key in the map. | - -Returns: - -[MapGet](./firestore_.mapget.md#mapget_class) - -## ExprWithAlias.max() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that finds the maximum value of a field across multiple stage inputs. - -```typescript -// Find the highest score in a leaderboard -Field.of("score").max().as("highestScore"); - -``` - A new `Accumulator` representing the 'max' aggregation. - -Signature: - -```typescript -max(): Max; -``` -Returns: - -[Max](./firestore_.max.md#max_class) - -## ExprWithAlias.min() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that finds the minimum value of a field across multiple stage inputs. - -```typescript -// Find the lowest price of all products -Field.of("price").min().as("lowestPrice"); - -``` - A new `Accumulator` representing the 'min' aggregation. - -Signature: - -```typescript -min(): Min; -``` -Returns: - -[Min](./firestore_.min.md#min_class) - -## ExprWithAlias.mod() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. - -```typescript -// Calculate the remainder of dividing the 'value' field by the 'divisor' field -Field.of("value").mod(Field.of("divisor")); - -``` - -Signature: - -```typescript -mod(other: Constant): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new Expr representing the modulo operation. | - -Returns: - -[Mod](./firestore_.mod.md#mod_class) - -## ExprWithAlias.mod() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. - -```typescript -// Calculate the remainder of dividing the 'value' field by 10 -Field.of("value").mod(10); - -``` - -Signature: - -```typescript -mod(other: any): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to divide by. A new Expr representing the modulo operation. | - -Returns: - -[Mod](./firestore_.mod.md#mod_class) - -## ExprWithAlias.multiply() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies this expression by another expression. - -```typescript -// Multiply the 'quantity' field by the 'price' field -Field.of("quantity").multiply(Field.of("price")); - -``` - -Signature: - -```typescript -multiply(other: Constant): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to multiply by. A new Expr representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_.multiply.md#multiply_class) - -## ExprWithAlias.multiply() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies this expression by a constant value. - -```typescript -// Multiply the 'value' field by 2 -Field.of("value").multiply(2); - -``` - -Signature: - -```typescript -multiply(other: any): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to multiply by. A new Expr representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_.multiply.md#multiply_class) - -## ExprWithAlias.neq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is not equal to another expression. - -```typescript -// Check if the 'status' field is not equal to "completed" -Field.of("status").neq("completed"); - -``` - -Signature: - -```typescript -neq(other: Constant): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for inequality. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_.neq.md#neq_class) - -## ExprWithAlias.neq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is not equal to a constant value. - -```typescript -// Check if the 'country' field is not equal to "USA" -Field.of("country").neq("USA"); - -``` - -Signature: - -```typescript -neq(other: any): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for inequality. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_.neq.md#neq_class) - -## ExprWithAlias.regexContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -Field.of("description").regexContains("(?i)example"); - -``` - -Signature: - -```typescript -regexContains(pattern: string): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_.regexcontains.md#regexcontains_class) - -## ExprWithAlias.regexContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains the regular expression stored in field 'regex' -Field.of("description").regexContains(Field.of("regex")); - -``` - -Signature: - -```typescript -regexContains(pattern: Constant): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_.regexcontains.md#regexcontains_class) - -## ExprWithAlias.regexMatch() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a valid email pattern -Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - -Signature: - -```typescript -regexMatch(pattern: string): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The regular expression to use for the match. A new Expr representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) - -## ExprWithAlias.regexMatch() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a regular expression stored in field 'regex' -Field.of("email").regexMatch(Field.of("regex")); - -``` - -Signature: - -```typescript -regexMatch(pattern: Constant): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the match. A new Expr representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) - -## ExprWithAlias.replaceAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within this string expression with another substring. - -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field -Field.of("message").replaceAll("hello", "hi"); - -``` - -Signature: - -```typescript -replaceAll(find: string, replace: string): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | string | The substring to search for. | -| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_.replaceall.md#replaceall_class) - -## ExprWithAlias.replaceAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. - -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); - -``` - -Signature: - -```typescript -replaceAll(find: Constant, replace: Constant): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_.replaceall.md#replaceall_class) - -## ExprWithAlias.replaceFirst() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. - -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field -Field.of("message").replaceFirst("hello", "hi"); - -``` - -Signature: - -```typescript -replaceFirst(find: string, replace: string): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | string | The substring to search for. | -| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) - -## ExprWithAlias.replaceFirst() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. - -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); - -``` - -Signature: - -```typescript -replaceFirst(find: Constant, replace: Constant): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) - -## ExprWithAlias.reverse() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that reverses this string expression. - -```typescript -// Reverse the value of the 'myString' field. -Field.of("myString").reverse(); - -``` - A new representing the reversed string. - -Signature: - -```typescript -reverse(): Reverse; -``` -Returns: - -[Reverse](./firestore_.reverse.md#reverse_class) - -## ExprWithAlias.startsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string starts with a given prefix. - -```typescript -// Check if the 'name' field starts with "Mr." -Field.of("name").startsWith("Mr."); - -``` - -Signature: - -```typescript -startsWith(prefix: string): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| prefix | string | The prefix to check for. A new Expr representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_.startswith.md#startswith_class) - -## ExprWithAlias.startsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string starts with a given prefix (represented as an expression). - -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -Field.of("fullName").startsWith(Field.of("firstName")); - -``` - -Signature: - -```typescript -startsWith(prefix: Constant): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| prefix | [Constant](./firestore_.constant.md#constant_class) | The prefix expression to check for. A new Expr representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_.startswith.md#startswith_class) - -## ExprWithAlias.strConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates string expressions together. - -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); - -``` - -Signature: - -```typescript -strConcat(...elements: Array): StrConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| elements | Array<string \| [Constant](./firestore_.constant.md#constant_class)> | The expressions (typically strings) to concatenate. A new Expr representing the concatenated string. | - -Returns: - -[StrConcat](./firestore_.strconcat.md#strconcat_class) - -## ExprWithAlias.strContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified substring. - -```typescript -// Check if the 'description' field contains "example". -Field.of("description").strContains("example"); - -``` - -Signature: - -```typescript -strContains(substring: string): StrContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| substring | string | The substring to search for. A new Expr representing the 'contains' comparison. | - -Returns: - -[StrContains](./firestore_.strcontains.md#strcontains_class) - -## ExprWithAlias.strContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains the string represented by another expression. - -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -Field.of("description").strContains(Field.of("keyword")); - -``` - -Signature: - -```typescript -strContains(expr: Constant): StrContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. A new Expr representing the 'contains' comparison. | - -Returns: - -[StrContains](./firestore_.strcontains.md#strcontains_class) - -## ExprWithAlias.subtract() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts another expression from this expression. - -```typescript -// Subtract the 'discount' field from the 'price' field -Field.of("price").subtract(Field.of("discount")); - -``` - -Signature: - -```typescript -subtract(other: Constant): Subtract; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to subtract from this expression. A new Expr representing the subtraction operation. | - -Returns: - -[Subtract](./firestore_.subtract.md#subtract_class) - -## ExprWithAlias.subtract() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a constant value from this expression. - -```typescript -// Subtract 20 from the value of the 'total' field -Field.of("total").subtract(20); - -``` - -Signature: - -```typescript -subtract(other: any): Subtract; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to subtract. A new Expr representing the subtraction operation. | - -Returns: - -[Subtract](./firestore_.subtract.md#subtract_class) - -## ExprWithAlias.sum() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. - -```typescript -// Calculate the total revenue from a set of orders -Field.of("orderAmount").sum().as("totalRevenue"); - -``` - A new `Accumulator` representing the 'sum' aggregation. - -Signature: - -```typescript -sum(): Sum; -``` -Returns: - -[Sum](./firestore_.sum.md#sum_class) - -## ExprWithAlias.timestampAdd() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to this timestamp expression. - -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); - -``` - -Signature: - -```typescript -timestampAdd(unit: Constant, amount: Constant): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) - -## ExprWithAlias.timestampAdd() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to this timestamp expression. - -```typescript -// Add 1 day to the 'timestamp' field. -Field.of("timestamp").timestampAdd("day", 1); - -``` - -Signature: - -```typescript -timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | -| amount | number | The amount of time to add. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) - -## ExprWithAlias.timestampSub() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from this timestamp expression. - -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); - -``` - -Signature: - -```typescript -timestampSub(unit: Constant, amount: Constant): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) - -## ExprWithAlias.timestampSub() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from this timestamp expression. - -```typescript -// Subtract 1 day from the 'timestamp' field. -Field.of("timestamp").timestampSub("day", 1); - -``` - -Signature: - -```typescript -timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | -| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) - -## ExprWithAlias.timestampToUnixMicros() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -Field.of("timestamp").timestampToUnixMicros(); - -``` - A new representing the number of microseconds since epoch. - -Signature: - -```typescript -timestampToUnixMicros(): TimestampToUnixMicros; -``` -Returns: - -[TimestampToUnixMicros](./firestore_.timestamptounixmicros.md#timestamptounixmicros_class) - -## ExprWithAlias.timestampToUnixMillis() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -Field.of("timestamp").timestampToUnixMillis(); - -``` - A new representing the number of milliseconds since epoch. - -Signature: - -```typescript -timestampToUnixMillis(): TimestampToUnixMillis; -``` -Returns: - -[TimestampToUnixMillis](./firestore_.timestamptounixmillis.md#timestamptounixmillis_class) - -## ExprWithAlias.timestampToUnixSeconds() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to seconds since epoch. -Field.of("timestamp").timestampToUnixSeconds(); - -``` - A new representing the number of seconds since epoch. - -Signature: - -```typescript -timestampToUnixSeconds(): TimestampToUnixSeconds; -``` -Returns: - -[TimestampToUnixSeconds](./firestore_.timestamptounixseconds.md#timestamptounixseconds_class) - -## ExprWithAlias.toLower() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string to lowercase. - -```typescript -// Convert the 'name' field to lowercase -Field.of("name").toLower(); - -``` - A new `Expr` representing the lowercase string. - -Signature: - -```typescript -toLower(): ToLower; -``` -Returns: - -[ToLower](./firestore_.tolower.md#tolower_class) - -## ExprWithAlias.toUpper() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string to uppercase. - -```typescript -// Convert the 'title' field to uppercase -Field.of("title").toUpper(); - -``` - A new `Expr` representing the uppercase string. - -Signature: - -```typescript -toUpper(): ToUpper; -``` -Returns: - -[ToUpper](./firestore_.toupper.md#toupper_class) - -## ExprWithAlias.trim() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that removes leading and trailing whitespace from a string. - -```typescript -// Trim whitespace from the 'userInput' field -Field.of("userInput").trim(); - -``` - A new `Expr` representing the trimmed string. - -Signature: - -```typescript -trim(): Trim; -``` -Returns: - -[Trim](./firestore_.trim.md#trim_class) - -## ExprWithAlias.unixMicrosToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -Field.of("microseconds").unixMicrosToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixMicrosToTimestamp(): UnixMicrosToTimestamp; -``` -Returns: - -[UnixMicrosToTimestamp](./firestore_.unixmicrostotimestamp.md#unixmicrostotimestamp_class) - -## ExprWithAlias.unixMillisToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -Field.of("milliseconds").unixMillisToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixMillisToTimestamp(): UnixMillisToTimestamp; -``` -Returns: - -[UnixMillisToTimestamp](./firestore_.unixmillistotimestamp.md#unixmillistotimestamp_class) - -## ExprWithAlias.unixSecondsToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'seconds' field as seconds since epoch. -Field.of("seconds").unixSecondsToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixSecondsToTimestamp(): UnixSecondsToTimestamp; -``` -Returns: - -[UnixSecondsToTimestamp](./firestore_.unixsecondstotimestamp.md#unixsecondstotimestamp_class) - -## ExprWithAlias.vectorLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. - -```typescript -// Get the vector length (dimension) of the field 'embedding'. -Field.of("embedding").vectorLength(); - -``` - A new representing the length of the vector. - -Signature: - -```typescript -vectorLength(): VectorLength; -``` -Returns: - -[VectorLength](./firestore_.vectorlength.md#vectorlength_class) - diff --git a/docs-devsite/firestore_.field.md b/docs-devsite/firestore_.field.md deleted file mode 100644 index d2406157dab..00000000000 --- a/docs-devsite/firestore_.field.md +++ /dev/null @@ -1,3275 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Field class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Represents a reference to a field in a Firestore document, or outputs of a [Pipeline](./firestore_.pipeline.md#pipeline_class) stage. - -

Field references are used to access document field values in expressions and to specify fields for sorting, filtering, and projecting data in Firestore pipelines. - -

You can create a `Field` instance using the static method: - -```typescript -// Create a Field instance for the 'name' field -const nameField = Field.of("name"); - -// Create a Field instance for a nested field 'address.city' -const cityField = Field.of("address.city"); - -``` - -Signature: - -```typescript -export declare class Field implements Selectable -``` -Implements: [Selectable](./firestore_.selectable.md#selectable_interface) - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [exprType](./firestore_.field.md#fieldexprtype) | | [ExprType](./firestore_.md#exprtype) | (BETA) | -| [selectable](./firestore_.field.md#fieldselectable) | | true | (BETA) | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [add(other)](./firestore_.field.md#fieldadd) | | (BETA) Creates an expression that adds this expression to another expression. -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -Field.of("quantity").add(Field.of("reserve")); - -``` - | -| [add(other)](./firestore_.field.md#fieldadd) | | (BETA) Creates an expression that adds this expression to a constant value. -```typescript -// Add 5 to the value of the 'age' field -Field.of("age").add(5); - -``` - | -| [arrayConcat(arrays)](./firestore_.field.md#fieldarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. -```typescript -// Combine the 'items' array with another array field. -Field.of("items").arrayConcat(Field.of("otherItems")); - -``` - | -| [arrayConcat(arrays)](./firestore_.field.md#fieldarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. -```typescript -// Combine the 'tags' array with a new array and an array field -Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); - -``` - | -| [arrayContains(element)](./firestore_.field.md#fieldarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific element. -```typescript -// Check if the 'sizes' array contains the value from the 'selectedSize' field -Field.of("sizes").arrayContains(Field.of("selectedSize")); - -``` - | -| [arrayContains(element)](./firestore_.field.md#fieldarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific value. -```typescript -// Check if the 'colors' array contains "red" -Field.of("colors").arrayContains("red"); - -``` - | -| [arrayContainsAll(values)](./firestore_.field.md#fieldarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. -```typescript -// Check if the 'tags' array contains both "news" and "sports" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - | -| [arrayContainsAll(values)](./firestore_.field.md#fieldarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - | -| [arrayContainsAny(values)](./firestore_.field.md#fieldarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "cate2" -Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); - -``` - | -| [arrayContainsAny(values)](./firestore_.field.md#fieldarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); - -``` - | -| [arrayLength()](./firestore_.field.md#fieldarraylength) | | (BETA) Creates an expression that calculates the length of an array. -```typescript -// Get the number of items in the 'cart' array -Field.of("cart").arrayLength(); - -``` - A new Expr representing the length of the array. | -| [as(name)](./firestore_.field.md#fieldas) | | (BETA) Assigns an alias to this expression.Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. -```typescript -// Calculate the total price and assign it the alias "totalPrice" and add it to the output. -firestore.pipeline().collection("items") -.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); - -``` - | -| [ascending()](./firestore_.field.md#fieldascending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. -```typescript -// Sort documents by the 'name' field in ascending order -pipeline().collection("users") -.sort(Field.of("name").ascending()); - -``` - A new Ordering for ascending sorting. | -| [avg()](./firestore_.field.md#fieldavg) | | (BETA) Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. -```typescript -// Calculate the average age of users -Field.of("age").avg().as("averageAge"); - -``` - A new Accumulator representing the 'avg' aggregation. | -| [byteLength()](./firestore_.field.md#fieldbytelength) | | (BETA) Creates an expression that calculates the length of this string expression in bytes. -```typescript -// Calculate the length of the 'myString' field in bytes. -Field.of("myString").byteLength(); - -``` - A new representing the length of the string in bytes. | -| [charLength()](./firestore_.field.md#fieldcharlength) | | (BETA) Creates an expression that calculates the character length of a string in UTF-8. -```typescript -// Get the character length of the 'name' field in its UTF-8 form. -Field.of("name").charLength(); - -``` - A new Expr representing the length of the string. | -| [cosineDistance(other)](./firestore_.field.md#fieldcosinedistance) | | (BETA) Calculates the cosine distance between two vectors. -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -Field.of("userVector").cosineDistance(Field.of("itemVector")); - -``` - | -| [cosineDistance(other)](./firestore_.field.md#fieldcosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); - -``` - | -| [cosineDistance(other)](./firestore_.field.md#fieldcosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance([37.7749, -122.4194]); - -``` - | -| [count()](./firestore_.field.md#fieldcount) | | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. -```typescript -// Count the total number of products -Field.of("productId").count().as("totalProducts"); - -``` - A new Accumulator representing the 'count' aggregation. | -| [descending()](./firestore_.field.md#fielddescending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") -.sort(Field.of("createdAt").descending()); - -``` - A new Ordering for descending sorting. | -| [divide(other)](./firestore_.field.md#fielddivide) | | (BETA) Creates an expression that divides this expression by another expression. -```typescript -// Divide the 'total' field by the 'count' field -Field.of("total").divide(Field.of("count")); - -``` - | -| [divide(other)](./firestore_.field.md#fielddivide) | | (BETA) Creates an expression that divides this expression by a constant value. -```typescript -// Divide the 'value' field by 10 -Field.of("value").divide(10); - -``` - | -| [dotProduct(other)](./firestore_.field.md#fielddotproduct) | | (BETA) Calculates the dot product between two vectors. -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct([0.5, 0.8, 0.2]); - -``` - | -| [dotProduct(other)](./firestore_.field.md#fielddotproduct) | | (BETA) Calculates the dot product between two vectors. -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); - -``` - | -| [dotProduct(other)](./firestore_.field.md#fielddotproduct) | | (BETA) | -| [endsWith(suffix)](./firestore_.field.md#fieldendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix. -```typescript -// Check if the 'filename' field ends with ".txt" -Field.of("filename").endsWith(".txt"); - -``` - | -| [endsWith(suffix)](./firestore_.field.md#fieldendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix (represented as an expression). -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -Field.of("url").endsWith(Field.of("extension")); - -``` - | -| [eq(other)](./firestore_.field.md#fieldeq) | | (BETA) Creates an expression that checks if this expression is equal to another expression. -```typescript -// Check if the 'age' field is equal to 21 -Field.of("age").eq(21); - -``` - | -| [eq(other)](./firestore_.field.md#fieldeq) | | (BETA) Creates an expression that checks if this expression is equal to a constant value. -```typescript -// Check if the 'city' field is equal to "London" -Field.of("city").eq("London"); - -``` - | -| [euclideanDistance(other)](./firestore_.field.md#fieldeuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance([37.7749, -122.4194]); - -``` - | -| [euclideanDistance(other)](./firestore_.field.md#fieldeuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); - -``` - | -| [euclideanDistance(other)](./firestore_.field.md#fieldeuclideandistance) | | (BETA) | -| [exists()](./firestore_.field.md#fieldexists) | | (BETA) Creates an expression that checks if a field exists in the document. -```typescript -// Check if the document has a field named "phoneNumber" -Field.of("phoneNumber").exists(); - -``` - A new Expr representing the 'exists' check. | -| [fieldName()](./firestore_.field.md#fieldfieldname) | | (BETA) | -| [gt(other)](./firestore_.field.md#fieldgt) | | (BETA) Creates an expression that checks if this expression is greater than another expression. -```typescript -// Check if the 'age' field is greater than the 'limit' field -Field.of("age").gt(Field.of("limit")); - -``` - | -| [gt(other)](./firestore_.field.md#fieldgt) | | (BETA) Creates an expression that checks if this expression is greater than a constant value. -```typescript -// Check if the 'price' field is greater than 100 -Field.of("price").gt(100); - -``` - | -| [gte(other)](./firestore_.field.md#fieldgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to another expression. -```typescript -// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 -Field.of("quantity").gte(Field.of('requirement').add(1)); - -``` - | -| [gte(other)](./firestore_.field.md#fieldgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to a constant value. -```typescript -// Check if the 'score' field is greater than or equal to 80 -Field.of("score").gte(80); - -``` - | -| [in(others)](./firestore_.field.md#fieldin) | | (BETA) Creates an expression that checks if this expression is equal to any of the provided values or expressions. -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -Field.of("category").in("Electronics", Field.of("primaryType")); - -``` - | -| [in(others)](./firestore_.field.md#fieldin) | | (BETA) | -| [isNaN()](./firestore_.field.md#fieldisnan) | | (BETA) Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). -```typescript -// Check if the result of a calculation is NaN -Field.of("value").divide(0).isNaN(); - -``` - A new Expr representing the 'isNaN' check. | -| [like(pattern)](./firestore_.field.md#fieldlike) | | (BETA) Creates an expression that performs a case-sensitive string comparison. -```typescript -// Check if the 'title' field contains the word "guide" (case-sensitive) -Field.of("title").like("%guide%"); - -``` - | -| [like(pattern)](./firestore_.field.md#fieldlike) | | (BETA) | -| [logicalMax(other)](./firestore_.field.md#fieldlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMax(Function.currentTimestamp()); - -``` - | -| [logicalMax(other)](./firestore_.field.md#fieldlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'value' field and 10. -Field.of("value").logicalMax(10); - -``` - | -| [logicalMin(other)](./firestore_.field.md#fieldlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMin(Function.currentTimestamp()); - -``` - | -| [logicalMin(other)](./firestore_.field.md#fieldlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'value' field and 10. -Field.of("value").logicalMin(10); - -``` - | -| [lt(other)](./firestore_.field.md#fieldlt) | | (BETA) Creates an expression that checks if this expression is less than another expression. -```typescript -// Check if the 'age' field is less than 'limit' -Field.of("age").lt(Field.of('limit')); - -``` - | -| [lt(other)](./firestore_.field.md#fieldlt) | | (BETA) Creates an expression that checks if this expression is less than a constant value. -```typescript -// Check if the 'price' field is less than 50 -Field.of("price").lt(50); - -``` - | -| [lte(other)](./firestore_.field.md#fieldlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to another expression. -```typescript -// Check if the 'quantity' field is less than or equal to 20 -Field.of("quantity").lte(Constant.of(20)); - -``` - | -| [lte(other)](./firestore_.field.md#fieldlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to a constant value. -```typescript -// Check if the 'score' field is less than or equal to 70 -Field.of("score").lte(70); - -``` - | -| [mapGet(subfield)](./firestore_.field.md#fieldmapget) | | (BETA) Accesses a value from a map (object) field using the provided key. -```typescript -// Get the 'city' value from the 'address' map field -Field.of("address").mapGet("city"); - -``` - | -| [max()](./firestore_.field.md#fieldmax) | | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. -```typescript -// Find the highest score in a leaderboard -Field.of("score").max().as("highestScore"); - -``` - A new Accumulator representing the 'max' aggregation. | -| [min()](./firestore_.field.md#fieldmin) | | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. -```typescript -// Find the lowest price of all products -Field.of("price").min().as("lowestPrice"); - -``` - A new Accumulator representing the 'min' aggregation. | -| [mod(other)](./firestore_.field.md#fieldmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. -```typescript -// Calculate the remainder of dividing the 'value' field by the 'divisor' field -Field.of("value").mod(Field.of("divisor")); - -``` - | -| [mod(other)](./firestore_.field.md#fieldmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. -```typescript -// Calculate the remainder of dividing the 'value' field by 10 -Field.of("value").mod(10); - -``` - | -| [multiply(other)](./firestore_.field.md#fieldmultiply) | | (BETA) Creates an expression that multiplies this expression by another expression. -```typescript -// Multiply the 'quantity' field by the 'price' field -Field.of("quantity").multiply(Field.of("price")); - -``` - | -| [multiply(other)](./firestore_.field.md#fieldmultiply) | | (BETA) Creates an expression that multiplies this expression by a constant value. -```typescript -// Multiply the 'value' field by 2 -Field.of("value").multiply(2); - -``` - | -| [neq(other)](./firestore_.field.md#fieldneq) | | (BETA) Creates an expression that checks if this expression is not equal to another expression. -```typescript -// Check if the 'status' field is not equal to "completed" -Field.of("status").neq("completed"); - -``` - | -| [neq(other)](./firestore_.field.md#fieldneq) | | (BETA) Creates an expression that checks if this expression is not equal to a constant value. -```typescript -// Check if the 'country' field is not equal to "USA" -Field.of("country").neq("USA"); - -``` - | -| [of(name)](./firestore_.field.md#fieldof) | static | (BETA) Creates a instance representing the field at the given path.The path can be a simple field name (e.g., "name") or a dot-separated path to a nested field (e.g., "address.city"). -```typescript -// Create a Field instance for the 'title' field -const titleField = Field.of("title"); - -// Create a Field instance for a nested field 'author.firstName' -const authorFirstNameField = Field.of("author.firstName"); - -``` - | -| [of(path)](./firestore_.field.md#fieldof) | static | (BETA) | -| [of(pipeline, name)](./firestore_.field.md#fieldof) | static | (BETA) | -| [regexContains(pattern)](./firestore_.field.md#fieldregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -Field.of("description").regexContains("(?i)example"); - -``` - | -| [regexContains(pattern)](./firestore_.field.md#fieldregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains the regular expression stored in field 'regex' -Field.of("description").regexContains(Field.of("regex")); - -``` - | -| [regexMatch(pattern)](./firestore_.field.md#fieldregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. -```typescript -// Check if the 'email' field matches a valid email pattern -Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - | -| [regexMatch(pattern)](./firestore_.field.md#fieldregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. -```typescript -// Check if the 'email' field matches a regular expression stored in field 'regex' -Field.of("email").regexMatch(Field.of("regex")); - -``` - | -| [replaceAll(find, replace)](./firestore_.field.md#fieldreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring. -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field -Field.of("message").replaceAll("hello", "hi"); - -``` - | -| [replaceAll(find, replace)](./firestore_.field.md#fieldreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); - -``` - | -| [replaceFirst(find, replace)](./firestore_.field.md#fieldreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field -Field.of("message").replaceFirst("hello", "hi"); - -``` - | -| [replaceFirst(find, replace)](./firestore_.field.md#fieldreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); - -``` - | -| [reverse()](./firestore_.field.md#fieldreverse) | | (BETA) Creates an expression that reverses this string expression. -```typescript -// Reverse the value of the 'myString' field. -Field.of("myString").reverse(); - -``` - A new representing the reversed string. | -| [startsWith(prefix)](./firestore_.field.md#fieldstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix. -```typescript -// Check if the 'name' field starts with "Mr." -Field.of("name").startsWith("Mr."); - -``` - | -| [startsWith(prefix)](./firestore_.field.md#fieldstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix (represented as an expression). -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -Field.of("fullName").startsWith(Field.of("firstName")); - -``` - | -| [strConcat(elements)](./firestore_.field.md#fieldstrconcat) | | (BETA) Creates an expression that concatenates string expressions together. -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); - -``` - | -| [strContains(substring)](./firestore_.field.md#fieldstrcontains) | | (BETA) Creates an expression that checks if a string contains a specified substring. -```typescript -// Check if the 'description' field contains "example". -Field.of("description").strContains("example"); - -``` - | -| [strContains(expr)](./firestore_.field.md#fieldstrcontains) | | (BETA) Creates an expression that checks if a string contains the string represented by another expression. -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -Field.of("description").strContains(Field.of("keyword")); - -``` - | -| [subtract(other)](./firestore_.field.md#fieldsubtract) | | (BETA) Creates an expression that subtracts another expression from this expression. -```typescript -// Subtract the 'discount' field from the 'price' field -Field.of("price").subtract(Field.of("discount")); - -``` - | -| [subtract(other)](./firestore_.field.md#fieldsubtract) | | (BETA) Creates an expression that subtracts a constant value from this expression. -```typescript -// Subtract 20 from the value of the 'total' field -Field.of("total").subtract(20); - -``` - | -| [sum()](./firestore_.field.md#fieldsum) | | (BETA) Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. -```typescript -// Calculate the total revenue from a set of orders -Field.of("orderAmount").sum().as("totalRevenue"); - -``` - A new Accumulator representing the 'sum' aggregation. | -| [timestampAdd(unit, amount)](./firestore_.field.md#fieldtimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampAdd(unit, amount)](./firestore_.field.md#fieldtimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. -```typescript -// Add 1 day to the 'timestamp' field. -Field.of("timestamp").timestampAdd("day", 1); - -``` - | -| [timestampSub(unit, amount)](./firestore_.field.md#fieldtimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampSub(unit, amount)](./firestore_.field.md#fieldtimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. -```typescript -// Subtract 1 day from the 'timestamp' field. -Field.of("timestamp").timestampSub("day", 1); - -``` - | -| [timestampToUnixMicros()](./firestore_.field.md#fieldtimestamptounixmicros) | | (BETA) Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -Field.of("timestamp").timestampToUnixMicros(); - -``` - A new representing the number of microseconds since epoch. | -| [timestampToUnixMillis()](./firestore_.field.md#fieldtimestamptounixmillis) | | (BETA) Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -Field.of("timestamp").timestampToUnixMillis(); - -``` - A new representing the number of milliseconds since epoch. | -| [timestampToUnixSeconds()](./firestore_.field.md#fieldtimestamptounixseconds) | | (BETA) Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to seconds since epoch. -Field.of("timestamp").timestampToUnixSeconds(); - -``` - A new representing the number of seconds since epoch. | -| [toLower()](./firestore_.field.md#fieldtolower) | | (BETA) Creates an expression that converts a string to lowercase. -```typescript -// Convert the 'name' field to lowercase -Field.of("name").toLower(); - -``` - A new Expr representing the lowercase string. | -| [toUpper()](./firestore_.field.md#fieldtoupper) | | (BETA) Creates an expression that converts a string to uppercase. -```typescript -// Convert the 'title' field to uppercase -Field.of("title").toUpper(); - -``` - A new Expr representing the uppercase string. | -| [trim()](./firestore_.field.md#fieldtrim) | | (BETA) Creates an expression that removes leading and trailing whitespace from a string. -```typescript -// Trim whitespace from the 'userInput' field -Field.of("userInput").trim(); - -``` - A new Expr representing the trimmed string. | -| [unixMicrosToTimestamp()](./firestore_.field.md#fieldunixmicrostotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -Field.of("microseconds").unixMicrosToTimestamp(); - -``` - A new representing the timestamp. | -| [unixMillisToTimestamp()](./firestore_.field.md#fieldunixmillistotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -Field.of("milliseconds").unixMillisToTimestamp(); - -``` - A new representing the timestamp. | -| [unixSecondsToTimestamp()](./firestore_.field.md#fieldunixsecondstotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'seconds' field as seconds since epoch. -Field.of("seconds").unixSecondsToTimestamp(); - -``` - A new representing the timestamp. | -| [vectorLength()](./firestore_.field.md#fieldvectorlength) | | (BETA) Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. -```typescript -// Get the vector length (dimension) of the field 'embedding'. -Field.of("embedding").vectorLength(); - -``` - A new representing the length of the vector. | - -## Field.exprType - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -exprType: ExprType; -``` - -## Field.selectable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -selectable: true; -``` - -## Field.add() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds this expression to another expression. - -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -Field.of("quantity").add(Field.of("reserve")); - -``` - -Signature: - -```typescript -add(other: Constant): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to add to this expression. A new Expr representing the addition operation. | - -Returns: - -[Add](./firestore_.add.md#add_class) - -## Field.add() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds this expression to a constant value. - -```typescript -// Add 5 to the value of the 'age' field -Field.of("age").add(5); - -``` - -Signature: - -```typescript -add(other: any): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to add. A new Expr representing the addition operation. | - -Returns: - -[Add](./firestore_.add.md#add_class) - -## Field.arrayConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with one or more other arrays. - -```typescript -// Combine the 'items' array with another array field. -Field.of("items").arrayConcat(Field.of("otherItems")); - -``` - -Signature: - -```typescript -arrayConcat(arrays: Constant[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| arrays | [Constant](./firestore_.constant.md#constant_class)\[\] | The array expressions to concatenate. A new Expr representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) - -## Field.arrayConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with one or more other arrays. - -```typescript -// Combine the 'tags' array with a new array and an array field -Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); - -``` - -Signature: - -```typescript -arrayConcat(arrays: any[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| arrays | any\[\] | The array expressions or values to concatenate. A new Expr representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) - -## Field.arrayContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains a specific element. - -```typescript -// Check if the 'sizes' array contains the value from the 'selectedSize' field -Field.of("sizes").arrayContains(Field.of("selectedSize")); - -``` - -Signature: - -```typescript -arrayContains(element: Constant): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | [Constant](./firestore_.constant.md#constant_class) | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) - -## Field.arrayContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains a specific value. - -```typescript -// Check if the 'colors' array contains "red" -Field.of("colors").arrayContains("red"); - -``` - -Signature: - -```typescript -arrayContains(element: any): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | any | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) - -## Field.arrayContainsAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both "news" and "sports" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - -Signature: - -```typescript -arrayContainsAll(...values: Constant[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) - -## Field.arrayContainsAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - -Signature: - -```typescript -arrayContainsAll(...values: any[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) - -## Field.arrayContainsAny() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains any of the specified elements. - -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "cate2" -Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); - -``` - -Signature: - -```typescript -arrayContainsAny(...values: Constant[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) - -## Field.arrayContainsAny() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains any of the specified elements. - -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); - -``` - -Signature: - -```typescript -arrayContainsAny(...values: any[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) - -## Field.arrayLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of an array. - -```typescript -// Get the number of items in the 'cart' array -Field.of("cart").arrayLength(); - -``` - A new `Expr` representing the length of the array. - -Signature: - -```typescript -arrayLength(): ArrayLength; -``` -Returns: - -[ArrayLength](./firestore_.arraylength.md#arraylength_class) - -## Field.as() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Assigns an alias to this expression. - -Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. - -```typescript -// Calculate the total price and assign it the alias "totalPrice" and add it to the output. -firestore.pipeline().collection("items") -.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); - -``` - -Signature: - -```typescript -as(name: string): ExprWithAlias; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | The alias to assign to this expression. A new [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) that wraps this expression and associates it with the provided alias. | - -Returns: - -[ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class)<this> - -## Field.ascending() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. - -```typescript -// Sort documents by the 'name' field in ascending order -pipeline().collection("users") -.sort(Field.of("name").ascending()); - -``` - A new `Ordering` for ascending sorting. - -Signature: - -```typescript -ascending(): Ordering; -``` -Returns: - -[Ordering](./firestore_.ordering.md#ordering_class) - -## Field.avg() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. - -```typescript -// Calculate the average age of users -Field.of("age").avg().as("averageAge"); - -``` - A new `Accumulator` representing the 'avg' aggregation. - -Signature: - -```typescript -avg(): Avg; -``` -Returns: - -[Avg](./firestore_.avg.md#avg_class) - -## Field.byteLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of this string expression in bytes. - -```typescript -// Calculate the length of the 'myString' field in bytes. -Field.of("myString").byteLength(); - -``` - A new representing the length of the string in bytes. - -Signature: - -```typescript -byteLength(): ByteLength; -``` -Returns: - -[ByteLength](./firestore_.bytelength.md#bytelength_class) - -## Field.charLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the character length of a string in UTF-8. - -```typescript -// Get the character length of the 'name' field in its UTF-8 form. -Field.of("name").charLength(); - -``` - A new `Expr` representing the length of the string. - -Signature: - -```typescript -charLength(): CharLength; -``` -Returns: - -[CharLength](./firestore_.charlength.md#charlength_class) - -## Field.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the cosine distance between two vectors. - -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -Field.of("userVector").cosineDistance(Field.of("itemVector")); - -``` - -Signature: - -```typescript -cosineDistance(other: Constant): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new Expr representing the cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) - -## Field.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vectors. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -cosineDistance(other: VectorValue): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) - -## Field.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vectors. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance([37.7749, -122.4194]); - -``` - -Signature: - -```typescript -cosineDistance(other: number[]): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | The other vector (as an array of numbers) to compare against. A new Expr representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) - -## Field.count() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. - -```typescript -// Count the total number of products -Field.of("productId").count().as("totalProducts"); - -``` - A new `Accumulator` representing the 'count' aggregation. - -Signature: - -```typescript -count(): Count; -``` -Returns: - -[Count](./firestore_.count.md#count_class) - -## Field.descending() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. - -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") -.sort(Field.of("createdAt").descending()); - -``` - A new `Ordering` for descending sorting. - -Signature: - -```typescript -descending(): Ordering; -``` -Returns: - -[Ordering](./firestore_.ordering.md#ordering_class) - -## Field.divide() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides this expression by another expression. - -```typescript -// Divide the 'total' field by the 'count' field -Field.of("total").divide(Field.of("count")); - -``` - -Signature: - -```typescript -divide(other: Constant): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new Expr representing the division operation. | - -Returns: - -[Divide](./firestore_.divide.md#divide_class) - -## Field.divide() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides this expression by a constant value. - -```typescript -// Divide the 'value' field by 10 -Field.of("value").divide(10); - -``` - -Signature: - -```typescript -divide(other: any): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to divide by. A new Expr representing the division operation. | - -Returns: - -[Divide](./firestore_.divide.md#divide_class) - -## Field.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vectors. - -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct([0.5, 0.8, 0.2]); - -``` - -Signature: - -```typescript -dotProduct(other: Constant): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_.dotproduct.md#dotproduct_class) - -## Field.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vectors. - -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); - -``` - -Signature: - -```typescript -dotProduct(other: VectorValue): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_.dotproduct.md#dotproduct_class) - -## Field.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -dotProduct(other: number[]): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | | - -Returns: - -[DotProduct](./firestore_.dotproduct.md#dotproduct_class) - -## Field.endsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string ends with a given postfix. - -```typescript -// Check if the 'filename' field ends with ".txt" -Field.of("filename").endsWith(".txt"); - -``` - -Signature: - -```typescript -endsWith(suffix: string): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| suffix | string | The postfix to check for. A new Expr representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_.endswith.md#endswith_class) - -## Field.endsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string ends with a given postfix (represented as an expression). - -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -Field.of("url").endsWith(Field.of("extension")); - -``` - -Signature: - -```typescript -endsWith(suffix: Constant): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| suffix | [Constant](./firestore_.constant.md#constant_class) | The postfix expression to check for. A new Expr representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_.endswith.md#endswith_class) - -## Field.eq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to another expression. - -```typescript -// Check if the 'age' field is equal to 21 -Field.of("age").eq(21); - -``` - -Signature: - -```typescript -eq(other: Constant): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for equality. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_.eq.md#eq_class) - -## Field.eq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to a constant value. - -```typescript -// Check if the 'city' field is equal to "London" -Field.of("city").eq("London"); - -``` - -Signature: - -```typescript -eq(other: any): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for equality. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_.eq.md#eq_class) - -## Field.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vectors. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance([37.7749, -122.4194]); - -``` - -Signature: - -```typescript -euclideanDistance(other: Constant): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) - -## Field.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vectors. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -euclideanDistance(other: VectorValue): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) - -## Field.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -euclideanDistance(other: number[]): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | | - -Returns: - -[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) - -## Field.exists() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field exists in the document. - -```typescript -// Check if the document has a field named "phoneNumber" -Field.of("phoneNumber").exists(); - -``` - A new `Expr` representing the 'exists' check. - -Signature: - -```typescript -exists(): Exists; -``` -Returns: - -[Exists](./firestore_.exists.md#exists_class) - -## Field.fieldName() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -fieldName(): string; -``` -Returns: - -string - -## Field.gt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than another expression. - -```typescript -// Check if the 'age' field is greater than the 'limit' field -Field.of("age").gt(Field.of("limit")); - -``` - -Signature: - -```typescript -gt(other: Constant): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for greater than. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_.gt.md#gt_class) - -## Field.gt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than a constant value. - -```typescript -// Check if the 'price' field is greater than 100 -Field.of("price").gt(100); - -``` - -Signature: - -```typescript -gt(other: any): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for greater than. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_.gt.md#gt_class) - -## Field.gte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than or equal to another expression. - -```typescript -// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 -Field.of("quantity").gte(Field.of('requirement').add(1)); - -``` - -Signature: - -```typescript -gte(other: Constant): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_.gte.md#gte_class) - -## Field.gte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than or equal to a constant value. - -```typescript -// Check if the 'score' field is greater than or equal to 80 -Field.of("score").gte(80); - -``` - -Signature: - -```typescript -gte(other: any): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_.gte.md#gte_class) - -## Field.in() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to any of the provided values or expressions. - -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -Field.of("category").in("Electronics", Field.of("primaryType")); - -``` - -Signature: - -```typescript -in(...others: Constant[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| others | [Constant](./firestore_.constant.md#constant_class)\[\] | The values or expressions to check against. A new Expr representing the 'IN' comparison. | - -Returns: - -[In](./firestore_.in.md#in_class) - -## Field.in() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -in(...others: any[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| others | any\[\] | | - -Returns: - -[In](./firestore_.in.md#in_class) - -## Field.isNaN() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). - -```typescript -// Check if the result of a calculation is NaN -Field.of("value").divide(0).isNaN(); - -``` - A new `Expr` representing the 'isNaN' check. - -Signature: - -```typescript -isNaN(): IsNan; -``` -Returns: - -[IsNan](./firestore_.isnan.md#isnan_class) - -## Field.like() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that performs a case-sensitive string comparison. - -```typescript -// Check if the 'title' field contains the word "guide" (case-sensitive) -Field.of("title").like("%guide%"); - -``` - -Signature: - -```typescript -like(pattern: string): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new Expr representing the 'like' comparison. | - -Returns: - -[Like](./firestore_.like.md#like_class) - -## Field.like() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -like(pattern: Constant): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_.constant.md#constant_class) | | - -Returns: - -[Like](./firestore_.like.md#like_class) - -## Field.logicalMax() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMax(Function.currentTimestamp()); - -``` - -Signature: - -```typescript -logicalMax(other: Constant): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare with. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) - -## Field.logicalMax() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'value' field and 10. -Field.of("value").logicalMax(10); - -``` - -Signature: - -```typescript -logicalMax(other: any): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare with. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) - -## Field.logicalMin() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMin(Function.currentTimestamp()); - -``` - -Signature: - -```typescript -logicalMin(other: Constant): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare with. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) - -## Field.logicalMin() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'value' field and 10. -Field.of("value").logicalMin(10); - -``` - -Signature: - -```typescript -logicalMin(other: any): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare with. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) - -## Field.lt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than another expression. - -```typescript -// Check if the 'age' field is less than 'limit' -Field.of("age").lt(Field.of('limit')); - -``` - -Signature: - -```typescript -lt(other: Constant): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for less than. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_.lt.md#lt_class) - -## Field.lt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than a constant value. - -```typescript -// Check if the 'price' field is less than 50 -Field.of("price").lt(50); - -``` - -Signature: - -```typescript -lt(other: any): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for less than. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_.lt.md#lt_class) - -## Field.lte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than or equal to another expression. - -```typescript -// Check if the 'quantity' field is less than or equal to 20 -Field.of("quantity").lte(Constant.of(20)); - -``` - -Signature: - -```typescript -lte(other: Constant): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_.lte.md#lte_class) - -## Field.lte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than or equal to a constant value. - -```typescript -// Check if the 'score' field is less than or equal to 70 -Field.of("score").lte(70); - -``` - -Signature: - -```typescript -lte(other: any): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_.lte.md#lte_class) - -## Field.mapGet() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Accesses a value from a map (object) field using the provided key. - -```typescript -// Get the 'city' value from the 'address' map field -Field.of("address").mapGet("city"); - -``` - -Signature: - -```typescript -mapGet(subfield: string): MapGet; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| subfield | string | The key to access in the map. A new Expr representing the value associated with the given key in the map. | - -Returns: - -[MapGet](./firestore_.mapget.md#mapget_class) - -## Field.max() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that finds the maximum value of a field across multiple stage inputs. - -```typescript -// Find the highest score in a leaderboard -Field.of("score").max().as("highestScore"); - -``` - A new `Accumulator` representing the 'max' aggregation. - -Signature: - -```typescript -max(): Max; -``` -Returns: - -[Max](./firestore_.max.md#max_class) - -## Field.min() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that finds the minimum value of a field across multiple stage inputs. - -```typescript -// Find the lowest price of all products -Field.of("price").min().as("lowestPrice"); - -``` - A new `Accumulator` representing the 'min' aggregation. - -Signature: - -```typescript -min(): Min; -``` -Returns: - -[Min](./firestore_.min.md#min_class) - -## Field.mod() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. - -```typescript -// Calculate the remainder of dividing the 'value' field by the 'divisor' field -Field.of("value").mod(Field.of("divisor")); - -``` - -Signature: - -```typescript -mod(other: Constant): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new Expr representing the modulo operation. | - -Returns: - -[Mod](./firestore_.mod.md#mod_class) - -## Field.mod() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. - -```typescript -// Calculate the remainder of dividing the 'value' field by 10 -Field.of("value").mod(10); - -``` - -Signature: - -```typescript -mod(other: any): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to divide by. A new Expr representing the modulo operation. | - -Returns: - -[Mod](./firestore_.mod.md#mod_class) - -## Field.multiply() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies this expression by another expression. - -```typescript -// Multiply the 'quantity' field by the 'price' field -Field.of("quantity").multiply(Field.of("price")); - -``` - -Signature: - -```typescript -multiply(other: Constant): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to multiply by. A new Expr representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_.multiply.md#multiply_class) - -## Field.multiply() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies this expression by a constant value. - -```typescript -// Multiply the 'value' field by 2 -Field.of("value").multiply(2); - -``` - -Signature: - -```typescript -multiply(other: any): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to multiply by. A new Expr representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_.multiply.md#multiply_class) - -## Field.neq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is not equal to another expression. - -```typescript -// Check if the 'status' field is not equal to "completed" -Field.of("status").neq("completed"); - -``` - -Signature: - -```typescript -neq(other: Constant): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for inequality. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_.neq.md#neq_class) - -## Field.neq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is not equal to a constant value. - -```typescript -// Check if the 'country' field is not equal to "USA" -Field.of("country").neq("USA"); - -``` - -Signature: - -```typescript -neq(other: any): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for inequality. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_.neq.md#neq_class) - -## Field.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a instance representing the field at the given path. - -The path can be a simple field name (e.g., "name") or a dot-separated path to a nested field (e.g., "address.city"). - -```typescript -// Create a Field instance for the 'title' field -const titleField = Field.of("title"); - -// Create a Field instance for a nested field 'author.firstName' -const authorFirstNameField = Field.of("author.firstName"); - -``` - -Signature: - -```typescript -static of(name: string): Field; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | The path to the field. A new instance representing the specified field. | - -Returns: - -[Field](./firestore_.field.md#field_class) - -## Field.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -static of(path: FieldPath): Field; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| path | [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | | - -Returns: - -[Field](./firestore_.field.md#field_class) - -## Field.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -static of(pipeline: Pipeline, name: string): Field; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pipeline | [Pipeline](./firestore_.pipeline.md#pipeline_class) | | -| name | string | | - -Returns: - -[Field](./firestore_.field.md#field_class) - -## Field.regexContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -Field.of("description").regexContains("(?i)example"); - -``` - -Signature: - -```typescript -regexContains(pattern: string): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_.regexcontains.md#regexcontains_class) - -## Field.regexContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains the regular expression stored in field 'regex' -Field.of("description").regexContains(Field.of("regex")); - -``` - -Signature: - -```typescript -regexContains(pattern: Constant): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_.regexcontains.md#regexcontains_class) - -## Field.regexMatch() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a valid email pattern -Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - -Signature: - -```typescript -regexMatch(pattern: string): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The regular expression to use for the match. A new Expr representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) - -## Field.regexMatch() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a regular expression stored in field 'regex' -Field.of("email").regexMatch(Field.of("regex")); - -``` - -Signature: - -```typescript -regexMatch(pattern: Constant): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the match. A new Expr representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) - -## Field.replaceAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within this string expression with another substring. - -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field -Field.of("message").replaceAll("hello", "hi"); - -``` - -Signature: - -```typescript -replaceAll(find: string, replace: string): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | string | The substring to search for. | -| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_.replaceall.md#replaceall_class) - -## Field.replaceAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. - -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); - -``` - -Signature: - -```typescript -replaceAll(find: Constant, replace: Constant): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_.replaceall.md#replaceall_class) - -## Field.replaceFirst() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. - -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field -Field.of("message").replaceFirst("hello", "hi"); - -``` - -Signature: - -```typescript -replaceFirst(find: string, replace: string): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | string | The substring to search for. | -| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) - -## Field.replaceFirst() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. - -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); - -``` - -Signature: - -```typescript -replaceFirst(find: Constant, replace: Constant): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) - -## Field.reverse() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that reverses this string expression. - -```typescript -// Reverse the value of the 'myString' field. -Field.of("myString").reverse(); - -``` - A new representing the reversed string. - -Signature: - -```typescript -reverse(): Reverse; -``` -Returns: - -[Reverse](./firestore_.reverse.md#reverse_class) - -## Field.startsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string starts with a given prefix. - -```typescript -// Check if the 'name' field starts with "Mr." -Field.of("name").startsWith("Mr."); - -``` - -Signature: - -```typescript -startsWith(prefix: string): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| prefix | string | The prefix to check for. A new Expr representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_.startswith.md#startswith_class) - -## Field.startsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string starts with a given prefix (represented as an expression). - -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -Field.of("fullName").startsWith(Field.of("firstName")); - -``` - -Signature: - -```typescript -startsWith(prefix: Constant): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| prefix | [Constant](./firestore_.constant.md#constant_class) | The prefix expression to check for. A new Expr representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_.startswith.md#startswith_class) - -## Field.strConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates string expressions together. - -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); - -``` - -Signature: - -```typescript -strConcat(...elements: Array): StrConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| elements | Array<string \| [Constant](./firestore_.constant.md#constant_class)> | The expressions (typically strings) to concatenate. A new Expr representing the concatenated string. | - -Returns: - -[StrConcat](./firestore_.strconcat.md#strconcat_class) - -## Field.strContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified substring. - -```typescript -// Check if the 'description' field contains "example". -Field.of("description").strContains("example"); - -``` - -Signature: - -```typescript -strContains(substring: string): StrContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| substring | string | The substring to search for. A new Expr representing the 'contains' comparison. | - -Returns: - -[StrContains](./firestore_.strcontains.md#strcontains_class) - -## Field.strContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains the string represented by another expression. - -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -Field.of("description").strContains(Field.of("keyword")); - -``` - -Signature: - -```typescript -strContains(expr: Constant): StrContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. A new Expr representing the 'contains' comparison. | - -Returns: - -[StrContains](./firestore_.strcontains.md#strcontains_class) - -## Field.subtract() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts another expression from this expression. - -```typescript -// Subtract the 'discount' field from the 'price' field -Field.of("price").subtract(Field.of("discount")); - -``` - -Signature: - -```typescript -subtract(other: Constant): Subtract; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to subtract from this expression. A new Expr representing the subtraction operation. | - -Returns: - -[Subtract](./firestore_.subtract.md#subtract_class) - -## Field.subtract() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a constant value from this expression. - -```typescript -// Subtract 20 from the value of the 'total' field -Field.of("total").subtract(20); - -``` - -Signature: - -```typescript -subtract(other: any): Subtract; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to subtract. A new Expr representing the subtraction operation. | - -Returns: - -[Subtract](./firestore_.subtract.md#subtract_class) - -## Field.sum() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. - -```typescript -// Calculate the total revenue from a set of orders -Field.of("orderAmount").sum().as("totalRevenue"); - -``` - A new `Accumulator` representing the 'sum' aggregation. - -Signature: - -```typescript -sum(): Sum; -``` -Returns: - -[Sum](./firestore_.sum.md#sum_class) - -## Field.timestampAdd() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to this timestamp expression. - -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); - -``` - -Signature: - -```typescript -timestampAdd(unit: Constant, amount: Constant): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) - -## Field.timestampAdd() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to this timestamp expression. - -```typescript -// Add 1 day to the 'timestamp' field. -Field.of("timestamp").timestampAdd("day", 1); - -``` - -Signature: - -```typescript -timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | -| amount | number | The amount of time to add. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) - -## Field.timestampSub() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from this timestamp expression. - -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); - -``` - -Signature: - -```typescript -timestampSub(unit: Constant, amount: Constant): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) - -## Field.timestampSub() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from this timestamp expression. - -```typescript -// Subtract 1 day from the 'timestamp' field. -Field.of("timestamp").timestampSub("day", 1); - -``` - -Signature: - -```typescript -timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | -| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) - -## Field.timestampToUnixMicros() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -Field.of("timestamp").timestampToUnixMicros(); - -``` - A new representing the number of microseconds since epoch. - -Signature: - -```typescript -timestampToUnixMicros(): TimestampToUnixMicros; -``` -Returns: - -[TimestampToUnixMicros](./firestore_.timestamptounixmicros.md#timestamptounixmicros_class) - -## Field.timestampToUnixMillis() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -Field.of("timestamp").timestampToUnixMillis(); - -``` - A new representing the number of milliseconds since epoch. - -Signature: - -```typescript -timestampToUnixMillis(): TimestampToUnixMillis; -``` -Returns: - -[TimestampToUnixMillis](./firestore_.timestamptounixmillis.md#timestamptounixmillis_class) - -## Field.timestampToUnixSeconds() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to seconds since epoch. -Field.of("timestamp").timestampToUnixSeconds(); - -``` - A new representing the number of seconds since epoch. - -Signature: - -```typescript -timestampToUnixSeconds(): TimestampToUnixSeconds; -``` -Returns: - -[TimestampToUnixSeconds](./firestore_.timestamptounixseconds.md#timestamptounixseconds_class) - -## Field.toLower() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string to lowercase. - -```typescript -// Convert the 'name' field to lowercase -Field.of("name").toLower(); - -``` - A new `Expr` representing the lowercase string. - -Signature: - -```typescript -toLower(): ToLower; -``` -Returns: - -[ToLower](./firestore_.tolower.md#tolower_class) - -## Field.toUpper() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string to uppercase. - -```typescript -// Convert the 'title' field to uppercase -Field.of("title").toUpper(); - -``` - A new `Expr` representing the uppercase string. - -Signature: - -```typescript -toUpper(): ToUpper; -``` -Returns: - -[ToUpper](./firestore_.toupper.md#toupper_class) - -## Field.trim() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that removes leading and trailing whitespace from a string. - -```typescript -// Trim whitespace from the 'userInput' field -Field.of("userInput").trim(); - -``` - A new `Expr` representing the trimmed string. - -Signature: - -```typescript -trim(): Trim; -``` -Returns: - -[Trim](./firestore_.trim.md#trim_class) - -## Field.unixMicrosToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -Field.of("microseconds").unixMicrosToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixMicrosToTimestamp(): UnixMicrosToTimestamp; -``` -Returns: - -[UnixMicrosToTimestamp](./firestore_.unixmicrostotimestamp.md#unixmicrostotimestamp_class) - -## Field.unixMillisToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -Field.of("milliseconds").unixMillisToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixMillisToTimestamp(): UnixMillisToTimestamp; -``` -Returns: - -[UnixMillisToTimestamp](./firestore_.unixmillistotimestamp.md#unixmillistotimestamp_class) - -## Field.unixSecondsToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'seconds' field as seconds since epoch. -Field.of("seconds").unixSecondsToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixSecondsToTimestamp(): UnixSecondsToTimestamp; -``` -Returns: - -[UnixSecondsToTimestamp](./firestore_.unixsecondstotimestamp.md#unixsecondstotimestamp_class) - -## Field.vectorLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. - -```typescript -// Get the vector length (dimension) of the field 'embedding'. -Field.of("embedding").vectorLength(); - -``` - A new representing the length of the vector. - -Signature: - -```typescript -vectorLength(): VectorLength; -``` -Returns: - -[VectorLength](./firestore_.vectorlength.md#vectorlength_class) - diff --git a/docs-devsite/firestore_.fields.md b/docs-devsite/firestore_.fields.md deleted file mode 100644 index 8baec029555..00000000000 --- a/docs-devsite/firestore_.fields.md +++ /dev/null @@ -1,3210 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Fields class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Fields implements Selectable -``` -Implements: [Selectable](./firestore_.selectable.md#selectable_interface) - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [exprType](./firestore_.fields.md#fieldsexprtype) | | [ExprType](./firestore_.md#exprtype) | (BETA) | -| [selectable](./firestore_.fields.md#fieldsselectable) | | true | (BETA) | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [add(other)](./firestore_.fields.md#fieldsadd) | | (BETA) Creates an expression that adds this expression to another expression. -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -Field.of("quantity").add(Field.of("reserve")); - -``` - | -| [add(other)](./firestore_.fields.md#fieldsadd) | | (BETA) Creates an expression that adds this expression to a constant value. -```typescript -// Add 5 to the value of the 'age' field -Field.of("age").add(5); - -``` - | -| [arrayConcat(arrays)](./firestore_.fields.md#fieldsarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. -```typescript -// Combine the 'items' array with another array field. -Field.of("items").arrayConcat(Field.of("otherItems")); - -``` - | -| [arrayConcat(arrays)](./firestore_.fields.md#fieldsarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. -```typescript -// Combine the 'tags' array with a new array and an array field -Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); - -``` - | -| [arrayContains(element)](./firestore_.fields.md#fieldsarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific element. -```typescript -// Check if the 'sizes' array contains the value from the 'selectedSize' field -Field.of("sizes").arrayContains(Field.of("selectedSize")); - -``` - | -| [arrayContains(element)](./firestore_.fields.md#fieldsarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific value. -```typescript -// Check if the 'colors' array contains "red" -Field.of("colors").arrayContains("red"); - -``` - | -| [arrayContainsAll(values)](./firestore_.fields.md#fieldsarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. -```typescript -// Check if the 'tags' array contains both "news" and "sports" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - | -| [arrayContainsAll(values)](./firestore_.fields.md#fieldsarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - | -| [arrayContainsAny(values)](./firestore_.fields.md#fieldsarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "cate2" -Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); - -``` - | -| [arrayContainsAny(values)](./firestore_.fields.md#fieldsarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); - -``` - | -| [arrayLength()](./firestore_.fields.md#fieldsarraylength) | | (BETA) Creates an expression that calculates the length of an array. -```typescript -// Get the number of items in the 'cart' array -Field.of("cart").arrayLength(); - -``` - A new Expr representing the length of the array. | -| [as(name)](./firestore_.fields.md#fieldsas) | | (BETA) Assigns an alias to this expression.Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. -```typescript -// Calculate the total price and assign it the alias "totalPrice" and add it to the output. -firestore.pipeline().collection("items") -.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); - -``` - | -| [ascending()](./firestore_.fields.md#fieldsascending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. -```typescript -// Sort documents by the 'name' field in ascending order -pipeline().collection("users") -.sort(Field.of("name").ascending()); - -``` - A new Ordering for ascending sorting. | -| [avg()](./firestore_.fields.md#fieldsavg) | | (BETA) Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. -```typescript -// Calculate the average age of users -Field.of("age").avg().as("averageAge"); - -``` - A new Accumulator representing the 'avg' aggregation. | -| [byteLength()](./firestore_.fields.md#fieldsbytelength) | | (BETA) Creates an expression that calculates the length of this string expression in bytes. -```typescript -// Calculate the length of the 'myString' field in bytes. -Field.of("myString").byteLength(); - -``` - A new representing the length of the string in bytes. | -| [charLength()](./firestore_.fields.md#fieldscharlength) | | (BETA) Creates an expression that calculates the character length of a string in UTF-8. -```typescript -// Get the character length of the 'name' field in its UTF-8 form. -Field.of("name").charLength(); - -``` - A new Expr representing the length of the string. | -| [cosineDistance(other)](./firestore_.fields.md#fieldscosinedistance) | | (BETA) Calculates the cosine distance between two vectors. -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -Field.of("userVector").cosineDistance(Field.of("itemVector")); - -``` - | -| [cosineDistance(other)](./firestore_.fields.md#fieldscosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); - -``` - | -| [cosineDistance(other)](./firestore_.fields.md#fieldscosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance([37.7749, -122.4194]); - -``` - | -| [count()](./firestore_.fields.md#fieldscount) | | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. -```typescript -// Count the total number of products -Field.of("productId").count().as("totalProducts"); - -``` - A new Accumulator representing the 'count' aggregation. | -| [descending()](./firestore_.fields.md#fieldsdescending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") -.sort(Field.of("createdAt").descending()); - -``` - A new Ordering for descending sorting. | -| [divide(other)](./firestore_.fields.md#fieldsdivide) | | (BETA) Creates an expression that divides this expression by another expression. -```typescript -// Divide the 'total' field by the 'count' field -Field.of("total").divide(Field.of("count")); - -``` - | -| [divide(other)](./firestore_.fields.md#fieldsdivide) | | (BETA) Creates an expression that divides this expression by a constant value. -```typescript -// Divide the 'value' field by 10 -Field.of("value").divide(10); - -``` - | -| [dotProduct(other)](./firestore_.fields.md#fieldsdotproduct) | | (BETA) Calculates the dot product between two vectors. -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct([0.5, 0.8, 0.2]); - -``` - | -| [dotProduct(other)](./firestore_.fields.md#fieldsdotproduct) | | (BETA) Calculates the dot product between two vectors. -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); - -``` - | -| [dotProduct(other)](./firestore_.fields.md#fieldsdotproduct) | | (BETA) | -| [endsWith(suffix)](./firestore_.fields.md#fieldsendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix. -```typescript -// Check if the 'filename' field ends with ".txt" -Field.of("filename").endsWith(".txt"); - -``` - | -| [endsWith(suffix)](./firestore_.fields.md#fieldsendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix (represented as an expression). -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -Field.of("url").endsWith(Field.of("extension")); - -``` - | -| [eq(other)](./firestore_.fields.md#fieldseq) | | (BETA) Creates an expression that checks if this expression is equal to another expression. -```typescript -// Check if the 'age' field is equal to 21 -Field.of("age").eq(21); - -``` - | -| [eq(other)](./firestore_.fields.md#fieldseq) | | (BETA) Creates an expression that checks if this expression is equal to a constant value. -```typescript -// Check if the 'city' field is equal to "London" -Field.of("city").eq("London"); - -``` - | -| [euclideanDistance(other)](./firestore_.fields.md#fieldseuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance([37.7749, -122.4194]); - -``` - | -| [euclideanDistance(other)](./firestore_.fields.md#fieldseuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); - -``` - | -| [euclideanDistance(other)](./firestore_.fields.md#fieldseuclideandistance) | | (BETA) | -| [exists()](./firestore_.fields.md#fieldsexists) | | (BETA) Creates an expression that checks if a field exists in the document. -```typescript -// Check if the document has a field named "phoneNumber" -Field.of("phoneNumber").exists(); - -``` - A new Expr representing the 'exists' check. | -| [fieldList()](./firestore_.fields.md#fieldsfieldlist) | | (BETA) | -| [gt(other)](./firestore_.fields.md#fieldsgt) | | (BETA) Creates an expression that checks if this expression is greater than another expression. -```typescript -// Check if the 'age' field is greater than the 'limit' field -Field.of("age").gt(Field.of("limit")); - -``` - | -| [gt(other)](./firestore_.fields.md#fieldsgt) | | (BETA) Creates an expression that checks if this expression is greater than a constant value. -```typescript -// Check if the 'price' field is greater than 100 -Field.of("price").gt(100); - -``` - | -| [gte(other)](./firestore_.fields.md#fieldsgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to another expression. -```typescript -// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 -Field.of("quantity").gte(Field.of('requirement').add(1)); - -``` - | -| [gte(other)](./firestore_.fields.md#fieldsgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to a constant value. -```typescript -// Check if the 'score' field is greater than or equal to 80 -Field.of("score").gte(80); - -``` - | -| [in(others)](./firestore_.fields.md#fieldsin) | | (BETA) Creates an expression that checks if this expression is equal to any of the provided values or expressions. -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -Field.of("category").in("Electronics", Field.of("primaryType")); - -``` - | -| [in(others)](./firestore_.fields.md#fieldsin) | | (BETA) | -| [isNaN()](./firestore_.fields.md#fieldsisnan) | | (BETA) Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). -```typescript -// Check if the result of a calculation is NaN -Field.of("value").divide(0).isNaN(); - -``` - A new Expr representing the 'isNaN' check. | -| [like(pattern)](./firestore_.fields.md#fieldslike) | | (BETA) Creates an expression that performs a case-sensitive string comparison. -```typescript -// Check if the 'title' field contains the word "guide" (case-sensitive) -Field.of("title").like("%guide%"); - -``` - | -| [like(pattern)](./firestore_.fields.md#fieldslike) | | (BETA) | -| [logicalMax(other)](./firestore_.fields.md#fieldslogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMax(Function.currentTimestamp()); - -``` - | -| [logicalMax(other)](./firestore_.fields.md#fieldslogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'value' field and 10. -Field.of("value").logicalMax(10); - -``` - | -| [logicalMin(other)](./firestore_.fields.md#fieldslogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMin(Function.currentTimestamp()); - -``` - | -| [logicalMin(other)](./firestore_.fields.md#fieldslogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'value' field and 10. -Field.of("value").logicalMin(10); - -``` - | -| [lt(other)](./firestore_.fields.md#fieldslt) | | (BETA) Creates an expression that checks if this expression is less than another expression. -```typescript -// Check if the 'age' field is less than 'limit' -Field.of("age").lt(Field.of('limit')); - -``` - | -| [lt(other)](./firestore_.fields.md#fieldslt) | | (BETA) Creates an expression that checks if this expression is less than a constant value. -```typescript -// Check if the 'price' field is less than 50 -Field.of("price").lt(50); - -``` - | -| [lte(other)](./firestore_.fields.md#fieldslte) | | (BETA) Creates an expression that checks if this expression is less than or equal to another expression. -```typescript -// Check if the 'quantity' field is less than or equal to 20 -Field.of("quantity").lte(Constant.of(20)); - -``` - | -| [lte(other)](./firestore_.fields.md#fieldslte) | | (BETA) Creates an expression that checks if this expression is less than or equal to a constant value. -```typescript -// Check if the 'score' field is less than or equal to 70 -Field.of("score").lte(70); - -``` - | -| [mapGet(subfield)](./firestore_.fields.md#fieldsmapget) | | (BETA) Accesses a value from a map (object) field using the provided key. -```typescript -// Get the 'city' value from the 'address' map field -Field.of("address").mapGet("city"); - -``` - | -| [max()](./firestore_.fields.md#fieldsmax) | | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. -```typescript -// Find the highest score in a leaderboard -Field.of("score").max().as("highestScore"); - -``` - A new Accumulator representing the 'max' aggregation. | -| [min()](./firestore_.fields.md#fieldsmin) | | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. -```typescript -// Find the lowest price of all products -Field.of("price").min().as("lowestPrice"); - -``` - A new Accumulator representing the 'min' aggregation. | -| [mod(other)](./firestore_.fields.md#fieldsmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. -```typescript -// Calculate the remainder of dividing the 'value' field by the 'divisor' field -Field.of("value").mod(Field.of("divisor")); - -``` - | -| [mod(other)](./firestore_.fields.md#fieldsmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. -```typescript -// Calculate the remainder of dividing the 'value' field by 10 -Field.of("value").mod(10); - -``` - | -| [multiply(other)](./firestore_.fields.md#fieldsmultiply) | | (BETA) Creates an expression that multiplies this expression by another expression. -```typescript -// Multiply the 'quantity' field by the 'price' field -Field.of("quantity").multiply(Field.of("price")); - -``` - | -| [multiply(other)](./firestore_.fields.md#fieldsmultiply) | | (BETA) Creates an expression that multiplies this expression by a constant value. -```typescript -// Multiply the 'value' field by 2 -Field.of("value").multiply(2); - -``` - | -| [neq(other)](./firestore_.fields.md#fieldsneq) | | (BETA) Creates an expression that checks if this expression is not equal to another expression. -```typescript -// Check if the 'status' field is not equal to "completed" -Field.of("status").neq("completed"); - -``` - | -| [neq(other)](./firestore_.fields.md#fieldsneq) | | (BETA) Creates an expression that checks if this expression is not equal to a constant value. -```typescript -// Check if the 'country' field is not equal to "USA" -Field.of("country").neq("USA"); - -``` - | -| [of(name, others)](./firestore_.fields.md#fieldsof) | static | (BETA) | -| [ofAll()](./firestore_.fields.md#fieldsofall) | static | (BETA) | -| [regexContains(pattern)](./firestore_.fields.md#fieldsregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -Field.of("description").regexContains("(?i)example"); - -``` - | -| [regexContains(pattern)](./firestore_.fields.md#fieldsregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains the regular expression stored in field 'regex' -Field.of("description").regexContains(Field.of("regex")); - -``` - | -| [regexMatch(pattern)](./firestore_.fields.md#fieldsregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. -```typescript -// Check if the 'email' field matches a valid email pattern -Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - | -| [regexMatch(pattern)](./firestore_.fields.md#fieldsregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. -```typescript -// Check if the 'email' field matches a regular expression stored in field 'regex' -Field.of("email").regexMatch(Field.of("regex")); - -``` - | -| [replaceAll(find, replace)](./firestore_.fields.md#fieldsreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring. -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field -Field.of("message").replaceAll("hello", "hi"); - -``` - | -| [replaceAll(find, replace)](./firestore_.fields.md#fieldsreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); - -``` - | -| [replaceFirst(find, replace)](./firestore_.fields.md#fieldsreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field -Field.of("message").replaceFirst("hello", "hi"); - -``` - | -| [replaceFirst(find, replace)](./firestore_.fields.md#fieldsreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); - -``` - | -| [reverse()](./firestore_.fields.md#fieldsreverse) | | (BETA) Creates an expression that reverses this string expression. -```typescript -// Reverse the value of the 'myString' field. -Field.of("myString").reverse(); - -``` - A new representing the reversed string. | -| [startsWith(prefix)](./firestore_.fields.md#fieldsstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix. -```typescript -// Check if the 'name' field starts with "Mr." -Field.of("name").startsWith("Mr."); - -``` - | -| [startsWith(prefix)](./firestore_.fields.md#fieldsstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix (represented as an expression). -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -Field.of("fullName").startsWith(Field.of("firstName")); - -``` - | -| [strConcat(elements)](./firestore_.fields.md#fieldsstrconcat) | | (BETA) Creates an expression that concatenates string expressions together. -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); - -``` - | -| [strContains(substring)](./firestore_.fields.md#fieldsstrcontains) | | (BETA) Creates an expression that checks if a string contains a specified substring. -```typescript -// Check if the 'description' field contains "example". -Field.of("description").strContains("example"); - -``` - | -| [strContains(expr)](./firestore_.fields.md#fieldsstrcontains) | | (BETA) Creates an expression that checks if a string contains the string represented by another expression. -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -Field.of("description").strContains(Field.of("keyword")); - -``` - | -| [subtract(other)](./firestore_.fields.md#fieldssubtract) | | (BETA) Creates an expression that subtracts another expression from this expression. -```typescript -// Subtract the 'discount' field from the 'price' field -Field.of("price").subtract(Field.of("discount")); - -``` - | -| [subtract(other)](./firestore_.fields.md#fieldssubtract) | | (BETA) Creates an expression that subtracts a constant value from this expression. -```typescript -// Subtract 20 from the value of the 'total' field -Field.of("total").subtract(20); - -``` - | -| [sum()](./firestore_.fields.md#fieldssum) | | (BETA) Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. -```typescript -// Calculate the total revenue from a set of orders -Field.of("orderAmount").sum().as("totalRevenue"); - -``` - A new Accumulator representing the 'sum' aggregation. | -| [timestampAdd(unit, amount)](./firestore_.fields.md#fieldstimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampAdd(unit, amount)](./firestore_.fields.md#fieldstimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. -```typescript -// Add 1 day to the 'timestamp' field. -Field.of("timestamp").timestampAdd("day", 1); - -``` - | -| [timestampSub(unit, amount)](./firestore_.fields.md#fieldstimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampSub(unit, amount)](./firestore_.fields.md#fieldstimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. -```typescript -// Subtract 1 day from the 'timestamp' field. -Field.of("timestamp").timestampSub("day", 1); - -``` - | -| [timestampToUnixMicros()](./firestore_.fields.md#fieldstimestamptounixmicros) | | (BETA) Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -Field.of("timestamp").timestampToUnixMicros(); - -``` - A new representing the number of microseconds since epoch. | -| [timestampToUnixMillis()](./firestore_.fields.md#fieldstimestamptounixmillis) | | (BETA) Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -Field.of("timestamp").timestampToUnixMillis(); - -``` - A new representing the number of milliseconds since epoch. | -| [timestampToUnixSeconds()](./firestore_.fields.md#fieldstimestamptounixseconds) | | (BETA) Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to seconds since epoch. -Field.of("timestamp").timestampToUnixSeconds(); - -``` - A new representing the number of seconds since epoch. | -| [toLower()](./firestore_.fields.md#fieldstolower) | | (BETA) Creates an expression that converts a string to lowercase. -```typescript -// Convert the 'name' field to lowercase -Field.of("name").toLower(); - -``` - A new Expr representing the lowercase string. | -| [toUpper()](./firestore_.fields.md#fieldstoupper) | | (BETA) Creates an expression that converts a string to uppercase. -```typescript -// Convert the 'title' field to uppercase -Field.of("title").toUpper(); - -``` - A new Expr representing the uppercase string. | -| [trim()](./firestore_.fields.md#fieldstrim) | | (BETA) Creates an expression that removes leading and trailing whitespace from a string. -```typescript -// Trim whitespace from the 'userInput' field -Field.of("userInput").trim(); - -``` - A new Expr representing the trimmed string. | -| [unixMicrosToTimestamp()](./firestore_.fields.md#fieldsunixmicrostotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -Field.of("microseconds").unixMicrosToTimestamp(); - -``` - A new representing the timestamp. | -| [unixMillisToTimestamp()](./firestore_.fields.md#fieldsunixmillistotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -Field.of("milliseconds").unixMillisToTimestamp(); - -``` - A new representing the timestamp. | -| [unixSecondsToTimestamp()](./firestore_.fields.md#fieldsunixsecondstotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'seconds' field as seconds since epoch. -Field.of("seconds").unixSecondsToTimestamp(); - -``` - A new representing the timestamp. | -| [vectorLength()](./firestore_.fields.md#fieldsvectorlength) | | (BETA) Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. -```typescript -// Get the vector length (dimension) of the field 'embedding'. -Field.of("embedding").vectorLength(); - -``` - A new representing the length of the vector. | - -## Fields.exprType - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -exprType: ExprType; -``` - -## Fields.selectable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -selectable: true; -``` - -## Fields.add() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds this expression to another expression. - -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -Field.of("quantity").add(Field.of("reserve")); - -``` - -Signature: - -```typescript -add(other: Constant): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to add to this expression. A new Expr representing the addition operation. | - -Returns: - -[Add](./firestore_.add.md#add_class) - -## Fields.add() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds this expression to a constant value. - -```typescript -// Add 5 to the value of the 'age' field -Field.of("age").add(5); - -``` - -Signature: - -```typescript -add(other: any): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to add. A new Expr representing the addition operation. | - -Returns: - -[Add](./firestore_.add.md#add_class) - -## Fields.arrayConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with one or more other arrays. - -```typescript -// Combine the 'items' array with another array field. -Field.of("items").arrayConcat(Field.of("otherItems")); - -``` - -Signature: - -```typescript -arrayConcat(arrays: Constant[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| arrays | [Constant](./firestore_.constant.md#constant_class)\[\] | The array expressions to concatenate. A new Expr representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) - -## Fields.arrayConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with one or more other arrays. - -```typescript -// Combine the 'tags' array with a new array and an array field -Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); - -``` - -Signature: - -```typescript -arrayConcat(arrays: any[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| arrays | any\[\] | The array expressions or values to concatenate. A new Expr representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) - -## Fields.arrayContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains a specific element. - -```typescript -// Check if the 'sizes' array contains the value from the 'selectedSize' field -Field.of("sizes").arrayContains(Field.of("selectedSize")); - -``` - -Signature: - -```typescript -arrayContains(element: Constant): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | [Constant](./firestore_.constant.md#constant_class) | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) - -## Fields.arrayContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains a specific value. - -```typescript -// Check if the 'colors' array contains "red" -Field.of("colors").arrayContains("red"); - -``` - -Signature: - -```typescript -arrayContains(element: any): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | any | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) - -## Fields.arrayContainsAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both "news" and "sports" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - -Signature: - -```typescript -arrayContainsAll(...values: Constant[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) - -## Fields.arrayContainsAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - -Signature: - -```typescript -arrayContainsAll(...values: any[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) - -## Fields.arrayContainsAny() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains any of the specified elements. - -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "cate2" -Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); - -``` - -Signature: - -```typescript -arrayContainsAny(...values: Constant[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) - -## Fields.arrayContainsAny() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains any of the specified elements. - -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); - -``` - -Signature: - -```typescript -arrayContainsAny(...values: any[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) - -## Fields.arrayLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of an array. - -```typescript -// Get the number of items in the 'cart' array -Field.of("cart").arrayLength(); - -``` - A new `Expr` representing the length of the array. - -Signature: - -```typescript -arrayLength(): ArrayLength; -``` -Returns: - -[ArrayLength](./firestore_.arraylength.md#arraylength_class) - -## Fields.as() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Assigns an alias to this expression. - -Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. - -```typescript -// Calculate the total price and assign it the alias "totalPrice" and add it to the output. -firestore.pipeline().collection("items") -.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); - -``` - -Signature: - -```typescript -as(name: string): ExprWithAlias; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | The alias to assign to this expression. A new [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) that wraps this expression and associates it with the provided alias. | - -Returns: - -[ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class)<this> - -## Fields.ascending() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. - -```typescript -// Sort documents by the 'name' field in ascending order -pipeline().collection("users") -.sort(Field.of("name").ascending()); - -``` - A new `Ordering` for ascending sorting. - -Signature: - -```typescript -ascending(): Ordering; -``` -Returns: - -[Ordering](./firestore_.ordering.md#ordering_class) - -## Fields.avg() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. - -```typescript -// Calculate the average age of users -Field.of("age").avg().as("averageAge"); - -``` - A new `Accumulator` representing the 'avg' aggregation. - -Signature: - -```typescript -avg(): Avg; -``` -Returns: - -[Avg](./firestore_.avg.md#avg_class) - -## Fields.byteLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of this string expression in bytes. - -```typescript -// Calculate the length of the 'myString' field in bytes. -Field.of("myString").byteLength(); - -``` - A new representing the length of the string in bytes. - -Signature: - -```typescript -byteLength(): ByteLength; -``` -Returns: - -[ByteLength](./firestore_.bytelength.md#bytelength_class) - -## Fields.charLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the character length of a string in UTF-8. - -```typescript -// Get the character length of the 'name' field in its UTF-8 form. -Field.of("name").charLength(); - -``` - A new `Expr` representing the length of the string. - -Signature: - -```typescript -charLength(): CharLength; -``` -Returns: - -[CharLength](./firestore_.charlength.md#charlength_class) - -## Fields.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the cosine distance between two vectors. - -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -Field.of("userVector").cosineDistance(Field.of("itemVector")); - -``` - -Signature: - -```typescript -cosineDistance(other: Constant): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new Expr representing the cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) - -## Fields.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vectors. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -cosineDistance(other: VectorValue): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) - -## Fields.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vectors. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance([37.7749, -122.4194]); - -``` - -Signature: - -```typescript -cosineDistance(other: number[]): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | The other vector (as an array of numbers) to compare against. A new Expr representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) - -## Fields.count() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. - -```typescript -// Count the total number of products -Field.of("productId").count().as("totalProducts"); - -``` - A new `Accumulator` representing the 'count' aggregation. - -Signature: - -```typescript -count(): Count; -``` -Returns: - -[Count](./firestore_.count.md#count_class) - -## Fields.descending() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. - -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") -.sort(Field.of("createdAt").descending()); - -``` - A new `Ordering` for descending sorting. - -Signature: - -```typescript -descending(): Ordering; -``` -Returns: - -[Ordering](./firestore_.ordering.md#ordering_class) - -## Fields.divide() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides this expression by another expression. - -```typescript -// Divide the 'total' field by the 'count' field -Field.of("total").divide(Field.of("count")); - -``` - -Signature: - -```typescript -divide(other: Constant): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new Expr representing the division operation. | - -Returns: - -[Divide](./firestore_.divide.md#divide_class) - -## Fields.divide() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides this expression by a constant value. - -```typescript -// Divide the 'value' field by 10 -Field.of("value").divide(10); - -``` - -Signature: - -```typescript -divide(other: any): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to divide by. A new Expr representing the division operation. | - -Returns: - -[Divide](./firestore_.divide.md#divide_class) - -## Fields.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vectors. - -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct([0.5, 0.8, 0.2]); - -``` - -Signature: - -```typescript -dotProduct(other: Constant): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_.dotproduct.md#dotproduct_class) - -## Fields.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vectors. - -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); - -``` - -Signature: - -```typescript -dotProduct(other: VectorValue): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_.dotproduct.md#dotproduct_class) - -## Fields.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -dotProduct(other: number[]): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | | - -Returns: - -[DotProduct](./firestore_.dotproduct.md#dotproduct_class) - -## Fields.endsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string ends with a given postfix. - -```typescript -// Check if the 'filename' field ends with ".txt" -Field.of("filename").endsWith(".txt"); - -``` - -Signature: - -```typescript -endsWith(suffix: string): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| suffix | string | The postfix to check for. A new Expr representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_.endswith.md#endswith_class) - -## Fields.endsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string ends with a given postfix (represented as an expression). - -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -Field.of("url").endsWith(Field.of("extension")); - -``` - -Signature: - -```typescript -endsWith(suffix: Constant): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| suffix | [Constant](./firestore_.constant.md#constant_class) | The postfix expression to check for. A new Expr representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_.endswith.md#endswith_class) - -## Fields.eq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to another expression. - -```typescript -// Check if the 'age' field is equal to 21 -Field.of("age").eq(21); - -``` - -Signature: - -```typescript -eq(other: Constant): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for equality. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_.eq.md#eq_class) - -## Fields.eq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to a constant value. - -```typescript -// Check if the 'city' field is equal to "London" -Field.of("city").eq("London"); - -``` - -Signature: - -```typescript -eq(other: any): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for equality. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_.eq.md#eq_class) - -## Fields.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vectors. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance([37.7749, -122.4194]); - -``` - -Signature: - -```typescript -euclideanDistance(other: Constant): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) - -## Fields.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vectors. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -euclideanDistance(other: VectorValue): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) - -## Fields.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -euclideanDistance(other: number[]): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | | - -Returns: - -[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) - -## Fields.exists() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field exists in the document. - -```typescript -// Check if the document has a field named "phoneNumber" -Field.of("phoneNumber").exists(); - -``` - A new `Expr` representing the 'exists' check. - -Signature: - -```typescript -exists(): Exists; -``` -Returns: - -[Exists](./firestore_.exists.md#exists_class) - -## Fields.fieldList() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -fieldList(): Field[]; -``` -Returns: - -[Field](./firestore_.field.md#field_class)\[\] - -## Fields.gt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than another expression. - -```typescript -// Check if the 'age' field is greater than the 'limit' field -Field.of("age").gt(Field.of("limit")); - -``` - -Signature: - -```typescript -gt(other: Constant): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for greater than. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_.gt.md#gt_class) - -## Fields.gt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than a constant value. - -```typescript -// Check if the 'price' field is greater than 100 -Field.of("price").gt(100); - -``` - -Signature: - -```typescript -gt(other: any): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for greater than. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_.gt.md#gt_class) - -## Fields.gte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than or equal to another expression. - -```typescript -// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 -Field.of("quantity").gte(Field.of('requirement').add(1)); - -``` - -Signature: - -```typescript -gte(other: Constant): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_.gte.md#gte_class) - -## Fields.gte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than or equal to a constant value. - -```typescript -// Check if the 'score' field is greater than or equal to 80 -Field.of("score").gte(80); - -``` - -Signature: - -```typescript -gte(other: any): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_.gte.md#gte_class) - -## Fields.in() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to any of the provided values or expressions. - -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -Field.of("category").in("Electronics", Field.of("primaryType")); - -``` - -Signature: - -```typescript -in(...others: Constant[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| others | [Constant](./firestore_.constant.md#constant_class)\[\] | The values or expressions to check against. A new Expr representing the 'IN' comparison. | - -Returns: - -[In](./firestore_.in.md#in_class) - -## Fields.in() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -in(...others: any[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| others | any\[\] | | - -Returns: - -[In](./firestore_.in.md#in_class) - -## Fields.isNaN() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). - -```typescript -// Check if the result of a calculation is NaN -Field.of("value").divide(0).isNaN(); - -``` - A new `Expr` representing the 'isNaN' check. - -Signature: - -```typescript -isNaN(): IsNan; -``` -Returns: - -[IsNan](./firestore_.isnan.md#isnan_class) - -## Fields.like() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that performs a case-sensitive string comparison. - -```typescript -// Check if the 'title' field contains the word "guide" (case-sensitive) -Field.of("title").like("%guide%"); - -``` - -Signature: - -```typescript -like(pattern: string): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new Expr representing the 'like' comparison. | - -Returns: - -[Like](./firestore_.like.md#like_class) - -## Fields.like() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -like(pattern: Constant): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_.constant.md#constant_class) | | - -Returns: - -[Like](./firestore_.like.md#like_class) - -## Fields.logicalMax() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMax(Function.currentTimestamp()); - -``` - -Signature: - -```typescript -logicalMax(other: Constant): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare with. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) - -## Fields.logicalMax() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'value' field and 10. -Field.of("value").logicalMax(10); - -``` - -Signature: - -```typescript -logicalMax(other: any): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare with. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) - -## Fields.logicalMin() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMin(Function.currentTimestamp()); - -``` - -Signature: - -```typescript -logicalMin(other: Constant): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare with. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) - -## Fields.logicalMin() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'value' field and 10. -Field.of("value").logicalMin(10); - -``` - -Signature: - -```typescript -logicalMin(other: any): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare with. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) - -## Fields.lt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than another expression. - -```typescript -// Check if the 'age' field is less than 'limit' -Field.of("age").lt(Field.of('limit')); - -``` - -Signature: - -```typescript -lt(other: Constant): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for less than. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_.lt.md#lt_class) - -## Fields.lt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than a constant value. - -```typescript -// Check if the 'price' field is less than 50 -Field.of("price").lt(50); - -``` - -Signature: - -```typescript -lt(other: any): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for less than. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_.lt.md#lt_class) - -## Fields.lte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than or equal to another expression. - -```typescript -// Check if the 'quantity' field is less than or equal to 20 -Field.of("quantity").lte(Constant.of(20)); - -``` - -Signature: - -```typescript -lte(other: Constant): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_.lte.md#lte_class) - -## Fields.lte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than or equal to a constant value. - -```typescript -// Check if the 'score' field is less than or equal to 70 -Field.of("score").lte(70); - -``` - -Signature: - -```typescript -lte(other: any): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_.lte.md#lte_class) - -## Fields.mapGet() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Accesses a value from a map (object) field using the provided key. - -```typescript -// Get the 'city' value from the 'address' map field -Field.of("address").mapGet("city"); - -``` - -Signature: - -```typescript -mapGet(subfield: string): MapGet; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| subfield | string | The key to access in the map. A new Expr representing the value associated with the given key in the map. | - -Returns: - -[MapGet](./firestore_.mapget.md#mapget_class) - -## Fields.max() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that finds the maximum value of a field across multiple stage inputs. - -```typescript -// Find the highest score in a leaderboard -Field.of("score").max().as("highestScore"); - -``` - A new `Accumulator` representing the 'max' aggregation. - -Signature: - -```typescript -max(): Max; -``` -Returns: - -[Max](./firestore_.max.md#max_class) - -## Fields.min() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that finds the minimum value of a field across multiple stage inputs. - -```typescript -// Find the lowest price of all products -Field.of("price").min().as("lowestPrice"); - -``` - A new `Accumulator` representing the 'min' aggregation. - -Signature: - -```typescript -min(): Min; -``` -Returns: - -[Min](./firestore_.min.md#min_class) - -## Fields.mod() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. - -```typescript -// Calculate the remainder of dividing the 'value' field by the 'divisor' field -Field.of("value").mod(Field.of("divisor")); - -``` - -Signature: - -```typescript -mod(other: Constant): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new Expr representing the modulo operation. | - -Returns: - -[Mod](./firestore_.mod.md#mod_class) - -## Fields.mod() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. - -```typescript -// Calculate the remainder of dividing the 'value' field by 10 -Field.of("value").mod(10); - -``` - -Signature: - -```typescript -mod(other: any): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to divide by. A new Expr representing the modulo operation. | - -Returns: - -[Mod](./firestore_.mod.md#mod_class) - -## Fields.multiply() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies this expression by another expression. - -```typescript -// Multiply the 'quantity' field by the 'price' field -Field.of("quantity").multiply(Field.of("price")); - -``` - -Signature: - -```typescript -multiply(other: Constant): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to multiply by. A new Expr representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_.multiply.md#multiply_class) - -## Fields.multiply() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies this expression by a constant value. - -```typescript -// Multiply the 'value' field by 2 -Field.of("value").multiply(2); - -``` - -Signature: - -```typescript -multiply(other: any): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to multiply by. A new Expr representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_.multiply.md#multiply_class) - -## Fields.neq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is not equal to another expression. - -```typescript -// Check if the 'status' field is not equal to "completed" -Field.of("status").neq("completed"); - -``` - -Signature: - -```typescript -neq(other: Constant): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for inequality. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_.neq.md#neq_class) - -## Fields.neq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is not equal to a constant value. - -```typescript -// Check if the 'country' field is not equal to "USA" -Field.of("country").neq("USA"); - -``` - -Signature: - -```typescript -neq(other: any): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for inequality. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_.neq.md#neq_class) - -## Fields.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -static of(name: string, ...others: string[]): Fields; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | | -| others | string\[\] | | - -Returns: - -[Fields](./firestore_.fields.md#fields_class) - -## Fields.ofAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -static ofAll(): Fields; -``` -Returns: - -[Fields](./firestore_.fields.md#fields_class) - -## Fields.regexContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -Field.of("description").regexContains("(?i)example"); - -``` - -Signature: - -```typescript -regexContains(pattern: string): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_.regexcontains.md#regexcontains_class) - -## Fields.regexContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains the regular expression stored in field 'regex' -Field.of("description").regexContains(Field.of("regex")); - -``` - -Signature: - -```typescript -regexContains(pattern: Constant): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_.regexcontains.md#regexcontains_class) - -## Fields.regexMatch() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a valid email pattern -Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - -Signature: - -```typescript -regexMatch(pattern: string): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The regular expression to use for the match. A new Expr representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) - -## Fields.regexMatch() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a regular expression stored in field 'regex' -Field.of("email").regexMatch(Field.of("regex")); - -``` - -Signature: - -```typescript -regexMatch(pattern: Constant): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the match. A new Expr representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) - -## Fields.replaceAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within this string expression with another substring. - -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field -Field.of("message").replaceAll("hello", "hi"); - -``` - -Signature: - -```typescript -replaceAll(find: string, replace: string): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | string | The substring to search for. | -| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_.replaceall.md#replaceall_class) - -## Fields.replaceAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. - -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); - -``` - -Signature: - -```typescript -replaceAll(find: Constant, replace: Constant): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_.replaceall.md#replaceall_class) - -## Fields.replaceFirst() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. - -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field -Field.of("message").replaceFirst("hello", "hi"); - -``` - -Signature: - -```typescript -replaceFirst(find: string, replace: string): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | string | The substring to search for. | -| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) - -## Fields.replaceFirst() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. - -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); - -``` - -Signature: - -```typescript -replaceFirst(find: Constant, replace: Constant): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) - -## Fields.reverse() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that reverses this string expression. - -```typescript -// Reverse the value of the 'myString' field. -Field.of("myString").reverse(); - -``` - A new representing the reversed string. - -Signature: - -```typescript -reverse(): Reverse; -``` -Returns: - -[Reverse](./firestore_.reverse.md#reverse_class) - -## Fields.startsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string starts with a given prefix. - -```typescript -// Check if the 'name' field starts with "Mr." -Field.of("name").startsWith("Mr."); - -``` - -Signature: - -```typescript -startsWith(prefix: string): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| prefix | string | The prefix to check for. A new Expr representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_.startswith.md#startswith_class) - -## Fields.startsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string starts with a given prefix (represented as an expression). - -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -Field.of("fullName").startsWith(Field.of("firstName")); - -``` - -Signature: - -```typescript -startsWith(prefix: Constant): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| prefix | [Constant](./firestore_.constant.md#constant_class) | The prefix expression to check for. A new Expr representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_.startswith.md#startswith_class) - -## Fields.strConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates string expressions together. - -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); - -``` - -Signature: - -```typescript -strConcat(...elements: Array): StrConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| elements | Array<string \| [Constant](./firestore_.constant.md#constant_class)> | The expressions (typically strings) to concatenate. A new Expr representing the concatenated string. | - -Returns: - -[StrConcat](./firestore_.strconcat.md#strconcat_class) - -## Fields.strContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified substring. - -```typescript -// Check if the 'description' field contains "example". -Field.of("description").strContains("example"); - -``` - -Signature: - -```typescript -strContains(substring: string): StrContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| substring | string | The substring to search for. A new Expr representing the 'contains' comparison. | - -Returns: - -[StrContains](./firestore_.strcontains.md#strcontains_class) - -## Fields.strContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains the string represented by another expression. - -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -Field.of("description").strContains(Field.of("keyword")); - -``` - -Signature: - -```typescript -strContains(expr: Constant): StrContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. A new Expr representing the 'contains' comparison. | - -Returns: - -[StrContains](./firestore_.strcontains.md#strcontains_class) - -## Fields.subtract() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts another expression from this expression. - -```typescript -// Subtract the 'discount' field from the 'price' field -Field.of("price").subtract(Field.of("discount")); - -``` - -Signature: - -```typescript -subtract(other: Constant): Subtract; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to subtract from this expression. A new Expr representing the subtraction operation. | - -Returns: - -[Subtract](./firestore_.subtract.md#subtract_class) - -## Fields.subtract() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a constant value from this expression. - -```typescript -// Subtract 20 from the value of the 'total' field -Field.of("total").subtract(20); - -``` - -Signature: - -```typescript -subtract(other: any): Subtract; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to subtract. A new Expr representing the subtraction operation. | - -Returns: - -[Subtract](./firestore_.subtract.md#subtract_class) - -## Fields.sum() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. - -```typescript -// Calculate the total revenue from a set of orders -Field.of("orderAmount").sum().as("totalRevenue"); - -``` - A new `Accumulator` representing the 'sum' aggregation. - -Signature: - -```typescript -sum(): Sum; -``` -Returns: - -[Sum](./firestore_.sum.md#sum_class) - -## Fields.timestampAdd() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to this timestamp expression. - -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); - -``` - -Signature: - -```typescript -timestampAdd(unit: Constant, amount: Constant): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) - -## Fields.timestampAdd() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to this timestamp expression. - -```typescript -// Add 1 day to the 'timestamp' field. -Field.of("timestamp").timestampAdd("day", 1); - -``` - -Signature: - -```typescript -timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | -| amount | number | The amount of time to add. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) - -## Fields.timestampSub() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from this timestamp expression. - -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); - -``` - -Signature: - -```typescript -timestampSub(unit: Constant, amount: Constant): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) - -## Fields.timestampSub() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from this timestamp expression. - -```typescript -// Subtract 1 day from the 'timestamp' field. -Field.of("timestamp").timestampSub("day", 1); - -``` - -Signature: - -```typescript -timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | -| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) - -## Fields.timestampToUnixMicros() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -Field.of("timestamp").timestampToUnixMicros(); - -``` - A new representing the number of microseconds since epoch. - -Signature: - -```typescript -timestampToUnixMicros(): TimestampToUnixMicros; -``` -Returns: - -[TimestampToUnixMicros](./firestore_.timestamptounixmicros.md#timestamptounixmicros_class) - -## Fields.timestampToUnixMillis() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -Field.of("timestamp").timestampToUnixMillis(); - -``` - A new representing the number of milliseconds since epoch. - -Signature: - -```typescript -timestampToUnixMillis(): TimestampToUnixMillis; -``` -Returns: - -[TimestampToUnixMillis](./firestore_.timestamptounixmillis.md#timestamptounixmillis_class) - -## Fields.timestampToUnixSeconds() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to seconds since epoch. -Field.of("timestamp").timestampToUnixSeconds(); - -``` - A new representing the number of seconds since epoch. - -Signature: - -```typescript -timestampToUnixSeconds(): TimestampToUnixSeconds; -``` -Returns: - -[TimestampToUnixSeconds](./firestore_.timestamptounixseconds.md#timestamptounixseconds_class) - -## Fields.toLower() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string to lowercase. - -```typescript -// Convert the 'name' field to lowercase -Field.of("name").toLower(); - -``` - A new `Expr` representing the lowercase string. - -Signature: - -```typescript -toLower(): ToLower; -``` -Returns: - -[ToLower](./firestore_.tolower.md#tolower_class) - -## Fields.toUpper() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string to uppercase. - -```typescript -// Convert the 'title' field to uppercase -Field.of("title").toUpper(); - -``` - A new `Expr` representing the uppercase string. - -Signature: - -```typescript -toUpper(): ToUpper; -``` -Returns: - -[ToUpper](./firestore_.toupper.md#toupper_class) - -## Fields.trim() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that removes leading and trailing whitespace from a string. - -```typescript -// Trim whitespace from the 'userInput' field -Field.of("userInput").trim(); - -``` - A new `Expr` representing the trimmed string. - -Signature: - -```typescript -trim(): Trim; -``` -Returns: - -[Trim](./firestore_.trim.md#trim_class) - -## Fields.unixMicrosToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -Field.of("microseconds").unixMicrosToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixMicrosToTimestamp(): UnixMicrosToTimestamp; -``` -Returns: - -[UnixMicrosToTimestamp](./firestore_.unixmicrostotimestamp.md#unixmicrostotimestamp_class) - -## Fields.unixMillisToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -Field.of("milliseconds").unixMillisToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixMillisToTimestamp(): UnixMillisToTimestamp; -``` -Returns: - -[UnixMillisToTimestamp](./firestore_.unixmillistotimestamp.md#unixmillistotimestamp_class) - -## Fields.unixSecondsToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'seconds' field as seconds since epoch. -Field.of("seconds").unixSecondsToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixSecondsToTimestamp(): UnixSecondsToTimestamp; -``` -Returns: - -[UnixSecondsToTimestamp](./firestore_.unixsecondstotimestamp.md#unixsecondstotimestamp_class) - -## Fields.vectorLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. - -```typescript -// Get the vector length (dimension) of the field 'embedding'. -Field.of("embedding").vectorLength(); - -``` - A new representing the length of the vector. - -Signature: - -```typescript -vectorLength(): VectorLength; -``` -Returns: - -[VectorLength](./firestore_.vectorlength.md#vectorlength_class) - diff --git a/docs-devsite/firestore_.filtercondition.md b/docs-devsite/firestore_.filtercondition.md deleted file mode 100644 index 2665d872f9d..00000000000 --- a/docs-devsite/firestore_.filtercondition.md +++ /dev/null @@ -1,39 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# FilterCondition interface -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -An interface that represents a filter condition. - -Signature: - -```typescript -export declare interface FilterCondition -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [filterable](./firestore_.filtercondition.md#filterconditionfilterable) | true | (BETA) | - -## FilterCondition.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_.findnearest.md b/docs-devsite/firestore_.findnearest.md deleted file mode 100644 index 3b3f5c29744..00000000000 --- a/docs-devsite/firestore_.findnearest.md +++ /dev/null @@ -1,39 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# FindNearest class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class FindNearest implements Stage -``` -Implements: [Stage](./firestore_.stage.md#stage_interface) - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_.findnearest.md#findnearestname) | | string | (BETA) | - -## FindNearest.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_.findnearestoptions.md b/docs-devsite/firestore_.findnearestoptions.md deleted file mode 100644 index 5a4835b418d..00000000000 --- a/docs-devsite/firestore_.findnearestoptions.md +++ /dev/null @@ -1,86 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# FindNearestOptions interface -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare interface FindNearestOptions -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [distanceField](./firestore_.findnearestoptions.md#findnearestoptionsdistancefield) | string | (BETA) | -| [distanceMeasure](./firestore_.findnearestoptions.md#findnearestoptionsdistancemeasure) | 'euclidean' \| 'cosine' \| 'dot\_product' | (BETA) | -| [field](./firestore_.findnearestoptions.md#findnearestoptionsfield) | [Field](./firestore_.field.md#field_class) | (BETA) | -| [limit](./firestore_.findnearestoptions.md#findnearestoptionslimit) | number | (BETA) | -| [vectorValue](./firestore_.findnearestoptions.md#findnearestoptionsvectorvalue) | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) \| number\[\] | (BETA) | - -## FindNearestOptions.distanceField - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -distanceField?: string; -``` - -## FindNearestOptions.distanceMeasure - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -distanceMeasure: 'euclidean' | 'cosine' | 'dot_product'; -``` - -## FindNearestOptions.field - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -field: Field; -``` - -## FindNearestOptions.limit - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -limit?: number; -``` - -## FindNearestOptions.vectorValue - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -vectorValue: VectorValue | number[]; -``` diff --git a/docs-devsite/firestore_.firestore.md b/docs-devsite/firestore_.firestore.md index a8b7561a3ba..01267d5b2d3 100644 --- a/docs-devsite/firestore_.firestore.md +++ b/docs-devsite/firestore_.firestore.md @@ -31,7 +31,6 @@ export declare class Firestore | Method | Modifiers | Description | | --- | --- | --- | -| [pipeline()](./firestore_.firestore.md#firestorepipeline) | | Pipeline query. | | [toJSON()](./firestore_.firestore.md#firestoretojson) | | Returns a JSON-serializable representation of this Firestore instance. | ## Firestore.app @@ -54,19 +53,6 @@ Whether it's a [Firestore](./firestore_.firestore.md#firestore_class) or Firesto type: 'firestore-lite' | 'firestore'; ``` -## Firestore.pipeline() - -Pipeline query. - -Signature: - -```typescript -pipeline(): PipelineSource; -``` -Returns: - -[PipelineSource](./firestore_.pipelinesource.md#pipelinesource_class) - ## Firestore.toJSON() Returns a JSON-serializable representation of this `Firestore` instance. diff --git a/docs-devsite/firestore_.firestorefunction.md b/docs-devsite/firestore_.firestorefunction.md deleted file mode 100644 index 43022c17c72..00000000000 --- a/docs-devsite/firestore_.firestorefunction.md +++ /dev/null @@ -1,3173 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# FirestoreFunction class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -This class defines the base class for Firestore [Pipeline](./firestore_.pipeline.md#pipeline_class) functions, which can be evaluated within pipeline execution. - -Typically, you would not use this class or its children directly. Use either the functions like , , or the methods on (, , etc) to construct new Function instances. - -Signature: - -```typescript -export declare class FirestoreFunction -``` - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(name, params)](./firestore_.firestorefunction.md#firestorefunctionconstructor) | | (BETA) Constructs a new instance of the FirestoreFunction class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [exprType](./firestore_.firestorefunction.md#firestorefunctionexprtype) | | [ExprType](./firestore_.md#exprtype) | (BETA) | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [add(other)](./firestore_.firestorefunction.md#firestorefunctionadd) | | (BETA) Creates an expression that adds this expression to another expression. -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -Field.of("quantity").add(Field.of("reserve")); - -``` - | -| [add(other)](./firestore_.firestorefunction.md#firestorefunctionadd) | | (BETA) Creates an expression that adds this expression to a constant value. -```typescript -// Add 5 to the value of the 'age' field -Field.of("age").add(5); - -``` - | -| [arrayConcat(arrays)](./firestore_.firestorefunction.md#firestorefunctionarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. -```typescript -// Combine the 'items' array with another array field. -Field.of("items").arrayConcat(Field.of("otherItems")); - -``` - | -| [arrayConcat(arrays)](./firestore_.firestorefunction.md#firestorefunctionarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. -```typescript -// Combine the 'tags' array with a new array and an array field -Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); - -``` - | -| [arrayContains(element)](./firestore_.firestorefunction.md#firestorefunctionarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific element. -```typescript -// Check if the 'sizes' array contains the value from the 'selectedSize' field -Field.of("sizes").arrayContains(Field.of("selectedSize")); - -``` - | -| [arrayContains(element)](./firestore_.firestorefunction.md#firestorefunctionarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific value. -```typescript -// Check if the 'colors' array contains "red" -Field.of("colors").arrayContains("red"); - -``` - | -| [arrayContainsAll(values)](./firestore_.firestorefunction.md#firestorefunctionarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. -```typescript -// Check if the 'tags' array contains both "news" and "sports" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - | -| [arrayContainsAll(values)](./firestore_.firestorefunction.md#firestorefunctionarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - | -| [arrayContainsAny(values)](./firestore_.firestorefunction.md#firestorefunctionarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "cate2" -Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); - -``` - | -| [arrayContainsAny(values)](./firestore_.firestorefunction.md#firestorefunctionarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); - -``` - | -| [arrayLength()](./firestore_.firestorefunction.md#firestorefunctionarraylength) | | (BETA) Creates an expression that calculates the length of an array. -```typescript -// Get the number of items in the 'cart' array -Field.of("cart").arrayLength(); - -``` - A new Expr representing the length of the array. | -| [as(name)](./firestore_.firestorefunction.md#firestorefunctionas) | | (BETA) Assigns an alias to this expression.Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. -```typescript -// Calculate the total price and assign it the alias "totalPrice" and add it to the output. -firestore.pipeline().collection("items") -.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); - -``` - | -| [ascending()](./firestore_.firestorefunction.md#firestorefunctionascending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. -```typescript -// Sort documents by the 'name' field in ascending order -pipeline().collection("users") -.sort(Field.of("name").ascending()); - -``` - A new Ordering for ascending sorting. | -| [avg()](./firestore_.firestorefunction.md#firestorefunctionavg) | | (BETA) Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. -```typescript -// Calculate the average age of users -Field.of("age").avg().as("averageAge"); - -``` - A new Accumulator representing the 'avg' aggregation. | -| [byteLength()](./firestore_.firestorefunction.md#firestorefunctionbytelength) | | (BETA) Creates an expression that calculates the length of this string expression in bytes. -```typescript -// Calculate the length of the 'myString' field in bytes. -Field.of("myString").byteLength(); - -``` - A new representing the length of the string in bytes. | -| [charLength()](./firestore_.firestorefunction.md#firestorefunctioncharlength) | | (BETA) Creates an expression that calculates the character length of a string in UTF-8. -```typescript -// Get the character length of the 'name' field in its UTF-8 form. -Field.of("name").charLength(); - -``` - A new Expr representing the length of the string. | -| [cosineDistance(other)](./firestore_.firestorefunction.md#firestorefunctioncosinedistance) | | (BETA) Calculates the cosine distance between two vectors. -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -Field.of("userVector").cosineDistance(Field.of("itemVector")); - -``` - | -| [cosineDistance(other)](./firestore_.firestorefunction.md#firestorefunctioncosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); - -``` - | -| [cosineDistance(other)](./firestore_.firestorefunction.md#firestorefunctioncosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance([37.7749, -122.4194]); - -``` - | -| [count()](./firestore_.firestorefunction.md#firestorefunctioncount) | | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. -```typescript -// Count the total number of products -Field.of("productId").count().as("totalProducts"); - -``` - A new Accumulator representing the 'count' aggregation. | -| [descending()](./firestore_.firestorefunction.md#firestorefunctiondescending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") -.sort(Field.of("createdAt").descending()); - -``` - A new Ordering for descending sorting. | -| [divide(other)](./firestore_.firestorefunction.md#firestorefunctiondivide) | | (BETA) Creates an expression that divides this expression by another expression. -```typescript -// Divide the 'total' field by the 'count' field -Field.of("total").divide(Field.of("count")); - -``` - | -| [divide(other)](./firestore_.firestorefunction.md#firestorefunctiondivide) | | (BETA) Creates an expression that divides this expression by a constant value. -```typescript -// Divide the 'value' field by 10 -Field.of("value").divide(10); - -``` - | -| [dotProduct(other)](./firestore_.firestorefunction.md#firestorefunctiondotproduct) | | (BETA) Calculates the dot product between two vectors. -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct([0.5, 0.8, 0.2]); - -``` - | -| [dotProduct(other)](./firestore_.firestorefunction.md#firestorefunctiondotproduct) | | (BETA) Calculates the dot product between two vectors. -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); - -``` - | -| [dotProduct(other)](./firestore_.firestorefunction.md#firestorefunctiondotproduct) | | (BETA) | -| [endsWith(suffix)](./firestore_.firestorefunction.md#firestorefunctionendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix. -```typescript -// Check if the 'filename' field ends with ".txt" -Field.of("filename").endsWith(".txt"); - -``` - | -| [endsWith(suffix)](./firestore_.firestorefunction.md#firestorefunctionendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix (represented as an expression). -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -Field.of("url").endsWith(Field.of("extension")); - -``` - | -| [eq(other)](./firestore_.firestorefunction.md#firestorefunctioneq) | | (BETA) Creates an expression that checks if this expression is equal to another expression. -```typescript -// Check if the 'age' field is equal to 21 -Field.of("age").eq(21); - -``` - | -| [eq(other)](./firestore_.firestorefunction.md#firestorefunctioneq) | | (BETA) Creates an expression that checks if this expression is equal to a constant value. -```typescript -// Check if the 'city' field is equal to "London" -Field.of("city").eq("London"); - -``` - | -| [euclideanDistance(other)](./firestore_.firestorefunction.md#firestorefunctioneuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance([37.7749, -122.4194]); - -``` - | -| [euclideanDistance(other)](./firestore_.firestorefunction.md#firestorefunctioneuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); - -``` - | -| [euclideanDistance(other)](./firestore_.firestorefunction.md#firestorefunctioneuclideandistance) | | (BETA) | -| [exists()](./firestore_.firestorefunction.md#firestorefunctionexists) | | (BETA) Creates an expression that checks if a field exists in the document. -```typescript -// Check if the document has a field named "phoneNumber" -Field.of("phoneNumber").exists(); - -``` - A new Expr representing the 'exists' check. | -| [gt(other)](./firestore_.firestorefunction.md#firestorefunctiongt) | | (BETA) Creates an expression that checks if this expression is greater than another expression. -```typescript -// Check if the 'age' field is greater than the 'limit' field -Field.of("age").gt(Field.of("limit")); - -``` - | -| [gt(other)](./firestore_.firestorefunction.md#firestorefunctiongt) | | (BETA) Creates an expression that checks if this expression is greater than a constant value. -```typescript -// Check if the 'price' field is greater than 100 -Field.of("price").gt(100); - -``` - | -| [gte(other)](./firestore_.firestorefunction.md#firestorefunctiongte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to another expression. -```typescript -// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 -Field.of("quantity").gte(Field.of('requirement').add(1)); - -``` - | -| [gte(other)](./firestore_.firestorefunction.md#firestorefunctiongte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to a constant value. -```typescript -// Check if the 'score' field is greater than or equal to 80 -Field.of("score").gte(80); - -``` - | -| [in(others)](./firestore_.firestorefunction.md#firestorefunctionin) | | (BETA) Creates an expression that checks if this expression is equal to any of the provided values or expressions. -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -Field.of("category").in("Electronics", Field.of("primaryType")); - -``` - | -| [in(others)](./firestore_.firestorefunction.md#firestorefunctionin) | | (BETA) | -| [isNaN()](./firestore_.firestorefunction.md#firestorefunctionisnan) | | (BETA) Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). -```typescript -// Check if the result of a calculation is NaN -Field.of("value").divide(0).isNaN(); - -``` - A new Expr representing the 'isNaN' check. | -| [like(pattern)](./firestore_.firestorefunction.md#firestorefunctionlike) | | (BETA) Creates an expression that performs a case-sensitive string comparison. -```typescript -// Check if the 'title' field contains the word "guide" (case-sensitive) -Field.of("title").like("%guide%"); - -``` - | -| [like(pattern)](./firestore_.firestorefunction.md#firestorefunctionlike) | | (BETA) | -| [logicalMax(other)](./firestore_.firestorefunction.md#firestorefunctionlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMax(Function.currentTimestamp()); - -``` - | -| [logicalMax(other)](./firestore_.firestorefunction.md#firestorefunctionlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'value' field and 10. -Field.of("value").logicalMax(10); - -``` - | -| [logicalMin(other)](./firestore_.firestorefunction.md#firestorefunctionlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMin(Function.currentTimestamp()); - -``` - | -| [logicalMin(other)](./firestore_.firestorefunction.md#firestorefunctionlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'value' field and 10. -Field.of("value").logicalMin(10); - -``` - | -| [lt(other)](./firestore_.firestorefunction.md#firestorefunctionlt) | | (BETA) Creates an expression that checks if this expression is less than another expression. -```typescript -// Check if the 'age' field is less than 'limit' -Field.of("age").lt(Field.of('limit')); - -``` - | -| [lt(other)](./firestore_.firestorefunction.md#firestorefunctionlt) | | (BETA) Creates an expression that checks if this expression is less than a constant value. -```typescript -// Check if the 'price' field is less than 50 -Field.of("price").lt(50); - -``` - | -| [lte(other)](./firestore_.firestorefunction.md#firestorefunctionlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to another expression. -```typescript -// Check if the 'quantity' field is less than or equal to 20 -Field.of("quantity").lte(Constant.of(20)); - -``` - | -| [lte(other)](./firestore_.firestorefunction.md#firestorefunctionlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to a constant value. -```typescript -// Check if the 'score' field is less than or equal to 70 -Field.of("score").lte(70); - -``` - | -| [mapGet(subfield)](./firestore_.firestorefunction.md#firestorefunctionmapget) | | (BETA) Accesses a value from a map (object) field using the provided key. -```typescript -// Get the 'city' value from the 'address' map field -Field.of("address").mapGet("city"); - -``` - | -| [max()](./firestore_.firestorefunction.md#firestorefunctionmax) | | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. -```typescript -// Find the highest score in a leaderboard -Field.of("score").max().as("highestScore"); - -``` - A new Accumulator representing the 'max' aggregation. | -| [min()](./firestore_.firestorefunction.md#firestorefunctionmin) | | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. -```typescript -// Find the lowest price of all products -Field.of("price").min().as("lowestPrice"); - -``` - A new Accumulator representing the 'min' aggregation. | -| [mod(other)](./firestore_.firestorefunction.md#firestorefunctionmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. -```typescript -// Calculate the remainder of dividing the 'value' field by the 'divisor' field -Field.of("value").mod(Field.of("divisor")); - -``` - | -| [mod(other)](./firestore_.firestorefunction.md#firestorefunctionmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. -```typescript -// Calculate the remainder of dividing the 'value' field by 10 -Field.of("value").mod(10); - -``` - | -| [multiply(other)](./firestore_.firestorefunction.md#firestorefunctionmultiply) | | (BETA) Creates an expression that multiplies this expression by another expression. -```typescript -// Multiply the 'quantity' field by the 'price' field -Field.of("quantity").multiply(Field.of("price")); - -``` - | -| [multiply(other)](./firestore_.firestorefunction.md#firestorefunctionmultiply) | | (BETA) Creates an expression that multiplies this expression by a constant value. -```typescript -// Multiply the 'value' field by 2 -Field.of("value").multiply(2); - -``` - | -| [neq(other)](./firestore_.firestorefunction.md#firestorefunctionneq) | | (BETA) Creates an expression that checks if this expression is not equal to another expression. -```typescript -// Check if the 'status' field is not equal to "completed" -Field.of("status").neq("completed"); - -``` - | -| [neq(other)](./firestore_.firestorefunction.md#firestorefunctionneq) | | (BETA) Creates an expression that checks if this expression is not equal to a constant value. -```typescript -// Check if the 'country' field is not equal to "USA" -Field.of("country").neq("USA"); - -``` - | -| [regexContains(pattern)](./firestore_.firestorefunction.md#firestorefunctionregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -Field.of("description").regexContains("(?i)example"); - -``` - | -| [regexContains(pattern)](./firestore_.firestorefunction.md#firestorefunctionregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains the regular expression stored in field 'regex' -Field.of("description").regexContains(Field.of("regex")); - -``` - | -| [regexMatch(pattern)](./firestore_.firestorefunction.md#firestorefunctionregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. -```typescript -// Check if the 'email' field matches a valid email pattern -Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - | -| [regexMatch(pattern)](./firestore_.firestorefunction.md#firestorefunctionregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. -```typescript -// Check if the 'email' field matches a regular expression stored in field 'regex' -Field.of("email").regexMatch(Field.of("regex")); - -``` - | -| [replaceAll(find, replace)](./firestore_.firestorefunction.md#firestorefunctionreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring. -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field -Field.of("message").replaceAll("hello", "hi"); - -``` - | -| [replaceAll(find, replace)](./firestore_.firestorefunction.md#firestorefunctionreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); - -``` - | -| [replaceFirst(find, replace)](./firestore_.firestorefunction.md#firestorefunctionreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field -Field.of("message").replaceFirst("hello", "hi"); - -``` - | -| [replaceFirst(find, replace)](./firestore_.firestorefunction.md#firestorefunctionreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); - -``` - | -| [reverse()](./firestore_.firestorefunction.md#firestorefunctionreverse) | | (BETA) Creates an expression that reverses this string expression. -```typescript -// Reverse the value of the 'myString' field. -Field.of("myString").reverse(); - -``` - A new representing the reversed string. | -| [startsWith(prefix)](./firestore_.firestorefunction.md#firestorefunctionstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix. -```typescript -// Check if the 'name' field starts with "Mr." -Field.of("name").startsWith("Mr."); - -``` - | -| [startsWith(prefix)](./firestore_.firestorefunction.md#firestorefunctionstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix (represented as an expression). -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -Field.of("fullName").startsWith(Field.of("firstName")); - -``` - | -| [strConcat(elements)](./firestore_.firestorefunction.md#firestorefunctionstrconcat) | | (BETA) Creates an expression that concatenates string expressions together. -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); - -``` - | -| [strContains(substring)](./firestore_.firestorefunction.md#firestorefunctionstrcontains) | | (BETA) Creates an expression that checks if a string contains a specified substring. -```typescript -// Check if the 'description' field contains "example". -Field.of("description").strContains("example"); - -``` - | -| [strContains(expr)](./firestore_.firestorefunction.md#firestorefunctionstrcontains) | | (BETA) Creates an expression that checks if a string contains the string represented by another expression. -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -Field.of("description").strContains(Field.of("keyword")); - -``` - | -| [subtract(other)](./firestore_.firestorefunction.md#firestorefunctionsubtract) | | (BETA) Creates an expression that subtracts another expression from this expression. -```typescript -// Subtract the 'discount' field from the 'price' field -Field.of("price").subtract(Field.of("discount")); - -``` - | -| [subtract(other)](./firestore_.firestorefunction.md#firestorefunctionsubtract) | | (BETA) Creates an expression that subtracts a constant value from this expression. -```typescript -// Subtract 20 from the value of the 'total' field -Field.of("total").subtract(20); - -``` - | -| [sum()](./firestore_.firestorefunction.md#firestorefunctionsum) | | (BETA) Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. -```typescript -// Calculate the total revenue from a set of orders -Field.of("orderAmount").sum().as("totalRevenue"); - -``` - A new Accumulator representing the 'sum' aggregation. | -| [timestampAdd(unit, amount)](./firestore_.firestorefunction.md#firestorefunctiontimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampAdd(unit, amount)](./firestore_.firestorefunction.md#firestorefunctiontimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. -```typescript -// Add 1 day to the 'timestamp' field. -Field.of("timestamp").timestampAdd("day", 1); - -``` - | -| [timestampSub(unit, amount)](./firestore_.firestorefunction.md#firestorefunctiontimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampSub(unit, amount)](./firestore_.firestorefunction.md#firestorefunctiontimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. -```typescript -// Subtract 1 day from the 'timestamp' field. -Field.of("timestamp").timestampSub("day", 1); - -``` - | -| [timestampToUnixMicros()](./firestore_.firestorefunction.md#firestorefunctiontimestamptounixmicros) | | (BETA) Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -Field.of("timestamp").timestampToUnixMicros(); - -``` - A new representing the number of microseconds since epoch. | -| [timestampToUnixMillis()](./firestore_.firestorefunction.md#firestorefunctiontimestamptounixmillis) | | (BETA) Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -Field.of("timestamp").timestampToUnixMillis(); - -``` - A new representing the number of milliseconds since epoch. | -| [timestampToUnixSeconds()](./firestore_.firestorefunction.md#firestorefunctiontimestamptounixseconds) | | (BETA) Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to seconds since epoch. -Field.of("timestamp").timestampToUnixSeconds(); - -``` - A new representing the number of seconds since epoch. | -| [toLower()](./firestore_.firestorefunction.md#firestorefunctiontolower) | | (BETA) Creates an expression that converts a string to lowercase. -```typescript -// Convert the 'name' field to lowercase -Field.of("name").toLower(); - -``` - A new Expr representing the lowercase string. | -| [toUpper()](./firestore_.firestorefunction.md#firestorefunctiontoupper) | | (BETA) Creates an expression that converts a string to uppercase. -```typescript -// Convert the 'title' field to uppercase -Field.of("title").toUpper(); - -``` - A new Expr representing the uppercase string. | -| [trim()](./firestore_.firestorefunction.md#firestorefunctiontrim) | | (BETA) Creates an expression that removes leading and trailing whitespace from a string. -```typescript -// Trim whitespace from the 'userInput' field -Field.of("userInput").trim(); - -``` - A new Expr representing the trimmed string. | -| [unixMicrosToTimestamp()](./firestore_.firestorefunction.md#firestorefunctionunixmicrostotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -Field.of("microseconds").unixMicrosToTimestamp(); - -``` - A new representing the timestamp. | -| [unixMillisToTimestamp()](./firestore_.firestorefunction.md#firestorefunctionunixmillistotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -Field.of("milliseconds").unixMillisToTimestamp(); - -``` - A new representing the timestamp. | -| [unixSecondsToTimestamp()](./firestore_.firestorefunction.md#firestorefunctionunixsecondstotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'seconds' field as seconds since epoch. -Field.of("seconds").unixSecondsToTimestamp(); - -``` - A new representing the timestamp. | -| [vectorLength()](./firestore_.firestorefunction.md#firestorefunctionvectorlength) | | (BETA) Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. -```typescript -// Get the vector length (dimension) of the field 'embedding'. -Field.of("embedding").vectorLength(); - -``` - A new representing the length of the vector. | - -## FirestoreFunction.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `FirestoreFunction` class - -Signature: - -```typescript -constructor(name: string, params: Constant[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | | -| params | [Constant](./firestore_.constant.md#constant_class)\[\] | | - -## FirestoreFunction.exprType - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -exprType: ExprType; -``` - -## FirestoreFunction.add() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds this expression to another expression. - -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -Field.of("quantity").add(Field.of("reserve")); - -``` - -Signature: - -```typescript -add(other: Constant): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to add to this expression. A new Expr representing the addition operation. | - -Returns: - -[Add](./firestore_.add.md#add_class) - -## FirestoreFunction.add() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds this expression to a constant value. - -```typescript -// Add 5 to the value of the 'age' field -Field.of("age").add(5); - -``` - -Signature: - -```typescript -add(other: any): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to add. A new Expr representing the addition operation. | - -Returns: - -[Add](./firestore_.add.md#add_class) - -## FirestoreFunction.arrayConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with one or more other arrays. - -```typescript -// Combine the 'items' array with another array field. -Field.of("items").arrayConcat(Field.of("otherItems")); - -``` - -Signature: - -```typescript -arrayConcat(arrays: Constant[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| arrays | [Constant](./firestore_.constant.md#constant_class)\[\] | The array expressions to concatenate. A new Expr representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) - -## FirestoreFunction.arrayConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with one or more other arrays. - -```typescript -// Combine the 'tags' array with a new array and an array field -Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); - -``` - -Signature: - -```typescript -arrayConcat(arrays: any[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| arrays | any\[\] | The array expressions or values to concatenate. A new Expr representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) - -## FirestoreFunction.arrayContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains a specific element. - -```typescript -// Check if the 'sizes' array contains the value from the 'selectedSize' field -Field.of("sizes").arrayContains(Field.of("selectedSize")); - -``` - -Signature: - -```typescript -arrayContains(element: Constant): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | [Constant](./firestore_.constant.md#constant_class) | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) - -## FirestoreFunction.arrayContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains a specific value. - -```typescript -// Check if the 'colors' array contains "red" -Field.of("colors").arrayContains("red"); - -``` - -Signature: - -```typescript -arrayContains(element: any): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | any | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) - -## FirestoreFunction.arrayContainsAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both "news" and "sports" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - -Signature: - -```typescript -arrayContainsAll(...values: Constant[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) - -## FirestoreFunction.arrayContainsAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - -Signature: - -```typescript -arrayContainsAll(...values: any[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) - -## FirestoreFunction.arrayContainsAny() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains any of the specified elements. - -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "cate2" -Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); - -``` - -Signature: - -```typescript -arrayContainsAny(...values: Constant[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) - -## FirestoreFunction.arrayContainsAny() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains any of the specified elements. - -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); - -``` - -Signature: - -```typescript -arrayContainsAny(...values: any[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) - -## FirestoreFunction.arrayLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of an array. - -```typescript -// Get the number of items in the 'cart' array -Field.of("cart").arrayLength(); - -``` - A new `Expr` representing the length of the array. - -Signature: - -```typescript -arrayLength(): ArrayLength; -``` -Returns: - -[ArrayLength](./firestore_.arraylength.md#arraylength_class) - -## FirestoreFunction.as() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Assigns an alias to this expression. - -Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. - -```typescript -// Calculate the total price and assign it the alias "totalPrice" and add it to the output. -firestore.pipeline().collection("items") -.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); - -``` - -Signature: - -```typescript -as(name: string): ExprWithAlias; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | The alias to assign to this expression. A new [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) that wraps this expression and associates it with the provided alias. | - -Returns: - -[ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class)<this> - -## FirestoreFunction.ascending() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. - -```typescript -// Sort documents by the 'name' field in ascending order -pipeline().collection("users") -.sort(Field.of("name").ascending()); - -``` - A new `Ordering` for ascending sorting. - -Signature: - -```typescript -ascending(): Ordering; -``` -Returns: - -[Ordering](./firestore_.ordering.md#ordering_class) - -## FirestoreFunction.avg() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. - -```typescript -// Calculate the average age of users -Field.of("age").avg().as("averageAge"); - -``` - A new `Accumulator` representing the 'avg' aggregation. - -Signature: - -```typescript -avg(): Avg; -``` -Returns: - -[Avg](./firestore_.avg.md#avg_class) - -## FirestoreFunction.byteLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of this string expression in bytes. - -```typescript -// Calculate the length of the 'myString' field in bytes. -Field.of("myString").byteLength(); - -``` - A new representing the length of the string in bytes. - -Signature: - -```typescript -byteLength(): ByteLength; -``` -Returns: - -[ByteLength](./firestore_.bytelength.md#bytelength_class) - -## FirestoreFunction.charLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the character length of a string in UTF-8. - -```typescript -// Get the character length of the 'name' field in its UTF-8 form. -Field.of("name").charLength(); - -``` - A new `Expr` representing the length of the string. - -Signature: - -```typescript -charLength(): CharLength; -``` -Returns: - -[CharLength](./firestore_.charlength.md#charlength_class) - -## FirestoreFunction.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the cosine distance between two vectors. - -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -Field.of("userVector").cosineDistance(Field.of("itemVector")); - -``` - -Signature: - -```typescript -cosineDistance(other: Constant): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new Expr representing the cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) - -## FirestoreFunction.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vectors. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -cosineDistance(other: VectorValue): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) - -## FirestoreFunction.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vectors. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance([37.7749, -122.4194]); - -``` - -Signature: - -```typescript -cosineDistance(other: number[]): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | The other vector (as an array of numbers) to compare against. A new Expr representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) - -## FirestoreFunction.count() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. - -```typescript -// Count the total number of products -Field.of("productId").count().as("totalProducts"); - -``` - A new `Accumulator` representing the 'count' aggregation. - -Signature: - -```typescript -count(): Count; -``` -Returns: - -[Count](./firestore_.count.md#count_class) - -## FirestoreFunction.descending() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. - -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") -.sort(Field.of("createdAt").descending()); - -``` - A new `Ordering` for descending sorting. - -Signature: - -```typescript -descending(): Ordering; -``` -Returns: - -[Ordering](./firestore_.ordering.md#ordering_class) - -## FirestoreFunction.divide() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides this expression by another expression. - -```typescript -// Divide the 'total' field by the 'count' field -Field.of("total").divide(Field.of("count")); - -``` - -Signature: - -```typescript -divide(other: Constant): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new Expr representing the division operation. | - -Returns: - -[Divide](./firestore_.divide.md#divide_class) - -## FirestoreFunction.divide() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides this expression by a constant value. - -```typescript -// Divide the 'value' field by 10 -Field.of("value").divide(10); - -``` - -Signature: - -```typescript -divide(other: any): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to divide by. A new Expr representing the division operation. | - -Returns: - -[Divide](./firestore_.divide.md#divide_class) - -## FirestoreFunction.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vectors. - -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct([0.5, 0.8, 0.2]); - -``` - -Signature: - -```typescript -dotProduct(other: Constant): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_.dotproduct.md#dotproduct_class) - -## FirestoreFunction.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vectors. - -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); - -``` - -Signature: - -```typescript -dotProduct(other: VectorValue): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_.dotproduct.md#dotproduct_class) - -## FirestoreFunction.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -dotProduct(other: number[]): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | | - -Returns: - -[DotProduct](./firestore_.dotproduct.md#dotproduct_class) - -## FirestoreFunction.endsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string ends with a given postfix. - -```typescript -// Check if the 'filename' field ends with ".txt" -Field.of("filename").endsWith(".txt"); - -``` - -Signature: - -```typescript -endsWith(suffix: string): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| suffix | string | The postfix to check for. A new Expr representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_.endswith.md#endswith_class) - -## FirestoreFunction.endsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string ends with a given postfix (represented as an expression). - -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -Field.of("url").endsWith(Field.of("extension")); - -``` - -Signature: - -```typescript -endsWith(suffix: Constant): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| suffix | [Constant](./firestore_.constant.md#constant_class) | The postfix expression to check for. A new Expr representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_.endswith.md#endswith_class) - -## FirestoreFunction.eq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to another expression. - -```typescript -// Check if the 'age' field is equal to 21 -Field.of("age").eq(21); - -``` - -Signature: - -```typescript -eq(other: Constant): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for equality. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_.eq.md#eq_class) - -## FirestoreFunction.eq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to a constant value. - -```typescript -// Check if the 'city' field is equal to "London" -Field.of("city").eq("London"); - -``` - -Signature: - -```typescript -eq(other: any): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for equality. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_.eq.md#eq_class) - -## FirestoreFunction.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vectors. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance([37.7749, -122.4194]); - -``` - -Signature: - -```typescript -euclideanDistance(other: Constant): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) - -## FirestoreFunction.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vectors. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -euclideanDistance(other: VectorValue): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) - -## FirestoreFunction.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -euclideanDistance(other: number[]): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | | - -Returns: - -[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) - -## FirestoreFunction.exists() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field exists in the document. - -```typescript -// Check if the document has a field named "phoneNumber" -Field.of("phoneNumber").exists(); - -``` - A new `Expr` representing the 'exists' check. - -Signature: - -```typescript -exists(): Exists; -``` -Returns: - -[Exists](./firestore_.exists.md#exists_class) - -## FirestoreFunction.gt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than another expression. - -```typescript -// Check if the 'age' field is greater than the 'limit' field -Field.of("age").gt(Field.of("limit")); - -``` - -Signature: - -```typescript -gt(other: Constant): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for greater than. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_.gt.md#gt_class) - -## FirestoreFunction.gt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than a constant value. - -```typescript -// Check if the 'price' field is greater than 100 -Field.of("price").gt(100); - -``` - -Signature: - -```typescript -gt(other: any): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for greater than. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_.gt.md#gt_class) - -## FirestoreFunction.gte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than or equal to another expression. - -```typescript -// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 -Field.of("quantity").gte(Field.of('requirement').add(1)); - -``` - -Signature: - -```typescript -gte(other: Constant): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_.gte.md#gte_class) - -## FirestoreFunction.gte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than or equal to a constant value. - -```typescript -// Check if the 'score' field is greater than or equal to 80 -Field.of("score").gte(80); - -``` - -Signature: - -```typescript -gte(other: any): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_.gte.md#gte_class) - -## FirestoreFunction.in() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to any of the provided values or expressions. - -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -Field.of("category").in("Electronics", Field.of("primaryType")); - -``` - -Signature: - -```typescript -in(...others: Constant[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| others | [Constant](./firestore_.constant.md#constant_class)\[\] | The values or expressions to check against. A new Expr representing the 'IN' comparison. | - -Returns: - -[In](./firestore_.in.md#in_class) - -## FirestoreFunction.in() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -in(...others: any[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| others | any\[\] | | - -Returns: - -[In](./firestore_.in.md#in_class) - -## FirestoreFunction.isNaN() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). - -```typescript -// Check if the result of a calculation is NaN -Field.of("value").divide(0).isNaN(); - -``` - A new `Expr` representing the 'isNaN' check. - -Signature: - -```typescript -isNaN(): IsNan; -``` -Returns: - -[IsNan](./firestore_.isnan.md#isnan_class) - -## FirestoreFunction.like() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that performs a case-sensitive string comparison. - -```typescript -// Check if the 'title' field contains the word "guide" (case-sensitive) -Field.of("title").like("%guide%"); - -``` - -Signature: - -```typescript -like(pattern: string): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new Expr representing the 'like' comparison. | - -Returns: - -[Like](./firestore_.like.md#like_class) - -## FirestoreFunction.like() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -like(pattern: Constant): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_.constant.md#constant_class) | | - -Returns: - -[Like](./firestore_.like.md#like_class) - -## FirestoreFunction.logicalMax() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMax(Function.currentTimestamp()); - -``` - -Signature: - -```typescript -logicalMax(other: Constant): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare with. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) - -## FirestoreFunction.logicalMax() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'value' field and 10. -Field.of("value").logicalMax(10); - -``` - -Signature: - -```typescript -logicalMax(other: any): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare with. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) - -## FirestoreFunction.logicalMin() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMin(Function.currentTimestamp()); - -``` - -Signature: - -```typescript -logicalMin(other: Constant): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare with. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) - -## FirestoreFunction.logicalMin() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'value' field and 10. -Field.of("value").logicalMin(10); - -``` - -Signature: - -```typescript -logicalMin(other: any): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare with. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) - -## FirestoreFunction.lt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than another expression. - -```typescript -// Check if the 'age' field is less than 'limit' -Field.of("age").lt(Field.of('limit')); - -``` - -Signature: - -```typescript -lt(other: Constant): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for less than. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_.lt.md#lt_class) - -## FirestoreFunction.lt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than a constant value. - -```typescript -// Check if the 'price' field is less than 50 -Field.of("price").lt(50); - -``` - -Signature: - -```typescript -lt(other: any): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for less than. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_.lt.md#lt_class) - -## FirestoreFunction.lte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than or equal to another expression. - -```typescript -// Check if the 'quantity' field is less than or equal to 20 -Field.of("quantity").lte(Constant.of(20)); - -``` - -Signature: - -```typescript -lte(other: Constant): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_.lte.md#lte_class) - -## FirestoreFunction.lte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than or equal to a constant value. - -```typescript -// Check if the 'score' field is less than or equal to 70 -Field.of("score").lte(70); - -``` - -Signature: - -```typescript -lte(other: any): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_.lte.md#lte_class) - -## FirestoreFunction.mapGet() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Accesses a value from a map (object) field using the provided key. - -```typescript -// Get the 'city' value from the 'address' map field -Field.of("address").mapGet("city"); - -``` - -Signature: - -```typescript -mapGet(subfield: string): MapGet; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| subfield | string | The key to access in the map. A new Expr representing the value associated with the given key in the map. | - -Returns: - -[MapGet](./firestore_.mapget.md#mapget_class) - -## FirestoreFunction.max() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that finds the maximum value of a field across multiple stage inputs. - -```typescript -// Find the highest score in a leaderboard -Field.of("score").max().as("highestScore"); - -``` - A new `Accumulator` representing the 'max' aggregation. - -Signature: - -```typescript -max(): Max; -``` -Returns: - -[Max](./firestore_.max.md#max_class) - -## FirestoreFunction.min() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that finds the minimum value of a field across multiple stage inputs. - -```typescript -// Find the lowest price of all products -Field.of("price").min().as("lowestPrice"); - -``` - A new `Accumulator` representing the 'min' aggregation. - -Signature: - -```typescript -min(): Min; -``` -Returns: - -[Min](./firestore_.min.md#min_class) - -## FirestoreFunction.mod() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. - -```typescript -// Calculate the remainder of dividing the 'value' field by the 'divisor' field -Field.of("value").mod(Field.of("divisor")); - -``` - -Signature: - -```typescript -mod(other: Constant): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new Expr representing the modulo operation. | - -Returns: - -[Mod](./firestore_.mod.md#mod_class) - -## FirestoreFunction.mod() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. - -```typescript -// Calculate the remainder of dividing the 'value' field by 10 -Field.of("value").mod(10); - -``` - -Signature: - -```typescript -mod(other: any): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to divide by. A new Expr representing the modulo operation. | - -Returns: - -[Mod](./firestore_.mod.md#mod_class) - -## FirestoreFunction.multiply() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies this expression by another expression. - -```typescript -// Multiply the 'quantity' field by the 'price' field -Field.of("quantity").multiply(Field.of("price")); - -``` - -Signature: - -```typescript -multiply(other: Constant): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to multiply by. A new Expr representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_.multiply.md#multiply_class) - -## FirestoreFunction.multiply() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies this expression by a constant value. - -```typescript -// Multiply the 'value' field by 2 -Field.of("value").multiply(2); - -``` - -Signature: - -```typescript -multiply(other: any): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to multiply by. A new Expr representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_.multiply.md#multiply_class) - -## FirestoreFunction.neq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is not equal to another expression. - -```typescript -// Check if the 'status' field is not equal to "completed" -Field.of("status").neq("completed"); - -``` - -Signature: - -```typescript -neq(other: Constant): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to compare for inequality. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_.neq.md#neq_class) - -## FirestoreFunction.neq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is not equal to a constant value. - -```typescript -// Check if the 'country' field is not equal to "USA" -Field.of("country").neq("USA"); - -``` - -Signature: - -```typescript -neq(other: any): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for inequality. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_.neq.md#neq_class) - -## FirestoreFunction.regexContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -Field.of("description").regexContains("(?i)example"); - -``` - -Signature: - -```typescript -regexContains(pattern: string): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_.regexcontains.md#regexcontains_class) - -## FirestoreFunction.regexContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains the regular expression stored in field 'regex' -Field.of("description").regexContains(Field.of("regex")); - -``` - -Signature: - -```typescript -regexContains(pattern: Constant): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_.regexcontains.md#regexcontains_class) - -## FirestoreFunction.regexMatch() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a valid email pattern -Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - -Signature: - -```typescript -regexMatch(pattern: string): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The regular expression to use for the match. A new Expr representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) - -## FirestoreFunction.regexMatch() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a regular expression stored in field 'regex' -Field.of("email").regexMatch(Field.of("regex")); - -``` - -Signature: - -```typescript -regexMatch(pattern: Constant): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the match. A new Expr representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) - -## FirestoreFunction.replaceAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within this string expression with another substring. - -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field -Field.of("message").replaceAll("hello", "hi"); - -``` - -Signature: - -```typescript -replaceAll(find: string, replace: string): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | string | The substring to search for. | -| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_.replaceall.md#replaceall_class) - -## FirestoreFunction.replaceAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. - -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); - -``` - -Signature: - -```typescript -replaceAll(find: Constant, replace: Constant): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_.replaceall.md#replaceall_class) - -## FirestoreFunction.replaceFirst() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. - -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field -Field.of("message").replaceFirst("hello", "hi"); - -``` - -Signature: - -```typescript -replaceFirst(find: string, replace: string): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | string | The substring to search for. | -| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) - -## FirestoreFunction.replaceFirst() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. - -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); - -``` - -Signature: - -```typescript -replaceFirst(find: Constant, replace: Constant): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) - -## FirestoreFunction.reverse() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that reverses this string expression. - -```typescript -// Reverse the value of the 'myString' field. -Field.of("myString").reverse(); - -``` - A new representing the reversed string. - -Signature: - -```typescript -reverse(): Reverse; -``` -Returns: - -[Reverse](./firestore_.reverse.md#reverse_class) - -## FirestoreFunction.startsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string starts with a given prefix. - -```typescript -// Check if the 'name' field starts with "Mr." -Field.of("name").startsWith("Mr."); - -``` - -Signature: - -```typescript -startsWith(prefix: string): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| prefix | string | The prefix to check for. A new Expr representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_.startswith.md#startswith_class) - -## FirestoreFunction.startsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string starts with a given prefix (represented as an expression). - -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -Field.of("fullName").startsWith(Field.of("firstName")); - -``` - -Signature: - -```typescript -startsWith(prefix: Constant): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| prefix | [Constant](./firestore_.constant.md#constant_class) | The prefix expression to check for. A new Expr representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_.startswith.md#startswith_class) - -## FirestoreFunction.strConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates string expressions together. - -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); - -``` - -Signature: - -```typescript -strConcat(...elements: Array): StrConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| elements | Array<string \| [Constant](./firestore_.constant.md#constant_class)> | The expressions (typically strings) to concatenate. A new Expr representing the concatenated string. | - -Returns: - -[StrConcat](./firestore_.strconcat.md#strconcat_class) - -## FirestoreFunction.strContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified substring. - -```typescript -// Check if the 'description' field contains "example". -Field.of("description").strContains("example"); - -``` - -Signature: - -```typescript -strContains(substring: string): StrContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| substring | string | The substring to search for. A new Expr representing the 'contains' comparison. | - -Returns: - -[StrContains](./firestore_.strcontains.md#strcontains_class) - -## FirestoreFunction.strContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains the string represented by another expression. - -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -Field.of("description").strContains(Field.of("keyword")); - -``` - -Signature: - -```typescript -strContains(expr: Constant): StrContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. A new Expr representing the 'contains' comparison. | - -Returns: - -[StrContains](./firestore_.strcontains.md#strcontains_class) - -## FirestoreFunction.subtract() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts another expression from this expression. - -```typescript -// Subtract the 'discount' field from the 'price' field -Field.of("price").subtract(Field.of("discount")); - -``` - -Signature: - -```typescript -subtract(other: Constant): Subtract; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_.constant.md#constant_class) | The expression to subtract from this expression. A new Expr representing the subtraction operation. | - -Returns: - -[Subtract](./firestore_.subtract.md#subtract_class) - -## FirestoreFunction.subtract() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a constant value from this expression. - -```typescript -// Subtract 20 from the value of the 'total' field -Field.of("total").subtract(20); - -``` - -Signature: - -```typescript -subtract(other: any): Subtract; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to subtract. A new Expr representing the subtraction operation. | - -Returns: - -[Subtract](./firestore_.subtract.md#subtract_class) - -## FirestoreFunction.sum() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. - -```typescript -// Calculate the total revenue from a set of orders -Field.of("orderAmount").sum().as("totalRevenue"); - -``` - A new `Accumulator` representing the 'sum' aggregation. - -Signature: - -```typescript -sum(): Sum; -``` -Returns: - -[Sum](./firestore_.sum.md#sum_class) - -## FirestoreFunction.timestampAdd() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to this timestamp expression. - -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); - -``` - -Signature: - -```typescript -timestampAdd(unit: Constant, amount: Constant): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) - -## FirestoreFunction.timestampAdd() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to this timestamp expression. - -```typescript -// Add 1 day to the 'timestamp' field. -Field.of("timestamp").timestampAdd("day", 1); - -``` - -Signature: - -```typescript -timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | -| amount | number | The amount of time to add. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) - -## FirestoreFunction.timestampSub() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from this timestamp expression. - -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); - -``` - -Signature: - -```typescript -timestampSub(unit: Constant, amount: Constant): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) - -## FirestoreFunction.timestampSub() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from this timestamp expression. - -```typescript -// Subtract 1 day from the 'timestamp' field. -Field.of("timestamp").timestampSub("day", 1); - -``` - -Signature: - -```typescript -timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | -| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) - -## FirestoreFunction.timestampToUnixMicros() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -Field.of("timestamp").timestampToUnixMicros(); - -``` - A new representing the number of microseconds since epoch. - -Signature: - -```typescript -timestampToUnixMicros(): TimestampToUnixMicros; -``` -Returns: - -[TimestampToUnixMicros](./firestore_.timestamptounixmicros.md#timestamptounixmicros_class) - -## FirestoreFunction.timestampToUnixMillis() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -Field.of("timestamp").timestampToUnixMillis(); - -``` - A new representing the number of milliseconds since epoch. - -Signature: - -```typescript -timestampToUnixMillis(): TimestampToUnixMillis; -``` -Returns: - -[TimestampToUnixMillis](./firestore_.timestamptounixmillis.md#timestamptounixmillis_class) - -## FirestoreFunction.timestampToUnixSeconds() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to seconds since epoch. -Field.of("timestamp").timestampToUnixSeconds(); - -``` - A new representing the number of seconds since epoch. - -Signature: - -```typescript -timestampToUnixSeconds(): TimestampToUnixSeconds; -``` -Returns: - -[TimestampToUnixSeconds](./firestore_.timestamptounixseconds.md#timestamptounixseconds_class) - -## FirestoreFunction.toLower() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string to lowercase. - -```typescript -// Convert the 'name' field to lowercase -Field.of("name").toLower(); - -``` - A new `Expr` representing the lowercase string. - -Signature: - -```typescript -toLower(): ToLower; -``` -Returns: - -[ToLower](./firestore_.tolower.md#tolower_class) - -## FirestoreFunction.toUpper() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string to uppercase. - -```typescript -// Convert the 'title' field to uppercase -Field.of("title").toUpper(); - -``` - A new `Expr` representing the uppercase string. - -Signature: - -```typescript -toUpper(): ToUpper; -``` -Returns: - -[ToUpper](./firestore_.toupper.md#toupper_class) - -## FirestoreFunction.trim() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that removes leading and trailing whitespace from a string. - -```typescript -// Trim whitespace from the 'userInput' field -Field.of("userInput").trim(); - -``` - A new `Expr` representing the trimmed string. - -Signature: - -```typescript -trim(): Trim; -``` -Returns: - -[Trim](./firestore_.trim.md#trim_class) - -## FirestoreFunction.unixMicrosToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -Field.of("microseconds").unixMicrosToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixMicrosToTimestamp(): UnixMicrosToTimestamp; -``` -Returns: - -[UnixMicrosToTimestamp](./firestore_.unixmicrostotimestamp.md#unixmicrostotimestamp_class) - -## FirestoreFunction.unixMillisToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -Field.of("milliseconds").unixMillisToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixMillisToTimestamp(): UnixMillisToTimestamp; -``` -Returns: - -[UnixMillisToTimestamp](./firestore_.unixmillistotimestamp.md#unixmillistotimestamp_class) - -## FirestoreFunction.unixSecondsToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'seconds' field as seconds since epoch. -Field.of("seconds").unixSecondsToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixSecondsToTimestamp(): UnixSecondsToTimestamp; -``` -Returns: - -[UnixSecondsToTimestamp](./firestore_.unixsecondstotimestamp.md#unixsecondstotimestamp_class) - -## FirestoreFunction.vectorLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. - -```typescript -// Get the vector length (dimension) of the field 'embedding'. -Field.of("embedding").vectorLength(); - -``` - A new representing the length of the vector. - -Signature: - -```typescript -vectorLength(): VectorLength; -``` -Returns: - -[VectorLength](./firestore_.vectorlength.md#vectorlength_class) - diff --git a/docs-devsite/firestore_.genericstage.md b/docs-devsite/firestore_.genericstage.md deleted file mode 100644 index 765ef090d87..00000000000 --- a/docs-devsite/firestore_.genericstage.md +++ /dev/null @@ -1,65 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# GenericStage class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class GenericStage implements Stage -``` -Implements: [Stage](./firestore_.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(name, params)](./firestore_.genericstage.md#genericstageconstructor) | | (BETA) Constructs a new instance of the GenericStage class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_.genericstage.md#genericstagename) | | string | (BETA) | - -## GenericStage.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `GenericStage` class - -Signature: - -```typescript -constructor(name: string, params: unknown[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | | -| params | unknown\[\] | | - -## GenericStage.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_.gt.md b/docs-devsite/firestore_.gt.md deleted file mode 100644 index 75843e172d7..00000000000 --- a/docs-devsite/firestore_.gt.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Gt class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Gt extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_.gt.md#gtconstructor) | | (BETA) Constructs a new instance of the Gt class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_.gt.md#gtfilterable) | | true | (BETA) | - -## Gt.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Gt` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | | -| right | [Constant](./firestore_.constant.md#constant_class) | | - -## Gt.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_.gte.md b/docs-devsite/firestore_.gte.md deleted file mode 100644 index 923ece3ab8d..00000000000 --- a/docs-devsite/firestore_.gte.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Gte class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Gte extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_.gte.md#gteconstructor) | | (BETA) Constructs a new instance of the Gte class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_.gte.md#gtefilterable) | | true | (BETA) | - -## Gte.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Gte` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | | -| right | [Constant](./firestore_.constant.md#constant_class) | | - -## Gte.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_.if.md b/docs-devsite/firestore_.if.md deleted file mode 100644 index 4f756b032b4..00000000000 --- a/docs-devsite/firestore_.if.md +++ /dev/null @@ -1,68 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# If class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class If extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(condition, thenExpr, elseExpr)](./firestore_.if.md#ifconstructor) | | (BETA) Constructs a new instance of the If class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_.if.md#iffilterable) | | true | (BETA) | - -## If.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `If` class - -Signature: - -```typescript -constructor(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| condition | [FilterExpr](./firestore_.md#filterexpr) | | -| thenExpr | [Constant](./firestore_.constant.md#constant_class) | | -| elseExpr | [Constant](./firestore_.constant.md#constant_class) | | - -## If.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_.in.md b/docs-devsite/firestore_.in.md deleted file mode 100644 index 76f38733041..00000000000 --- a/docs-devsite/firestore_.in.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# In class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class In extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, others)](./firestore_.in.md#inconstructor) | | (BETA) Constructs a new instance of the In class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_.in.md#infilterable) | | true | (BETA) | - -## In.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `In` class - -Signature: - -```typescript -constructor(left: Constant, others: Constant[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | | -| others | [Constant](./firestore_.constant.md#constant_class)\[\] | | - -## In.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_.isnan.md b/docs-devsite/firestore_.isnan.md deleted file mode 100644 index bbeb8e4fa51..00000000000 --- a/docs-devsite/firestore_.isnan.md +++ /dev/null @@ -1,66 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# IsNan class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class IsNan extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr)](./firestore_.isnan.md#isnanconstructor) | | (BETA) Constructs a new instance of the IsNan class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_.isnan.md#isnanfilterable) | | true | (BETA) | - -## IsNan.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `IsNan` class - -Signature: - -```typescript -constructor(expr: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | | - -## IsNan.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_.like.md b/docs-devsite/firestore_.like.md deleted file mode 100644 index 94e680dd723..00000000000 --- a/docs-devsite/firestore_.like.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Like class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Like extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr, pattern)](./firestore_.like.md#likeconstructor) | | (BETA) Constructs a new instance of the Like class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_.like.md#likefilterable) | | true | (BETA) | - -## Like.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Like` class - -Signature: - -```typescript -constructor(expr: Constant, pattern: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | | -| pattern | [Constant](./firestore_.constant.md#constant_class) | | - -## Like.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_.limit.md b/docs-devsite/firestore_.limit.md deleted file mode 100644 index 81ad7339037..00000000000 --- a/docs-devsite/firestore_.limit.md +++ /dev/null @@ -1,64 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Limit class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Limit implements Stage -``` -Implements: [Stage](./firestore_.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(limit)](./firestore_.limit.md#limitconstructor) | | (BETA) Constructs a new instance of the Limit class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_.limit.md#limitname) | | string | (BETA) | - -## Limit.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Limit` class - -Signature: - -```typescript -constructor(limit: number); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| limit | number | | - -## Limit.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_.logicalmax.md b/docs-devsite/firestore_.logicalmax.md deleted file mode 100644 index 633947cdaba..00000000000 --- a/docs-devsite/firestore_.logicalmax.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# LogicalMax class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class LogicalMax extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_.logicalmax.md#logicalmaxconstructor) | | (BETA) Constructs a new instance of the LogicalMax class | - -## LogicalMax.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `LogicalMax` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | | -| right | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.logicalmin.md b/docs-devsite/firestore_.logicalmin.md deleted file mode 100644 index 65bf7ad5dc1..00000000000 --- a/docs-devsite/firestore_.logicalmin.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# LogicalMin class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class LogicalMin extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_.logicalmin.md#logicalminconstructor) | | (BETA) Constructs a new instance of the LogicalMin class | - -## LogicalMin.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `LogicalMin` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | | -| right | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.lt.md b/docs-devsite/firestore_.lt.md deleted file mode 100644 index 54911158139..00000000000 --- a/docs-devsite/firestore_.lt.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Lt class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Lt extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_.lt.md#ltconstructor) | | (BETA) Constructs a new instance of the Lt class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_.lt.md#ltfilterable) | | true | (BETA) | - -## Lt.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Lt` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | | -| right | [Constant](./firestore_.constant.md#constant_class) | | - -## Lt.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_.lte.md b/docs-devsite/firestore_.lte.md deleted file mode 100644 index 7bd5cbe4420..00000000000 --- a/docs-devsite/firestore_.lte.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Lte class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Lte extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_.lte.md#lteconstructor) | | (BETA) Constructs a new instance of the Lte class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_.lte.md#ltefilterable) | | true | (BETA) | - -## Lte.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Lte` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | | -| right | [Constant](./firestore_.constant.md#constant_class) | | - -## Lte.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_.mapget.md b/docs-devsite/firestore_.mapget.md deleted file mode 100644 index c2fe330f2f3..00000000000 --- a/docs-devsite/firestore_.mapget.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# MapGet class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class MapGet extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(map, name)](./firestore_.mapget.md#mapgetconstructor) | | (BETA) Constructs a new instance of the MapGet class | - -## MapGet.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `MapGet` class - -Signature: - -```typescript -constructor(map: Constant, name: string); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| map | [Constant](./firestore_.constant.md#constant_class) | | -| name | string | | - diff --git a/docs-devsite/firestore_.max.md b/docs-devsite/firestore_.max.md deleted file mode 100644 index 5fe1c376f93..00000000000 --- a/docs-devsite/firestore_.max.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Max class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Max extends FirestoreFunction implements Accumulator -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [Accumulator](./firestore_.accumulator.md#accumulator_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value, distinct)](./firestore_.max.md#maxconstructor) | | (BETA) Constructs a new instance of the Max class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [accumulator](./firestore_.max.md#maxaccumulator) | | true | (BETA) | - -## Max.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Max` class - -Signature: - -```typescript -constructor(value: Constant, distinct: boolean); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) | | -| distinct | boolean | | - -## Max.accumulator - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -accumulator: true; -``` diff --git a/docs-devsite/firestore_.md b/docs-devsite/firestore_.md index 4393d8999dc..74e960c833b 100644 --- a/docs-devsite/firestore_.md +++ b/docs-devsite/firestore_.md @@ -34,7 +34,6 @@ https://github.com/firebase/firebase-js-sdk | [namedQuery(firestore, name)](./firestore_.md#namedquery_6438876) | Reads a Firestore [Query](./firestore_.query.md#query_class) from local cache, identified by the given name.The named queries are packaged into bundles on the server side (along with resulting documents), and loaded to local cache using loadBundle. Once in local cache, use this method to extract a [Query](./firestore_.query.md#query_class) by name. | | [onSnapshotsInSync(firestore, observer)](./firestore_.md#onsnapshotsinsync_2f0dfa4) | Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if a single server-generated change affects multiple listeners.NOTE: The snapshots-in-sync event only indicates that listeners are in sync with each other, but does not relate to whether those snapshots are in sync with the server. Use SnapshotMetadata in the individual listeners to determine if a snapshot is from the cache or the server. | | [onSnapshotsInSync(firestore, onSync)](./firestore_.md#onsnapshotsinsync_1901c06) | Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if a single server-generated change affects multiple listeners.NOTE: The snapshots-in-sync event only indicates that listeners are in sync with each other, but does not relate to whether those snapshots are in sync with the server. Use SnapshotMetadata in the individual listeners to determine if a snapshot is from the cache or the server. | -| [pipeline(firestore)](./firestore_.md#pipeline_231a8e0) | Experimental Modular API for console testing. | | [runTransaction(firestore, updateFunction, options)](./firestore_.md#runtransaction_6f03ec4) | Executes the given updateFunction and then attempts to commit the changes applied within the transaction. If any document read within the transaction has changed, Cloud Firestore retries the updateFunction. If it fails to commit after 5 attempts, the transaction fails.The maximum number of writes allowed in a single transaction is 500. | | [setIndexConfiguration(firestore, configuration)](./firestore_.md#setindexconfiguration_c362f04) | (BETA) Configures indexing for local query execution. Any previous index configuration is overridden. The Promise resolves once the index configuration has been persisted.The index entries themselves are created asynchronously. You can continue to use queries that require indexing even if the indices are not yet available. Query execution will automatically start using the index once the index entries have been written.Indexes are only supported with IndexedDb persistence. If IndexedDb is not enabled, any index configuration is ignored. | | [setIndexConfiguration(firestore, json)](./firestore_.md#setindexconfiguration_90d0285) | (BETA) Configures indexing for local query execution. Any previous index configuration is overridden. The Promise resolves once the index configuration has been persisted.The index entries themselves are created asynchronously. You can continue to use queries that require indexing even if the indices are not yet available. Query execution will automatically start using the index once the index entries have been written.Indexes are only supported with IndexedDb persistence. Invoke either enableIndexedDbPersistence() or enableMultiTabIndexedDbPersistence() before setting an index configuration. If IndexedDb is not enabled, any index configuration is ignored.The method accepts the JSON format exported by the Firebase CLI (firebase firestore:indexes). If the JSON format is invalid, this method throws an error. | @@ -43,9447 +42,2418 @@ https://github.com/firebase/firebase-js-sdk | [writeBatch(firestore)](./firestore_.md#writebatch_231a8e0) | Creates a write batch, used for performing multiple writes as a single atomic operation. The maximum number of writes allowed in a single [WriteBatch](./firestore_.writebatch.md#writebatch_class) is 500.Unlike transactions, write batches are persisted offline and therefore are preferable when you don't need to condition your writes on read data. | | function() | | [count()](./firestore_.md#count) | Create an AggregateField object that can be used to compute the count of documents in the result set of a query. | -| [countAll()](./firestore_.md#countall) | (BETA) Creates an aggregation that counts the total number of stage inputs. -```typescript -// Count the total number of users -countAll().as("totalUsers"); - -``` - A new representing the 'countAll' aggregation. | | [deleteField()](./firestore_.md#deletefield) | Returns a sentinel for use with [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) or [setDoc()](./firestore_lite.md#setdoc_ee215ad) with {merge: true} to mark a field for deletion. | | [documentId()](./firestore_.md#documentid) | Returns a special sentinel FieldPath to refer to the ID of a document. It can be used in queries to sort or filter by the document ID. | | [getFirestore()](./firestore_.md#getfirestore) | Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. | | [memoryEagerGarbageCollector()](./firestore_.md#memoryeagergarbagecollector) | Creates an instance of MemoryEagerGarbageCollector. This is also the default garbage collector unless it is explicitly specified otherwise. | | [persistentMultipleTabManager()](./firestore_.md#persistentmultipletabmanager) | Creates an instance of PersistentMultipleTabManager. | | [serverTimestamp()](./firestore_.md#servertimestamp) | Returns a sentinel used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) to include a server-generated timestamp in the written data. | -| [useFirestorePipelines()](./firestore_.md#usefirestorepipelines) | Copyright 2024 Google LLCLicensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | -| function(array, ...) | -| [arrayConcat(array, elements)](./firestore_.md#arrayconcat_0b3ddb9) | (BETA) Creates an expression that concatenates an array expression with other arrays. -```typescript -// Combine the 'items' array with two new item arrays -arrayConcat(Field.of("items"), [Field.of("newItems"), Field.of("otherItems")]); - -``` - | -| [arrayConcat(array, elements)](./firestore_.md#arrayconcat_21991c1) | (BETA) Creates an expression that concatenates an array expression with other arrays and/or values. -```typescript -// Combine the 'tags' array with a new array -arrayConcat(Field.of("tags"), ["newTag1", "newTag2"]); - -``` - | -| [arrayConcat(array, elements)](./firestore_.md#arrayconcat_f8d5d5e) | (BETA) Creates an expression that concatenates a field's array value with other arrays. -```typescript -// Combine the 'items' array with two new item arrays -arrayConcat("items", [Field.of("newItems"), Field.of("otherItems")]); - -``` - | -| [arrayConcat(array, elements)](./firestore_.md#arrayconcat_5a66d99) | (BETA) Creates an expression that concatenates a field's array value with other arrays and/or values. -```typescript -// Combine the 'tags' array with a new array -arrayConcat("tags", ["newTag1", "newTag2"]); - -``` - | -| [arrayContains(array, element)](./firestore_.md#arraycontains_01ea7c0) | (BETA) Creates an expression that checks if an array expression contains a specific element. -```typescript -// Check if the 'colors' array contains the value of field 'selectedColor' -arrayContains(Field.of("colors"), Field.of("selectedColor")); - -``` - | -| [arrayContains(array, element)](./firestore_.md#arraycontains_60f8f2f) | (BETA) Creates an expression that checks if an array expression contains a specific element. -```typescript -// Check if the 'colors' array contains "red" -arrayContains(Field.of("colors"), "red"); - -``` - | -| [arrayContains(array, element)](./firestore_.md#arraycontains_0ebdbfe) | (BETA) Creates an expression that checks if a field's array value contains a specific element. -```typescript -// Check if the 'colors' array contains the value of field 'selectedColor' -arrayContains("colors", Field.of("selectedColor")); - -``` - | -| [arrayContains(array, element)](./firestore_.md#arraycontains_8f718df) | (BETA) Creates an expression that checks if a field's array value contains a specific value. -```typescript -// Check if the 'colors' array contains "red" -arrayContains("colors", "red"); - -``` - | -| [arrayContainsAll(array, values)](./firestore_.md#arraycontainsall_7b7433a) | (BETA) Creates an expression that checks if an array expression contains all the specified elements. -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" -arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); - -``` - | -| [arrayContainsAll(array, values)](./firestore_.md#arraycontainsall_d919466) | (BETA) Creates an expression that checks if an array expression contains all the specified elements. -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" -arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); - -``` - | -| [arrayContainsAll(array, values)](./firestore_.md#arraycontainsall_b40e2df) | (BETA) Creates an expression that checks if a field's array value contains all the specified values or expressions. -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); - -``` - | -| [arrayContainsAll(array, values)](./firestore_.md#arraycontainsall_b08efbb) | (BETA) Creates an expression that checks if a field's array value contains all the specified values or expressions. -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); - -``` - | -| [arrayContainsAny(array, values)](./firestore_.md#arraycontainsany_7b7433a) | (BETA) Creates an expression that checks if an array expression contains any of the specified elements. -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "Science" -arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); - -``` - | -| [arrayContainsAny(array, values)](./firestore_.md#arraycontainsany_d919466) | (BETA) Creates an expression that checks if an array expression contains any of the specified elements. -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "Science" -arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); - -``` - | -| [arrayContainsAny(array, values)](./firestore_.md#arraycontainsany_b40e2df) | (BETA) Creates an expression that checks if a field's array value contains any of the specified elements. -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -arrayContainsAny("categories", [Field.of("cate1"), "Science"]); - -``` - | -| [arrayContainsAny(array, values)](./firestore_.md#arraycontainsany_b08efbb) | (BETA) Creates an expression that checks if a field's array value contains any of the specified elements. -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -arrayContainsAny("categories", [Field.of("cate1"), "Science"]); - -``` - | -| [arrayLength(array)](./firestore_.md#arraylength_0bb5dbb) | (BETA) Creates an expression that calculates the length of an array expression. -```typescript -// Get the number of items in the 'cart' array -arrayLength(Field.of("cart")); - -``` - | -| function(condition, ...) | -| [ifFunction(condition, thenExpr, elseExpr)](./firestore_.md#iffunction_f7b2404) | (BETA) Creates a conditional expression that evaluates to a 'then' expression if a condition is true and an 'else' expression if the condition is false. -```typescript -// If 'age' is greater than 18, return "Adult"; otherwise, return "Minor". -ifFunction( - gt("age", 18), Constant.of("Adult"), Constant.of("Minor")); - -``` - | | function(databaseId, ...) | | [getFirestore(databaseId)](./firestore_.md#getfirestore_53dc891) | (BETA) Returns the existing named [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. | -| function(element, ...) | -| [inAny(element, others)](./firestore_.md#inany_a73b259) | (BETA) Creates an expression that checks if an expression is equal to any of the provided values or expressions. -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -inAny(Field.of("category"), [Constant.of("Electronics"), Field.of("primaryType")]); - -``` - | -| [inAny(element, others)](./firestore_.md#inany_f5721c6) | (BETA) Creates an expression that checks if an expression is equal to any of the provided values or expressions. -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -inAny(Field.of("category"), ["Electronics", Field.of("primaryType")]); - -``` - | -| [inAny(element, others)](./firestore_.md#inany_c6646ea) | (BETA) Creates an expression that checks if a field's value is equal to any of the provided values or expressions. -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -inAny("category", [Constant.of("Electronics"), Field.of("primaryType")]); - -``` - | -| [inAny(element, others)](./firestore_.md#inany_e6877aa) | (BETA) Creates an expression that checks if a field's value is equal to any of the provided values or expressions. -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -inAny("category", ["Electronics", Field.of("primaryType")]); - -``` - | -| [notInAny(element, others)](./firestore_.md#notinany_a73b259) | (BETA) Creates an expression that checks if an expression is not equal to any of the provided values or expressions. -```typescript -// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' -notInAny(Field.of("status"), [Constant.of("pending"), Field.of("rejectedStatus")]); - -``` - | -| [notInAny(element, others)](./firestore_.md#notinany_f5721c6) | (BETA) Creates an expression that checks if an expression is not equal to any of the provided values or expressions. -```typescript -// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' -notInAny(Field.of("status"), ["pending", Field.of("rejectedStatus")]); - -``` - | -| [notInAny(element, others)](./firestore_.md#notinany_c6646ea) | (BETA) Creates an expression that checks if a field's value is not equal to any of the provided values or expressions. -```typescript -// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' -notInAny("status", [Constant.of("pending"), Field.of("rejectedStatus")]); - -``` - | -| [notInAny(element, others)](./firestore_.md#notinany_e6877aa) | (BETA) Creates an expression that checks if a field's value is not equal to any of the provided values or expressions. -```typescript -// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' -notInAny("status", ["pending", Field.of("rejectedStatus")]); - -``` - | | function(elements, ...) | | [arrayRemove(elements)](./firestore_.md#arrayremove_7d853aa) | Returns a special value that can be used with [setDoc()](./firestore_.md#setdoc_ee215ad) or that tells the server to remove the given elements from any array value that already exists on the server. All instances of each element specified will be removed from the array. If the field being modified is not already an array it will be overwritten with an empty array. | | [arrayUnion(elements)](./firestore_.md#arrayunion_7d853aa) | Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to union the given elements with any array value that already exists on the server. Each specified element that doesn't already exist in the array will be added to the end. If the field being modified is not already an array it will be overwritten with an array containing exactly the specified elements. | -| function(expr, ...) | -| [ascending(expr)](./firestore_.md#ascending_f3fb767) | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. -```typescript -// Sort documents by the 'name' field in ascending order -firestore.pipeline().collection("users") - .sort(ascending(Field.of("name"))); - -``` - | -| [byteLength(expr)](./firestore_.md#bytelength_f3fb767) | (BETA) Creates an expression that calculates the byte length of a string in UTF-8, or just the length of a Blob. -```typescript -// Calculate the length of the 'myString' field in bytes. -byteLength(Field.of("myString")); - -``` - | -| [charLength(expr)](./firestore_.md#charlength_f3fb767) | (BETA) Creates an expression that calculates the character length of a string expression in UTF-8. -```typescript -// Get the character length of the 'name' field in UTF-8. -strLength(Field.of("name")); - -``` - | -| [cosineDistance(expr, other)](./firestore_.md#cosinedistance_b4c7dc2) | (BETA) Calculates the Cosine distance between a field's vector value and a double array. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -cosineDistance("location", [37.7749, -122.4194]); - -``` - | -| [cosineDistance(expr, other)](./firestore_.md#cosinedistance_8d2bd9d) | (BETA) Calculates the Cosine distance between a field's vector value and a VectorValue. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -cosineDistance("location", new VectorValue([37.7749, -122.4194])); - -``` - | -| [cosineDistance(expr, other)](./firestore_.md#cosinedistance_c9ae0bc) | (BETA) Calculates the Cosine distance between a field's vector value and a vector expression. -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -cosineDistance("userVector", Field.of("itemVector")); - -``` - | -| [cosineDistance(expr, other)](./firestore_.md#cosinedistance_e701952) | (BETA) Calculates the Cosine distance between a vector expression and a double array. -```typescript -// Calculate the cosine distance between the 'location' field and a target location -cosineDistance(Field.of("location"), [37.7749, -122.4194]); - -``` - | -| [cosineDistance(expr, other)](./firestore_.md#cosinedistance_cc2e83e) | (BETA) Calculates the Cosine distance between a vector expression and a VectorValue. -```typescript -// Calculate the cosine distance between the 'location' field and a target location -cosineDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); - -``` - | -| [cosineDistance(expr, other)](./firestore_.md#cosinedistance_0896fbd) | (BETA) Calculates the Cosine distance between two vector expressions. -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -cosineDistance(Field.of("userVector"), Field.of("itemVector")); +| function(field, ...) | +| [average(field)](./firestore_.md#average_aacc3a9) | Create an AggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query. | +| [sum(field)](./firestore_.md#sum_aacc3a9) | Create an AggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query. | +| function(fieldPath, ...) | +| [orderBy(fieldPath, directionStr)](./firestore_.md#orderby_006d61f) | Creates a [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) that sorts the query result by the specified field, optionally in descending order instead of ascending.Note: Documents that do not contain the specified field will not be present in the query result. | +| [where(fieldPath, opStr, value)](./firestore_.md#where_0fae4bf) | Creates a [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) that enforces that documents must contain the specified field and that the value should satisfy the relation constraint provided. | +| function(fieldValues, ...) | +| [endAt(fieldValues)](./firestore_.md#endat_8b2f2c8) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | +| [endBefore(fieldValues)](./firestore_.md#endbefore_8b2f2c8) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | +| [startAfter(fieldValues)](./firestore_.md#startafter_8b2f2c8) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | +| [startAt(fieldValues)](./firestore_.md#startat_8b2f2c8) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | +| function(indexManager, ...) | +| [deleteAllPersistentCacheIndexes(indexManager)](./firestore_.md#deleteallpersistentcacheindexes_98b2645) | Removes all persistent cache indexes.Please note this function will also deletes indexes generated by setIndexConfiguration(), which is deprecated. | +| [disablePersistentCacheIndexAutoCreation(indexManager)](./firestore_.md#disablepersistentcacheindexautocreation_98b2645) | Stops creating persistent cache indexes automatically for local query execution. The indexes which have been created by calling enablePersistentCacheIndexAutoCreation() still take effect. | +| [enablePersistentCacheIndexAutoCreation(indexManager)](./firestore_.md#enablepersistentcacheindexautocreation_98b2645) | Enables the SDK to create persistent cache indexes automatically for local query execution when the SDK believes cache indexes can help improve performance.This feature is disabled by default. | +| function(left, ...) | +| [aggregateFieldEqual(left, right)](./firestore_.md#aggregatefieldequal_e80a2b2) | Compares two 'AggregateField\` instances for equality. | +| [aggregateQuerySnapshotEqual(left, right)](./firestore_.md#aggregatequerysnapshotequal_1529a20) | Compares two AggregateQuerySnapshot instances for equality.Two AggregateQuerySnapshot instances are considered "equal" if they have underlying queries that compare equal, and the same data. | +| [queryEqual(left, right)](./firestore_.md#queryequal_7a1f045) | Returns true if the provided queries point to the same collection and apply the same constraints. | +| [refEqual(left, right)](./firestore_.md#refequal_598b780) | Returns true if the provided references are equal. | +| [snapshotEqual(left, right)](./firestore_.md#snapshotequal_5109204) | Returns true if the provided snapshots are equal. | +| function(limit, ...) | +| [limit(limit)](./firestore_.md#limit_ec46c78) | Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the first matching documents. | +| [limitToLast(limit)](./firestore_.md#limittolast_ec46c78) | Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the last matching documents.You must specify at least one orderBy clause for limitToLast queries, otherwise an exception will be thrown during execution. | +| function(logLevel, ...) | +| [setLogLevel(logLevel)](./firestore_.md#setloglevel_d02fda2) | Sets the verbosity of Cloud Firestore logs (debug, error, or silent). | +| function(n, ...) | +| [increment(n)](./firestore_.md#increment_5685735) | Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to increment the field's current value by the given value.If either the operand or the current field value uses floating point precision, all arithmetic follows IEEE 754 semantics. If both values are integers, values outside of JavaScript's safe number range (Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER) are also subject to precision loss. Furthermore, once processed by the Firestore backend, all integer operations are capped between -2^63 and 2^63-1.If the current field value is not of type number, or if the field does not yet exist, the transformation sets the field to the given value. | +| function(query, ...) | +| [getAggregateFromServer(query, aggregateSpec)](./firestore_.md#getaggregatefromserver_2073a74) | Calculates the specified aggregations over the documents in the result set of the given query without actually downloading the documents.Using this function to perform aggregations is efficient because only the final aggregation values, not the documents' data, are downloaded. This function can perform aggregations of the documents in cases where the result set is prohibitively large to download entirely (thousands of documents).The result received from the server is presented, unaltered, without considering any local state. That is, documents in the local cache are not taken into consideration, neither are local modifications not yet synchronized with the server. Previously-downloaded results, if any, are not used. Every invocation of this function necessarily involves a round trip to the server. | +| [getCountFromServer(query)](./firestore_.md#getcountfromserver_4e56953) | Calculates the number of documents in the result set of the given query without actually downloading the documents.Using this function to count the documents is efficient because only the final count, not the documents' data, is downloaded. This function can count the documents in cases where the result set is prohibitively large to download entirely (thousands of documents).The result received from the server is presented, unaltered, without considering any local state. That is, documents in the local cache are not taken into consideration, neither are local modifications not yet synchronized with the server. Previously-downloaded results, if any, are not used. Every invocation of this function necessarily involves a round trip to the server. | +| [getDocs(query)](./firestore_.md#getdocs_4e56953) | Executes the query and returns the results as a QuerySnapshot.Note: getDocs() attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. To specify this behavior, invoke [getDocsFromCache()](./firestore_.md#getdocsfromcache_4e56953) or [getDocsFromServer()](./firestore_.md#getdocsfromserver_4e56953). | +| [getDocsFromCache(query)](./firestore_.md#getdocsfromcache_4e56953) | Executes the query and returns the results as a QuerySnapshot from cache. Returns an empty result set if no documents matching the query are currently cached. | +| [getDocsFromServer(query)](./firestore_.md#getdocsfromserver_4e56953) | Executes the query and returns the results as a QuerySnapshot from the server. Returns an error if the network is not available. | +| [onSnapshot(query, observer)](./firestore_.md#onsnapshot_8d14049) | Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [onSnapshot(query, options, observer)](./firestore_.md#onsnapshot_03dfff5) | Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [onSnapshot(query, onNext, onError, onCompletion)](./firestore_.md#onsnapshot_3ebfbe2) | Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [onSnapshot(query, options, onNext, onError, onCompletion)](./firestore_.md#onsnapshot_b8f9c47) | Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [query(query, compositeFilter, queryConstraints)](./firestore_.md#query_9f7b0f4) | Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. | +| [query(query, queryConstraints)](./firestore_.md#query_0f46da1) | Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. | +| function(queryConstraints, ...) | +| [and(queryConstraints)](./firestore_.md#and_e72c712) | Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a conjunction of the given filter constraints. A conjunction filter includes a document if it satisfies all of the given filters. | +| [or(queryConstraints)](./firestore_.md#or_e72c712) | Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a disjunction of the given filter constraints. A disjunction filter includes a document if it satisfies any of the given filters. | +| function(reference, ...) | +| [addDoc(reference, data)](./firestore_.md#adddoc_6e783ff) | Add a new document to specified CollectionReference with the given data, assigning it a document ID automatically. | +| [collection(reference, path, pathSegments)](./firestore_.md#collection_568f98d) | Gets a CollectionReference instance that refers to a subcollection of reference at the specified relative path. | +| [collection(reference, path, pathSegments)](./firestore_.md#collection_70b4396) | Gets a CollectionReference instance that refers to a subcollection of reference at the specified relative path. | +| [deleteDoc(reference)](./firestore_.md#deletedoc_4569087) | Deletes the document referred to by the specified DocumentReference. | +| [doc(reference, path, pathSegments)](./firestore_.md#doc_568f98d) | Gets a DocumentReference instance that refers to a document within reference at the specified relative path. If no path is specified, an automatically-generated unique ID will be used for the returned DocumentReference. | +| [doc(reference, path, pathSegments)](./firestore_.md#doc_70b4396) | Gets a DocumentReference instance that refers to a document within reference at the specified relative path. | +| [getDoc(reference)](./firestore_.md#getdoc_4569087) | Reads the document referred to by this DocumentReference.Note: getDoc() attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. To specify this behavior, invoke [getDocFromCache()](./firestore_.md#getdocfromcache_4569087) or [getDocFromServer()](./firestore_.md#getdocfromserver_4569087). | +| [getDocFromCache(reference)](./firestore_.md#getdocfromcache_4569087) | Reads the document referred to by this DocumentReference from cache. Returns an error if the document is not currently cached. | +| [getDocFromServer(reference)](./firestore_.md#getdocfromserver_4569087) | Reads the document referred to by this DocumentReference from the server. Returns an error if the network is not available. | +| [onSnapshot(reference, observer)](./firestore_.md#onsnapshot_0312fd7) | Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [onSnapshot(reference, options, observer)](./firestore_.md#onsnapshot_86b6b9e) | Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [onSnapshot(reference, onNext, onError, onCompletion)](./firestore_.md#onsnapshot_905f42c) | Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [onSnapshot(reference, options, onNext, onError, onCompletion)](./firestore_.md#onsnapshot_0c39991) | Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | +| [setDoc(reference, data)](./firestore_.md#setdoc_ee215ad) | Writes to the document referred to by this DocumentReference. If the document does not yet exist, it will be created. | +| [setDoc(reference, data, options)](./firestore_.md#setdoc_ff80739) | Writes to the document referred to by the specified DocumentReference. If the document does not yet exist, it will be created. If you provide merge or mergeFields, the provided data can be merged into an existing document. | +| [updateDoc(reference, data)](./firestore_.md#updatedoc_51a65e3) | Updates fields in the document referred to by the specified DocumentReference. The update will fail if applied to a document that does not exist. | +| [updateDoc(reference, field, value, moreFieldsAndValues)](./firestore_.md#updatedoc_7c28659) | Updates fields in the document referred to by the specified DocumentReference The update will fail if applied to a document that does not exist.Nested fields can be updated by providing dot-separated field path strings or by providing FieldPath objects. | +| function(settings, ...) | +| [memoryLocalCache(settings)](./firestore_.md#memorylocalcache_05f4bf2) | Creates an instance of MemoryLocalCache. The instance can be set to FirestoreSettings.cache to tell the SDK which cache layer to use. | +| [memoryLruGarbageCollector(settings)](./firestore_.md#memorylrugarbagecollector_5ee014c) | Creates an instance of MemoryLruGarbageCollector.A target size can be specified as part of the setting parameter. The collector will start deleting documents once the cache size exceeds the given size. The default cache size is 40MB (40 \* 1024 \* 1024 bytes). | +| [persistentLocalCache(settings)](./firestore_.md#persistentlocalcache_d312f71) | Creates an instance of PersistentLocalCache. The instance can be set to FirestoreSettings.cache to tell the SDK which cache layer to use.Persistent cache cannot be used in a Node.js environment. | +| [persistentSingleTabManager(settings)](./firestore_.md#persistentsingletabmanager_c99c68d) | Creates an instance of PersistentSingleTabManager. | +| function(snapshot, ...) | +| [endAt(snapshot)](./firestore_.md#endat_9a4477f) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided document (inclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. | +| [endBefore(snapshot)](./firestore_.md#endbefore_9a4477f) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided document (exclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. | +| [startAfter(snapshot)](./firestore_.md#startafter_9a4477f) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided document (exclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. | +| [startAt(snapshot)](./firestore_.md#startat_9a4477f) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided document (inclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of this query. | +| function(values, ...) | +| [vector(values)](./firestore_.md#vector_0dbdaf2) | Creates a new VectorValue constructed with a copy of the given array of numbers. | -``` - | -| [descending(expr)](./firestore_.md#descending_f3fb767) | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") - .sort(descending(Field.of("createdAt"))); +## Classes -``` - | -| [dotProduct(expr, other)](./firestore_.md#dotproduct_b4c7dc2) | (BETA) Calculates the dot product between a field's vector value and a double array. -```typescript -// Calculate the dot product distance between a feature vector and a target vector -dotProduct("features", [0.5, 0.8, 0.2]); +| Class | Description | +| --- | --- | +| [AggregateField](./firestore_.aggregatefield.md#aggregatefield_class) | Represents an aggregation that can be performed by Firestore. | +| [AggregateQuerySnapshot](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshot_class) | The results of executing an aggregation query. | +| [Bytes](./firestore_.bytes.md#bytes_class) | An immutable object representing an array of bytes. | +| [CollectionReference](./firestore_.collectionreference.md#collectionreference_class) | A CollectionReference object can be used for adding documents, getting document references, and querying for documents (using [query()](./firestore_.md#query_9f7b0f4)). | +| [DocumentReference](./firestore_.documentreference.md#documentreference_class) | A DocumentReference refers to a document location in a Firestore database and can be used to write, read, or listen to the location. The document at the referenced location may or may not exist. | +| [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class) | A DocumentSnapshot contains data read from a document in your Firestore database. The data can be extracted with .data() or .get(<field>) to get a specific field.For a DocumentSnapshot that points to a non-existing document, any data access will return 'undefined'. You can use the exists() method to explicitly verify a document's existence. | +| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | A FieldPath refers to a field in a document. The path may consist of a single field name (referring to a top-level field in the document), or a list of field names (referring to a nested field in the document).Create a FieldPath by providing field names. If more than one field name is provided, the path will point to a nested field in a document. | +| [FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) | Sentinel values that can be used when writing document fields with set() or update(). | +| [Firestore](./firestore_.firestore.md#firestore_class) | The Cloud Firestore service interface.Do not call this constructor directly. Instead, use [getFirestore()](./firestore_.md#getfirestore). | +| [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) | An error returned by a Firestore operation. | +| [GeoPoint](./firestore_.geopoint.md#geopoint_class) | An immutable object representing a geographic location in Firestore. The location is represented as latitude/longitude pair.Latitude values are in the range of \[-90, 90\]. Longitude values are in the range of \[-180, 180\]. | +| [LoadBundleTask](./firestore_.loadbundletask.md#loadbundletask_class) | Represents the task of loading a Firestore bundle. It provides progress of bundle loading, as well as task completion and error events.The API is compatible with Promise<LoadBundleTaskProgress>. | +| [PersistentCacheIndexManager](./firestore_.persistentcacheindexmanager.md#persistentcacheindexmanager_class) | A PersistentCacheIndexManager for configuring persistent cache indexes used for local query execution.To use, call getPersistentCacheIndexManager() to get an instance. | +| [Query](./firestore_.query.md#query_class) | A Query refers to a query which you can read or listen to. You can also construct refined Query objects by adding filters and ordering. | +| [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) | A QueryCompositeFilterConstraint is used to narrow the set of documents returned by a Firestore query by performing the logical OR or AND of multiple [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class)s or [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class)s. QueryCompositeFilterConstraints are created by invoking [or()](./firestore_.md#or_e72c712) or [and()](./firestore_.md#and_e72c712) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the QueryCompositeFilterConstraint. | +| [QueryConstraint](./firestore_.queryconstraint.md#queryconstraint_class) | A QueryConstraint is used to narrow the set of documents returned by a Firestore query. QueryConstraints are created by invoking [where()](./firestore_.md#where_0fae4bf), [orderBy()](./firestore_.md#orderby_006d61f), [startAt()](./firestore_.md#startat_9a4477f), [startAfter()](./firestore_.md#startafter_9a4477f), [endBefore()](./firestore_.md#endbefore_9a4477f), [endAt()](./firestore_.md#endat_9a4477f), [limit()](./firestore_.md#limit_ec46c78), [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryConstraint. | +| [QueryDocumentSnapshot](./firestore_.querydocumentsnapshot.md#querydocumentsnapshot_class) | A QueryDocumentSnapshot contains data read from a document in your Firestore database as part of a query. The document is guaranteed to exist and its data can be extracted with .data() or .get(<field>) to get a specific field.A QueryDocumentSnapshot offers the same API surface as a DocumentSnapshot. Since query results contain only existing documents, the exists property will always be true and data() will never return 'undefined'. | +| [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) | A QueryEndAtConstraint is used to exclude documents from the end of a result set returned by a Firestore query. QueryEndAtConstraints are created by invoking [endAt()](./firestore_.md#endat_9a4477f) or [endBefore()](./firestore_.md#endbefore_9a4477f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryEndAtConstraint. | +| [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) | A QueryFieldFilterConstraint is used to narrow the set of documents returned by a Firestore query by filtering on one or more document fields. QueryFieldFilterConstraints are created by invoking [where()](./firestore_.md#where_0fae4bf) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryFieldFilterConstraint. | +| [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) | A QueryLimitConstraint is used to limit the number of documents returned by a Firestore query. QueryLimitConstraints are created by invoking [limit()](./firestore_.md#limit_ec46c78) or [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryLimitConstraint. | +| [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) | A QueryOrderByConstraint is used to sort the set of documents returned by a Firestore query. QueryOrderByConstraints are created by invoking [orderBy()](./firestore_.md#orderby_006d61f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryOrderByConstraint.Note: Documents that do not contain the orderBy field will not be present in the query result. | +| [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class) | A QuerySnapshot contains zero or more DocumentSnapshot objects representing the results of a query. The documents can be accessed as an array via the docs property or enumerated using the forEach method. The number of documents can be determined via the empty and size properties. | +| [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) | A QueryStartAtConstraint is used to exclude documents from the start of a result set returned by a Firestore query. QueryStartAtConstraints are created by invoking [startAt()](./firestore_.md#startat_9a4477f) or [startAfter()](./firestore_.md#startafter_9a4477f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryStartAtConstraint. | +| [SnapshotMetadata](./firestore_.snapshotmetadata.md#snapshotmetadata_class) | Metadata about a snapshot, describing the state of the snapshot. | +| [Timestamp](./firestore_.timestamp.md#timestamp_class) | A Timestamp represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time.It is encoded using the Proleptic Gregorian Calendar which extends the Gregorian calendar backwards to year one. It is encoded assuming all minutes are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.For examples and further specifications, refer to the [Timestamp definition](https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto). | +| [Transaction](./firestore_.transaction.md#transaction_class) | A reference to a transaction.The Transaction object passed to a transaction's updateFunction provides the methods to read and write data within the transaction context. See [runTransaction()](./firestore_.md#runtransaction_6f03ec4). | +| [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | Represents a vector type in Firestore documents. Create an instance with . VectorValue | +| [WriteBatch](./firestore_.writebatch.md#writebatch_class) | A write batch, used to perform multiple writes as a single atomic unit.A WriteBatch object can be acquired by calling [writeBatch()](./firestore_.md#writebatch_231a8e0). It provides methods for adding writes to the write batch. None of the writes will be committed (or visible locally) until [WriteBatch.commit()](./firestore_.writebatch.md#writebatchcommit) is called. | -``` - | -| [dotProduct(expr, other)](./firestore_.md#dotproduct_8d2bd9d) | (BETA) Calculates the dot product between a field's vector value and a VectorValue. -```typescript -// Calculate the dot product distance between a feature vector and a target vector -dotProduct("features", new VectorValue([0.5, 0.8, 0.2])); +## Interfaces -``` - | -| [dotProduct(expr, other)](./firestore_.md#dotproduct_c9ae0bc) | (BETA) Calculates the dot product between a field's vector value and a vector expression. -```typescript -// Calculate the dot product distance between two document vectors: 'docVector1' and 'docVector2' -dotProduct("docVector1", Field.of("docVector2")); +| Interface | Description | +| --- | --- | +| [AggregateSpec](./firestore_.aggregatespec.md#aggregatespec_interface) | Specifies a set of aggregations and their aliases. | +| [DocumentChange](./firestore_.documentchange.md#documentchange_interface) | A DocumentChange represents a change to the documents matching a query. It contains the document affected and the type of change that occurred. | +| [DocumentData](./firestore_.documentdata.md#documentdata_interface) | Document data (for use with [setDoc()](./firestore_lite.md#setdoc_ee215ad)) consists of fields mapped to values. | +| [ExperimentalLongPollingOptions](./firestore_.experimentallongpollingoptions.md#experimentallongpollingoptions_interface) | Options that configure the SDK’s underlying network transport (WebChannel) when long-polling is used.Note: This interface is "experimental" and is subject to change.See FirestoreSettings.experimentalAutoDetectLongPolling, FirestoreSettings.experimentalForceLongPolling, and FirestoreSettings.experimentalLongPollingOptions. | +| [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface) | Converter used by withConverter() to transform user objects of type AppModelType into Firestore data of type DbModelType.Using the converter allows you to specify generic type arguments when storing and retrieving objects from Firestore.In this context, an "AppModel" is a class that is used in an application to package together related information and functionality. Such a class could, for example, have properties with complex, nested data types, properties used for memoization, properties of types not supported by Firestore (such as symbol and bigint), and helper functions that perform compound operations. Such classes are not suitable and/or possible to store into a Firestore database. Instead, instances of such classes need to be converted to "plain old JavaScript objects" (POJOs) with exclusively primitive properties, potentially nested inside other POJOs or arrays of POJOs. In this context, this type is referred to as the "DbModel" and would be an object suitable for persisting into Firestore. For convenience, applications can implement FirestoreDataConverter and register the converter with Firestore objects, such as DocumentReference or Query, to automatically convert AppModel to DbModel when storing into Firestore, and convert DbModel to AppModel when retrieving from Firestore. | +| [FirestoreSettings](./firestore_.firestoresettings.md#firestoresettings_interface) | Specifies custom configurations for your Cloud Firestore instance. You must set these before invoking any other methods. | +| [Index](./firestore_.index.md#index_interface) | (BETA) The SDK definition of a Firestore index. | +| [IndexConfiguration](./firestore_.indexconfiguration.md#indexconfiguration_interface) | (BETA) A list of Firestore indexes to speed up local query execution.See [JSON Format](https://firebase.google.com/docs/reference/firestore/indexes/#json_format) for a description of the format of the index definition. | +| [IndexField](./firestore_.indexfield.md#indexfield_interface) | (BETA) A single field element in an index configuration. | +| [LoadBundleTaskProgress](./firestore_.loadbundletaskprogress.md#loadbundletaskprogress_interface) | Represents a progress update or a final state from loading bundles. | +| [MemoryCacheSettings](./firestore_.memorycachesettings.md#memorycachesettings_interface) | An settings object to configure an MemoryLocalCache instance. | +| [MemoryEagerGarbageCollector](./firestore_.memoryeagergarbagecollector.md#memoryeagergarbagecollector_interface) | A garbage collector deletes documents whenever they are not part of any active queries, and have no local mutations attached to them.This collector tries to ensure lowest memory footprints from the SDK, at the risk of documents not being cached for offline queries or for direct queries to the cache.Use factory function to create an instance of this collector. | +| [MemoryLocalCache](./firestore_.memorylocalcache.md#memorylocalcache_interface) | Provides an in-memory cache to the SDK. This is the default cache unless explicitly configured otherwise.To use, create an instance using the factory function , then set the instance to FirestoreSettings.cache and call initializeFirestore using the settings object. | +| [MemoryLruGarbageCollector](./firestore_.memorylrugarbagecollector.md#memorylrugarbagecollector_interface) | A garbage collector deletes Least-Recently-Used documents in multiple batches.This collector is configured with a target size, and will only perform collection when the cached documents exceed the target size. It avoids querying backend repeated for the same query or document, at the risk of having a larger memory footprint.Use factory function to create a instance of this collector. | +| [PersistenceSettings](./firestore_.persistencesettings.md#persistencesettings_interface) | Settings that can be passed to enableIndexedDbPersistence() to configure Firestore persistence.Persistence cannot be used in a Node.js environment. | +| [PersistentCacheSettings](./firestore_.persistentcachesettings.md#persistentcachesettings_interface) | An settings object to configure an PersistentLocalCache instance.Persistent cache cannot be used in a Node.js environment. | +| [PersistentLocalCache](./firestore_.persistentlocalcache.md#persistentlocalcache_interface) | Provides a persistent cache backed by IndexedDb to the SDK.To use, create an instance using the factory function , then set the instance to FirestoreSettings.cache and call initializeFirestore using the settings object. | +| [PersistentMultipleTabManager](./firestore_.persistentmultipletabmanager.md#persistentmultipletabmanager_interface) | A tab manager supporting multiple tabs. SDK will synchronize queries and mutations done across all tabs using the SDK. | +| [PersistentSingleTabManager](./firestore_.persistentsingletabmanager.md#persistentsingletabmanager_interface) | A tab manager supporting only one tab, no synchronization will be performed across tabs. | +| [PersistentSingleTabManagerSettings](./firestore_.persistentsingletabmanagersettings.md#persistentsingletabmanagersettings_interface) | Type to configure an PersistentSingleTabManager instance. | +| [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | An options object that can be passed to [onSnapshot()](./firestore_.md#onsnapshot_0312fd7) and [QuerySnapshot.docChanges()](./firestore_.querysnapshot.md#querysnapshotdocchanges) to control which types of changes to include in the result set. | +| [SnapshotOptions](./firestore_.snapshotoptions.md#snapshotoptions_interface) | Options that configure how data is retrieved from a DocumentSnapshot (for example the desired behavior for server timestamps that have not yet been set to their final value). | +| [TransactionOptions](./firestore_.transactionoptions.md#transactionoptions_interface) | Options to customize transaction behavior. | +| [Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) | A function returned by onSnapshot() that removes the listener when invoked. | -``` - | -| [dotProduct(expr, other)](./firestore_.md#dotproduct_e701952) | (BETA) Calculates the dot product between a vector expression and a double array. -```typescript -// Calculate the dot product between a feature vector and a target vector -dotProduct(Field.of("features"), [0.5, 0.8, 0.2]); +## Variables -``` - | -| [dotProduct(expr, other)](./firestore_.md#dotproduct_cc2e83e) | (BETA) Calculates the dot product between a vector expression and a VectorValue. -```typescript -// Calculate the dot product between a feature vector and a target vector -dotProduct(Field.of("features"), new VectorValue([0.5, 0.8, 0.2])); +| Variable | Description | +| --- | --- | +| [CACHE\_SIZE\_UNLIMITED](./firestore_.md#cache_size_unlimited) | Constant used to indicate the LRU garbage collection should be disabled. Set this value as the cacheSizeBytes on the settings passed to the [Firestore](./firestore_.firestore.md#firestore_class) instance. | -``` - | -| [dotProduct(expr, other)](./firestore_.md#dotproduct_0896fbd) | (BETA) Calculates the dot product between two vector expressions. -```typescript -// Calculate the dot product between two document vectors: 'docVector1' and 'docVector2' -dotProduct(Field.of("docVector1"), Field.of("docVector2")); +## Type Aliases -``` - | -| [endsWith(expr, suffix)](./firestore_.md#endswith_88569cd) | (BETA) Creates an expression that checks if a field's value ends with a given postfix. -```typescript -// Check if the 'filename' field ends with ".txt" -endsWith("filename", ".txt"); - -``` - | -| [endsWith(expr, suffix)](./firestore_.md#endswith_e2e794e) | (BETA) Creates an expression that checks if a field's value ends with a given postfix. -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -endsWith("url", Field.of("extension")); - -``` - | -| [endsWith(expr, suffix)](./firestore_.md#endswith_6308b81) | (BETA) Creates an expression that checks if a string expression ends with a given postfix. -```typescript -// Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." -endsWith(Field.of("fullName"), "Jr."); - -``` - | -| [endsWith(expr, suffix)](./firestore_.md#endswith_ab1cc39) | (BETA) Creates an expression that checks if a string expression ends with a given postfix. -```typescript -// Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." -endsWith(Field.of("fullName"), Constant.of("Jr.")); - -``` - | -| [euclideanDistance(expr, other)](./firestore_.md#euclideandistance_b4c7dc2) | (BETA) Calculates the Euclidean distance between a field's vector value and a double array. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -euclideanDistance("location", [37.7749, -122.4194]); - -``` - | -| [euclideanDistance(expr, other)](./firestore_.md#euclideandistance_8d2bd9d) | (BETA) Calculates the Euclidean distance between a field's vector value and a VectorValue. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -euclideanDistance("location", new VectorValue([37.7749, -122.4194])); - -``` - | -| [euclideanDistance(expr, other)](./firestore_.md#euclideandistance_c9ae0bc) | (BETA) Calculates the Euclidean distance between a field's vector value and a vector expression. -```typescript -// Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' -euclideanDistance("pointA", Field.of("pointB")); - -``` - | -| [euclideanDistance(expr, other)](./firestore_.md#euclideandistance_e701952) | (BETA) Calculates the Euclidean distance between a vector expression and a double array. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location - -euclideanDistance(Field.of("location"), [37.7749, -122.4194]); - -``` - | -| [euclideanDistance(expr, other)](./firestore_.md#euclideandistance_cc2e83e) | (BETA) Calculates the Euclidean distance between a vector expression and a VectorValue. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -euclideanDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); - -``` - | -| [euclideanDistance(expr, other)](./firestore_.md#euclideandistance_0896fbd) | (BETA) Calculates the Euclidean distance between two vector expressions. -```typescript -// Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' -euclideanDistance(Field.of("pointA"), Field.of("pointB")); - -``` - | -| [reverse(expr)](./firestore_.md#reverse_f3fb767) | (BETA) Creates an expression that reverses a string. -```typescript -// Reverse the value of the 'myString' field. -reverse(Field.of("myString")); - -``` - | -| [startsWith(expr, prefix)](./firestore_.md#startswith_484d9f3) | (BETA) Creates an expression that checks if a field's value starts with a given prefix. -```typescript -// Check if the 'name' field starts with "Mr." -startsWith("name", "Mr."); - -``` - | -| [startsWith(expr, prefix)](./firestore_.md#startswith_7deb5c7) | (BETA) Creates an expression that checks if a field's value starts with a given prefix. -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -startsWith("fullName", Field.of("firstName")); - -``` - | -| [startsWith(expr, prefix)](./firestore_.md#startswith_68300d1) | (BETA) Creates an expression that checks if a string expression starts with a given prefix. -```typescript -// Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." -startsWith(Field.of("fullName"), "Mr."); - -``` - | -| [startsWith(expr, prefix)](./firestore_.md#startswith_5774b68) | (BETA) Creates an expression that checks if a string expression starts with a given prefix. -```typescript -// Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." -startsWith(Field.of("fullName"), Field.of("prefix")); - -``` - | -| [timestampToUnixMicros(expr)](./firestore_.md#timestamptounixmicros_f3fb767) | (BETA) Creates an expression that converts a timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -timestampToUnixMicros(Field.of("timestamp")); - -``` - | -| [timestampToUnixMillis(expr)](./firestore_.md#timestamptounixmillis_f3fb767) | (BETA) Creates an expression that converts a timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -timestampToUnixMillis(Field.of("timestamp")); - -``` - | -| [timestampToUnixSeconds(expr)](./firestore_.md#timestamptounixseconds_f3fb767) | (BETA) Creates an expression that converts a timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to seconds since epoch. -timestampToUnixSeconds(Field.of("timestamp")); - -``` - | -| [toLower(expr)](./firestore_.md#tolower_1e536ed) | (BETA) Creates an expression that converts a string field to lowercase. -```typescript -// Convert the 'name' field to lowercase -toLower("name"); - -``` - | -| [toLower(expr)](./firestore_.md#tolower_f3fb767) | (BETA) Creates an expression that converts a string expression to lowercase. -```typescript -// Convert the 'name' field to lowercase -toLower(Field.of("name")); - -``` - | -| [toUpper(expr)](./firestore_.md#toupper_1e536ed) | (BETA) Creates an expression that converts a string field to uppercase. -```typescript -// Convert the 'title' field to uppercase -toUpper("title"); - -``` - | -| [toUpper(expr)](./firestore_.md#toupper_f3fb767) | (BETA) Creates an expression that converts a string expression to uppercase. -```typescript -// Convert the 'title' field to uppercase -toUppercase(Field.of("title")); - -``` - | -| [trim(expr)](./firestore_.md#trim_1e536ed) | (BETA) Creates an expression that removes leading and trailing whitespace from a string field. -```typescript -// Trim whitespace from the 'userInput' field -trim("userInput"); - -``` - | -| [trim(expr)](./firestore_.md#trim_f3fb767) | (BETA) Creates an expression that removes leading and trailing whitespace from a string expression. -```typescript -// Trim whitespace from the 'userInput' field -trim(Field.of("userInput")); - -``` - | -| [unixMicrosToTimestamp(expr)](./firestore_.md#unixmicrostotimestamp_f3fb767) | (BETA) Creates an expression that interprets an expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -unixMicrosToTimestamp(Field.of("microseconds")); - -``` - | -| [unixMillisToTimestamp(expr)](./firestore_.md#unixmillistotimestamp_f3fb767) | (BETA) Creates an expression that interprets an expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -unixMillisToTimestamp(Field.of("milliseconds")); - -``` - | -| [unixSecondsToTimestamp(expr)](./firestore_.md#unixsecondstotimestamp_f3fb767) | (BETA) Creates an expression that interprets an expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'seconds' field as seconds since epoch. -unixSecondsToTimestamp(Field.of("seconds")); - -``` - | -| [vectorLength(expr)](./firestore_.md#vectorlength_f3fb767) | (BETA) Creates an expression that calculates the length of a Firestore Vector. -```typescript -// Get the vector length (dimension) of the field 'embedding'. -vectorLength(Field.of("embedding")); - -``` - | -| function(field, ...) | -| [average(field)](./firestore_.md#average_aacc3a9) | Create an AggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query. | -| [byteLength(field)](./firestore_.md#bytelength_0fb8cd4) | (BETA) Creates an expression that calculates the length of a string represented by a field in UTF-8 bytes, or just the length of a Blob. -```typescript -// Calculate the length of the 'myString' field in bytes. -byteLength("myString"); - -``` - | -| [charLength(field)](./firestore_.md#charlength_0fb8cd4) | (BETA) Creates an expression that calculates the character length of a string field in UTF8. -```typescript -// Get the character length of the 'name' field in UTF-8. -strLength("name"); - -``` - | -| [exists(field)](./firestore_.md#exists_0fb8cd4) | (BETA) Creates an expression that checks if a field exists. -```typescript -// Check if the document has a field named "phoneNumber" -exists("phoneNumber"); - -``` - | -| [replaceAll(field, find, replace)](./firestore_.md#replaceall_b257ab0) | (BETA) Creates an expression that replaces all occurrences of a substring within a string represented by a field with another substring. -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field. -replaceAll("message", "hello", "hi"); - -``` - | -| [replaceFirst(field, find, replace)](./firestore_.md#replacefirst_b257ab0) | (BETA) Creates an expression that replaces the first occurrence of a substring within a string represented by a field with another substring. -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field. -replaceFirst("message", "hello", "hi"); - -``` - | -| [reverse(field)](./firestore_.md#reverse_0fb8cd4) | (BETA) Creates an expression that reverses a string represented by a field. -```typescript -// Reverse the value of the 'myString' field. -reverse("myString"); - -``` - | -| [sum(field)](./firestore_.md#sum_aacc3a9) | Create an AggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query. | -| [timestampAdd(field, unit, amount)](./firestore_.md#timestampadd_565792c) | (BETA) Creates an expression that adds a specified amount of time to a timestamp represented by a field. -```typescript -// Add 1 day to the 'timestamp' field. -timestampAdd("timestamp", "day", 1); - -``` - | -| [timestampSub(field, unit, amount)](./firestore_.md#timestampsub_565792c) | (BETA) Creates an expression that subtracts a specified amount of time from a timestamp represented by a field. -```typescript -// Subtract 1 day from the 'timestamp' field. -timestampSub("timestamp", "day", 1); - -``` - | -| [timestampToUnixMicros(field)](./firestore_.md#timestamptounixmicros_0fb8cd4) | (BETA) Creates an expression that converts a timestamp field to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -timestampToUnixMicros("timestamp"); - -``` - | -| [timestampToUnixMillis(field)](./firestore_.md#timestamptounixmillis_0fb8cd4) | (BETA) Creates an expression that converts a timestamp field to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -timestampToUnixMillis("timestamp"); - -``` - | -| [timestampToUnixSeconds(field)](./firestore_.md#timestamptounixseconds_0fb8cd4) | (BETA) Creates an expression that converts a timestamp field to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to seconds since epoch. -timestampToUnixSeconds("timestamp"); - -``` - | -| [unixMicrosToTimestamp(field)](./firestore_.md#unixmicrostotimestamp_0fb8cd4) | (BETA) Creates an expression that interprets a field's value as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -unixMicrosToTimestamp("microseconds"); - -``` - | -| [unixMillisToTimestamp(field)](./firestore_.md#unixmillistotimestamp_0fb8cd4) | (BETA) Creates an expression that interprets a field's value as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -unixMillisToTimestamp("milliseconds"); - -``` - | -| [unixSecondsToTimestamp(field)](./firestore_.md#unixsecondstotimestamp_0fb8cd4) | (BETA) Creates an expression that interprets a field's value as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'seconds' field as seconds since epoch. -unixSecondsToTimestamp("seconds"); - -``` - | -| [vectorLength(field)](./firestore_.md#vectorlength_0fb8cd4) | (BETA) Creates an expression that calculates the length of a Firestore Vector represented by a field. -```typescript -// Get the vector length (dimension) of the field 'embedding'. -vectorLength("embedding"); - -``` - | -| function(fieldPath, ...) | -| [orderBy(fieldPath, directionStr)](./firestore_.md#orderby_006d61f) | Creates a [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) that sorts the query result by the specified field, optionally in descending order instead of ascending.Note: Documents that do not contain the specified field will not be present in the query result. | -| [where(fieldPath, opStr, value)](./firestore_.md#where_0fae4bf) | Creates a [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) that enforces that documents must contain the specified field and that the value should satisfy the relation constraint provided. | -| function(fieldValues, ...) | -| [endAt(fieldValues)](./firestore_.md#endat_8b2f2c8) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | -| [endBefore(fieldValues)](./firestore_.md#endbefore_8b2f2c8) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | -| [startAfter(fieldValues)](./firestore_.md#startafter_8b2f2c8) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | -| [startAt(fieldValues)](./firestore_.md#startat_8b2f2c8) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | -| function(filter, ...) | -| [not(filter)](./firestore_.md#not_5520849) | (BETA) Creates an expression that negates a filter condition. -```typescript -// Find documents where the 'completed' field is NOT true -not(eq("completed", true)); - -``` - | -| function(first, ...) | -| [strConcat(first, elements)](./firestore_.md#strconcat_0f1bdbf) | (BETA) Creates an expression that concatenates string functions, fields or constants together. -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -strConcat("firstName", " ", Field.of("lastName")); - -``` - | -| [strConcat(first, elements)](./firestore_.md#strconcat_1eb0ac1) | (BETA) Creates an expression that concatenates string expressions together. -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -strConcat(Field.of("firstName"), " ", Field.of("lastName")); - -``` - | -| function(indexManager, ...) | -| [deleteAllPersistentCacheIndexes(indexManager)](./firestore_.md#deleteallpersistentcacheindexes_98b2645) | Removes all persistent cache indexes.Please note this function will also deletes indexes generated by setIndexConfiguration(), which is deprecated. | -| [disablePersistentCacheIndexAutoCreation(indexManager)](./firestore_.md#disablepersistentcacheindexautocreation_98b2645) | Stops creating persistent cache indexes automatically for local query execution. The indexes which have been created by calling enablePersistentCacheIndexAutoCreation() still take effect. | -| [enablePersistentCacheIndexAutoCreation(indexManager)](./firestore_.md#enablepersistentcacheindexautocreation_98b2645) | Enables the SDK to create persistent cache indexes automatically for local query execution when the SDK believes cache indexes can help improve performance.This feature is disabled by default. | -| function(left, ...) | -| [add(left, right)](./firestore_.md#add_be96f75) | (BETA) Creates an expression that adds two expressions together. -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -add(Field.of("quantity"), Field.of("reserve")); - -``` - | -| [add(left, right)](./firestore_.md#add_010ba9e) | (BETA) Creates an expression that adds an expression to a constant value. -```typescript -// Add 5 to the value of the 'age' field -add(Field.of("age"), 5); - -``` - | -| [add(left, right)](./firestore_.md#add_674c63f) | (BETA) Creates an expression that adds a field's value to an expression. -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -add("quantity", Field.of("reserve")); - -``` - | -| [add(left, right)](./firestore_.md#add_1f46a76) | (BETA) Creates an expression that adds a field's value to a constant value. -```typescript -// Add 5 to the value of the 'age' field -add("age", 5); - -``` - | -| [aggregateFieldEqual(left, right)](./firestore_.md#aggregatefieldequal_e80a2b2) | Compares two 'AggregateField\` instances for equality. | -| [aggregateQuerySnapshotEqual(left, right)](./firestore_.md#aggregatequerysnapshotequal_1529a20) | Compares two AggregateQuerySnapshot instances for equality.Two AggregateQuerySnapshot instances are considered "equal" if they have underlying queries that compare equal, and the same data. | -| [and(left, right)](./firestore_.md#and_eba7e36) | (BETA) Creates an expression that performs a logical 'AND' operation on multiple filter conditions. -```typescript -// Check if the 'age' field is greater than 18 AND the 'city' field is "London" AND -// the 'status' field is "active" -const condition = and(gt("age", 18), eq("city", "London"), eq("status", "active")); - -``` - | -| [divide(left, right)](./firestore_.md#divide_be96f75) | (BETA) Creates an expression that divides two expressions. -```typescript -// Divide the 'total' field by the 'count' field -divide(Field.of("total"), Field.of("count")); - -``` - | -| [divide(left, right)](./firestore_.md#divide_010ba9e) | (BETA) Creates an expression that divides an expression by a constant value. -```typescript -// Divide the 'value' field by 10 -divide(Field.of("value"), 10); - -``` - | -| [divide(left, right)](./firestore_.md#divide_674c63f) | (BETA) Creates an expression that divides a field's value by an expression. -```typescript -// Divide the 'total' field by the 'count' field -divide("total", Field.of("count")); - -``` - | -| [divide(left, right)](./firestore_.md#divide_1f46a76) | (BETA) Creates an expression that divides a field's value by a constant value. -```typescript -// Divide the 'value' field by 10 -divide("value", 10); - -``` - | -| [eq(left, right)](./firestore_.md#eq_be96f75) | (BETA) Creates an expression that checks if two expressions are equal. -```typescript -// Check if the 'age' field is equal to an expression -eq(Field.of("age"), Field.of("minAge").add(10)); - -``` - | -| [eq(left, right)](./firestore_.md#eq_010ba9e) | (BETA) Creates an expression that checks if an expression is equal to a constant value. -```typescript -// Check if the 'age' field is equal to 21 -eq(Field.of("age"), 21); - -``` - | -| [eq(left, right)](./firestore_.md#eq_674c63f) | (BETA) Creates an expression that checks if a field's value is equal to an expression. -```typescript -// Check if the 'age' field is equal to the 'limit' field -eq("age", Field.of("limit")); - -``` - | -| [eq(left, right)](./firestore_.md#eq_1f46a76) | (BETA) Creates an expression that checks if a field's value is equal to a constant value. -```typescript -// Check if the 'city' field is equal to string constant "London" -eq("city", "London"); - -``` - | -| [gt(left, right)](./firestore_.md#gt_be96f75) | (BETA) Creates an expression that checks if the first expression is greater than the second expression. -```typescript -// Check if the 'age' field is greater than 18 -gt(Field.of("age"), Constant(9).add(9)); - -``` - | -| [gt(left, right)](./firestore_.md#gt_010ba9e) | (BETA) Creates an expression that checks if an expression is greater than a constant value. -```typescript -// Check if the 'age' field is greater than 18 -gt(Field.of("age"), 18); - -``` - | -| [gt(left, right)](./firestore_.md#gt_674c63f) | (BETA) Creates an expression that checks if a field's value is greater than an expression. -```typescript -// Check if the value of field 'age' is greater than the value of field 'limit' -gt("age", Field.of("limit")); - -``` - | -| [gt(left, right)](./firestore_.md#gt_1f46a76) | (BETA) Creates an expression that checks if a field's value is greater than a constant value. -```typescript -// Check if the 'price' field is greater than 100 -gt("price", 100); - -``` - | -| [gte(left, right)](./firestore_.md#gte_be96f75) | (BETA) Creates an expression that checks if the first expression is greater than or equal to the second expression. -```typescript -// Check if the 'quantity' field is greater than or equal to the field "threshold" -gte(Field.of("quantity"), Field.of("threshold")); - -``` - | -| [gte(left, right)](./firestore_.md#gte_010ba9e) | (BETA) Creates an expression that checks if an expression is greater than or equal to a constant value. -```typescript -// Check if the 'quantity' field is greater than or equal to 10 -gte(Field.of("quantity"), 10); - -``` - | -| [gte(left, right)](./firestore_.md#gte_674c63f) | (BETA) Creates an expression that checks if a field's value is greater than or equal to an expression. -```typescript -// Check if the value of field 'age' is greater than or equal to the value of field 'limit' -gte("age", Field.of("limit")); - -``` - | -| [gte(left, right)](./firestore_.md#gte_1f46a76) | (BETA) Creates an expression that checks if a field's value is greater than or equal to a constant value. -```typescript -// Check if the 'score' field is greater than or equal to 80 -gte("score", 80); - -``` - | -| [like(left, pattern)](./firestore_.md#like_33ec01b) | (BETA) Creates an expression that performs a case-sensitive wildcard string comparison against a field. -```typescript -// Check if the 'title' field contains the string "guide" -like("title", "%guide%"); - -``` - | -| [like(left, pattern)](./firestore_.md#like_dd84184) | (BETA) Creates an expression that performs a case-sensitive wildcard string comparison against a field. -```typescript -// Check if the 'title' field contains the string "guide" -like("title", Field.of("pattern")); - -``` - | -| [like(left, pattern)](./firestore_.md#like_3aaffe0) | (BETA) Creates an expression that performs a case-sensitive wildcard string comparison. -```typescript -// Check if the 'title' field contains the string "guide" -like(Field.of("title"), "%guide%"); - -``` - | -| [like(left, pattern)](./firestore_.md#like_a2c3e8b) | (BETA) Creates an expression that performs a case-sensitive wildcard string comparison. -```typescript -// Check if the 'title' field contains the string "guide" -like(Field.of("title"), Field.of("pattern")); - -``` - | -| [logicalMax(left, right)](./firestore_.md#logicalmax_be96f75) | (BETA) Creates an expression that returns the larger value between two expressions, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'field1' field and the 'field2' field. -logicalMax(Field.of("field1"), Field.of("field2")); - -``` - | -| [logicalMax(left, right)](./firestore_.md#logicalmax_010ba9e) | (BETA) Creates an expression that returns the larger value between an expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'value' field and 10. -logicalMax(Field.of("value"), 10); - -``` - | -| [logicalMax(left, right)](./firestore_.md#logicalmax_674c63f) | (BETA) Creates an expression that returns the larger value between a field and an expression, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'field1' field and the 'field2' field. -logicalMax("field1", Field.of('field2')); - -``` - | -| [logicalMax(left, right)](./firestore_.md#logicalmax_1f46a76) | (BETA) Creates an expression that returns the larger value between a field and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'value' field and 10. -logicalMax("value", 10); - -``` - | -| [logicalMin(left, right)](./firestore_.md#logicalmin_be96f75) | (BETA) Creates an expression that returns the smaller value between two expressions, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'field1' field and the 'field2' field. -logicalMin(Field.of("field1"), Field.of("field2")); - -``` - | -| [logicalMin(left, right)](./firestore_.md#logicalmin_010ba9e) | (BETA) Creates an expression that returns the smaller value between an expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'value' field and 10. -logicalMin(Field.of("value"), 10); - -``` - | -| [logicalMin(left, right)](./firestore_.md#logicalmin_674c63f) | (BETA) Creates an expression that returns the smaller value between a field and an expression, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'field1' field and the 'field2' field. -logicalMin("field1", Field.of("field2")); - -``` - | -| [logicalMin(left, right)](./firestore_.md#logicalmin_1f46a76) | (BETA) Creates an expression that returns the smaller value between a field and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'value' field and 10. -logicalMin("value", 10); - -``` - | -| [lt(left, right)](./firestore_.md#lt_be96f75) | (BETA) Creates an expression that checks if the first expression is less than the second expression. -```typescript -// Check if the 'age' field is less than 30 -lt(Field.of("age"), Field.of("limit")); - -``` - | -| [lt(left, right)](./firestore_.md#lt_010ba9e) | (BETA) Creates an expression that checks if an expression is less than a constant value. -```typescript -// Check if the 'age' field is less than 30 -lt(Field.of("age"), 30); - -``` - | -| [lt(left, right)](./firestore_.md#lt_674c63f) | (BETA) Creates an expression that checks if a field's value is less than an expression. -```typescript -// Check if the 'age' field is less than the 'limit' field -lt("age", Field.of("limit")); - -``` - | -| [lt(left, right)](./firestore_.md#lt_1f46a76) | (BETA) Creates an expression that checks if a field's value is less than a constant value. -```typescript -// Check if the 'price' field is less than 50 -lt("price", 50); - -``` - | -| [lte(left, right)](./firestore_.md#lte_be96f75) | (BETA) Creates an expression that checks if the first expression is less than or equal to the second expression. -```typescript -// Check if the 'quantity' field is less than or equal to 20 -lte(Field.of("quantity"), Field.of("limit")); - -``` - | -| [lte(left, right)](./firestore_.md#lte_010ba9e) | (BETA) Creates an expression that checks if an expression is less than or equal to a constant value. -```typescript -// Check if the 'quantity' field is less than or equal to 20 -lte(Field.of("quantity"), 20); - -``` - | -| [lte(left, right)](./firestore_.md#lte_674c63f) | Creates an expression that checks if a field's value is less than or equal to an expression. -```typescript -// Check if the 'quantity' field is less than or equal to the 'limit' field -lte("quantity", Field.of("limit")); - -``` - | -| [lte(left, right)](./firestore_.md#lte_1f46a76) | (BETA) Creates an expression that checks if a field's value is less than or equal to a constant value. -```typescript -// Check if the 'score' field is less than or equal to 70 -lte("score", 70); - -``` - | -| [mod(left, right)](./firestore_.md#mod_be96f75) | (BETA) Creates an expression that calculates the modulo (remainder) of dividing two expressions. -```typescript -// Calculate the remainder of dividing 'field1' by 'field2'. -mod(Field.of("field1"), Field.of("field2")); - -``` - | -| [mod(left, right)](./firestore_.md#mod_010ba9e) | (BETA) Creates an expression that calculates the modulo (remainder) of dividing an expression by a constant. -```typescript -// Calculate the remainder of dividing 'field1' by 5. -mod(Field.of("field1"), 5); - -``` - | -| [mod(left, right)](./firestore_.md#mod_674c63f) | (BETA) Creates an expression that calculates the modulo (remainder) of dividing a field's value by an expression. -```typescript -// Calculate the remainder of dividing 'field1' by 'field2'. -mod("field1", Field.of("field2")); - -``` - | -| [mod(left, right)](./firestore_.md#mod_1f46a76) | (BETA) Creates an expression that calculates the modulo (remainder) of dividing a field's value by a constant. -```typescript -// Calculate the remainder of dividing 'field1' by 5. -mod("field1", 5); - -``` - | -| [multiply(left, right)](./firestore_.md#multiply_be96f75) | (BETA) Creates an expression that multiplies two expressions together. -```typescript -// Multiply the 'quantity' field by the 'price' field -multiply(Field.of("quantity"), Field.of("price")); - -``` - | -| [multiply(left, right)](./firestore_.md#multiply_010ba9e) | (BETA) Creates an expression that multiplies an expression by a constant value. -```typescript -// Multiply the value of the 'price' field by 2 -multiply(Field.of("price"), 2); - -``` - | -| [multiply(left, right)](./firestore_.md#multiply_674c63f) | (BETA) Creates an expression that multiplies a field's value by an expression. -```typescript -// Multiply the 'quantity' field by the 'price' field -multiply("quantity", Field.of("price")); - -``` - | -| [multiply(left, right)](./firestore_.md#multiply_1f46a76) | (BETA) Creates an expression that multiplies a field's value by a constant value. -```typescript -// Multiply the 'value' field by 2 -multiply("value", 2); - -``` - | -| [neq(left, right)](./firestore_.md#neq_be96f75) | (BETA) Creates an expression that checks if two expressions are not equal. -```typescript -// Check if the 'status' field is not equal to field 'finalState' -neq(Field.of("status"), Field.of("finalState")); - -``` - | -| [neq(left, right)](./firestore_.md#neq_010ba9e) | (BETA) Creates an expression that checks if an expression is not equal to a constant value. -```typescript -// Check if the 'status' field is not equal to "completed" -neq(Field.of("status"), "completed"); - -``` - | -| [neq(left, right)](./firestore_.md#neq_674c63f) | (BETA) Creates an expression that checks if a field's value is not equal to an expression. -```typescript -// Check if the 'status' field is not equal to the value of 'expectedStatus' -neq("status", Field.of("expectedStatus")); - -``` - | -| [neq(left, right)](./firestore_.md#neq_1f46a76) | (BETA) Creates an expression that checks if a field's value is not equal to a constant value. -```typescript -// Check if the 'country' field is not equal to "USA" -neq("country", "USA"); - -``` - | -| [or(left, right)](./firestore_.md#or_eba7e36) | (BETA) Creates an expression that performs a logical 'OR' operation on multiple filter conditions. -```typescript -// Check if the 'age' field is greater than 18 OR the 'city' field is "London" OR -// the 'status' field is "active" -const condition = or(gt("age", 18), eq("city", "London"), eq("status", "active")); - -``` - | -| [queryEqual(left, right)](./firestore_.md#queryequal_7a1f045) | Returns true if the provided queries point to the same collection and apply the same constraints. | -| [refEqual(left, right)](./firestore_.md#refequal_598b780) | Returns true if the provided references are equal. | -| [regexContains(left, pattern)](./firestore_.md#regexcontains_33ec01b) | (BETA) Creates an expression that checks if a string field contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -regexContains("description", "(?i)example"); - -``` - | -| [regexContains(left, pattern)](./firestore_.md#regexcontains_dd84184) | (BETA) Creates an expression that checks if a string field contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -regexContains("description", Field.of("pattern")); - -``` - | -| [regexContains(left, pattern)](./firestore_.md#regexcontains_3aaffe0) | (BETA) Creates an expression that checks if a string expression contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -regexContains(Field.of("description"), "(?i)example"); - -``` - | -| [regexContains(left, pattern)](./firestore_.md#regexcontains_a2c3e8b) | (BETA) Creates an expression that checks if a string expression contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -regexContains(Field.of("description"), Field.of("pattern")); - -``` - | -| [regexMatch(left, pattern)](./firestore_.md#regexmatch_33ec01b) | (BETA) Creates an expression that checks if a string field matches a specified regular expression. -```typescript -// Check if the 'email' field matches a valid email pattern -regexMatch("email", "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - | -| [regexMatch(left, pattern)](./firestore_.md#regexmatch_dd84184) | (BETA) Creates an expression that checks if a string field matches a specified regular expression. -```typescript -// Check if the 'email' field matches a valid email pattern -regexMatch("email", Field.of("pattern")); - -``` - | -| [regexMatch(left, pattern)](./firestore_.md#regexmatch_3aaffe0) | (BETA) Creates an expression that checks if a string expression matches a specified regular expression. -```typescript -// Check if the 'email' field matches a valid email pattern -regexMatch(Field.of("email"), "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - | -| [regexMatch(left, pattern)](./firestore_.md#regexmatch_a2c3e8b) | (BETA) Creates an expression that checks if a string expression matches a specified regular expression. -```typescript -// Check if the 'email' field matches a valid email pattern -regexMatch(Field.of("email"), Field.of("pattern")); - -``` - | -| [snapshotEqual(left, right)](./firestore_.md#snapshotequal_5109204) | Returns true if the provided snapshots are equal. | -| [strContains(left, substring)](./firestore_.md#strcontains_18eaf5d) | (BETA) Creates an expression that checks if a string field contains a specified substring. -```typescript -// Check if the 'description' field contains "example". -strContains("description", "example"); - -``` - | -| [strContains(left, substring)](./firestore_.md#strcontains_f0f1f2f) | (BETA) Creates an expression that checks if a string field contains a substring specified by an expression. -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -strContains("description", Field.of("keyword")); - -``` - | -| [strContains(left, substring)](./firestore_.md#strcontains_5fdbd29) | (BETA) Creates an expression that checks if a string expression contains a specified substring. -```typescript -// Check if the 'description' field contains "example". -strContains(Field.of("description"), "example"); - -``` - | -| [strContains(left, substring)](./firestore_.md#strcontains_d9d749f) | (BETA) Creates an expression that checks if a string expression contains a substring specified by another expression. -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -strContains(Field.of("description"), Field.of("keyword")); - -``` - | -| [subtract(left, right)](./firestore_.md#subtract_be96f75) | (BETA) Creates an expression that subtracts two expressions. -```typescript -// Subtract the 'discount' field from the 'price' field -subtract(Field.of("price"), Field.of("discount")); - -``` - | -| [subtract(left, right)](./firestore_.md#subtract_010ba9e) | (BETA) Creates an expression that subtracts a constant value from an expression. -```typescript -// Subtract the constant value 2 from the 'value' field -subtract(Field.of("value"), 2); - -``` - | -| [subtract(left, right)](./firestore_.md#subtract_674c63f) | (BETA) Creates an expression that subtracts an expression from a field's value. -```typescript -// Subtract the 'discount' field from the 'price' field -subtract("price", Field.of("discount")); - -``` - | -| [subtract(left, right)](./firestore_.md#subtract_1f46a76) | (BETA) Creates an expression that subtracts a constant value from a field's value. -```typescript -// Subtract 20 from the value of the 'total' field -subtract("total", 20); - -``` - | -| [xor(left, right)](./firestore_.md#xor_eba7e36) | (BETA) Creates an expression that performs a logical 'XOR' (exclusive OR) operation on multiple filter conditions. -```typescript -// Check if only one of the conditions is true: 'age' greater than 18, 'city' is "London", -// or 'status' is "active". -const condition = xor( - gt("age", 18), - eq("city", "London"), - eq("status", "active")); - -``` - | -| function(limit, ...) | -| [limit(limit)](./firestore_.md#limit_ec46c78) | Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the first matching documents. | -| [limitToLast(limit)](./firestore_.md#limittolast_ec46c78) | Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the last matching documents.You must specify at least one orderBy clause for limitToLast queries, otherwise an exception will be thrown during execution. | -| function(logLevel, ...) | -| [setLogLevel(logLevel)](./firestore_.md#setloglevel_d02fda2) | Sets the verbosity of Cloud Firestore logs (debug, error, or silent). | -| function(mapExpr, ...) | -| [mapGet(mapExpr, subField)](./firestore_.md#mapget_9715f90) | (BETA) Accesses a value from a map (object) expression using the provided key. -```typescript -// Get the 'city' value from the 'address' map field -mapGet(Field.of("address"), "city"); - -``` - | -| function(mapField, ...) | -| [mapGet(mapField, subField)](./firestore_.md#mapget_b37bbb6) | (BETA) Accesses a value from a map (object) field using the provided key. -```typescript -// Get the 'city' value from the 'address' map field -mapGet("address", "city"); - -``` - | -| function(n, ...) | -| [increment(n)](./firestore_.md#increment_5685735) | Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to increment the field's current value by the given value.If either the operand or the current field value uses floating point precision, all arithmetic follows IEEE 754 semantics. If both values are integers, values outside of JavaScript's safe number range (Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER) are also subject to precision loss. Furthermore, once processed by the Firestore backend, all integer operations are capped between -2^63 and 2^63-1.If the current field value is not of type number, or if the field does not yet exist, the transformation sets the field to the given value. | -| function(name, ...) | -| [genericFunction(name, params)](./firestore_.md#genericfunction_b886545) | (BETA) Creates functions that work on the backend but do not exist in the SDK yet. -```typescript -// Call a user defined function named "myFunc" with the arguments 10 and 20 -// This is the same of the 'sum(Field.of("price"))', if it did not exist -genericFunction("sum", [Field.of("price")]); - -``` - | -| function(pipeline, ...) | -| [execute(pipeline)](./firestore_.md#execute_86486e6) | (BETA) Modular API for console experimentation. | -| function(query, ...) | -| [getAggregateFromServer(query, aggregateSpec)](./firestore_.md#getaggregatefromserver_2073a74) | Calculates the specified aggregations over the documents in the result set of the given query without actually downloading the documents.Using this function to perform aggregations is efficient because only the final aggregation values, not the documents' data, are downloaded. This function can perform aggregations of the documents in cases where the result set is prohibitively large to download entirely (thousands of documents).The result received from the server is presented, unaltered, without considering any local state. That is, documents in the local cache are not taken into consideration, neither are local modifications not yet synchronized with the server. Previously-downloaded results, if any, are not used. Every invocation of this function necessarily involves a round trip to the server. | -| [getCountFromServer(query)](./firestore_.md#getcountfromserver_4e56953) | Calculates the number of documents in the result set of the given query without actually downloading the documents.Using this function to count the documents is efficient because only the final count, not the documents' data, is downloaded. This function can count the documents in cases where the result set is prohibitively large to download entirely (thousands of documents).The result received from the server is presented, unaltered, without considering any local state. That is, documents in the local cache are not taken into consideration, neither are local modifications not yet synchronized with the server. Previously-downloaded results, if any, are not used. Every invocation of this function necessarily involves a round trip to the server. | -| [getDocs(query)](./firestore_.md#getdocs_4e56953) | Executes the query and returns the results as a QuerySnapshot.Note: getDocs() attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. To specify this behavior, invoke [getDocsFromCache()](./firestore_.md#getdocsfromcache_4e56953) or [getDocsFromServer()](./firestore_.md#getdocsfromserver_4e56953). | -| [getDocsFromCache(query)](./firestore_.md#getdocsfromcache_4e56953) | Executes the query and returns the results as a QuerySnapshot from cache. Returns an empty result set if no documents matching the query are currently cached. | -| [getDocsFromServer(query)](./firestore_.md#getdocsfromserver_4e56953) | Executes the query and returns the results as a QuerySnapshot from the server. Returns an error if the network is not available. | -| [onSnapshot(query, observer)](./firestore_.md#onsnapshot_8d14049) | Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | -| [onSnapshot(query, options, observer)](./firestore_.md#onsnapshot_03dfff5) | Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | -| [onSnapshot(query, onNext, onError, onCompletion)](./firestore_.md#onsnapshot_3ebfbe2) | Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | -| [onSnapshot(query, options, onNext, onError, onCompletion)](./firestore_.md#onsnapshot_b8f9c47) | Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | -| [pipeline(query)](./firestore_.md#pipeline_20b2416) | Experimental Modular API for console testing. | -| [query(query, compositeFilter, queryConstraints)](./firestore_.md#query_9f7b0f4) | Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. | -| [query(query, queryConstraints)](./firestore_.md#query_0f46da1) | Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. | -| function(queryConstraints, ...) | -| [and(queryConstraints)](./firestore_.md#and_e72c712) | Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a conjunction of the given filter constraints. A conjunction filter includes a document if it satisfies all of the given filters. | -| [or(queryConstraints)](./firestore_.md#or_e72c712) | Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a disjunction of the given filter constraints. A disjunction filter includes a document if it satisfies any of the given filters. | -| function(reference, ...) | -| [addDoc(reference, data)](./firestore_.md#adddoc_6e783ff) | Add a new document to specified CollectionReference with the given data, assigning it a document ID automatically. | -| [collection(reference, path, pathSegments)](./firestore_.md#collection_568f98d) | Gets a CollectionReference instance that refers to a subcollection of reference at the specified relative path. | -| [collection(reference, path, pathSegments)](./firestore_.md#collection_70b4396) | Gets a CollectionReference instance that refers to a subcollection of reference at the specified relative path. | -| [deleteDoc(reference)](./firestore_.md#deletedoc_4569087) | Deletes the document referred to by the specified DocumentReference. | -| [doc(reference, path, pathSegments)](./firestore_.md#doc_568f98d) | Gets a DocumentReference instance that refers to a document within reference at the specified relative path. If no path is specified, an automatically-generated unique ID will be used for the returned DocumentReference. | -| [doc(reference, path, pathSegments)](./firestore_.md#doc_70b4396) | Gets a DocumentReference instance that refers to a document within reference at the specified relative path. | -| [getDoc(reference)](./firestore_.md#getdoc_4569087) | Reads the document referred to by this DocumentReference.Note: getDoc() attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. To specify this behavior, invoke [getDocFromCache()](./firestore_.md#getdocfromcache_4569087) or [getDocFromServer()](./firestore_.md#getdocfromserver_4569087). | -| [getDocFromCache(reference)](./firestore_.md#getdocfromcache_4569087) | Reads the document referred to by this DocumentReference from cache. Returns an error if the document is not currently cached. | -| [getDocFromServer(reference)](./firestore_.md#getdocfromserver_4569087) | Reads the document referred to by this DocumentReference from the server. Returns an error if the network is not available. | -| [onSnapshot(reference, observer)](./firestore_.md#onsnapshot_0312fd7) | Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | -| [onSnapshot(reference, options, observer)](./firestore_.md#onsnapshot_86b6b9e) | Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | -| [onSnapshot(reference, onNext, onError, onCompletion)](./firestore_.md#onsnapshot_905f42c) | Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | -| [onSnapshot(reference, options, onNext, onError, onCompletion)](./firestore_.md#onsnapshot_0c39991) | Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. | -| [setDoc(reference, data)](./firestore_.md#setdoc_ee215ad) | Writes to the document referred to by this DocumentReference. If the document does not yet exist, it will be created. | -| [setDoc(reference, data, options)](./firestore_.md#setdoc_ff80739) | Writes to the document referred to by the specified DocumentReference. If the document does not yet exist, it will be created. If you provide merge or mergeFields, the provided data can be merged into an existing document. | -| [updateDoc(reference, data)](./firestore_.md#updatedoc_51a65e3) | Updates fields in the document referred to by the specified DocumentReference. The update will fail if applied to a document that does not exist. | -| [updateDoc(reference, field, value, moreFieldsAndValues)](./firestore_.md#updatedoc_7c28659) | Updates fields in the document referred to by the specified DocumentReference The update will fail if applied to a document that does not exist.Nested fields can be updated by providing dot-separated field path strings or by providing FieldPath objects. | -| function(settings, ...) | -| [memoryLocalCache(settings)](./firestore_.md#memorylocalcache_05f4bf2) | Creates an instance of MemoryLocalCache. The instance can be set to FirestoreSettings.cache to tell the SDK which cache layer to use. | -| [memoryLruGarbageCollector(settings)](./firestore_.md#memorylrugarbagecollector_5ee014c) | Creates an instance of MemoryLruGarbageCollector.A target size can be specified as part of the setting parameter. The collector will start deleting documents once the cache size exceeds the given size. The default cache size is 40MB (40 \* 1024 \* 1024 bytes). | -| [persistentLocalCache(settings)](./firestore_.md#persistentlocalcache_d312f71) | Creates an instance of PersistentLocalCache. The instance can be set to FirestoreSettings.cache to tell the SDK which cache layer to use.Persistent cache cannot be used in a Node.js environment. | -| [persistentSingleTabManager(settings)](./firestore_.md#persistentsingletabmanager_c99c68d) | Creates an instance of PersistentSingleTabManager. | -| function(snapshot, ...) | -| [endAt(snapshot)](./firestore_.md#endat_9a4477f) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided document (inclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. | -| [endBefore(snapshot)](./firestore_.md#endbefore_9a4477f) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided document (exclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. | -| [startAfter(snapshot)](./firestore_.md#startafter_9a4477f) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided document (exclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. | -| [startAt(snapshot)](./firestore_.md#startat_9a4477f) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided document (inclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of this query. | -| function(timestamp, ...) | -| [timestampAdd(timestamp, unit, amount)](./firestore_.md#timestampadd_87db576) | (BETA) Creates an expression that adds a specified amount of time to a timestamp. -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -timestampAdd(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampAdd(timestamp, unit, amount)](./firestore_.md#timestampadd_46a2d7e) | (BETA) Creates an expression that adds a specified amount of time to a timestamp. -```typescript -// Add 1 day to the 'timestamp' field. -timestampAdd(Field.of("timestamp"), "day", 1); - -``` - | -| [timestampSub(timestamp, unit, amount)](./firestore_.md#timestampsub_87db576) | (BETA) Creates an expression that subtracts a specified amount of time from a timestamp. -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -timestampSub(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampSub(timestamp, unit, amount)](./firestore_.md#timestampsub_46a2d7e) | (BETA) Creates an expression that subtracts a specified amount of time from a timestamp. -```typescript -// Subtract 1 day from the 'timestamp' field. -timestampSub(Field.of("timestamp"), "day", 1); - -``` - | -| function(value, ...) | -| [avg(value)](./firestore_.md#avg_f83680a) | (BETA) Creates an aggregation that calculates the average (mean) of values from an expression across multiple stage inputs. -```typescript -// Calculate the average age of users -avg(Field.of("age")).as("averageAge"); - -``` - | -| [avg(value)](./firestore_.md#avg_7c807cd) | (BETA) Creates an aggregation that calculates the average (mean) of a field's values across multiple stage inputs. -```typescript -// Calculate the average age of users -avg("age").as("averageAge"); - -``` - | -| [countExpression(value)](./firestore_.md#countexpression_f83680a) | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the provided expression. -```typescript -// Count the number of items where the price is greater than 10 -count(Field.of("price").gt(10)).as("expensiveItemCount"); - -``` - | -| [countExpression(value)](./firestore_.md#countexpression_7c807cd) | Creates an aggregation that counts the number of stage inputs with valid evaluations of the provided field. -```typescript -// Count the total number of products -count("productId").as("totalProducts"); - -``` - | -| [exists(value)](./firestore_.md#exists_f83680a) | (BETA) Creates an expression that checks if a field exists. -```typescript -// Check if the document has a field named "phoneNumber" -exists(Field.of("phoneNumber")); - -``` - | -| [isNan(value)](./firestore_.md#isnan_f83680a) | (BETA) Creates an expression that checks if an expression evaluates to 'NaN' (Not a Number). -```typescript -// Check if the result of a calculation is NaN -isNaN(Field.of("value").divide(0)); - -``` - | -| [isNan(value)](./firestore_.md#isnan_7c807cd) | (BETA) Creates an expression that checks if a field's value evaluates to 'NaN' (Not a Number). -```typescript -// Check if the result of a calculation is NaN -isNaN("value"); - -``` - | -| [max(value)](./firestore_.md#max_f83680a) | (BETA) Creates an aggregation that finds the maximum value of an expression across multiple stage inputs. -```typescript -// Find the highest score in a leaderboard -max(Field.of("score")).as("highestScore"); - -``` - | -| [max(value)](./firestore_.md#max_7c807cd) | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. -```typescript -// Find the highest score in a leaderboard -max("score").as("highestScore"); - -``` - | -| [min(value)](./firestore_.md#min_f83680a) | (BETA) Creates an aggregation that finds the minimum value of an expression across multiple stage inputs. -```typescript -// Find the lowest price of all products -min(Field.of("price")).as("lowestPrice"); - -``` - | -| [min(value)](./firestore_.md#min_7c807cd) | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. -```typescript -// Find the lowest price of all products -min("price").as("lowestPrice"); - -``` - | -| [replaceAll(value, find, replace)](./firestore_.md#replaceall_f06d323) | (BETA) Creates an expression that replaces all occurrences of a substring within a string with another substring. -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field. -replaceAll(Field.of("message"), "hello", "hi"); - -``` - | -| [replaceAll(value, find, replace)](./firestore_.md#replaceall_26a7926) | (BETA) Creates an expression that replaces all occurrences of a substring within a string with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field. -replaceAll(Field.of("message"), Field.of("findField"), Field.of("replaceField")); - -``` - | -| [replaceFirst(value, find, replace)](./firestore_.md#replacefirst_f06d323) | (BETA) Creates an expression that replaces the first occurrence of a substring within a string with another substring. -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field. -replaceFirst(Field.of("message"), "hello", "hi"); - -``` - | -| [replaceFirst(value, find, replace)](./firestore_.md#replacefirst_26a7926) | (BETA) Creates an expression that replaces the first occurrence of a substring within a string with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field. -replaceFirst(Field.of("message"), Field.of("findField"), Field.of("replaceField")); - -``` - | -| [sumExpression(value)](./firestore_.md#sumexpression_f83680a) | (BETA) Creates an aggregation that calculates the sum of values from an expression across multiple stage inputs. -```typescript -// Calculate the total revenue from a set of orders -sum(Field.of("orderAmount")).as("totalRevenue"); - -``` - | -| [sumExpression(value)](./firestore_.md#sumexpression_7c807cd) | (BETA) Creates an aggregation that calculates the sum of a field's values across multiple stage inputs. -```typescript -// Calculate the total revenue from a set of orders -sum("orderAmount").as("totalRevenue"); - -``` - | -| function(values, ...) | -| [vector(values)](./firestore_.md#vector_0dbdaf2) | Creates a new VectorValue constructed with a copy of the given array of numbers. | - -## Classes - -| Class | Description | -| --- | --- | -| [Add](./firestore_.add.md#add_class) | (BETA) | -| [AddFields](./firestore_.addfields.md#addfields_class) | (BETA) | -| [Aggregate](./firestore_.aggregate.md#aggregate_class) | (BETA) | -| [AggregateField](./firestore_.aggregatefield.md#aggregatefield_class) | Represents an aggregation that can be performed by Firestore. | -| [AggregateQuerySnapshot](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshot_class) | The results of executing an aggregation query. | -| [And](./firestore_.and.md#and_class) | (BETA) | -| [ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) | (BETA) | -| [ArrayContains](./firestore_.arraycontains.md#arraycontains_class) | (BETA) | -| [ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) | (BETA) | -| [ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) | (BETA) | -| [ArrayElement](./firestore_.arrayelement.md#arrayelement_class) | (BETA) | -| [ArrayLength](./firestore_.arraylength.md#arraylength_class) | (BETA) | -| [ArrayReverse](./firestore_.arrayreverse.md#arrayreverse_class) | (BETA) | -| [Avg](./firestore_.avg.md#avg_class) | (BETA) | -| [ByteLength](./firestore_.bytelength.md#bytelength_class) | (BETA) | -| [Bytes](./firestore_.bytes.md#bytes_class) | An immutable object representing an array of bytes. | -| [CharLength](./firestore_.charlength.md#charlength_class) | (BETA) | -| [CollectionGroupSource](./firestore_.collectiongroupsource.md#collectiongroupsource_class) | (BETA) | -| [CollectionReference](./firestore_.collectionreference.md#collectionreference_class) | A CollectionReference object can be used for adding documents, getting document references, and querying for documents (using [query()](./firestore_.md#query_9f7b0f4)). | -| [CollectionSource](./firestore_.collectionsource.md#collectionsource_class) | (BETA) | -| [Constant](./firestore_.constant.md#constant_class) | (BETA) Represents a constant value that can be used in a Firestore pipeline expression.You can create a Constant instance using the static method: -```typescript -// Create a Constant instance for the number 10 -const ten = Constant.of(10); - -// Create a Constant instance for the string "hello" -const hello = Constant.of("hello"); - -``` - | -| [CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) | (BETA) | -| [Count](./firestore_.count.md#count_class) | (BETA) | -| [DatabaseSource](./firestore_.databasesource.md#databasesource_class) | (BETA) | -| [Distinct](./firestore_.distinct.md#distinct_class) | (BETA) | -| [Divide](./firestore_.divide.md#divide_class) | (BETA) | -| [DocumentReference](./firestore_.documentreference.md#documentreference_class) | A DocumentReference refers to a document location in a Firestore database and can be used to write, read, or listen to the location. The document at the referenced location may or may not exist. | -| [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class) | A DocumentSnapshot contains data read from a document in your Firestore database. The data can be extracted with .data() or .get(<field>) to get a specific field.For a DocumentSnapshot that points to a non-existing document, any data access will return 'undefined'. You can use the exists() method to explicitly verify a document's existence. | -| [DocumentsSource](./firestore_.documentssource.md#documentssource_class) | (BETA) | -| [DotProduct](./firestore_.dotproduct.md#dotproduct_class) | (BETA) | -| [EndsWith](./firestore_.endswith.md#endswith_class) | (BETA) | -| [Eq](./firestore_.eq.md#eq_class) | (BETA) | -| [EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) | (BETA) | -| [Exists](./firestore_.exists.md#exists_class) | (BETA) | -| [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) | (BETA) | -| [Field](./firestore_.field.md#field_class) | (BETA) Represents a reference to a field in a Firestore document, or outputs of a [Pipeline](./firestore_.pipeline.md#pipeline_class) stage.

Field references are used to access document field values in expressions and to specify fields for sorting, filtering, and projecting data in Firestore pipelines.

You can create a Field instance using the static method: -```typescript -// Create a Field instance for the 'name' field -const nameField = Field.of("name"); - -// Create a Field instance for a nested field 'address.city' -const cityField = Field.of("address.city"); - -``` - | -| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | A FieldPath refers to a field in a document. The path may consist of a single field name (referring to a top-level field in the document), or a list of field names (referring to a nested field in the document).Create a FieldPath by providing field names. If more than one field name is provided, the path will point to a nested field in a document. | -| [Fields](./firestore_.fields.md#fields_class) | (BETA) | -| [FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) | Sentinel values that can be used when writing document fields with set() or update(). | -| [FindNearest](./firestore_.findnearest.md#findnearest_class) | (BETA) | -| [Firestore](./firestore_.firestore.md#firestore_class) | The Cloud Firestore service interface.Do not call this constructor directly. Instead, use [getFirestore()](./firestore_.md#getfirestore). | -| [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) | An error returned by a Firestore operation. | -| [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) | (BETA) This class defines the base class for Firestore [Pipeline](./firestore_.pipeline.md#pipeline_class) functions, which can be evaluated within pipeline execution.Typically, you would not use this class or its children directly. Use either the functions like , , or the methods on (, , etc) to construct new Function instances. | -| [GenericStage](./firestore_.genericstage.md#genericstage_class) | (BETA) | -| [GeoPoint](./firestore_.geopoint.md#geopoint_class) | An immutable object representing a geographic location in Firestore. The location is represented as latitude/longitude pair.Latitude values are in the range of \[-90, 90\]. Longitude values are in the range of \[-180, 180\]. | -| [Gt](./firestore_.gt.md#gt_class) | (BETA) | -| [Gte](./firestore_.gte.md#gte_class) | (BETA) | -| [If](./firestore_.if.md#if_class) | (BETA) | -| [In](./firestore_.in.md#in_class) | (BETA) | -| [IsNan](./firestore_.isnan.md#isnan_class) | (BETA) | -| [Like](./firestore_.like.md#like_class) | (BETA) | -| [Limit](./firestore_.limit.md#limit_class) | (BETA) | -| [LoadBundleTask](./firestore_.loadbundletask.md#loadbundletask_class) | Represents the task of loading a Firestore bundle. It provides progress of bundle loading, as well as task completion and error events.The API is compatible with Promise<LoadBundleTaskProgress>. | -| [LogicalMax](./firestore_.logicalmax.md#logicalmax_class) | (BETA) | -| [LogicalMin](./firestore_.logicalmin.md#logicalmin_class) | (BETA) | -| [Lt](./firestore_.lt.md#lt_class) | (BETA) | -| [Lte](./firestore_.lte.md#lte_class) | (BETA) | -| [MapGet](./firestore_.mapget.md#mapget_class) | (BETA) | -| [Max](./firestore_.max.md#max_class) | (BETA) | -| [Min](./firestore_.min.md#min_class) | (BETA) | -| [Mod](./firestore_.mod.md#mod_class) | (BETA) | -| [Multiply](./firestore_.multiply.md#multiply_class) | (BETA) | -| [Neq](./firestore_.neq.md#neq_class) | (BETA) | -| [Not](./firestore_.not.md#not_class) | (BETA) | -| [Offset](./firestore_.offset.md#offset_class) | (BETA) | -| [Or](./firestore_.or.md#or_class) | (BETA) | -| [Ordering](./firestore_.ordering.md#ordering_class) | (BETA) Represents an ordering criterion for sorting documents in a Firestore pipeline.You create Ordering instances using the ascending and descending helper functions. | -| [PersistentCacheIndexManager](./firestore_.persistentcacheindexmanager.md#persistentcacheindexmanager_class) | A PersistentCacheIndexManager for configuring persistent cache indexes used for local query execution.To use, call getPersistentCacheIndexManager() to get an instance. | -| [Pipeline](./firestore_.pipeline.md#pipeline_class) | | -| [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) | (BETA) A PipelineResult contains data read from a Firestore Pipeline. The data can be extracted with the or methods.

If the PipelineResult represents a non-document result, ref will return a undefined value. | -| [PipelineSource](./firestore_.pipelinesource.md#pipelinesource_class) | (BETA) Represents the source of a Firestore [Pipeline](./firestore_.pipeline.md#pipeline_class). | -| [Query](./firestore_.query.md#query_class) | A Query refers to a query which you can read or listen to. You can also construct refined Query objects by adding filters and ordering. | -| [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) | A QueryCompositeFilterConstraint is used to narrow the set of documents returned by a Firestore query by performing the logical OR or AND of multiple [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class)s or [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class)s. QueryCompositeFilterConstraints are created by invoking or and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the QueryCompositeFilterConstraint. | -| [QueryConstraint](./firestore_.queryconstraint.md#queryconstraint_class) | A QueryConstraint is used to narrow the set of documents returned by a Firestore query. QueryConstraints are created by invoking [where()](./firestore_.md#where_0fae4bf), [orderBy()](./firestore_.md#orderby_006d61f), [startAt()](./firestore_.md#startat_9a4477f), [startAfter()](./firestore_.md#startafter_9a4477f), [endBefore()](./firestore_.md#endbefore_9a4477f), [endAt()](./firestore_.md#endat_9a4477f), [limit()](./firestore_.md#limit_ec46c78), [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryConstraint. | -| [QueryDocumentSnapshot](./firestore_.querydocumentsnapshot.md#querydocumentsnapshot_class) | A QueryDocumentSnapshot contains data read from a document in your Firestore database as part of a query. The document is guaranteed to exist and its data can be extracted with .data() or .get(<field>) to get a specific field.A QueryDocumentSnapshot offers the same API surface as a DocumentSnapshot. Since query results contain only existing documents, the exists property will always be true and data() will never return 'undefined'. | -| [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) | A QueryEndAtConstraint is used to exclude documents from the end of a result set returned by a Firestore query. QueryEndAtConstraints are created by invoking [endAt()](./firestore_.md#endat_9a4477f) or [endBefore()](./firestore_.md#endbefore_9a4477f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryEndAtConstraint. | -| [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) | A QueryFieldFilterConstraint is used to narrow the set of documents returned by a Firestore query by filtering on one or more document fields. QueryFieldFilterConstraints are created by invoking [where()](./firestore_.md#where_0fae4bf) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryFieldFilterConstraint. | -| [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) | A QueryLimitConstraint is used to limit the number of documents returned by a Firestore query. QueryLimitConstraints are created by invoking [limit()](./firestore_.md#limit_ec46c78) or [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryLimitConstraint. | -| [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) | A QueryOrderByConstraint is used to sort the set of documents returned by a Firestore query. QueryOrderByConstraints are created by invoking [orderBy()](./firestore_.md#orderby_006d61f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryOrderByConstraint.Note: Documents that do not contain the orderBy field will not be present in the query result. | -| [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class) | A QuerySnapshot contains zero or more DocumentSnapshot objects representing the results of a query. The documents can be accessed as an array via the docs property or enumerated using the forEach method. The number of documents can be determined via the empty and size properties. | -| [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) | A QueryStartAtConstraint is used to exclude documents from the start of a result set returned by a Firestore query. QueryStartAtConstraints are created by invoking [startAt()](./firestore_.md#startat_9a4477f) or [startAfter()](./firestore_.md#startafter_9a4477f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryStartAtConstraint. | -| [RegexContains](./firestore_.regexcontains.md#regexcontains_class) | (BETA) | -| [RegexMatch](./firestore_.regexmatch.md#regexmatch_class) | (BETA) | -| [ReplaceAll](./firestore_.replaceall.md#replaceall_class) | (BETA) | -| [ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) | (BETA) | -| [Reverse](./firestore_.reverse.md#reverse_class) | (BETA) | -| [Select](./firestore_.select.md#select_class) | (BETA) | -| [SnapshotMetadata](./firestore_.snapshotmetadata.md#snapshotmetadata_class) | Metadata about a snapshot, describing the state of the snapshot. | -| [Sort](./firestore_.sort.md#sort_class) | (BETA) | -| [StartsWith](./firestore_.startswith.md#startswith_class) | (BETA) | -| [StrConcat](./firestore_.strconcat.md#strconcat_class) | (BETA) | -| [StrContains](./firestore_.strcontains.md#strcontains_class) | (BETA) | -| [Subtract](./firestore_.subtract.md#subtract_class) | (BETA) | -| [Sum](./firestore_.sum.md#sum_class) | (BETA) | -| [Timestamp](./firestore_.timestamp.md#timestamp_class) | A Timestamp represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time.It is encoded using the Proleptic Gregorian Calendar which extends the Gregorian calendar backwards to year one. It is encoded assuming all minutes are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.For examples and further specifications, refer to the [Timestamp definition](https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto). | -| [TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) | (BETA) | -| [TimestampSub](./firestore_.timestampsub.md#timestampsub_class) | (BETA) | -| [TimestampToUnixMicros](./firestore_.timestamptounixmicros.md#timestamptounixmicros_class) | (BETA) | -| [TimestampToUnixMillis](./firestore_.timestamptounixmillis.md#timestamptounixmillis_class) | (BETA) | -| [TimestampToUnixSeconds](./firestore_.timestamptounixseconds.md#timestamptounixseconds_class) | (BETA) | -| [ToLower](./firestore_.tolower.md#tolower_class) | (BETA) | -| [ToUpper](./firestore_.toupper.md#toupper_class) | (BETA) | -| [Transaction](./firestore_.transaction.md#transaction_class) | A reference to a transaction.The Transaction object passed to a transaction's updateFunction provides the methods to read and write data within the transaction context. See [runTransaction()](./firestore_.md#runtransaction_6f03ec4). | -| [Trim](./firestore_.trim.md#trim_class) | (BETA) | -| [UnixMicrosToTimestamp](./firestore_.unixmicrostotimestamp.md#unixmicrostotimestamp_class) | (BETA) | -| [UnixMillisToTimestamp](./firestore_.unixmillistotimestamp.md#unixmillistotimestamp_class) | (BETA) | -| [UnixSecondsToTimestamp](./firestore_.unixsecondstotimestamp.md#unixsecondstotimestamp_class) | (BETA) | -| [VectorLength](./firestore_.vectorlength.md#vectorlength_class) | (BETA) | -| [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | Represents a vector type in Firestore documents. Create an instance with . VectorValue | -| [Where](./firestore_.where.md#where_class) | (BETA) | -| [WriteBatch](./firestore_.writebatch.md#writebatch_class) | A write batch, used to perform multiple writes as a single atomic unit.A WriteBatch object can be acquired by calling [writeBatch()](./firestore_.md#writebatch_231a8e0). It provides methods for adding writes to the write batch. None of the writes will be committed (or visible locally) until [WriteBatch.commit()](./firestore_.writebatch.md#writebatchcommit) is called. | -| [Xor](./firestore_.xor.md#xor_class) | (BETA) | - -## Interfaces - -| Interface | Description | -| --- | --- | -| [Accumulator](./firestore_.accumulator.md#accumulator_interface) | (BETA) An interface that represents an accumulator. | -| [AggregateSpec](./firestore_.aggregatespec.md#aggregatespec_interface) | Specifies a set of aggregations and their aliases. | -| [DocumentChange](./firestore_.documentchange.md#documentchange_interface) | A DocumentChange represents a change to the documents matching a query. It contains the document affected and the type of change that occurred. | -| [DocumentData](./firestore_.documentdata.md#documentdata_interface) | Document data (for use with [setDoc()](./firestore_lite.md#setdoc_ee215ad)) consists of fields mapped to values. | -| [ExperimentalLongPollingOptions](./firestore_.experimentallongpollingoptions.md#experimentallongpollingoptions_interface) | Options that configure the SDK’s underlying network transport (WebChannel) when long-polling is used.Note: This interface is "experimental" and is subject to change.See FirestoreSettings.experimentalAutoDetectLongPolling, FirestoreSettings.experimentalForceLongPolling, and FirestoreSettings.experimentalLongPollingOptions. | -| [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) | (BETA) An interface that represents a filter condition. | -| [FindNearestOptions](./firestore_.findnearestoptions.md#findnearestoptions_interface) | (BETA) | -| [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface) | Converter used by withConverter() to transform user objects of type AppModelType into Firestore data of type DbModelType.Using the converter allows you to specify generic type arguments when storing and retrieving objects from Firestore.In this context, an "AppModel" is a class that is used in an application to package together related information and functionality. Such a class could, for example, have properties with complex, nested data types, properties used for memoization, properties of types not supported by Firestore (such as symbol and bigint), and helper functions that perform compound operations. Such classes are not suitable and/or possible to store into a Firestore database. Instead, instances of such classes need to be converted to "plain old JavaScript objects" (POJOs) with exclusively primitive properties, potentially nested inside other POJOs or arrays of POJOs. In this context, this type is referred to as the "DbModel" and would be an object suitable for persisting into Firestore. For convenience, applications can implement FirestoreDataConverter and register the converter with Firestore objects, such as DocumentReference or Query, to automatically convert AppModel to DbModel when storing into Firestore, and convert DbModel to AppModel when retrieving from Firestore. | -| [FirestoreSettings](./firestore_.firestoresettings.md#firestoresettings_interface) | Specifies custom configurations for your Cloud Firestore instance. You must set these before invoking any other methods. | -| [Index](./firestore_.index.md#index_interface) | (BETA) The SDK definition of a Firestore index. | -| [IndexConfiguration](./firestore_.indexconfiguration.md#indexconfiguration_interface) | (BETA) A list of Firestore indexes to speed up local query execution.See [JSON Format](https://firebase.google.com/docs/reference/firestore/indexes/#json_format) for a description of the format of the index definition. | -| [IndexField](./firestore_.indexfield.md#indexfield_interface) | (BETA) A single field element in an index configuration. | -| [LoadBundleTaskProgress](./firestore_.loadbundletaskprogress.md#loadbundletaskprogress_interface) | Represents a progress update or a final state from loading bundles. | -| [MemoryCacheSettings](./firestore_.memorycachesettings.md#memorycachesettings_interface) | An settings object to configure an MemoryLocalCache instance. | -| [MemoryEagerGarbageCollector](./firestore_.memoryeagergarbagecollector.md#memoryeagergarbagecollector_interface) | A garbage collector deletes documents whenever they are not part of any active queries, and have no local mutations attached to them.This collector tries to ensure lowest memory footprints from the SDK, at the risk of documents not being cached for offline queries or for direct queries to the cache.Use factory function to create an instance of this collector. | -| [MemoryLocalCache](./firestore_.memorylocalcache.md#memorylocalcache_interface) | Provides an in-memory cache to the SDK. This is the default cache unless explicitly configured otherwise.To use, create an instance using the factory function , then set the instance to FirestoreSettings.cache and call initializeFirestore using the settings object. | -| [MemoryLruGarbageCollector](./firestore_.memorylrugarbagecollector.md#memorylrugarbagecollector_interface) | A garbage collector deletes Least-Recently-Used documents in multiple batches.This collector is configured with a target size, and will only perform collection when the cached documents exceed the target size. It avoids querying backend repeated for the same query or document, at the risk of having a larger memory footprint.Use factory function to create a instance of this collector. | -| [PersistenceSettings](./firestore_.persistencesettings.md#persistencesettings_interface) | Settings that can be passed to enableIndexedDbPersistence() to configure Firestore persistence.Persistence cannot be used in a Node.js environment. | -| [PersistentCacheSettings](./firestore_.persistentcachesettings.md#persistentcachesettings_interface) | An settings object to configure an PersistentLocalCache instance.Persistent cache cannot be used in a Node.js environment. | -| [PersistentLocalCache](./firestore_.persistentlocalcache.md#persistentlocalcache_interface) | Provides a persistent cache backed by IndexedDb to the SDK.To use, create an instance using the factory function , then set the instance to FirestoreSettings.cache and call initializeFirestore using the settings object. | -| [PersistentMultipleTabManager](./firestore_.persistentmultipletabmanager.md#persistentmultipletabmanager_interface) | A tab manager supporting multiple tabs. SDK will synchronize queries and mutations done across all tabs using the SDK. | -| [PersistentSingleTabManager](./firestore_.persistentsingletabmanager.md#persistentsingletabmanager_interface) | A tab manager supporting only one tab, no synchronization will be performed across tabs. | -| [PersistentSingleTabManagerSettings](./firestore_.persistentsingletabmanagersettings.md#persistentsingletabmanagersettings_interface) | Type to configure an PersistentSingleTabManager instance. | -| [Selectable](./firestore_.selectable.md#selectable_interface) | (BETA) An interface that represents a selectable expression. | -| [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | An options object that can be passed to [onSnapshot()](./firestore_.md#onsnapshot_0312fd7) and [QuerySnapshot.docChanges()](./firestore_.querysnapshot.md#querysnapshotdocchanges) to control which types of changes to include in the result set. | -| [SnapshotOptions](./firestore_.snapshotoptions.md#snapshotoptions_interface) | Options that configure how data is retrieved from a DocumentSnapshot (for example the desired behavior for server timestamps that have not yet been set to their final value). | -| [Stage](./firestore_.stage.md#stage_interface) | (BETA) | -| [TransactionOptions](./firestore_.transactionoptions.md#transactionoptions_interface) | Options to customize transaction behavior. | -| [Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) | A function returned by onSnapshot() that removes the listener when invoked. | - -## Namespaces - -| Namespace | Description | -| --- | --- | -| [and](./firestore_.and.md#and_namespace) | | -| [or](./firestore_.or.md#or_namespace) | | - -## Variables - -| Variable | Description | -| --- | --- | -| [CACHE\_SIZE\_UNLIMITED](./firestore_.md#cache_size_unlimited) | Constant used to indicate the LRU garbage collection should be disabled. Set this value as the cacheSizeBytes on the settings passed to the [Firestore](./firestore_.firestore.md#firestore_class) instance. | - -## Type Aliases - -| Type Alias | Description | -| --- | --- | -| [AccumulatorTarget](./firestore_.md#accumulatortarget) | (BETA) An accumulator target, which is an expression with an alias that also implements the Accumulator interface. | -| [AddPrefixToKeys](./firestore_.md#addprefixtokeys) | Returns a new map where every key is prefixed with the outer key appended to a dot. | -| [AggregateFieldType](./firestore_.md#aggregatefieldtype) | The union of all AggregateField types that are supported by Firestore. | -| [AggregateSpecData](./firestore_.md#aggregatespecdata) | A type whose keys are taken from an AggregateSpec, and whose values are the result of the aggregation performed by the corresponding AggregateField from the input AggregateSpec. | -| [AggregateType](./firestore_.md#aggregatetype) | Union type representing the aggregate type to be performed. | -| [ChildUpdateFields](./firestore_.md#childupdatefields) | Helper for calculating the nested fields for a given type T1. This is needed to distribute union types such as undefined | {...} (happens for optional props) or {a: A} | {b: B}.In this use case, V is used to distribute the union types of T[K] on Record, since T[K] is evaluated as an expression and not distributed.See https://www.typescriptlang.org/docs/handbook/advanced-types.html\#distributive-conditional-types | -| [DocumentChangeType](./firestore_.md#documentchangetype) | The type of a DocumentChange may be 'added', 'removed', or 'modified'. | -| [ExprType](./firestore_.md#exprtype) | (BETA) An enumeration of the different types of expressions. | -| [FilterExpr](./firestore_.md#filterexpr) | (BETA) A filter expression, which is an expression that also implements the FilterCondition interface. | -| [FirestoreErrorCode](./firestore_.md#firestoreerrorcode) | The set of Firestore status codes. The codes are the same at the ones exposed by gRPC here: https://github.com/grpc/grpc/blob/master/doc/statuscodes.mdPossible values: - 'cancelled': The operation was cancelled (typically by the caller). - 'unknown': Unknown error or an error from a different error domain. - 'invalid-argument': Client specified an invalid argument. Note that this differs from 'failed-precondition'. 'invalid-argument' indicates arguments that are problematic regardless of the state of the system (e.g. an invalid field name). - 'deadline-exceeded': Deadline expired before operation could complete. For operations that change the state of the system, this error may be returned even if the operation has completed successfully. For example, a successful response from a server could have been delayed long enough for the deadline to expire. - 'not-found': Some requested document was not found. - 'already-exists': Some document that we attempted to create already exists. - 'permission-denied': The caller does not have permission to execute the specified operation. - 'resource-exhausted': Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space. - 'failed-precondition': Operation was rejected because the system is not in a state required for the operation's execution. - 'aborted': The operation was aborted, typically due to a concurrency issue like transaction aborts, etc. - 'out-of-range': Operation was attempted past the valid range. - 'unimplemented': Operation is not implemented or not supported/enabled. - 'internal': Internal errors. Means some invariants expected by underlying system has been broken. If you see one of these errors, something is very broken. - 'unavailable': The service is currently unavailable. This is most likely a transient condition and may be corrected by retrying with a backoff. - 'data-loss': Unrecoverable data loss or corruption. - 'unauthenticated': The request does not have valid authentication credentials for the operation. | -| [FirestoreLocalCache](./firestore_.md#firestorelocalcache) | Union type from all supported SDK cache layer. | -| [ListenSource](./firestore_.md#listensource) | Describe the source a query listens to.Set to default to listen to both cache and server changes. Set to cache to listen to changes in cache only. | -| [MemoryGarbageCollector](./firestore_.md#memorygarbagecollector) | Union type from all support garbage collectors for memory local cache. | -| [NestedUpdateFields](./firestore_.md#nestedupdatefields) | For each field (e.g. 'bar'), find all nested keys (e.g. {'bar.baz': T1, 'bar.qux': T2}). Intersect them together to make a single map containing all possible keys that are all marked as optional | -| [OrderByDirection](./firestore_.md#orderbydirection) | The direction of a [orderBy()](./firestore_.md#orderby_006d61f) clause is specified as 'desc' or 'asc' (descending or ascending). | -| [PartialWithFieldValue](./firestore_.md#partialwithfieldvalue) | Similar to TypeScript's Partial<T>, but allows nested fields to be omitted and FieldValues to be passed in as property values. | -| [PersistentTabManager](./firestore_.md#persistenttabmanager) | A union of all available tab managers. | -| [Primitive](./firestore_.md#primitive) | Primitive types. | -| [QueryConstraintType](./firestore_.md#queryconstrainttype) | Describes the different query constraints available in this SDK. | -| [QueryFilterConstraint](./firestore_.md#queryfilterconstraint) | QueryFilterConstraint is a helper union type that represents [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) and [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). | -| [QueryNonFilterConstraint](./firestore_.md#querynonfilterconstraint) | QueryNonFilterConstraint is a helper union type that represents QueryConstraints which are used to narrow or order the set of documents, but that do not explicitly filter on a document field. QueryNonFilterConstraints are created by invoking [orderBy()](./firestore_.md#orderby_006d61f), [startAt()](./firestore_.md#startat_9a4477f), [startAfter()](./firestore_.md#startafter_9a4477f), [endBefore()](./firestore_.md#endbefore_9a4477f), [endAt()](./firestore_.md#endat_9a4477f), [limit()](./firestore_.md#limit_ec46c78) or [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the QueryConstraint. | -| [SelectableExpr](./firestore_.md#selectableexpr) | (BETA) A selectable expression, which is an expression that also implements the Selectable interface. | -| [SetOptions](./firestore_.md#setoptions) | An options object that configures the behavior of [setDoc()](./firestore_lite.md#setdoc_ee215ad), and calls. These calls can be configured to perform granular merges instead of overwriting the target documents in their entirety by providing a SetOptions with merge: true. | -| [TaskState](./firestore_.md#taskstate) | Represents the state of bundle loading tasks.Both 'Error' and 'Success' are sinking state: task will abort or complete and there will be no more updates after they are reported. | -| [UnionToIntersection](./firestore_.md#uniontointersection) | Given a union type U = T1 | T2 | ..., returns an intersected type (T1 & T2 & ...).Uses distributive conditional types and inference from conditional types. This works because multiple candidates for the same type variable in contra-variant positions causes an intersection type to be inferred. https://www.typescriptlang.org/docs/handbook/advanced-types.html\#type-inference-in-conditional-types https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type | -| [UpdateData](./firestore_.md#updatedata) | Update data (for use with [updateDoc()](./firestore_.md#updatedoc_51a65e3)) that consists of field paths (e.g. 'foo' or 'foo.baz') mapped to values. Fields that contain dots reference nested fields within the document. FieldValues can be passed in as property values. | -| [WhereFilterOp](./firestore_.md#wherefilterop) | Filter conditions in a [where()](./firestore_.md#where_0fae4bf) clause are specified using the strings '&lt;', '&lt;=', '==', '!=', '&gt;=', '&gt;', 'array-contains', 'in', 'array-contains-any', and 'not-in'. | -| [WithFieldValue](./firestore_.md#withfieldvalue) | Allows FieldValues to be passed in as a property value while maintaining type safety. | - -## function(app, ...) - -### getFirestore(app) {:#getfirestore_cf608e1} - -Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. - -Signature: - -```typescript -export declare function getFirestore(app: FirebaseApp): Firestore; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) instance that the returned [Firestore](./firestore_.firestore.md#firestore_class) instance is associated with. | - -Returns: - -[Firestore](./firestore_.firestore.md#firestore_class) - -The default [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. - -### getFirestore(app, databaseId) {:#getfirestore_48de6cb} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Returns the existing named [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. - -Signature: - -```typescript -export declare function getFirestore(app: FirebaseApp, databaseId: string): Firestore; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) instance that the returned [Firestore](./firestore_.firestore.md#firestore_class) instance is associated with. | -| databaseId | string | The name of the database. | - -Returns: - -[Firestore](./firestore_.firestore.md#firestore_class) - -The named [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. - -### initializeFirestore(app, settings, databaseId) {:#initializefirestore_fc7d200} - -Initializes a new instance of [Firestore](./firestore_.firestore.md#firestore_class) with the provided settings. Can only be called before any other function, including [getFirestore()](./firestore_.md#getfirestore). If the custom settings are empty, this function is equivalent to calling [getFirestore()](./firestore_.md#getfirestore). - -Signature: - -```typescript -export declare function initializeFirestore(app: FirebaseApp, settings: FirestoreSettings, databaseId?: string): Firestore; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) with which the [Firestore](./firestore_.firestore.md#firestore_class) instance will be associated. | -| settings | [FirestoreSettings](./firestore_.firestoresettings.md#firestoresettings_interface) | A settings object to configure the [Firestore](./firestore_.firestore.md#firestore_class) instance. | -| databaseId | string | The name of the database. | - -Returns: - -[Firestore](./firestore_.firestore.md#firestore_class) - -A newly initialized [Firestore](./firestore_.firestore.md#firestore_class) instance. - -## function(firestore, ...) - -### clearIndexedDbPersistence(firestore) {:#clearindexeddbpersistence_231a8e0} - -Clears the persistent storage. This includes pending writes and cached documents. - -Must be called while the [Firestore](./firestore_.firestore.md#firestore_class) instance is not started (after the app is terminated or when the app is first initialized). On startup, this function must be called before other functions (other than [initializeFirestore()](./firestore_.md#initializefirestore_fc7d200) or [getFirestore()](./firestore_.md#getfirestore))). If the [Firestore](./firestore_.firestore.md#firestore_class) instance is still running, the promise will be rejected with the error code of `failed-precondition`. - -Note: `clearIndexedDbPersistence()` is primarily intended to help write reliable tests that use Cloud Firestore. It uses an efficient mechanism for dropping existing data but does not attempt to securely overwrite or otherwise make cached data unrecoverable. For applications that are sensitive to the disclosure of cached data in between user sessions, we strongly recommend not enabling persistence at all. - -Signature: - -```typescript -export declare function clearIndexedDbPersistence(firestore: Firestore): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to clear persistence for. | - -Returns: - -Promise<void> - -A `Promise` that is resolved when the persistent storage is cleared. Otherwise, the promise is rejected with an error. - -### collection(firestore, path, pathSegments) {:#collection_1eb4c23} - -Gets a `CollectionReference` instance that refers to the collection at the specified absolute path. - -Signature: - -```typescript -export declare function collection(firestore: Firestore, path: string, ...pathSegments: string[]): CollectionReference; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | A reference to the root Firestore instance. | -| path | string | A slash-separated path to a collection. | -| pathSegments | string\[\] | Additional path segments to apply relative to the first argument. | - -Returns: - -[CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> - -The `CollectionReference` instance. - -#### Exceptions - -If the final path has an even number of segments and does not point to a collection. - -### collectionGroup(firestore, collectionId) {:#collectiongroup_1838fc3} - -Creates and returns a new `Query` instance that includes all documents in the database that are contained in a collection or subcollection with the given `collectionId`. - -Signature: - -```typescript -export declare function collectionGroup(firestore: Firestore, collectionId: string): Query; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | A reference to the root Firestore instance. | -| collectionId | string | Identifies the collections to query over. Every collection or subcollection with this ID as the last segment of its path will be included. Cannot contain a slash. | - -Returns: - -[Query](./firestore_.query.md#query_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> - -The created `Query`. - -### connectFirestoreEmulator(firestore, host, port, options) {:#connectfirestoreemulator_7c247cd} - -Modify this instance to communicate with the Cloud Firestore emulator. - -Note: This must be called before this instance has been used to do any operations. - -Signature: - -```typescript -export declare function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: { - mockUserToken?: EmulatorMockTokenOptions | string; -}): void; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The Firestore instance to configure to connect to the emulator. | -| host | string | the emulator host (ex: localhost). | -| port | number | the emulator port (ex: 9000). | -| options | { mockUserToken?: [EmulatorMockTokenOptions](./util.md#emulatormocktokenoptions) \| string; } | | - -Returns: - -void - -### disableNetwork(firestore) {:#disablenetwork_231a8e0} - -Disables network usage for this instance. It can be re-enabled via [enableNetwork()](./firestore_.md#enablenetwork_231a8e0). While the network is disabled, any snapshot listeners, `getDoc()` or `getDocs()` calls will return results from cache, and any write operations will be queued until the network is restored. - -Signature: - -```typescript -export declare function disableNetwork(firestore: Firestore): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | - -Returns: - -Promise<void> - -A `Promise` that is resolved once the network has been disabled. - -### doc(firestore, path, pathSegments) {:#doc_1eb4c23} - -Gets a `DocumentReference` instance that refers to the document at the specified absolute path. - -Signature: - -```typescript -export declare function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | A reference to the root Firestore instance. | -| path | string | A slash-separated path to a document. | -| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | - -Returns: - -[DocumentReference](./firestore_.documentreference.md#documentreference_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> - -The `DocumentReference` instance. - -#### Exceptions - -If the final path has an odd number of segments and does not point to a document. - -### enableIndexedDbPersistence(firestore, persistenceSettings) {:#enableindexeddbpersistence_224174f} - -> Warning: This API is now obsolete. -> -> This function will be removed in a future major release. Instead, set `FirestoreSettings.localCache` to an instance of `PersistentLocalCache` to turn on IndexedDb cache. Calling this function when `FirestoreSettings.localCache` is already specified will throw an exception. -> - -Attempts to enable persistent storage, if possible. - -On failure, `enableIndexedDbPersistence()` will reject the promise or throw an exception. There are several reasons why this can fail, which can be identified by the `code` on the error. - -\* failed-precondition: The app is already open in another browser tab. \* unimplemented: The browser is incompatible with the offline persistence implementation. - -Note that even after a failure, the [Firestore](./firestore_.firestore.md#firestore_class) instance will remain usable, however offline persistence will be disabled. - -Note: `enableIndexedDbPersistence()` must be called before any other functions (other than [initializeFirestore()](./firestore_.md#initializefirestore_fc7d200), [getFirestore()](./firestore_.md#getfirestore) or [clearIndexedDbPersistence()](./firestore_.md#clearindexeddbpersistence_231a8e0). - -Persistence cannot be used in a Node.js environment. - -Signature: - -```typescript -export declare function enableIndexedDbPersistence(firestore: Firestore, persistenceSettings?: PersistenceSettings): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to enable persistence for. | -| persistenceSettings | [PersistenceSettings](./firestore_.persistencesettings.md#persistencesettings_interface) | Optional settings object to configure persistence. | - -Returns: - -Promise<void> - -A `Promise` that represents successfully enabling persistent storage. - -### enableMultiTabIndexedDbPersistence(firestore) {:#enablemultitabindexeddbpersistence_231a8e0} - -> Warning: This API is now obsolete. -> -> This function will be removed in a future major release. Instead, set `FirestoreSettings.localCache` to an instance of `PersistentLocalCache` to turn on indexeddb cache. Calling this function when `FirestoreSettings.localCache` is already specified will throw an exception. -> - -Attempts to enable multi-tab persistent storage, if possible. If enabled across all tabs, all operations share access to local persistence, including shared execution of queries and latency-compensated local document updates across all connected instances. - -On failure, `enableMultiTabIndexedDbPersistence()` will reject the promise or throw an exception. There are several reasons why this can fail, which can be identified by the `code` on the error. - -\* failed-precondition: The app is already open in another browser tab and multi-tab is not enabled. \* unimplemented: The browser is incompatible with the offline persistence implementation. - -Note that even after a failure, the [Firestore](./firestore_.firestore.md#firestore_class) instance will remain usable, however offline persistence will be disabled. - -Signature: - -```typescript -export declare function enableMultiTabIndexedDbPersistence(firestore: Firestore): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to enable persistence for. | - -Returns: - -Promise<void> - -A `Promise` that represents successfully enabling persistent storage. - -### enableNetwork(firestore) {:#enablenetwork_231a8e0} - -Re-enables use of the network for this [Firestore](./firestore_.firestore.md#firestore_class) instance after a prior call to [disableNetwork()](./firestore_.md#disablenetwork_231a8e0). - -Signature: - -```typescript -export declare function enableNetwork(firestore: Firestore): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | - -Returns: - -Promise<void> - -A `Promise` that is resolved once the network has been enabled. - -### getPersistentCacheIndexManager(firestore) {:#getpersistentcacheindexmanager_231a8e0} - -Returns the PersistentCache Index Manager used by the given `Firestore` object. - - The `PersistentCacheIndexManager` instance, or `null` if local persistent storage is not in use. - -Signature: - -```typescript -export declare function getPersistentCacheIndexManager(firestore: Firestore): PersistentCacheIndexManager | null; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | - -Returns: - -[PersistentCacheIndexManager](./firestore_.persistentcacheindexmanager.md#persistentcacheindexmanager_class) \| null - -### loadBundle(firestore, bundleData) {:#loadbundle_bec5b75} - -Loads a Firestore bundle into the local cache. - -Signature: - -```typescript -export declare function loadBundle(firestore: Firestore, bundleData: ReadableStream | ArrayBuffer | string): LoadBundleTask; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to load bundles for. | -| bundleData | ReadableStream<Uint8Array> \| ArrayBuffer \| string | An object representing the bundle to be loaded. Valid objects are ArrayBuffer, ReadableStream<Uint8Array> or string. | - -Returns: - -[LoadBundleTask](./firestore_.loadbundletask.md#loadbundletask_class) - -A `LoadBundleTask` object, which notifies callers with progress updates, and completion or error events. It can be used as a `Promise`. - -### namedQuery(firestore, name) {:#namedquery_6438876} - -Reads a Firestore [Query](./firestore_.query.md#query_class) from local cache, identified by the given name. - -The named queries are packaged into bundles on the server side (along with resulting documents), and loaded to local cache using `loadBundle`. Once in local cache, use this method to extract a [Query](./firestore_.query.md#query_class) by name. - -Signature: - -```typescript -export declare function namedQuery(firestore: Firestore, name: string): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to read the query from. | -| name | string | The name of the query. | - -Returns: - -Promise<[Query](./firestore_.query.md#query_class) \| null> - -A `Promise` that is resolved with the Query or `null`. - -### onSnapshotsInSync(firestore, observer) {:#onsnapshotsinsync_2f0dfa4} - -Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if a single server-generated change affects multiple listeners. - -NOTE: The snapshots-in-sync event only indicates that listeners are in sync with each other, but does not relate to whether those snapshots are in sync with the server. Use SnapshotMetadata in the individual listeners to determine if a snapshot is from the cache or the server. - -Signature: - -```typescript -export declare function onSnapshotsInSync(firestore: Firestore, observer: { - next?: (value: void) => void; - error?: (error: FirestoreError) => void; - complete?: () => void; -}): Unsubscribe; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The instance of Firestore for synchronizing snapshots. | -| observer | { next?: (value: void) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | - -Returns: - -[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) - -An unsubscribe function that can be called to cancel the snapshot listener. - -### onSnapshotsInSync(firestore, onSync) {:#onsnapshotsinsync_1901c06} - -Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if a single server-generated change affects multiple listeners. - -NOTE: The snapshots-in-sync event only indicates that listeners are in sync with each other, but does not relate to whether those snapshots are in sync with the server. Use `SnapshotMetadata` in the individual listeners to determine if a snapshot is from the cache or the server. - -Signature: - -```typescript -export declare function onSnapshotsInSync(firestore: Firestore, onSync: () => void): Unsubscribe; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The Firestore instance for synchronizing snapshots. | -| onSync | () => void | A callback to be called every time all snapshot listeners are in sync with each other. | - -Returns: - -[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) - -An unsubscribe function that can be called to cancel the snapshot listener. - -### pipeline(firestore) {:#pipeline_231a8e0} - -Experimental Modular API for console testing. - -Signature: - -```typescript -export declare function pipeline(firestore: Firestore): PipelineSource; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | - -Returns: - -[PipelineSource](./firestore_.pipelinesource.md#pipelinesource_class) - -### runTransaction(firestore, updateFunction, options) {:#runtransaction_6f03ec4} - -Executes the given `updateFunction` and then attempts to commit the changes applied within the transaction. If any document read within the transaction has changed, Cloud Firestore retries the `updateFunction`. If it fails to commit after 5 attempts, the transaction fails. - -The maximum number of writes allowed in a single transaction is 500. - -Signature: - -```typescript -export declare function runTransaction(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise, options?: TransactionOptions): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | A reference to the Firestore database to run this transaction against. | -| updateFunction | (transaction: [Transaction](./firestore_.transaction.md#transaction_class)) => Promise<T> | The function to execute within the transaction context. | -| options | [TransactionOptions](./firestore_.transactionoptions.md#transactionoptions_interface) | An options object to configure maximum number of attempts to commit. | - -Returns: - -Promise<T> - -If the transaction completed successfully or was explicitly aborted (the `updateFunction` returned a failed promise), the promise returned by the `updateFunction `is returned here. Otherwise, if the transaction failed, a rejected promise with the corresponding failure error is returned. - -### setIndexConfiguration(firestore, configuration) {:#setindexconfiguration_c362f04} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -> Warning: This API is now obsolete. -> -> Instead of creating cache indexes manually, consider using `enablePersistentCacheIndexAutoCreation()` to let the SDK decide whether to create cache indexes for queries running locally. -> - -Configures indexing for local query execution. Any previous index configuration is overridden. The `Promise` resolves once the index configuration has been persisted. - -The index entries themselves are created asynchronously. You can continue to use queries that require indexing even if the indices are not yet available. Query execution will automatically start using the index once the index entries have been written. - -Indexes are only supported with IndexedDb persistence. If IndexedDb is not enabled, any index configuration is ignored. - -Signature: - -```typescript -export declare function setIndexConfiguration(firestore: Firestore, configuration: IndexConfiguration): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to configure indexes for. | -| configuration | [IndexConfiguration](./firestore_.indexconfiguration.md#indexconfiguration_interface) | The index definition. | - -Returns: - -Promise<void> - -A `Promise` that resolves once all indices are successfully configured. - -#### Exceptions - -FirestoreError if the JSON format is invalid. - -### setIndexConfiguration(firestore, json) {:#setindexconfiguration_90d0285} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -> Warning: This API is now obsolete. -> -> Instead of creating cache indexes manually, consider using `enablePersistentCacheIndexAutoCreation()` to let the SDK decide whether to create cache indexes for queries running locally. -> - -Configures indexing for local query execution. Any previous index configuration is overridden. The `Promise` resolves once the index configuration has been persisted. - -The index entries themselves are created asynchronously. You can continue to use queries that require indexing even if the indices are not yet available. Query execution will automatically start using the index once the index entries have been written. - -Indexes are only supported with IndexedDb persistence. Invoke either `enableIndexedDbPersistence()` or `enableMultiTabIndexedDbPersistence()` before setting an index configuration. If IndexedDb is not enabled, any index configuration is ignored. - -The method accepts the JSON format exported by the Firebase CLI (`firebase firestore:indexes`). If the JSON format is invalid, this method throws an error. - -Signature: - -```typescript -export declare function setIndexConfiguration(firestore: Firestore, json: string): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to configure indexes for. | -| json | string | The JSON format exported by the Firebase CLI. | - -Returns: - -Promise<void> - -A `Promise` that resolves once all indices are successfully configured. - -#### Exceptions - -FirestoreError if the JSON format is invalid. - -### terminate(firestore) {:#terminate_231a8e0} - -Terminates the provided [Firestore](./firestore_.firestore.md#firestore_class) instance. - -After calling `terminate()` only the `clearIndexedDbPersistence()` function may be used. Any other function will throw a `FirestoreError`. - -To restart after termination, create a new instance of FirebaseFirestore with [getFirestore()](./firestore_.md#getfirestore). - -Termination does not cancel any pending writes, and any promises that are awaiting a response from the server will not be resolved. If you have persistence enabled, the next time you start this instance, it will resume sending these writes to the server. - -Note: Under normal circumstances, calling `terminate()` is not required. This function is useful only when you want to force this instance to release all of its resources or in combination with `clearIndexedDbPersistence()` to ensure that all local state is destroyed between test runs. - -Signature: - -```typescript -export declare function terminate(firestore: Firestore): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | - -Returns: - -Promise<void> - -A `Promise` that is resolved when the instance has been successfully terminated. - -### waitForPendingWrites(firestore) {:#waitforpendingwrites_231a8e0} - -Waits until all currently pending writes for the active user have been acknowledged by the backend. - -The returned promise resolves immediately if there are no outstanding writes. Otherwise, the promise waits for all previously issued writes (including those written in a previous app session), but it does not wait for writes that were added after the function is called. If you want to wait for additional writes, call `waitForPendingWrites()` again. - -Any outstanding `waitForPendingWrites()` promises are rejected during user changes. - -Signature: - -```typescript -export declare function waitForPendingWrites(firestore: Firestore): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | - -Returns: - -Promise<void> - -A `Promise` which resolves when all currently pending writes have been acknowledged by the backend. - -### writeBatch(firestore) {:#writebatch_231a8e0} - -Creates a write batch, used for performing multiple writes as a single atomic operation. The maximum number of writes allowed in a single [WriteBatch](./firestore_.writebatch.md#writebatch_class) is 500. - -Unlike transactions, write batches are persisted offline and therefore are preferable when you don't need to condition your writes on read data. - -Signature: - -```typescript -export declare function writeBatch(firestore: Firestore): WriteBatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | - -Returns: - -[WriteBatch](./firestore_.writebatch.md#writebatch_class) - -A [WriteBatch](./firestore_.writebatch.md#writebatch_class) that can be used to atomically execute multiple writes. - -## function() - -### count() {:#count} - -Create an AggregateField object that can be used to compute the count of documents in the result set of a query. - -Signature: - -```typescript -export declare function count(): AggregateField; -``` -Returns: - -[AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<number> - -### countAll() {:#countall} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that counts the total number of stage inputs. - -```typescript -// Count the total number of users -countAll().as("totalUsers"); - -``` - A new representing the 'countAll' aggregation. - -Signature: - -```typescript -export declare function countAll(): Count; -``` -Returns: - -[Count](./firestore_.count.md#count_class) - -### deleteField() {:#deletefield} - -Returns a sentinel for use with [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) or [setDoc()](./firestore_lite.md#setdoc_ee215ad) with `{merge: true}` to mark a field for deletion. - -Signature: - -```typescript -export declare function deleteField(): FieldValue; -``` -Returns: - -[FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) - -### documentId() {:#documentid} - -Returns a special sentinel `FieldPath` to refer to the ID of a document. It can be used in queries to sort or filter by the document ID. - -Signature: - -```typescript -export declare function documentId(): FieldPath; -``` -Returns: - -[FieldPath](./firestore_.fieldpath.md#fieldpath_class) - -### getFirestore() {:#getfirestore} - -Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. - -Signature: - -```typescript -export declare function getFirestore(): Firestore; -``` -Returns: - -[Firestore](./firestore_.firestore.md#firestore_class) - -The default [Firestore](./firestore_.firestore.md#firestore_class) instance of the default app. - -### memoryEagerGarbageCollector() {:#memoryeagergarbagecollector} - -Creates an instance of `MemoryEagerGarbageCollector`. This is also the default garbage collector unless it is explicitly specified otherwise. - -Signature: - -```typescript -export declare function memoryEagerGarbageCollector(): MemoryEagerGarbageCollector; -``` -Returns: - -[MemoryEagerGarbageCollector](./firestore_.memoryeagergarbagecollector.md#memoryeagergarbagecollector_interface) - -### persistentMultipleTabManager() {:#persistentmultipletabmanager} - -Creates an instance of `PersistentMultipleTabManager`. - -Signature: - -```typescript -export declare function persistentMultipleTabManager(): PersistentMultipleTabManager; -``` -Returns: - -[PersistentMultipleTabManager](./firestore_.persistentmultipletabmanager.md#persistentmultipletabmanager_interface) - -### serverTimestamp() {:#servertimestamp} - -Returns a sentinel used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) to include a server-generated timestamp in the written data. - -Signature: - -```typescript -export declare function serverTimestamp(): FieldValue; -``` -Returns: - -[FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) - -### useFirestorePipelines() {:#usefirestorepipelines} - - Copyright 2024 Google LLC - -Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - -Signature: - -```typescript -export declare function useFirestorePipelines(): void; -``` -Returns: - -void - -## function(array, ...) - -### arrayConcat(array, elements) {:#arrayconcat_0b3ddb9} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with other arrays. - -```typescript -// Combine the 'items' array with two new item arrays -arrayConcat(Field.of("items"), [Field.of("newItems"), Field.of("otherItems")]); - -``` - -Signature: - -```typescript -export declare function arrayConcat(array: Constant, elements: Constant[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_.constant.md#constant_class) | The array expression to concatenate to. | -| elements | [Constant](./firestore_.constant.md#constant_class)\[\] | The array expressions to concatenate. A new representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) - -### arrayConcat(array, elements) {:#arrayconcat_21991c1} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with other arrays and/or values. - -```typescript -// Combine the 'tags' array with a new array -arrayConcat(Field.of("tags"), ["newTag1", "newTag2"]); - -``` - -Signature: - -```typescript -export declare function arrayConcat(array: Constant, elements: any[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_.constant.md#constant_class) | The array expression to concatenate to. | -| elements | any\[\] | The array expressions or single values to concatenate. A new representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) - -### arrayConcat(array, elements) {:#arrayconcat_f8d5d5e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates a field's array value with other arrays. - -```typescript -// Combine the 'items' array with two new item arrays -arrayConcat("items", [Field.of("newItems"), Field.of("otherItems")]); - -``` - -Signature: - -```typescript -export declare function arrayConcat(array: string, elements: Constant[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | string | The field name containing array values. | -| elements | [Constant](./firestore_.constant.md#constant_class)\[\] | The array expressions to concatenate. A new representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) - -### arrayConcat(array, elements) {:#arrayconcat_5a66d99} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates a field's array value with other arrays and/or values. - -```typescript -// Combine the 'tags' array with a new array -arrayConcat("tags", ["newTag1", "newTag2"]); - -``` - -Signature: - -```typescript -export declare function arrayConcat(array: string, elements: any[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | string | The field name containing array values. | -| elements | any\[\] | The array expressions or single values to concatenate. A new representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_.arrayconcat.md#arrayconcat_class) - -### arrayContains(array, element) {:#arraycontains_01ea7c0} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array expression contains a specific element. - -```typescript -// Check if the 'colors' array contains the value of field 'selectedColor' -arrayContains(Field.of("colors"), Field.of("selectedColor")); - -``` - -Signature: - -```typescript -export declare function arrayContains(array: Constant, element: Constant): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_.constant.md#constant_class) | The array expression to check. | -| element | [Constant](./firestore_.constant.md#constant_class) | The element to search for in the array. A new representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) - -### arrayContains(array, element) {:#arraycontains_60f8f2f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array expression contains a specific element. - -```typescript -// Check if the 'colors' array contains "red" -arrayContains(Field.of("colors"), "red"); - -``` - -Signature: - -```typescript -export declare function arrayContains(array: Constant, element: any): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_.constant.md#constant_class) | The array expression to check. | -| element | any | The element to search for in the array. A new representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) - -### arrayContains(array, element) {:#arraycontains_0ebdbfe} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's array value contains a specific element. - -```typescript -// Check if the 'colors' array contains the value of field 'selectedColor' -arrayContains("colors", Field.of("selectedColor")); - -``` - -Signature: - -```typescript -export declare function arrayContains(array: string, element: Constant): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | string | The field name to check. | -| element | [Constant](./firestore_.constant.md#constant_class) | The element to search for in the array. A new representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) - -### arrayContains(array, element) {:#arraycontains_8f718df} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's array value contains a specific value. - -```typescript -// Check if the 'colors' array contains "red" -arrayContains("colors", "red"); - -``` - -Signature: - -```typescript -export declare function arrayContains(array: string, element: any): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | string | The field name to check. | -| element | any | The element to search for in the array. A new representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_.arraycontains.md#arraycontains_class) - -### arrayContainsAll(array, values) {:#arraycontainsall_7b7433a} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array expression contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" -arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); - -``` - -Signature: - -```typescript -export declare function arrayContainsAll(array: Constant, values: Constant[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_.constant.md#constant_class) | The array expression to check. | -| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) - -### arrayContainsAll(array, values) {:#arraycontainsall_d919466} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array expression contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" -arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); - -``` - -Signature: - -```typescript -export declare function arrayContainsAll(array: Constant, values: any[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_.constant.md#constant_class) | The array expression to check. | -| values | any\[\] | The elements to check for in the array. A new representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) - -### arrayContainsAll(array, values) {:#arraycontainsall_b40e2df} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's array value contains all the specified values or expressions. - -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); - -``` - -Signature: - -```typescript -export declare function arrayContainsAll(array: string, values: Constant[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | string | The field name to check. | -| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) - -### arrayContainsAll(array, values) {:#arraycontainsall_b08efbb} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's array value contains all the specified values or expressions. - -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); - -``` - -Signature: - -```typescript -export declare function arrayContainsAll(array: string, values: any[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | string | The field name to check. | -| values | any\[\] | The elements to check for in the array. A new representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_.arraycontainsall.md#arraycontainsall_class) - -### arrayContainsAny(array, values) {:#arraycontainsany_7b7433a} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array expression contains any of the specified elements. - -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "Science" -arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); - -``` - -Signature: - -```typescript -export declare function arrayContainsAny(array: Constant, values: Constant[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_.constant.md#constant_class) | The array expression to check. | -| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) - -### arrayContainsAny(array, values) {:#arraycontainsany_d919466} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array expression contains any of the specified elements. - -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "Science" -arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); - -``` - -Signature: - -```typescript -export declare function arrayContainsAny(array: Constant, values: any[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_.constant.md#constant_class) | The array expression to check. | -| values | any\[\] | The elements to check for in the array. A new representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) - -### arrayContainsAny(array, values) {:#arraycontainsany_b40e2df} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's array value contains any of the specified elements. - -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -arrayContainsAny("categories", [Field.of("cate1"), "Science"]); - -``` - -Signature: - -```typescript -export declare function arrayContainsAny(array: string, values: Constant[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | string | The field name to check. | -| values | [Constant](./firestore_.constant.md#constant_class)\[\] | The elements to check for in the array. A new representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) - -### arrayContainsAny(array, values) {:#arraycontainsany_b08efbb} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's array value contains any of the specified elements. - -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -arrayContainsAny("categories", [Field.of("cate1"), "Science"]); - -``` - -Signature: - -```typescript -export declare function arrayContainsAny(array: string, values: any[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | string | The field name to check. | -| values | any\[\] | The elements to check for in the array. A new representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_.arraycontainsany.md#arraycontainsany_class) - -### arrayLength(array) {:#arraylength_0bb5dbb} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of an array expression. - -```typescript -// Get the number of items in the 'cart' array -arrayLength(Field.of("cart")); - -``` - -Signature: - -```typescript -export declare function arrayLength(array: Constant): ArrayLength; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_.constant.md#constant_class) | The array expression to calculate the length of. A new representing the length of the array. | - -Returns: - -[ArrayLength](./firestore_.arraylength.md#arraylength_class) - -## function(condition, ...) - -### ifFunction(condition, thenExpr, elseExpr) {:#iffunction_f7b2404} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a conditional expression that evaluates to a 'then' expression if a condition is true and an 'else' expression if the condition is false. - -```typescript -// If 'age' is greater than 18, return "Adult"; otherwise, return "Minor". -ifFunction( - gt("age", 18), Constant.of("Adult"), Constant.of("Minor")); - -``` - -Signature: - -```typescript -export declare function ifFunction(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant): If; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| condition | [FilterExpr](./firestore_.md#filterexpr) | The condition to evaluate. | -| thenExpr | [Constant](./firestore_.constant.md#constant_class) | The expression to evaluate if the condition is true. | -| elseExpr | [Constant](./firestore_.constant.md#constant_class) | The expression to evaluate if the condition is false. A new representing the conditional expression. | - -Returns: - -[If](./firestore_.if.md#if_class) - -## function(databaseId, ...) - -### getFirestore(databaseId) {:#getfirestore_53dc891} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Returns the existing named [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. - -Signature: - -```typescript -export declare function getFirestore(databaseId: string): Firestore; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| databaseId | string | The name of the database. | - -Returns: - -[Firestore](./firestore_.firestore.md#firestore_class) - -The named [Firestore](./firestore_.firestore.md#firestore_class) instance of the default app. - -## function(element, ...) - -### inAny(element, others) {:#inany_a73b259} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an expression is equal to any of the provided values or expressions. - -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -inAny(Field.of("category"), [Constant.of("Electronics"), Field.of("primaryType")]); - -``` - -Signature: - -```typescript -export declare function inAny(element: Constant, others: Constant[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | [Constant](./firestore_.constant.md#constant_class) | The expression to compare. | -| others | [Constant](./firestore_.constant.md#constant_class)\[\] | The values to check against. A new representing the 'IN' comparison. | - -Returns: - -[In](./firestore_.in.md#in_class) - -### inAny(element, others) {:#inany_f5721c6} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an expression is equal to any of the provided values or expressions. - -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -inAny(Field.of("category"), ["Electronics", Field.of("primaryType")]); - -``` - -Signature: - -```typescript -export declare function inAny(element: Constant, others: any[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | [Constant](./firestore_.constant.md#constant_class) | The expression to compare. | -| others | any\[\] | The values to check against. A new representing the 'IN' comparison. | - -Returns: - -[In](./firestore_.in.md#in_class) - -### inAny(element, others) {:#inany_c6646ea} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is equal to any of the provided values or expressions. - -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -inAny("category", [Constant.of("Electronics"), Field.of("primaryType")]); - -``` - -Signature: - -```typescript -export declare function inAny(element: string, others: Constant[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | string | The field to compare. | -| others | [Constant](./firestore_.constant.md#constant_class)\[\] | The values to check against. A new representing the 'IN' comparison. | - -Returns: - -[In](./firestore_.in.md#in_class) - -### inAny(element, others) {:#inany_e6877aa} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is equal to any of the provided values or expressions. - -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -inAny("category", ["Electronics", Field.of("primaryType")]); - -``` - -Signature: - -```typescript -export declare function inAny(element: string, others: any[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | string | The field to compare. | -| others | any\[\] | The values to check against. A new representing the 'IN' comparison. | - -Returns: - -[In](./firestore_.in.md#in_class) - -### notInAny(element, others) {:#notinany_a73b259} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an expression is not equal to any of the provided values or expressions. - -```typescript -// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' -notInAny(Field.of("status"), [Constant.of("pending"), Field.of("rejectedStatus")]); - -``` - -Signature: - -```typescript -export declare function notInAny(element: Constant, others: Constant[]): Not; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | [Constant](./firestore_.constant.md#constant_class) | The expression to compare. | -| others | [Constant](./firestore_.constant.md#constant_class)\[\] | The values to check against. A new representing the 'NOT IN' comparison. | - -Returns: - -[Not](./firestore_.not.md#not_class) - -### notInAny(element, others) {:#notinany_f5721c6} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an expression is not equal to any of the provided values or expressions. - -```typescript -// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' -notInAny(Field.of("status"), ["pending", Field.of("rejectedStatus")]); - -``` - -Signature: - -```typescript -export declare function notInAny(element: Constant, others: any[]): Not; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | [Constant](./firestore_.constant.md#constant_class) | The expression to compare. | -| others | any\[\] | The values to check against. A new representing the 'NOT IN' comparison. | - -Returns: - -[Not](./firestore_.not.md#not_class) - -### notInAny(element, others) {:#notinany_c6646ea} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is not equal to any of the provided values or expressions. - -```typescript -// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' -notInAny("status", [Constant.of("pending"), Field.of("rejectedStatus")]); - -``` - -Signature: - -```typescript -export declare function notInAny(element: string, others: Constant[]): Not; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | string | The field name to compare. | -| others | [Constant](./firestore_.constant.md#constant_class)\[\] | The values to check against. A new representing the 'NOT IN' comparison. | - -Returns: - -[Not](./firestore_.not.md#not_class) - -### notInAny(element, others) {:#notinany_e6877aa} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is not equal to any of the provided values or expressions. - -```typescript -// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' -notInAny("status", ["pending", Field.of("rejectedStatus")]); - -``` - -Signature: - -```typescript -export declare function notInAny(element: string, others: any[]): Not; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | string | The field name to compare. | -| others | any\[\] | The values to check against. A new representing the 'NOT IN' comparison. | - -Returns: - -[Not](./firestore_.not.md#not_class) - -## function(elements, ...) - -### arrayRemove(elements) {:#arrayremove_7d853aa} - -Returns a special value that can be used with [setDoc()](./firestore_.md#setdoc_ee215ad) or that tells the server to remove the given elements from any array value that already exists on the server. All instances of each element specified will be removed from the array. If the field being modified is not already an array it will be overwritten with an empty array. - -Signature: - -```typescript -export declare function arrayRemove(...elements: unknown[]): FieldValue; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| elements | unknown\[\] | The elements to remove from the array. | - -Returns: - -[FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) - -The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()` - -### arrayUnion(elements) {:#arrayunion_7d853aa} - -Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to union the given elements with any array value that already exists on the server. Each specified element that doesn't already exist in the array will be added to the end. If the field being modified is not already an array it will be overwritten with an array containing exactly the specified elements. - -Signature: - -```typescript -export declare function arrayUnion(...elements: unknown[]): FieldValue; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| elements | unknown\[\] | The elements to union into the array. | - -Returns: - -[FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) - -The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()`. - -## function(expr, ...) - -### ascending(expr) {:#ascending_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. - -```typescript -// Sort documents by the 'name' field in ascending order -firestore.pipeline().collection("users") - .sort(ascending(Field.of("name"))); - -``` - -Signature: - -```typescript -export declare function ascending(expr: Constant): Ordering; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression to create an ascending ordering for. A new Ordering for ascending sorting. | - -Returns: - -[Ordering](./firestore_.ordering.md#ordering_class) - -### byteLength(expr) {:#bytelength_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the byte length of a string in UTF-8, or just the length of a Blob. - -```typescript -// Calculate the length of the 'myString' field in bytes. -byteLength(Field.of("myString")); - -``` - -Signature: - -```typescript -export declare function byteLength(expr: Constant): ByteLength; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string. A new representing the length of the string in bytes. | - -Returns: - -[ByteLength](./firestore_.bytelength.md#bytelength_class) - -### charLength(expr) {:#charlength_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the character length of a string expression in UTF-8. - -```typescript -// Get the character length of the 'name' field in UTF-8. -strLength(Field.of("name")); - -``` - -Signature: - -```typescript -export declare function charLength(expr: Constant): CharLength; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to calculate the length of. A new representing the length of the string. | - -Returns: - -[CharLength](./firestore_.charlength.md#charlength_class) - -### cosineDistance(expr, other) {:#cosinedistance_b4c7dc2} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between a field's vector value and a double array. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -cosineDistance("location", [37.7749, -122.4194]); - -``` - -Signature: - -```typescript -export declare function cosineDistance(expr: string, other: number[]): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the first vector. | -| other | number\[\] | The other vector (as an array of doubles) to compare against. A new representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) - -### cosineDistance(expr, other) {:#cosinedistance_8d2bd9d} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between a field's vector value and a VectorValue. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -cosineDistance("location", new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -export declare function cosineDistance(expr: string, other: VectorValue): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the first vector. | -| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) - -### cosineDistance(expr, other) {:#cosinedistance_c9ae0bc} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between a field's vector value and a vector expression. - -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -cosineDistance("userVector", Field.of("itemVector")); - -``` - -Signature: - -```typescript -export declare function cosineDistance(expr: string, other: Constant): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the first vector. | -| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new representing the cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) - -### cosineDistance(expr, other) {:#cosinedistance_e701952} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between a vector expression and a double array. - -```typescript -// Calculate the cosine distance between the 'location' field and a target location -cosineDistance(Field.of("location"), [37.7749, -122.4194]); - -``` - -Signature: - -```typescript -export declare function cosineDistance(expr: Constant, other: number[]): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | -| other | number\[\] | The other vector (as an array of doubles) to compare against. A new representing the cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) - -### cosineDistance(expr, other) {:#cosinedistance_cc2e83e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between a vector expression and a VectorValue. - -```typescript -// Calculate the cosine distance between the 'location' field and a target location -cosineDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -export declare function cosineDistance(expr: Constant, other: VectorValue): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | -| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new representing the cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) - -### cosineDistance(expr, other) {:#cosinedistance_0896fbd} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vector expressions. - -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -cosineDistance(Field.of("userVector"), Field.of("itemVector")); - -``` - -Signature: - -```typescript -export declare function cosineDistance(expr: Constant, other: Constant): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | -| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new representing the cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_.cosinedistance.md#cosinedistance_class) - -### descending(expr) {:#descending_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. - -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") - .sort(descending(Field.of("createdAt"))); - -``` - -Signature: - -```typescript -export declare function descending(expr: Constant): Ordering; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression to create a descending ordering for. A new Ordering for descending sorting. | - -Returns: - -[Ordering](./firestore_.ordering.md#ordering_class) - -### dotProduct(expr, other) {:#dotproduct_b4c7dc2} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between a field's vector value and a double array. - -```typescript -// Calculate the dot product distance between a feature vector and a target vector -dotProduct("features", [0.5, 0.8, 0.2]); - -``` - -Signature: - -```typescript -export declare function dotProduct(expr: string, other: number[]): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the first vector. | -| other | number\[\] | The other vector (as an array of doubles) to calculate with. A new representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_.dotproduct.md#dotproduct_class) - -### dotProduct(expr, other) {:#dotproduct_8d2bd9d} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between a field's vector value and a VectorValue. - -```typescript -// Calculate the dot product distance between a feature vector and a target vector -dotProduct("features", new VectorValue([0.5, 0.8, 0.2])); - -``` - -Signature: - -```typescript -export declare function dotProduct(expr: string, other: VectorValue): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the first vector. | -| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to calculate with. A new representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_.dotproduct.md#dotproduct_class) - -### dotProduct(expr, other) {:#dotproduct_c9ae0bc} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between a field's vector value and a vector expression. - -```typescript -// Calculate the dot product distance between two document vectors: 'docVector1' and 'docVector2' -dotProduct("docVector1", Field.of("docVector2")); - -``` - -Signature: - -```typescript -export declare function dotProduct(expr: string, other: Constant): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the first vector. | -| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to calculate with. A new representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_.dotproduct.md#dotproduct_class) - -### dotProduct(expr, other) {:#dotproduct_e701952} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between a vector expression and a double array. - -```typescript -// Calculate the dot product between a feature vector and a target vector -dotProduct(Field.of("features"), [0.5, 0.8, 0.2]); - -``` - -Signature: - -```typescript -export declare function dotProduct(expr: Constant, other: number[]): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The first vector (represented as an Expr) to calculate with. | -| other | number\[\] | The other vector (as an array of doubles) to calculate with. A new representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_.dotproduct.md#dotproduct_class) - -### dotProduct(expr, other) {:#dotproduct_cc2e83e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between a vector expression and a VectorValue. - -```typescript -// Calculate the dot product between a feature vector and a target vector -dotProduct(Field.of("features"), new VectorValue([0.5, 0.8, 0.2])); - -``` - -Signature: - -```typescript -export declare function dotProduct(expr: Constant, other: VectorValue): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The first vector (represented as an Expr) to calculate with. | -| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to calculate with. A new representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_.dotproduct.md#dotproduct_class) - -### dotProduct(expr, other) {:#dotproduct_0896fbd} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vector expressions. - -```typescript -// Calculate the dot product between two document vectors: 'docVector1' and 'docVector2' -dotProduct(Field.of("docVector1"), Field.of("docVector2")); - -``` - -Signature: - -```typescript -export declare function dotProduct(expr: Constant, other: Constant): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The first vector (represented as an Expr) to calculate with. | -| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to calculate with. A new representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_.dotproduct.md#dotproduct_class) - -### endsWith(expr, suffix) {:#endswith_88569cd} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value ends with a given postfix. - -```typescript -// Check if the 'filename' field ends with ".txt" -endsWith("filename", ".txt"); - -``` - -Signature: - -```typescript -export declare function endsWith(expr: string, suffix: string): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The field name to check. | -| suffix | string | The postfix to check for. A new representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_.endswith.md#endswith_class) - -### endsWith(expr, suffix) {:#endswith_e2e794e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value ends with a given postfix. - -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -endsWith("url", Field.of("extension")); - -``` - -Signature: - -```typescript -export declare function endsWith(expr: string, suffix: Constant): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The field name to check. | -| suffix | [Constant](./firestore_.constant.md#constant_class) | The expression representing the postfix. A new representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_.endswith.md#endswith_class) - -### endsWith(expr, suffix) {:#endswith_6308b81} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string expression ends with a given postfix. - -```typescript -// Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." -endsWith(Field.of("fullName"), "Jr."); - -``` - -Signature: - -```typescript -export declare function endsWith(expr: Constant, suffix: string): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression to check. | -| suffix | string | The postfix to check for. A new representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_.endswith.md#endswith_class) - -### endsWith(expr, suffix) {:#endswith_ab1cc39} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string expression ends with a given postfix. - -```typescript -// Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." -endsWith(Field.of("fullName"), Constant.of("Jr.")); - -``` - -Signature: - -```typescript -export declare function endsWith(expr: Constant, suffix: Constant): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression to check. | -| suffix | [Constant](./firestore_.constant.md#constant_class) | The postfix to check for. A new representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_.endswith.md#endswith_class) - -### euclideanDistance(expr, other) {:#euclideandistance_b4c7dc2} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between a field's vector value and a double array. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -euclideanDistance("location", [37.7749, -122.4194]); - -``` - -Signature: - -```typescript -export declare function euclideanDistance(expr: string, other: number[]): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the first vector. | -| other | number\[\] | The other vector (as an array of doubles) to compare against. A new representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) - -### euclideanDistance(expr, other) {:#euclideandistance_8d2bd9d} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between a field's vector value and a VectorValue. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -euclideanDistance("location", new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -export declare function euclideanDistance(expr: string, other: VectorValue): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the first vector. | -| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) - -### euclideanDistance(expr, other) {:#euclideandistance_c9ae0bc} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between a field's vector value and a vector expression. - -```typescript -// Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' -euclideanDistance("pointA", Field.of("pointB")); - -``` - -Signature: - -```typescript -export declare function euclideanDistance(expr: string, other: Constant): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the first vector. | -| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) - -### euclideanDistance(expr, other) {:#euclideandistance_e701952} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between a vector expression and a double array. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location - -euclideanDistance(Field.of("location"), [37.7749, -122.4194]); - -``` - -Signature: - -```typescript -export declare function euclideanDistance(expr: Constant, other: number[]): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | -| other | number\[\] | The other vector (as an array of doubles) to compare against. A new representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) - -### euclideanDistance(expr, other) {:#euclideandistance_cc2e83e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between a vector expression and a VectorValue. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -euclideanDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -export declare function euclideanDistance(expr: Constant, other: VectorValue): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | -| other | [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) - -### euclideanDistance(expr, other) {:#euclideandistance_0896fbd} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vector expressions. - -```typescript -// Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' -euclideanDistance(Field.of("pointA"), Field.of("pointB")); - -``` - -Signature: - -```typescript -export declare function euclideanDistance(expr: Constant, other: Constant): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | -| other | [Constant](./firestore_.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_.euclideandistance.md#euclideandistance_class) - -### reverse(expr) {:#reverse_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that reverses a string. - -```typescript -// Reverse the value of the 'myString' field. -reverse(Field.of("myString")); - -``` - -Signature: - -```typescript -export declare function reverse(expr: Constant): Reverse; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to reverse. A new representing the reversed string. | - -Returns: - -[Reverse](./firestore_.reverse.md#reverse_class) - -### startsWith(expr, prefix) {:#startswith_484d9f3} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value starts with a given prefix. - -```typescript -// Check if the 'name' field starts with "Mr." -startsWith("name", "Mr."); - -``` - -Signature: - -```typescript -export declare function startsWith(expr: string, prefix: string): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The field name to check. | -| prefix | string | The prefix to check for. A new representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_.startswith.md#startswith_class) - -### startsWith(expr, prefix) {:#startswith_7deb5c7} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value starts with a given prefix. - -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -startsWith("fullName", Field.of("firstName")); - -``` - -Signature: - -```typescript -export declare function startsWith(expr: string, prefix: Constant): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The field name to check. | -| prefix | [Constant](./firestore_.constant.md#constant_class) | The expression representing the prefix. A new representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_.startswith.md#startswith_class) - -### startsWith(expr, prefix) {:#startswith_68300d1} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string expression starts with a given prefix. - -```typescript -// Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." -startsWith(Field.of("fullName"), "Mr."); - -``` - -Signature: - -```typescript -export declare function startsWith(expr: Constant, prefix: string): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression to check. | -| prefix | string | The prefix to check for. A new representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_.startswith.md#startswith_class) - -### startsWith(expr, prefix) {:#startswith_5774b68} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string expression starts with a given prefix. - -```typescript -// Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." -startsWith(Field.of("fullName"), Field.of("prefix")); - -``` - -Signature: - -```typescript -export declare function startsWith(expr: Constant, prefix: Constant): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression to check. | -| prefix | [Constant](./firestore_.constant.md#constant_class) | The prefix to check for. A new representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_.startswith.md#startswith_class) - -### timestampToUnixMicros(expr) {:#timestamptounixmicros_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -timestampToUnixMicros(Field.of("timestamp")); - -``` - -Signature: - -```typescript -export declare function timestampToUnixMicros(expr: Constant): TimestampToUnixMicros; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the timestamp. A new representing the number of microseconds since epoch. | - -Returns: - -[TimestampToUnixMicros](./firestore_.timestamptounixmicros.md#timestamptounixmicros_class) - -### timestampToUnixMillis(expr) {:#timestamptounixmillis_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -timestampToUnixMillis(Field.of("timestamp")); - -``` - -Signature: - -```typescript -export declare function timestampToUnixMillis(expr: Constant): TimestampToUnixMillis; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the timestamp. A new representing the number of milliseconds since epoch. | - -Returns: - -[TimestampToUnixMillis](./firestore_.timestamptounixmillis.md#timestamptounixmillis_class) - -### timestampToUnixSeconds(expr) {:#timestamptounixseconds_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to seconds since epoch. -timestampToUnixSeconds(Field.of("timestamp")); - -``` - -Signature: - -```typescript -export declare function timestampToUnixSeconds(expr: Constant): TimestampToUnixSeconds; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the timestamp. A new representing the number of seconds since epoch. | - -Returns: - -[TimestampToUnixSeconds](./firestore_.timestamptounixseconds.md#timestamptounixseconds_class) - -### toLower(expr) {:#tolower_1e536ed} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string field to lowercase. - -```typescript -// Convert the 'name' field to lowercase -toLower("name"); - -``` - -Signature: - -```typescript -export declare function toLower(expr: string): ToLower; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the string. A new representing the lowercase string. | - -Returns: - -[ToLower](./firestore_.tolower.md#tolower_class) - -### toLower(expr) {:#tolower_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string expression to lowercase. - -```typescript -// Convert the 'name' field to lowercase -toLower(Field.of("name")); - -``` - -Signature: - -```typescript -export declare function toLower(expr: Constant): ToLower; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to convert to lowercase. A new representing the lowercase string. | - -Returns: - -[ToLower](./firestore_.tolower.md#tolower_class) - -### toUpper(expr) {:#toupper_1e536ed} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string field to uppercase. - -```typescript -// Convert the 'title' field to uppercase -toUpper("title"); - -``` - -Signature: - -```typescript -export declare function toUpper(expr: string): ToUpper; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the string. A new representing the uppercase string. | - -Returns: - -[ToUpper](./firestore_.toupper.md#toupper_class) - -### toUpper(expr) {:#toupper_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string expression to uppercase. - -```typescript -// Convert the 'title' field to uppercase -toUppercase(Field.of("title")); - -``` - -Signature: - -```typescript -export declare function toUpper(expr: Constant): ToUpper; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to convert to uppercase. A new representing the uppercase string. | - -Returns: - -[ToUpper](./firestore_.toupper.md#toupper_class) - -### trim(expr) {:#trim_1e536ed} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that removes leading and trailing whitespace from a string field. - -```typescript -// Trim whitespace from the 'userInput' field -trim("userInput"); - -``` - -Signature: - -```typescript -export declare function trim(expr: string): Trim; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the string. A new representing the trimmed string. | - -Returns: - -[Trim](./firestore_.trim.md#trim_class) - -### trim(expr) {:#trim_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that removes leading and trailing whitespace from a string expression. - -```typescript -// Trim whitespace from the 'userInput' field -trim(Field.of("userInput")); - -``` - -Signature: - -```typescript -export declare function trim(expr: Constant): Trim; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to trim. A new representing the trimmed string. | - -Returns: - -[Trim](./firestore_.trim.md#trim_class) - -### unixMicrosToTimestamp(expr) {:#unixmicrostotimestamp_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets an expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -unixMicrosToTimestamp(Field.of("microseconds")); - -``` - -Signature: - -```typescript -export declare function unixMicrosToTimestamp(expr: Constant): UnixMicrosToTimestamp; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the number of microseconds since epoch. A new representing the timestamp. | - -Returns: - -[UnixMicrosToTimestamp](./firestore_.unixmicrostotimestamp.md#unixmicrostotimestamp_class) - -### unixMillisToTimestamp(expr) {:#unixmillistotimestamp_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets an expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -unixMillisToTimestamp(Field.of("milliseconds")); - -``` - -Signature: - -```typescript -export declare function unixMillisToTimestamp(expr: Constant): UnixMillisToTimestamp; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the number of milliseconds since epoch. A new representing the timestamp. | - -Returns: - -[UnixMillisToTimestamp](./firestore_.unixmillistotimestamp.md#unixmillistotimestamp_class) - -### unixSecondsToTimestamp(expr) {:#unixsecondstotimestamp_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets an expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'seconds' field as seconds since epoch. -unixSecondsToTimestamp(Field.of("seconds")); - -``` - -Signature: - -```typescript -export declare function unixSecondsToTimestamp(expr: Constant): UnixSecondsToTimestamp; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the number of seconds since epoch. A new representing the timestamp. | - -Returns: - -[UnixSecondsToTimestamp](./firestore_.unixsecondstotimestamp.md#unixsecondstotimestamp_class) - -### vectorLength(expr) {:#vectorlength_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of a Firestore Vector. - -```typescript -// Get the vector length (dimension) of the field 'embedding'. -vectorLength(Field.of("embedding")); - -``` - -Signature: - -```typescript -export declare function vectorLength(expr: Constant): VectorLength; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the Firestore Vector. A new representing the length of the array. | - -Returns: - -[VectorLength](./firestore_.vectorlength.md#vectorlength_class) - -## function(field, ...) - -### average(field) {:#average_aacc3a9} - -Create an AggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query. - -Signature: - -```typescript -export declare function average(field: string | FieldPath): AggregateField; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | Specifies the field to average across the result set. | - -Returns: - -[AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<number \| null> - -### byteLength(field) {:#bytelength_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of a string represented by a field in UTF-8 bytes, or just the length of a Blob. - -```typescript -// Calculate the length of the 'myString' field in bytes. -byteLength("myString"); - -``` - -Signature: - -```typescript -export declare function byteLength(field: string): ByteLength; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the string. A new representing the length of the string in bytes. | - -Returns: - -[ByteLength](./firestore_.bytelength.md#bytelength_class) - -### charLength(field) {:#charlength_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the character length of a string field in UTF8. - -```typescript -// Get the character length of the 'name' field in UTF-8. -strLength("name"); - -``` - -Signature: - -```typescript -export declare function charLength(field: string): CharLength; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field containing the string. A new representing the length of the string. | - -Returns: - -[CharLength](./firestore_.charlength.md#charlength_class) - -### exists(field) {:#exists_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field exists. - -```typescript -// Check if the document has a field named "phoneNumber" -exists("phoneNumber"); - -``` - -Signature: - -```typescript -export declare function exists(field: string): Exists; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The field name to check. A new representing the 'exists' check. | - -Returns: - -[Exists](./firestore_.exists.md#exists_class) - -### replaceAll(field, find, replace) {:#replaceall_b257ab0} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within a string represented by a field with another substring. - -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field. -replaceAll("message", "hello", "hi"); - -``` - -Signature: - -```typescript -export declare function replaceAll(field: string, find: string, replace: string): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the string to perform the replacement on. | -| find | string | The substring to search for. | -| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_.replaceall.md#replaceall_class) - -### replaceFirst(field, find, replace) {:#replacefirst_b257ab0} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within a string represented by a field with another substring. - -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field. -replaceFirst("message", "hello", "hi"); - -``` - -Signature: - -```typescript -export declare function replaceFirst(field: string, find: string, replace: string): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the string to perform the replacement on. | -| find | string | The substring to search for. | -| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) - -### reverse(field) {:#reverse_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that reverses a string represented by a field. - -```typescript -// Reverse the value of the 'myString' field. -reverse("myString"); - -``` - -Signature: - -```typescript -export declare function reverse(field: string): Reverse; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the string to reverse. A new representing the reversed string. | - -Returns: - -[Reverse](./firestore_.reverse.md#reverse_class) - -### sum(field) {:#sum_aacc3a9} - -Create an AggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query. - -Signature: - -```typescript -export declare function sum(field: string | FieldPath): AggregateField; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | Specifies the field to sum across the result set. | - -Returns: - -[AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<number> - -### timestampAdd(field, unit, amount) {:#timestampadd_565792c} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to a timestamp represented by a field. - -```typescript -// Add 1 day to the 'timestamp' field. -timestampAdd("timestamp", "day", 1); - -``` - -Signature: - -```typescript -export declare function timestampAdd(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the timestamp. | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | -| amount | number | The amount of time to add. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) - -### timestampSub(field, unit, amount) {:#timestampsub_565792c} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from a timestamp represented by a field. - -```typescript -// Subtract 1 day from the 'timestamp' field. -timestampSub("timestamp", "day", 1); - -``` - -Signature: - -```typescript -export declare function timestampSub(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the timestamp. | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | -| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) - -### timestampToUnixMicros(field) {:#timestamptounixmicros_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a timestamp field to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -timestampToUnixMicros("timestamp"); - -``` - -Signature: - -```typescript -export declare function timestampToUnixMicros(field: string): TimestampToUnixMicros; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the timestamp. A new representing the number of microseconds since epoch. | - -Returns: - -[TimestampToUnixMicros](./firestore_.timestamptounixmicros.md#timestamptounixmicros_class) - -### timestampToUnixMillis(field) {:#timestamptounixmillis_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a timestamp field to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -timestampToUnixMillis("timestamp"); - -``` - -Signature: - -```typescript -export declare function timestampToUnixMillis(field: string): TimestampToUnixMillis; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the timestamp. A new representing the number of milliseconds since epoch. | - -Returns: - -[TimestampToUnixMillis](./firestore_.timestamptounixmillis.md#timestamptounixmillis_class) - -### timestampToUnixSeconds(field) {:#timestamptounixseconds_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a timestamp field to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to seconds since epoch. -timestampToUnixSeconds("timestamp"); - -``` - -Signature: - -```typescript -export declare function timestampToUnixSeconds(field: string): TimestampToUnixSeconds; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the timestamp. A new representing the number of seconds since epoch. | - -Returns: - -[TimestampToUnixSeconds](./firestore_.timestamptounixseconds.md#timestamptounixseconds_class) - -### unixMicrosToTimestamp(field) {:#unixmicrostotimestamp_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets a field's value as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -unixMicrosToTimestamp("microseconds"); - -``` - -Signature: - -```typescript -export declare function unixMicrosToTimestamp(field: string): UnixMicrosToTimestamp; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the number of microseconds since epoch. A new representing the timestamp. | - -Returns: - -[UnixMicrosToTimestamp](./firestore_.unixmicrostotimestamp.md#unixmicrostotimestamp_class) - -### unixMillisToTimestamp(field) {:#unixmillistotimestamp_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets a field's value as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -unixMillisToTimestamp("milliseconds"); - -``` - -Signature: - -```typescript -export declare function unixMillisToTimestamp(field: string): UnixMillisToTimestamp; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the number of milliseconds since epoch. A new representing the timestamp. | - -Returns: - -[UnixMillisToTimestamp](./firestore_.unixmillistotimestamp.md#unixmillistotimestamp_class) - -### unixSecondsToTimestamp(field) {:#unixsecondstotimestamp_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets a field's value as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'seconds' field as seconds since epoch. -unixSecondsToTimestamp("seconds"); - -``` - -Signature: - -```typescript -export declare function unixSecondsToTimestamp(field: string): UnixSecondsToTimestamp; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the number of seconds since epoch. A new representing the timestamp. | - -Returns: - -[UnixSecondsToTimestamp](./firestore_.unixsecondstotimestamp.md#unixsecondstotimestamp_class) - -### vectorLength(field) {:#vectorlength_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of a Firestore Vector represented by a field. - -```typescript -// Get the vector length (dimension) of the field 'embedding'. -vectorLength("embedding"); - -``` - -Signature: - -```typescript -export declare function vectorLength(field: string): VectorLength; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the Firestore Vector. A new representing the length of the array. | - -Returns: - -[VectorLength](./firestore_.vectorlength.md#vectorlength_class) - -## function(fieldPath, ...) - -### orderBy(fieldPath, directionStr) {:#orderby_006d61f} - -Creates a [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) that sorts the query result by the specified field, optionally in descending order instead of ascending. - -Note: Documents that do not contain the specified field will not be present in the query result. - -Signature: - -```typescript -export declare function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryOrderByConstraint; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| fieldPath | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | The field to sort by. | -| directionStr | [OrderByDirection](./firestore_.md#orderbydirection) | Optional direction to sort by ('asc' or 'desc'). If not specified, order will be ascending. | - -Returns: - -[QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) - -The created [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class). - -### where(fieldPath, opStr, value) {:#where_0fae4bf} - -Creates a [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) that enforces that documents must contain the specified field and that the value should satisfy the relation constraint provided. - -Signature: - -```typescript -export declare function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryFieldFilterConstraint; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| fieldPath | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | The path to compare | -| opStr | [WhereFilterOp](./firestore_.md#wherefilterop) | The operation string (e.g "&lt;", "&lt;=", "==", "&lt;", "&lt;=", "!="). | -| value | unknown | The value for comparison | - -Returns: - -[QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) - -The created [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class). - -## function(fieldValues, ...) - -### endAt(fieldValues) {:#endat_8b2f2c8} - -Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. - -Signature: - -```typescript -export declare function endAt(...fieldValues: unknown[]): QueryEndAtConstraint; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| fieldValues | unknown\[\] | The field values to end this query at, in order of the query's order by. | - -Returns: - -[QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) - -A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` - -### endBefore(fieldValues) {:#endbefore_8b2f2c8} - -Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. - -Signature: - -```typescript -export declare function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| fieldValues | unknown\[\] | The field values to end this query before, in order of the query's order by. | - -Returns: - -[QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) - -A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` - -### startAfter(fieldValues) {:#startafter_8b2f2c8} - -Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. - -Signature: - -```typescript -export declare function startAfter(...fieldValues: unknown[]): QueryStartAtConstraint; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| fieldValues | unknown\[\] | The field values to start this query after, in order of the query's order by. | - -Returns: - -[QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) - -A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()` - -### startAt(fieldValues) {:#startat_8b2f2c8} - -Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. - -Signature: - -```typescript -export declare function startAt(...fieldValues: unknown[]): QueryStartAtConstraint; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| fieldValues | unknown\[\] | The field values to start this query at, in order of the query's order by. | - -Returns: - -[QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) - -A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()`. - -## function(filter, ...) - -### not(filter) {:#not_5520849} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that negates a filter condition. - -```typescript -// Find documents where the 'completed' field is NOT true -not(eq("completed", true)); - -``` - -Signature: - -```typescript -export declare function not(filter: FilterExpr): Not; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| filter | [FilterExpr](./firestore_.md#filterexpr) | The filter condition to negate. A new representing the negated filter condition. | - -Returns: - -[Not](./firestore_.not.md#not_class) - -## function(first, ...) - -### strConcat(first, elements) {:#strconcat_0f1bdbf} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates string functions, fields or constants together. - -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -strConcat("firstName", " ", Field.of("lastName")); - -``` - -Signature: - -```typescript -export declare function strConcat(first: string, ...elements: Array): StrConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| first | string | The field name containing the initial string value. | -| elements | Array<[Constant](./firestore_.constant.md#constant_class) \| string> | The expressions (typically strings) to concatenate. A new representing the concatenated string. | - -Returns: - -[StrConcat](./firestore_.strconcat.md#strconcat_class) - -### strConcat(first, elements) {:#strconcat_1eb0ac1} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates string expressions together. - -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -strConcat(Field.of("firstName"), " ", Field.of("lastName")); - -``` - -Signature: - -```typescript -export declare function strConcat(first: Constant, ...elements: Array): StrConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| first | [Constant](./firestore_.constant.md#constant_class) | The initial string expression to concatenate to. | -| elements | Array<[Constant](./firestore_.constant.md#constant_class) \| string> | The expressions (typically strings) to concatenate. A new representing the concatenated string. | - -Returns: - -[StrConcat](./firestore_.strconcat.md#strconcat_class) - -## function(indexManager, ...) - -### deleteAllPersistentCacheIndexes(indexManager) {:#deleteallpersistentcacheindexes_98b2645} - -Removes all persistent cache indexes. - -Please note this function will also deletes indexes generated by `setIndexConfiguration()`, which is deprecated. - -Signature: - -```typescript -export declare function deleteAllPersistentCacheIndexes(indexManager: PersistentCacheIndexManager): void; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| indexManager | [PersistentCacheIndexManager](./firestore_.persistentcacheindexmanager.md#persistentcacheindexmanager_class) | | - -Returns: - -void - -### disablePersistentCacheIndexAutoCreation(indexManager) {:#disablepersistentcacheindexautocreation_98b2645} - -Stops creating persistent cache indexes automatically for local query execution. The indexes which have been created by calling `enablePersistentCacheIndexAutoCreation()` still take effect. - -Signature: - -```typescript -export declare function disablePersistentCacheIndexAutoCreation(indexManager: PersistentCacheIndexManager): void; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| indexManager | [PersistentCacheIndexManager](./firestore_.persistentcacheindexmanager.md#persistentcacheindexmanager_class) | | - -Returns: - -void - -### enablePersistentCacheIndexAutoCreation(indexManager) {:#enablepersistentcacheindexautocreation_98b2645} - -Enables the SDK to create persistent cache indexes automatically for local query execution when the SDK believes cache indexes can help improve performance. - -This feature is disabled by default. - -Signature: - -```typescript -export declare function enablePersistentCacheIndexAutoCreation(indexManager: PersistentCacheIndexManager): void; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| indexManager | [PersistentCacheIndexManager](./firestore_.persistentcacheindexmanager.md#persistentcacheindexmanager_class) | | - -Returns: - -void - -## function(left, ...) - -### add(left, right) {:#add_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds two expressions together. - -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -add(Field.of("quantity"), Field.of("reserve")); - -``` - -Signature: - -```typescript -export declare function add(left: Constant, right: Constant): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The first expression to add. | -| right | [Constant](./firestore_.constant.md#constant_class) | The second expression to add. A new representing the addition operation. | - -Returns: - -[Add](./firestore_.add.md#add_class) - -### add(left, right) {:#add_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds an expression to a constant value. - -```typescript -// Add 5 to the value of the 'age' field -add(Field.of("age"), 5); - -``` - -Signature: - -```typescript -export declare function add(left: Constant, right: any): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The expression to add to. | -| right | any | The constant value to add. A new representing the addition operation. | - -Returns: - -[Add](./firestore_.add.md#add_class) - -### add(left, right) {:#add_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a field's value to an expression. - -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -add("quantity", Field.of("reserve")); - -``` - -Signature: - -```typescript -export declare function add(left: string, right: Constant): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to add to. | -| right | [Constant](./firestore_.constant.md#constant_class) | The expression to add. A new representing the addition operation. | - -Returns: - -[Add](./firestore_.add.md#add_class) - -### add(left, right) {:#add_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a field's value to a constant value. - -```typescript -// Add 5 to the value of the 'age' field -add("age", 5); - -``` - -Signature: - -```typescript -export declare function add(left: string, right: any): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to add to. | -| right | any | The constant value to add. A new representing the addition operation. | - -Returns: - -[Add](./firestore_.add.md#add_class) - -### aggregateFieldEqual(left, right) {:#aggregatefieldequal_e80a2b2} - -Compares two 'AggregateField\` instances for equality. - -Signature: - -```typescript -export declare function aggregateFieldEqual(left: AggregateField, right: AggregateField): boolean; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<unknown> | Compare this AggregateField to the right. | -| right | [AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<unknown> | Compare this AggregateField to the left. | - -Returns: - -boolean - -### aggregateQuerySnapshotEqual(left, right) {:#aggregatequerysnapshotequal_1529a20} - -Compares two `AggregateQuerySnapshot` instances for equality. - -Two `AggregateQuerySnapshot` instances are considered "equal" if they have underlying queries that compare equal, and the same data. - -Signature: - -```typescript -export declare function aggregateQuerySnapshotEqual(left: AggregateQuerySnapshot, right: AggregateQuerySnapshot): boolean; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [AggregateQuerySnapshot](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType> | The first AggregateQuerySnapshot to compare. | -| right | [AggregateQuerySnapshot](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType> | The second AggregateQuerySnapshot to compare. | - -Returns: - -boolean - -`true` if the objects are "equal", as defined above, or `false` otherwise. - -### and(left, right) {:#and_eba7e36} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that performs a logical 'AND' operation on multiple filter conditions. - -```typescript -// Check if the 'age' field is greater than 18 AND the 'city' field is "London" AND -// the 'status' field is "active" -const condition = and(gt("age", 18), eq("city", "London"), eq("status", "active")); - -``` - -Signature: - -```typescript -export declare function and(left: FilterExpr, ...right: FilterExpr[]): And; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [FilterExpr](./firestore_.md#filterexpr) | The first filter condition. | -| right | [FilterExpr](./firestore_.md#filterexpr)\[\] | Additional filter conditions to 'AND' together. A new representing the logical 'AND' operation. | - -Returns: - -[And](./firestore_.and.md#and_class) - -### divide(left, right) {:#divide_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides two expressions. - -```typescript -// Divide the 'total' field by the 'count' field -divide(Field.of("total"), Field.of("count")); - -``` - -Signature: - -```typescript -export declare function divide(left: Constant, right: Constant): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The expression to be divided. | -| right | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new representing the division operation. | - -Returns: - -[Divide](./firestore_.divide.md#divide_class) - -### divide(left, right) {:#divide_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides an expression by a constant value. - -```typescript -// Divide the 'value' field by 10 -divide(Field.of("value"), 10); - -``` - -Signature: - -```typescript -export declare function divide(left: Constant, right: any): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The expression to be divided. | -| right | any | The constant value to divide by. A new representing the division operation. | - -Returns: - -[Divide](./firestore_.divide.md#divide_class) - -### divide(left, right) {:#divide_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides a field's value by an expression. - -```typescript -// Divide the 'total' field by the 'count' field -divide("total", Field.of("count")); - -``` - -Signature: - -```typescript -export declare function divide(left: string, right: Constant): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to be divided. | -| right | [Constant](./firestore_.constant.md#constant_class) | The expression to divide by. A new representing the division operation. | - -Returns: - -[Divide](./firestore_.divide.md#divide_class) - -### divide(left, right) {:#divide_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides a field's value by a constant value. - -```typescript -// Divide the 'value' field by 10 -divide("value", 10); - -``` - -Signature: - -```typescript -export declare function divide(left: string, right: any): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to be divided. | -| right | any | The constant value to divide by. A new representing the division operation. | - -Returns: - -[Divide](./firestore_.divide.md#divide_class) - -### eq(left, right) {:#eq_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if two expressions are equal. - -```typescript -// Check if the 'age' field is equal to an expression -eq(Field.of("age"), Field.of("minAge").add(10)); - -``` - -Signature: - -```typescript -export declare function eq(left: Constant, right: Constant): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The first expression to compare. | -| right | [Constant](./firestore_.constant.md#constant_class) | The second expression to compare. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_.eq.md#eq_class) - -### eq(left, right) {:#eq_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an expression is equal to a constant value. - -```typescript -// Check if the 'age' field is equal to 21 -eq(Field.of("age"), 21); - -``` - -Signature: - -```typescript -export declare function eq(left: Constant, right: any): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The expression to compare. | -| right | any | The constant value to compare to. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_.eq.md#eq_class) - -### eq(left, right) {:#eq_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is equal to an expression. - -```typescript -// Check if the 'age' field is equal to the 'limit' field -eq("age", Field.of("limit")); - -``` - -Signature: - -```typescript -export declare function eq(left: string, right: Constant): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | [Constant](./firestore_.constant.md#constant_class) | The expression to compare to. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_.eq.md#eq_class) - -### eq(left, right) {:#eq_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is equal to a constant value. - -```typescript -// Check if the 'city' field is equal to string constant "London" -eq("city", "London"); - -``` - -Signature: - -```typescript -export declare function eq(left: string, right: any): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | any | The constant value to compare to. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_.eq.md#eq_class) - -### gt(left, right) {:#gt_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if the first expression is greater than the second expression. - -```typescript -// Check if the 'age' field is greater than 18 -gt(Field.of("age"), Constant(9).add(9)); - -``` - -Signature: - -```typescript -export declare function gt(left: Constant, right: Constant): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The first expression to compare. | -| right | [Constant](./firestore_.constant.md#constant_class) | The second expression to compare. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_.gt.md#gt_class) - -### gt(left, right) {:#gt_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an expression is greater than a constant value. - -```typescript -// Check if the 'age' field is greater than 18 -gt(Field.of("age"), 18); - -``` - -Signature: - -```typescript -export declare function gt(left: Constant, right: any): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The expression to compare. | -| right | any | The constant value to compare to. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_.gt.md#gt_class) - -### gt(left, right) {:#gt_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is greater than an expression. - -```typescript -// Check if the value of field 'age' is greater than the value of field 'limit' -gt("age", Field.of("limit")); - -``` - -Signature: - -```typescript -export declare function gt(left: string, right: Constant): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | [Constant](./firestore_.constant.md#constant_class) | The expression to compare to. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_.gt.md#gt_class) - -### gt(left, right) {:#gt_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is greater than a constant value. - -```typescript -// Check if the 'price' field is greater than 100 -gt("price", 100); - -``` - -Signature: - -```typescript -export declare function gt(left: string, right: any): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | any | The constant value to compare to. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_.gt.md#gt_class) - -### gte(left, right) {:#gte_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if the first expression is greater than or equal to the second expression. - -```typescript -// Check if the 'quantity' field is greater than or equal to the field "threshold" -gte(Field.of("quantity"), Field.of("threshold")); - -``` - -Signature: - -```typescript -export declare function gte(left: Constant, right: Constant): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The first expression to compare. | -| right | [Constant](./firestore_.constant.md#constant_class) | The second expression to compare. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_.gte.md#gte_class) - -### gte(left, right) {:#gte_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an expression is greater than or equal to a constant value. - -```typescript -// Check if the 'quantity' field is greater than or equal to 10 -gte(Field.of("quantity"), 10); - -``` - -Signature: - -```typescript -export declare function gte(left: Constant, right: any): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The expression to compare. | -| right | any | The constant value to compare to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_.gte.md#gte_class) - -### gte(left, right) {:#gte_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is greater than or equal to an expression. - -```typescript -// Check if the value of field 'age' is greater than or equal to the value of field 'limit' -gte("age", Field.of("limit")); - -``` - -Signature: - -```typescript -export declare function gte(left: string, right: Constant): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | [Constant](./firestore_.constant.md#constant_class) | The expression to compare to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_.gte.md#gte_class) - -### gte(left, right) {:#gte_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is greater than or equal to a constant value. - -```typescript -// Check if the 'score' field is greater than or equal to 80 -gte("score", 80); - -``` - -Signature: - -```typescript -export declare function gte(left: string, right: any): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | any | The constant value to compare to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_.gte.md#gte_class) - -### like(left, pattern) {:#like_33ec01b} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that performs a case-sensitive wildcard string comparison against a field. - -```typescript -// Check if the 'title' field contains the string "guide" -like("title", "%guide%"); - -``` - -Signature: - -```typescript -export declare function like(left: string, pattern: string): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The name of the field containing the string. | -| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new representing the 'like' comparison. | - -Returns: - -[Like](./firestore_.like.md#like_class) - -### like(left, pattern) {:#like_dd84184} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that performs a case-sensitive wildcard string comparison against a field. - -```typescript -// Check if the 'title' field contains the string "guide" -like("title", Field.of("pattern")); - -``` - -Signature: - -```typescript -export declare function like(left: string, pattern: Constant): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The name of the field containing the string. | -| pattern | [Constant](./firestore_.constant.md#constant_class) | The pattern to search for. You can use "%" as a wildcard character. A new representing the 'like' comparison. | - -Returns: - -[Like](./firestore_.like.md#like_class) - -### like(left, pattern) {:#like_3aaffe0} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that performs a case-sensitive wildcard string comparison. - -```typescript -// Check if the 'title' field contains the string "guide" -like(Field.of("title"), "%guide%"); - -``` - -Signature: - -```typescript -export declare function like(left: Constant, pattern: string): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to perform the comparison on. | -| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new representing the 'like' comparison. | - -Returns: - -[Like](./firestore_.like.md#like_class) - -### like(left, pattern) {:#like_a2c3e8b} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that performs a case-sensitive wildcard string comparison. - -```typescript -// Check if the 'title' field contains the string "guide" -like(Field.of("title"), Field.of("pattern")); - -``` - -Signature: - -```typescript -export declare function like(left: Constant, pattern: Constant): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to perform the comparison on. | -| pattern | [Constant](./firestore_.constant.md#constant_class) | The pattern to search for. You can use "%" as a wildcard character. A new representing the 'like' comparison. | - -Returns: - -[Like](./firestore_.like.md#like_class) - -### logicalMax(left, right) {:#logicalmax_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between two expressions, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'field1' field and the 'field2' field. -logicalMax(Field.of("field1"), Field.of("field2")); - -``` - -Signature: - -```typescript -export declare function logicalMax(left: Constant, right: Constant): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The left operand expression. | -| right | [Constant](./firestore_.constant.md#constant_class) | The right operand expression. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) - -### logicalMax(left, right) {:#logicalmax_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between an expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'value' field and 10. -logicalMax(Field.of("value"), 10); - -``` - -Signature: - -```typescript -export declare function logicalMax(left: Constant, right: any): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The left operand expression. | -| right | any | The right operand constant. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) - -### logicalMax(left, right) {:#logicalmax_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between a field and an expression, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'field1' field and the 'field2' field. -logicalMax("field1", Field.of('field2')); - -``` - -Signature: - -```typescript -export declare function logicalMax(left: string, right: Constant): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The left operand field name. | -| right | [Constant](./firestore_.constant.md#constant_class) | The right operand expression. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) - -### logicalMax(left, right) {:#logicalmax_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between a field and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'value' field and 10. -logicalMax("value", 10); - -``` - -Signature: - -```typescript -export declare function logicalMax(left: string, right: any): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The left operand field name. | -| right | any | The right operand constant. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_.logicalmax.md#logicalmax_class) - -### logicalMin(left, right) {:#logicalmin_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between two expressions, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'field1' field and the 'field2' field. -logicalMin(Field.of("field1"), Field.of("field2")); - -``` - -Signature: - -```typescript -export declare function logicalMin(left: Constant, right: Constant): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The left operand expression. | -| right | [Constant](./firestore_.constant.md#constant_class) | The right operand expression. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) - -### logicalMin(left, right) {:#logicalmin_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between an expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'value' field and 10. -logicalMin(Field.of("value"), 10); - -``` - -Signature: - -```typescript -export declare function logicalMin(left: Constant, right: any): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The left operand expression. | -| right | any | The right operand constant. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) - -### logicalMin(left, right) {:#logicalmin_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between a field and an expression, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'field1' field and the 'field2' field. -logicalMin("field1", Field.of("field2")); - -``` - -Signature: - -```typescript -export declare function logicalMin(left: string, right: Constant): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The left operand field name. | -| right | [Constant](./firestore_.constant.md#constant_class) | The right operand expression. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) - -### logicalMin(left, right) {:#logicalmin_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between a field and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'value' field and 10. -logicalMin("value", 10); - -``` - -Signature: - -```typescript -export declare function logicalMin(left: string, right: any): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The left operand field name. | -| right | any | The right operand constant. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_.logicalmin.md#logicalmin_class) - -### lt(left, right) {:#lt_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if the first expression is less than the second expression. - -```typescript -// Check if the 'age' field is less than 30 -lt(Field.of("age"), Field.of("limit")); - -``` - -Signature: - -```typescript -export declare function lt(left: Constant, right: Constant): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The first expression to compare. | -| right | [Constant](./firestore_.constant.md#constant_class) | The second expression to compare. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_.lt.md#lt_class) - -### lt(left, right) {:#lt_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an expression is less than a constant value. - -```typescript -// Check if the 'age' field is less than 30 -lt(Field.of("age"), 30); - -``` - -Signature: - -```typescript -export declare function lt(left: Constant, right: any): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The expression to compare. | -| right | any | The constant value to compare to. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_.lt.md#lt_class) - -### lt(left, right) {:#lt_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is less than an expression. - -```typescript -// Check if the 'age' field is less than the 'limit' field -lt("age", Field.of("limit")); - -``` - -Signature: - -```typescript -export declare function lt(left: string, right: Constant): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | [Constant](./firestore_.constant.md#constant_class) | The expression to compare to. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_.lt.md#lt_class) - -### lt(left, right) {:#lt_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is less than a constant value. - -```typescript -// Check if the 'price' field is less than 50 -lt("price", 50); - -``` - -Signature: - -```typescript -export declare function lt(left: string, right: any): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | any | The constant value to compare to. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_.lt.md#lt_class) - -### lte(left, right) {:#lte_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if the first expression is less than or equal to the second expression. - -```typescript -// Check if the 'quantity' field is less than or equal to 20 -lte(Field.of("quantity"), Field.of("limit")); - -``` - -Signature: - -```typescript -export declare function lte(left: Constant, right: Constant): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The first expression to compare. | -| right | [Constant](./firestore_.constant.md#constant_class) | The second expression to compare. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_.lte.md#lte_class) - -### lte(left, right) {:#lte_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an expression is less than or equal to a constant value. - -```typescript -// Check if the 'quantity' field is less than or equal to 20 -lte(Field.of("quantity"), 20); - -``` - -Signature: - -```typescript -export declare function lte(left: Constant, right: any): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The expression to compare. | -| right | any | The constant value to compare to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_.lte.md#lte_class) - -### lte(left, right) {:#lte_674c63f} - -Creates an expression that checks if a field's value is less than or equal to an expression. - -```typescript -// Check if the 'quantity' field is less than or equal to the 'limit' field -lte("quantity", Field.of("limit")); - -``` - -Signature: - -```typescript -export declare function lte(left: string, right: Constant): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | [Constant](./firestore_.constant.md#constant_class) | The expression to compare to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_.lte.md#lte_class) - -### lte(left, right) {:#lte_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is less than or equal to a constant value. - -```typescript -// Check if the 'score' field is less than or equal to 70 -lte("score", 70); - -``` - -Signature: - -```typescript -export declare function lte(left: string, right: any): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | any | The constant value to compare to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_.lte.md#lte_class) - -### mod(left, right) {:#mod_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing two expressions. - -```typescript -// Calculate the remainder of dividing 'field1' by 'field2'. -mod(Field.of("field1"), Field.of("field2")); - -``` - -Signature: - -```typescript -export declare function mod(left: Constant, right: Constant): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The dividend expression. | -| right | [Constant](./firestore_.constant.md#constant_class) | The divisor expression. A new representing the modulo operation. | - -Returns: - -[Mod](./firestore_.mod.md#mod_class) - -### mod(left, right) {:#mod_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing an expression by a constant. - -```typescript -// Calculate the remainder of dividing 'field1' by 5. -mod(Field.of("field1"), 5); - -``` - -Signature: - -```typescript -export declare function mod(left: Constant, right: any): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The dividend expression. | -| right | any | The divisor constant. A new representing the modulo operation. | - -Returns: - -[Mod](./firestore_.mod.md#mod_class) - -### mod(left, right) {:#mod_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing a field's value by an expression. - -```typescript -// Calculate the remainder of dividing 'field1' by 'field2'. -mod("field1", Field.of("field2")); - -``` - -Signature: - -```typescript -export declare function mod(left: string, right: Constant): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The dividend field name. | -| right | [Constant](./firestore_.constant.md#constant_class) | The divisor expression. A new representing the modulo operation. | - -Returns: - -[Mod](./firestore_.mod.md#mod_class) - -### mod(left, right) {:#mod_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing a field's value by a constant. - -```typescript -// Calculate the remainder of dividing 'field1' by 5. -mod("field1", 5); - -``` - -Signature: - -```typescript -export declare function mod(left: string, right: any): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The dividend field name. | -| right | any | The divisor constant. A new representing the modulo operation. | - -Returns: - -[Mod](./firestore_.mod.md#mod_class) - -### multiply(left, right) {:#multiply_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies two expressions together. - -```typescript -// Multiply the 'quantity' field by the 'price' field -multiply(Field.of("quantity"), Field.of("price")); - -``` - -Signature: - -```typescript -export declare function multiply(left: Constant, right: Constant): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The first expression to multiply. | -| right | [Constant](./firestore_.constant.md#constant_class) | The second expression to multiply. A new representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_.multiply.md#multiply_class) - -### multiply(left, right) {:#multiply_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies an expression by a constant value. - -```typescript -// Multiply the value of the 'price' field by 2 -multiply(Field.of("price"), 2); - -``` - -Signature: - -```typescript -export declare function multiply(left: Constant, right: any): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The expression to multiply. | -| right | any | The constant value to multiply by. A new representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_.multiply.md#multiply_class) - -### multiply(left, right) {:#multiply_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies a field's value by an expression. - -```typescript -// Multiply the 'quantity' field by the 'price' field -multiply("quantity", Field.of("price")); - -``` - -Signature: - -```typescript -export declare function multiply(left: string, right: Constant): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to multiply. | -| right | [Constant](./firestore_.constant.md#constant_class) | The expression to multiply by. A new representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_.multiply.md#multiply_class) - -### multiply(left, right) {:#multiply_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies a field's value by a constant value. - -```typescript -// Multiply the 'value' field by 2 -multiply("value", 2); - -``` - -Signature: - -```typescript -export declare function multiply(left: string, right: any): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to multiply. | -| right | any | The constant value to multiply by. A new representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_.multiply.md#multiply_class) - -### neq(left, right) {:#neq_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if two expressions are not equal. - -```typescript -// Check if the 'status' field is not equal to field 'finalState' -neq(Field.of("status"), Field.of("finalState")); - -``` - -Signature: - -```typescript -export declare function neq(left: Constant, right: Constant): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The first expression to compare. | -| right | [Constant](./firestore_.constant.md#constant_class) | The second expression to compare. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_.neq.md#neq_class) - -### neq(left, right) {:#neq_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +| Type Alias | Description | +| --- | --- | +| [AddPrefixToKeys](./firestore_.md#addprefixtokeys) | Returns a new map where every key is prefixed with the outer key appended to a dot. | +| [AggregateFieldType](./firestore_.md#aggregatefieldtype) | The union of all AggregateField types that are supported by Firestore. | +| [AggregateSpecData](./firestore_.md#aggregatespecdata) | A type whose keys are taken from an AggregateSpec, and whose values are the result of the aggregation performed by the corresponding AggregateField from the input AggregateSpec. | +| [AggregateType](./firestore_.md#aggregatetype) | Union type representing the aggregate type to be performed. | +| [ChildUpdateFields](./firestore_.md#childupdatefields) | Helper for calculating the nested fields for a given type T1. This is needed to distribute union types such as undefined | {...} (happens for optional props) or {a: A} | {b: B}.In this use case, V is used to distribute the union types of T[K] on Record, since T[K] is evaluated as an expression and not distributed.See https://www.typescriptlang.org/docs/handbook/advanced-types.html\#distributive-conditional-types | +| [DocumentChangeType](./firestore_.md#documentchangetype) | The type of a DocumentChange may be 'added', 'removed', or 'modified'. | +| [FirestoreErrorCode](./firestore_.md#firestoreerrorcode) | The set of Firestore status codes. The codes are the same at the ones exposed by gRPC here: https://github.com/grpc/grpc/blob/master/doc/statuscodes.mdPossible values: - 'cancelled': The operation was cancelled (typically by the caller). - 'unknown': Unknown error or an error from a different error domain. - 'invalid-argument': Client specified an invalid argument. Note that this differs from 'failed-precondition'. 'invalid-argument' indicates arguments that are problematic regardless of the state of the system (e.g. an invalid field name). - 'deadline-exceeded': Deadline expired before operation could complete. For operations that change the state of the system, this error may be returned even if the operation has completed successfully. For example, a successful response from a server could have been delayed long enough for the deadline to expire. - 'not-found': Some requested document was not found. - 'already-exists': Some document that we attempted to create already exists. - 'permission-denied': The caller does not have permission to execute the specified operation. - 'resource-exhausted': Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space. - 'failed-precondition': Operation was rejected because the system is not in a state required for the operation's execution. - 'aborted': The operation was aborted, typically due to a concurrency issue like transaction aborts, etc. - 'out-of-range': Operation was attempted past the valid range. - 'unimplemented': Operation is not implemented or not supported/enabled. - 'internal': Internal errors. Means some invariants expected by underlying system has been broken. If you see one of these errors, something is very broken. - 'unavailable': The service is currently unavailable. This is most likely a transient condition and may be corrected by retrying with a backoff. - 'data-loss': Unrecoverable data loss or corruption. - 'unauthenticated': The request does not have valid authentication credentials for the operation. | +| [FirestoreLocalCache](./firestore_.md#firestorelocalcache) | Union type from all supported SDK cache layer. | +| [ListenSource](./firestore_.md#listensource) | Describe the source a query listens to.Set to default to listen to both cache and server changes. Set to cache to listen to changes in cache only. | +| [MemoryGarbageCollector](./firestore_.md#memorygarbagecollector) | Union type from all support garbage collectors for memory local cache. | +| [NestedUpdateFields](./firestore_.md#nestedupdatefields) | For each field (e.g. 'bar'), find all nested keys (e.g. {'bar.baz': T1, 'bar.qux': T2}). Intersect them together to make a single map containing all possible keys that are all marked as optional | +| [OrderByDirection](./firestore_.md#orderbydirection) | The direction of a [orderBy()](./firestore_.md#orderby_006d61f) clause is specified as 'desc' or 'asc' (descending or ascending). | +| [PartialWithFieldValue](./firestore_.md#partialwithfieldvalue) | Similar to TypeScript's Partial<T>, but allows nested fields to be omitted and FieldValues to be passed in as property values. | +| [PersistentTabManager](./firestore_.md#persistenttabmanager) | A union of all available tab managers. | +| [Primitive](./firestore_.md#primitive) | Primitive types. | +| [QueryConstraintType](./firestore_.md#queryconstrainttype) | Describes the different query constraints available in this SDK. | +| [QueryFilterConstraint](./firestore_.md#queryfilterconstraint) | QueryFilterConstraint is a helper union type that represents [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) and [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). | +| [QueryNonFilterConstraint](./firestore_.md#querynonfilterconstraint) | QueryNonFilterConstraint is a helper union type that represents QueryConstraints which are used to narrow or order the set of documents, but that do not explicitly filter on a document field. QueryNonFilterConstraints are created by invoking [orderBy()](./firestore_.md#orderby_006d61f), [startAt()](./firestore_.md#startat_9a4477f), [startAfter()](./firestore_.md#startafter_9a4477f), [endBefore()](./firestore_.md#endbefore_9a4477f), [endAt()](./firestore_.md#endat_9a4477f), [limit()](./firestore_.md#limit_ec46c78) or [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the QueryConstraint. | +| [SetOptions](./firestore_.md#setoptions) | An options object that configures the behavior of [setDoc()](./firestore_lite.md#setdoc_ee215ad), and calls. These calls can be configured to perform granular merges instead of overwriting the target documents in their entirety by providing a SetOptions with merge: true. | +| [TaskState](./firestore_.md#taskstate) | Represents the state of bundle loading tasks.Both 'Error' and 'Success' are sinking state: task will abort or complete and there will be no more updates after they are reported. | +| [UnionToIntersection](./firestore_.md#uniontointersection) | Given a union type U = T1 | T2 | ..., returns an intersected type (T1 & T2 & ...).Uses distributive conditional types and inference from conditional types. This works because multiple candidates for the same type variable in contra-variant positions causes an intersection type to be inferred. https://www.typescriptlang.org/docs/handbook/advanced-types.html\#type-inference-in-conditional-types https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type | +| [UpdateData](./firestore_.md#updatedata) | Update data (for use with [updateDoc()](./firestore_.md#updatedoc_51a65e3)) that consists of field paths (e.g. 'foo' or 'foo.baz') mapped to values. Fields that contain dots reference nested fields within the document. FieldValues can be passed in as property values. | +| [WhereFilterOp](./firestore_.md#wherefilterop) | Filter conditions in a [where()](./firestore_.md#where_0fae4bf) clause are specified using the strings '&lt;', '&lt;=', '==', '!=', '&gt;=', '&gt;', 'array-contains', 'in', 'array-contains-any', and 'not-in'. | +| [WithFieldValue](./firestore_.md#withfieldvalue) | Allows FieldValues to be passed in as a property value while maintaining type safety. | -Creates an expression that checks if an expression is not equal to a constant value. +## function(app, ...) -```typescript -// Check if the 'status' field is not equal to "completed" -neq(Field.of("status"), "completed"); +### getFirestore(app) {:#getfirestore_cf608e1} -``` +Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. Signature: ```typescript -export declare function neq(left: Constant, right: any): Neq; +export declare function getFirestore(app: FirebaseApp): Firestore; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The expression to compare. | -| right | any | The constant value to compare to. A new Expr representing the inequality comparison. | +| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) instance that the returned [Firestore](./firestore_.firestore.md#firestore_class) instance is associated with. | Returns: -[Neq](./firestore_.neq.md#neq_class) - -### neq(left, right) {:#neq_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is not equal to an expression. - -```typescript -// Check if the 'status' field is not equal to the value of 'expectedStatus' -neq("status", Field.of("expectedStatus")); - -``` - -Signature: - -```typescript -export declare function neq(left: string, right: Constant): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | [Constant](./firestore_.constant.md#constant_class) | The expression to compare to. A new Expr representing the inequality comparison. | - -Returns: +[Firestore](./firestore_.firestore.md#firestore_class) -[Neq](./firestore_.neq.md#neq_class) +The default [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. -### neq(left, right) {:#neq_1f46a76} +### getFirestore(app, databaseId) {:#getfirestore_48de6cb} > This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. > -Creates an expression that checks if a field's value is not equal to a constant value. - -```typescript -// Check if the 'country' field is not equal to "USA" -neq("country", "USA"); - -``` +Returns the existing named [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. Signature: ```typescript -export declare function neq(left: string, right: any): Neq; +export declare function getFirestore(app: FirebaseApp, databaseId: string): Firestore; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | string | The field name to compare. | -| right | any | The constant value to compare to. A new Expr representing the inequality comparison. | +| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) instance that the returned [Firestore](./firestore_.firestore.md#firestore_class) instance is associated with. | +| databaseId | string | The name of the database. | Returns: -[Neq](./firestore_.neq.md#neq_class) - -### or(left, right) {:#or_eba7e36} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +[Firestore](./firestore_.firestore.md#firestore_class) -Creates an expression that performs a logical 'OR' operation on multiple filter conditions. +The named [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. -```typescript -// Check if the 'age' field is greater than 18 OR the 'city' field is "London" OR -// the 'status' field is "active" -const condition = or(gt("age", 18), eq("city", "London"), eq("status", "active")); +### initializeFirestore(app, settings, databaseId) {:#initializefirestore_fc7d200} -``` +Initializes a new instance of [Firestore](./firestore_.firestore.md#firestore_class) with the provided settings. Can only be called before any other function, including [getFirestore()](./firestore_.md#getfirestore). If the custom settings are empty, this function is equivalent to calling [getFirestore()](./firestore_.md#getfirestore). Signature: ```typescript -export declare function or(left: FilterExpr, ...right: FilterExpr[]): Or; +export declare function initializeFirestore(app: FirebaseApp, settings: FirestoreSettings, databaseId?: string): Firestore; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [FilterExpr](./firestore_.md#filterexpr) | The first filter condition. | -| right | [FilterExpr](./firestore_.md#filterexpr)\[\] | Additional filter conditions to 'OR' together. A new representing the logical 'OR' operation. | +| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) with which the [Firestore](./firestore_.firestore.md#firestore_class) instance will be associated. | +| settings | [FirestoreSettings](./firestore_.firestoresettings.md#firestoresettings_interface) | A settings object to configure the [Firestore](./firestore_.firestore.md#firestore_class) instance. | +| databaseId | string | The name of the database. | Returns: -[Or](./firestore_.or.md#or_class) - -### queryEqual(left, right) {:#queryequal_7a1f045} - -Returns true if the provided queries point to the same collection and apply the same constraints. - -Signature: - -```typescript -export declare function queryEqual(left: Query, right: Query): boolean; -``` - -#### Parameters +[Firestore](./firestore_.firestore.md#firestore_class) -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | A Query to compare. | -| right | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | A Query to compare. | +A newly initialized [Firestore](./firestore_.firestore.md#firestore_class) instance. -Returns: +## function(firestore, ...) -boolean +### clearIndexedDbPersistence(firestore) {:#clearindexeddbpersistence_231a8e0} -true if the references point to the same location in the same Firestore database. +Clears the persistent storage. This includes pending writes and cached documents. -### refEqual(left, right) {:#refequal_598b780} +Must be called while the [Firestore](./firestore_.firestore.md#firestore_class) instance is not started (after the app is terminated or when the app is first initialized). On startup, this function must be called before other functions (other than [initializeFirestore()](./firestore_.md#initializefirestore_fc7d200) or [getFirestore()](./firestore_.md#getfirestore))). If the [Firestore](./firestore_.firestore.md#firestore_class) instance is still running, the promise will be rejected with the error code of `failed-precondition`. -Returns true if the provided references are equal. +Note: `clearIndexedDbPersistence()` is primarily intended to help write reliable tests that use Cloud Firestore. It uses an efficient mechanism for dropping existing data but does not attempt to securely overwrite or otherwise make cached data unrecoverable. For applications that are sensitive to the disclosure of cached data in between user sessions, we strongly recommend not enabling persistence at all. Signature: ```typescript -export declare function refEqual(left: DocumentReference | CollectionReference, right: DocumentReference | CollectionReference): boolean; +export declare function clearIndexedDbPersistence(firestore: Firestore): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> \| [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to compare. | -| right | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> \| [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to compare. | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to clear persistence for. | Returns: -boolean - -true if the references point to the same location in the same Firestore database. - -### regexContains(left, pattern) {:#regexcontains_33ec01b} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +Promise<void> -Creates an expression that checks if a string field contains a specified regular expression as a substring. +A `Promise` that is resolved when the persistent storage is cleared. Otherwise, the promise is rejected with an error. -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -regexContains("description", "(?i)example"); +### collection(firestore, path, pathSegments) {:#collection_1eb4c23} -``` +Gets a `CollectionReference` instance that refers to the collection at the specified absolute path. Signature: ```typescript -export declare function regexContains(left: string, pattern: string): RegexContains; +export declare function collection(firestore: Firestore, path: string, ...pathSegments: string[]): CollectionReference; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | string | The name of the field containing the string. | -| pattern | string | The regular expression to use for the search. A new representing the 'contains' comparison. | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | A reference to the root Firestore instance. | +| path | string | A slash-separated path to a collection. | +| pathSegments | string\[\] | Additional path segments to apply relative to the first argument. | Returns: -[RegexContains](./firestore_.regexcontains.md#regexcontains_class) +[CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> -### regexContains(left, pattern) {:#regexcontains_dd84184} +The `CollectionReference` instance. -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +#### Exceptions -Creates an expression that checks if a string field contains a specified regular expression as a substring. +If the final path has an even number of segments and does not point to a collection. -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -regexContains("description", Field.of("pattern")); +### collectionGroup(firestore, collectionId) {:#collectiongroup_1838fc3} -``` +Creates and returns a new `Query` instance that includes all documents in the database that are contained in a collection or subcollection with the given `collectionId`. Signature: ```typescript -export declare function regexContains(left: string, pattern: Constant): RegexContains; +export declare function collectionGroup(firestore: Firestore, collectionId: string): Query; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | string | The name of the field containing the string. | -| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the search. A new representing the 'contains' comparison. | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | A reference to the root Firestore instance. | +| collectionId | string | Identifies the collections to query over. Every collection or subcollection with this ID as the last segment of its path will be included. Cannot contain a slash. | Returns: -[RegexContains](./firestore_.regexcontains.md#regexcontains_class) - -### regexContains(left, pattern) {:#regexcontains_3aaffe0} +[Query](./firestore_.query.md#query_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +The created `Query`. -Creates an expression that checks if a string expression contains a specified regular expression as a substring. +### connectFirestoreEmulator(firestore, host, port, options) {:#connectfirestoreemulator_7c247cd} -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -regexContains(Field.of("description"), "(?i)example"); +Modify this instance to communicate with the Cloud Firestore emulator. -``` +Note: This must be called before this instance has been used to do any operations. Signature: ```typescript -export declare function regexContains(left: Constant, pattern: string): RegexContains; +export declare function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: { + mockUserToken?: EmulatorMockTokenOptions | string; +}): void; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to perform the comparison on. | -| pattern | string | The regular expression to use for the search. A new representing the 'contains' comparison. | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The Firestore instance to configure to connect to the emulator. | +| host | string | the emulator host (ex: localhost). | +| port | number | the emulator port (ex: 9000). | +| options | { mockUserToken?: [EmulatorMockTokenOptions](./util.md#emulatormocktokenoptions) \| string; } | | Returns: -[RegexContains](./firestore_.regexcontains.md#regexcontains_class) - -### regexContains(left, pattern) {:#regexcontains_a2c3e8b} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string expression contains a specified regular expression as a substring. +void -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -regexContains(Field.of("description"), Field.of("pattern")); +### disableNetwork(firestore) {:#disablenetwork_231a8e0} -``` +Disables network usage for this instance. It can be re-enabled via [enableNetwork()](./firestore_.md#enablenetwork_231a8e0). While the network is disabled, any snapshot listeners, `getDoc()` or `getDocs()` calls will return results from cache, and any write operations will be queued until the network is restored. Signature: ```typescript -export declare function regexContains(left: Constant, pattern: Constant): RegexContains; +export declare function disableNetwork(firestore: Firestore): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to perform the comparison on. | -| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the search. A new representing the 'contains' comparison. | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | Returns: -[RegexContains](./firestore_.regexcontains.md#regexcontains_class) - -### regexMatch(left, pattern) {:#regexmatch_33ec01b} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +Promise<void> -Creates an expression that checks if a string field matches a specified regular expression. +A `Promise` that is resolved once the network has been disabled. -```typescript -// Check if the 'email' field matches a valid email pattern -regexMatch("email", "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); +### doc(firestore, path, pathSegments) {:#doc_1eb4c23} -``` +Gets a `DocumentReference` instance that refers to the document at the specified absolute path. Signature: ```typescript -export declare function regexMatch(left: string, pattern: string): RegexMatch; +export declare function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | string | The name of the field containing the string. | -| pattern | string | The regular expression to use for the match. A new representing the regular expression match. | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | A reference to the root Firestore instance. | +| path | string | A slash-separated path to a document. | +| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | Returns: -[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) - -### regexMatch(left, pattern) {:#regexmatch_dd84184} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string field matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a valid email pattern -regexMatch("email", Field.of("pattern")); - -``` +[DocumentReference](./firestore_.documentreference.md#documentreference_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> -Signature: +The `DocumentReference` instance. -```typescript -export declare function regexMatch(left: string, pattern: Constant): RegexMatch; -``` +#### Exceptions -#### Parameters +If the final path has an odd number of segments and does not point to a document. -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The name of the field containing the string. | -| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the match. A new representing the regular expression match. | +### enableIndexedDbPersistence(firestore, persistenceSettings) {:#enableindexeddbpersistence_224174f} -Returns: +> Warning: This API is now obsolete. +> +> This function will be removed in a future major release. Instead, set `FirestoreSettings.localCache` to an instance of `PersistentLocalCache` to turn on IndexedDb cache. Calling this function when `FirestoreSettings.localCache` is already specified will throw an exception. +> -[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) +Attempts to enable persistent storage, if possible. -### regexMatch(left, pattern) {:#regexmatch_3aaffe0} +On failure, `enableIndexedDbPersistence()` will reject the promise or throw an exception. There are several reasons why this can fail, which can be identified by the `code` on the error. -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +\* failed-precondition: The app is already open in another browser tab. \* unimplemented: The browser is incompatible with the offline persistence implementation. -Creates an expression that checks if a string expression matches a specified regular expression. +Note that even after a failure, the [Firestore](./firestore_.firestore.md#firestore_class) instance will remain usable, however offline persistence will be disabled. -```typescript -// Check if the 'email' field matches a valid email pattern -regexMatch(Field.of("email"), "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); +Note: `enableIndexedDbPersistence()` must be called before any other functions (other than [initializeFirestore()](./firestore_.md#initializefirestore_fc7d200), [getFirestore()](./firestore_.md#getfirestore) or [clearIndexedDbPersistence()](./firestore_.md#clearindexeddbpersistence_231a8e0). -``` +Persistence cannot be used in a Node.js environment. Signature: ```typescript -export declare function regexMatch(left: Constant, pattern: string): RegexMatch; +export declare function enableIndexedDbPersistence(firestore: Firestore, persistenceSettings?: PersistenceSettings): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to match against. | -| pattern | string | The regular expression to use for the match. A new representing the regular expression match. | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to enable persistence for. | +| persistenceSettings | [PersistenceSettings](./firestore_.persistencesettings.md#persistencesettings_interface) | Optional settings object to configure persistence. | Returns: -[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) - -### regexMatch(left, pattern) {:#regexmatch_a2c3e8b} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string expression matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a valid email pattern -regexMatch(Field.of("email"), Field.of("pattern")); - -``` - -Signature: +Promise<void> -```typescript -export declare function regexMatch(left: Constant, pattern: Constant): RegexMatch; -``` +A `Promise` that represents successfully enabling persistent storage. -#### Parameters +### enableMultiTabIndexedDbPersistence(firestore) {:#enablemultitabindexeddbpersistence_231a8e0} -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to match against. | -| pattern | [Constant](./firestore_.constant.md#constant_class) | The regular expression to use for the match. A new representing the regular expression match. | +> Warning: This API is now obsolete. +> +> This function will be removed in a future major release. Instead, set `FirestoreSettings.localCache` to an instance of `PersistentLocalCache` to turn on indexeddb cache. Calling this function when `FirestoreSettings.localCache` is already specified will throw an exception. +> -Returns: +Attempts to enable multi-tab persistent storage, if possible. If enabled across all tabs, all operations share access to local persistence, including shared execution of queries and latency-compensated local document updates across all connected instances. -[RegexMatch](./firestore_.regexmatch.md#regexmatch_class) +On failure, `enableMultiTabIndexedDbPersistence()` will reject the promise or throw an exception. There are several reasons why this can fail, which can be identified by the `code` on the error. -### snapshotEqual(left, right) {:#snapshotequal_5109204} +\* failed-precondition: The app is already open in another browser tab and multi-tab is not enabled. \* unimplemented: The browser is incompatible with the offline persistence implementation. -Returns true if the provided snapshots are equal. +Note that even after a failure, the [Firestore](./firestore_.firestore.md#firestore_class) instance will remain usable, however offline persistence will be disabled. Signature: ```typescript -export declare function snapshotEqual(left: DocumentSnapshot | QuerySnapshot, right: DocumentSnapshot | QuerySnapshot): boolean; +export declare function enableMultiTabIndexedDbPersistence(firestore: Firestore): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> \| [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType> | A snapshot to compare. | -| right | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> \| [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType> | A snapshot to compare. | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to enable persistence for. | Returns: -boolean - -true if the snapshots are equal. - -### strContains(left, substring) {:#strcontains_18eaf5d} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +Promise<void> -Creates an expression that checks if a string field contains a specified substring. +A `Promise` that represents successfully enabling persistent storage. -```typescript -// Check if the 'description' field contains "example". -strContains("description", "example"); +### enableNetwork(firestore) {:#enablenetwork_231a8e0} -``` +Re-enables use of the network for this [Firestore](./firestore_.firestore.md#firestore_class) instance after a prior call to [disableNetwork()](./firestore_.md#disablenetwork_231a8e0). Signature: ```typescript -export declare function strContains(left: string, substring: string): StrContains; +export declare function enableNetwork(firestore: Firestore): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | string | The name of the field containing the string. | -| substring | string | The substring to search for. A new representing the 'contains' comparison. | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | Returns: -[StrContains](./firestore_.strcontains.md#strcontains_class) - -### strContains(left, substring) {:#strcontains_f0f1f2f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +Promise<void> -Creates an expression that checks if a string field contains a substring specified by an expression. +A `Promise` that is resolved once the network has been enabled. -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -strContains("description", Field.of("keyword")); +### getPersistentCacheIndexManager(firestore) {:#getpersistentcacheindexmanager_231a8e0} -``` +Returns the PersistentCache Index Manager used by the given `Firestore` object. + + The `PersistentCacheIndexManager` instance, or `null` if local persistent storage is not in use. Signature: ```typescript -export declare function strContains(left: string, substring: Constant): StrContains; +export declare function getPersistentCacheIndexManager(firestore: Firestore): PersistentCacheIndexManager | null; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | string | The name of the field containing the string. | -| substring | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. A new representing the 'contains' comparison. | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | Returns: -[StrContains](./firestore_.strcontains.md#strcontains_class) - -### strContains(left, substring) {:#strcontains_5fdbd29} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string expression contains a specified substring. +[PersistentCacheIndexManager](./firestore_.persistentcacheindexmanager.md#persistentcacheindexmanager_class) \| null -```typescript -// Check if the 'description' field contains "example". -strContains(Field.of("description"), "example"); +### loadBundle(firestore, bundleData) {:#loadbundle_bec5b75} -``` +Loads a Firestore bundle into the local cache. Signature: ```typescript -export declare function strContains(left: Constant, substring: string): StrContains; +export declare function loadBundle(firestore: Firestore, bundleData: ReadableStream | ArrayBuffer | string): LoadBundleTask; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to perform the comparison on. | -| substring | string | The substring to search for. A new representing the 'contains' comparison. | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to load bundles for. | +| bundleData | ReadableStream<Uint8Array> \| ArrayBuffer \| string | An object representing the bundle to be loaded. Valid objects are ArrayBuffer, ReadableStream<Uint8Array> or string. | Returns: -[StrContains](./firestore_.strcontains.md#strcontains_class) - -### strContains(left, substring) {:#strcontains_d9d749f} +[LoadBundleTask](./firestore_.loadbundletask.md#loadbundletask_class) -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +A `LoadBundleTask` object, which notifies callers with progress updates, and completion or error events. It can be used as a `Promise`. -Creates an expression that checks if a string expression contains a substring specified by another expression. +### namedQuery(firestore, name) {:#namedquery_6438876} -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -strContains(Field.of("description"), Field.of("keyword")); +Reads a Firestore [Query](./firestore_.query.md#query_class) from local cache, identified by the given name. -``` +The named queries are packaged into bundles on the server side (along with resulting documents), and loaded to local cache using `loadBundle`. Once in local cache, use this method to extract a [Query](./firestore_.query.md#query_class) by name. Signature: ```typescript -export declare function strContains(left: Constant, substring: Constant): StrContains; +export declare function namedQuery(firestore: Firestore, name: string): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to perform the comparison on. | -| substring | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. A new representing the 'contains' comparison. | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to read the query from. | +| name | string | The name of the query. | Returns: -[StrContains](./firestore_.strcontains.md#strcontains_class) - -### subtract(left, right) {:#subtract_be96f75} +Promise<[Query](./firestore_.query.md#query_class) \| null> -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +A `Promise` that is resolved with the Query or `null`. -Creates an expression that subtracts two expressions. +### onSnapshotsInSync(firestore, observer) {:#onsnapshotsinsync_2f0dfa4} -```typescript -// Subtract the 'discount' field from the 'price' field -subtract(Field.of("price"), Field.of("discount")); +Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if a single server-generated change affects multiple listeners. -``` +NOTE: The snapshots-in-sync event only indicates that listeners are in sync with each other, but does not relate to whether those snapshots are in sync with the server. Use SnapshotMetadata in the individual listeners to determine if a snapshot is from the cache or the server. Signature: ```typescript -export declare function subtract(left: Constant, right: Constant): Subtract; +export declare function onSnapshotsInSync(firestore: Firestore, observer: { + next?: (value: void) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; +}): Unsubscribe; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The expression to subtract from. | -| right | [Constant](./firestore_.constant.md#constant_class) | The expression to subtract. A new representing the subtraction operation. | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The instance of Firestore for synchronizing snapshots. | +| observer | { next?: (value: void) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | Returns: -[Subtract](./firestore_.subtract.md#subtract_class) - -### subtract(left, right) {:#subtract_010ba9e} +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +An unsubscribe function that can be called to cancel the snapshot listener. -Creates an expression that subtracts a constant value from an expression. +### onSnapshotsInSync(firestore, onSync) {:#onsnapshotsinsync_1901c06} -```typescript -// Subtract the constant value 2 from the 'value' field -subtract(Field.of("value"), 2); +Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if a single server-generated change affects multiple listeners. -``` +NOTE: The snapshots-in-sync event only indicates that listeners are in sync with each other, but does not relate to whether those snapshots are in sync with the server. Use `SnapshotMetadata` in the individual listeners to determine if a snapshot is from the cache or the server. Signature: ```typescript -export declare function subtract(left: Constant, right: any): Subtract; +export declare function onSnapshotsInSync(firestore: Firestore, onSync: () => void): Unsubscribe; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | The expression to subtract from. | -| right | any | The constant value to subtract. A new representing the subtraction operation. | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The Firestore instance for synchronizing snapshots. | +| onSync | () => void | A callback to be called every time all snapshot listeners are in sync with each other. | Returns: -[Subtract](./firestore_.subtract.md#subtract_class) - -### subtract(left, right) {:#subtract_674c63f} +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +An unsubscribe function that can be called to cancel the snapshot listener. -Creates an expression that subtracts an expression from a field's value. +### runTransaction(firestore, updateFunction, options) {:#runtransaction_6f03ec4} -```typescript -// Subtract the 'discount' field from the 'price' field -subtract("price", Field.of("discount")); +Executes the given `updateFunction` and then attempts to commit the changes applied within the transaction. If any document read within the transaction has changed, Cloud Firestore retries the `updateFunction`. If it fails to commit after 5 attempts, the transaction fails. -``` +The maximum number of writes allowed in a single transaction is 500. Signature: ```typescript -export declare function subtract(left: string, right: Constant): Subtract; +export declare function runTransaction(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise, options?: TransactionOptions): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | string | The field name to subtract from. | -| right | [Constant](./firestore_.constant.md#constant_class) | The expression to subtract. A new representing the subtraction operation. | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | A reference to the Firestore database to run this transaction against. | +| updateFunction | (transaction: [Transaction](./firestore_.transaction.md#transaction_class)) => Promise<T> | The function to execute within the transaction context. | +| options | [TransactionOptions](./firestore_.transactionoptions.md#transactionoptions_interface) | An options object to configure maximum number of attempts to commit. | Returns: -[Subtract](./firestore_.subtract.md#subtract_class) +Promise<T> + +If the transaction completed successfully or was explicitly aborted (the `updateFunction` returned a failed promise), the promise returned by the `updateFunction `is returned here. Otherwise, if the transaction failed, a rejected promise with the corresponding failure error is returned. -### subtract(left, right) {:#subtract_1f46a76} +### setIndexConfiguration(firestore, configuration) {:#setindexconfiguration_c362f04} > This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. > -Creates an expression that subtracts a constant value from a field's value. +> Warning: This API is now obsolete. +> +> Instead of creating cache indexes manually, consider using `enablePersistentCacheIndexAutoCreation()` to let the SDK decide whether to create cache indexes for queries running locally. +> -```typescript -// Subtract 20 from the value of the 'total' field -subtract("total", 20); +Configures indexing for local query execution. Any previous index configuration is overridden. The `Promise` resolves once the index configuration has been persisted. -``` +The index entries themselves are created asynchronously. You can continue to use queries that require indexing even if the indices are not yet available. Query execution will automatically start using the index once the index entries have been written. + +Indexes are only supported with IndexedDb persistence. If IndexedDb is not enabled, any index configuration is ignored. Signature: ```typescript -export declare function subtract(left: string, right: any): Subtract; +export declare function setIndexConfiguration(firestore: Firestore, configuration: IndexConfiguration): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | string | The field name to subtract from. | -| right | any | The constant value to subtract. A new representing the subtraction operation. | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to configure indexes for. | +| configuration | [IndexConfiguration](./firestore_.indexconfiguration.md#indexconfiguration_interface) | The index definition. | Returns: -[Subtract](./firestore_.subtract.md#subtract_class) +Promise<void> + +A `Promise` that resolves once all indices are successfully configured. + +#### Exceptions + +FirestoreError if the JSON format is invalid. -### xor(left, right) {:#xor_eba7e36} +### setIndexConfiguration(firestore, json) {:#setindexconfiguration_90d0285} > This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. > -Creates an expression that performs a logical 'XOR' (exclusive OR) operation on multiple filter conditions. +> Warning: This API is now obsolete. +> +> Instead of creating cache indexes manually, consider using `enablePersistentCacheIndexAutoCreation()` to let the SDK decide whether to create cache indexes for queries running locally. +> -```typescript -// Check if only one of the conditions is true: 'age' greater than 18, 'city' is "London", -// or 'status' is "active". -const condition = xor( - gt("age", 18), - eq("city", "London"), - eq("status", "active")); +Configures indexing for local query execution. Any previous index configuration is overridden. The `Promise` resolves once the index configuration has been persisted. -``` +The index entries themselves are created asynchronously. You can continue to use queries that require indexing even if the indices are not yet available. Query execution will automatically start using the index once the index entries have been written. + +Indexes are only supported with IndexedDb persistence. Invoke either `enableIndexedDbPersistence()` or `enableMultiTabIndexedDbPersistence()` before setting an index configuration. If IndexedDb is not enabled, any index configuration is ignored. + +The method accepts the JSON format exported by the Firebase CLI (`firebase firestore:indexes`). If the JSON format is invalid, this method throws an error. Signature: ```typescript -export declare function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; +export declare function setIndexConfiguration(firestore: Firestore, json: string): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [FilterExpr](./firestore_.md#filterexpr) | The first filter condition. | -| right | [FilterExpr](./firestore_.md#filterexpr)\[\] | Additional filter conditions to 'XOR' together. A new representing the logical 'XOR' operation. | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance to configure indexes for. | +| json | string | The JSON format exported by the Firebase CLI. | Returns: -[Xor](./firestore_.xor.md#xor_class) +Promise<void> + +A `Promise` that resolves once all indices are successfully configured. -## function(limit, ...) +#### Exceptions -### limit(limit) {:#limit_ec46c78} +FirestoreError if the JSON format is invalid. -Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the first matching documents. +### terminate(firestore) {:#terminate_231a8e0} + +Terminates the provided [Firestore](./firestore_.firestore.md#firestore_class) instance. + +After calling `terminate()` only the `clearIndexedDbPersistence()` function may be used. Any other function will throw a `FirestoreError`. + +To restart after termination, create a new instance of FirebaseFirestore with [getFirestore()](./firestore_.md#getfirestore). + +Termination does not cancel any pending writes, and any promises that are awaiting a response from the server will not be resolved. If you have persistence enabled, the next time you start this instance, it will resume sending these writes to the server. + +Note: Under normal circumstances, calling `terminate()` is not required. This function is useful only when you want to force this instance to release all of its resources or in combination with `clearIndexedDbPersistence()` to ensure that all local state is destroyed between test runs. Signature: ```typescript -export declare function limit(limit: number): QueryLimitConstraint; +export declare function terminate(firestore: Firestore): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| limit | number | The maximum number of items to return. | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | Returns: -[QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) +Promise<void> -The created [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class). +A `Promise` that is resolved when the instance has been successfully terminated. -### limitToLast(limit) {:#limittolast_ec46c78} +### waitForPendingWrites(firestore) {:#waitforpendingwrites_231a8e0} -Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the last matching documents. +Waits until all currently pending writes for the active user have been acknowledged by the backend. -You must specify at least one `orderBy` clause for `limitToLast` queries, otherwise an exception will be thrown during execution. +The returned promise resolves immediately if there are no outstanding writes. Otherwise, the promise waits for all previously issued writes (including those written in a previous app session), but it does not wait for writes that were added after the function is called. If you want to wait for additional writes, call `waitForPendingWrites()` again. + +Any outstanding `waitForPendingWrites()` promises are rejected during user changes. Signature: ```typescript -export declare function limitToLast(limit: number): QueryLimitConstraint; +export declare function waitForPendingWrites(firestore: Firestore): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| limit | number | The maximum number of items to return. | +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | Returns: -[QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) +Promise<void> -The created [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class). +A `Promise` which resolves when all currently pending writes have been acknowledged by the backend. -## function(logLevel, ...) +### writeBatch(firestore) {:#writebatch_231a8e0} -### setLogLevel(logLevel) {:#setloglevel_d02fda2} +Creates a write batch, used for performing multiple writes as a single atomic operation. The maximum number of writes allowed in a single [WriteBatch](./firestore_.writebatch.md#writebatch_class) is 500. -Sets the verbosity of Cloud Firestore logs (debug, error, or silent). +Unlike transactions, write batches are persisted offline and therefore are preferable when you don't need to condition your writes on read data. Signature: ```typescript -export declare function setLogLevel(logLevel: LogLevel): void; +export declare function writeBatch(firestore: Firestore): WriteBatch; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| logLevel | LogLevel | The verbosity you set for activity and error logging. Can be any of the following values:

  • debug for the most verbose logging level, primarily for debugging.
  • error to log errors only.
  • silent to turn off logging.
| +| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | | Returns: -void - -## function(mapExpr, ...) - -### mapGet(mapExpr, subField) {:#mapget_9715f90} +[WriteBatch](./firestore_.writebatch.md#writebatch_class) -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +A [WriteBatch](./firestore_.writebatch.md#writebatch_class) that can be used to atomically execute multiple writes. -Accesses a value from a map (object) expression using the provided key. +## function() -```typescript -// Get the 'city' value from the 'address' map field -mapGet(Field.of("address"), "city"); +### count() {:#count} -``` +Create an AggregateField object that can be used to compute the count of documents in the result set of a query. Signature: ```typescript -export declare function mapGet(mapExpr: Constant, subField: string): MapGet; +export declare function count(): AggregateField; ``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| mapExpr | [Constant](./firestore_.constant.md#constant_class) | The expression representing the map. | -| subField | string | The key to access in the map. A new representing the value associated with the given key in the map. | - Returns: -[MapGet](./firestore_.mapget.md#mapget_class) - -## function(mapField, ...) +[AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<number> -### mapGet(mapField, subField) {:#mapget_b37bbb6} +### deleteField() {:#deletefield} -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +Returns a sentinel for use with [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) or [setDoc()](./firestore_lite.md#setdoc_ee215ad) with `{merge: true}` to mark a field for deletion. -Accesses a value from a map (object) field using the provided key. +Signature: ```typescript -// Get the 'city' value from the 'address' map field -mapGet("address", "city"); - +export declare function deleteField(): FieldValue; ``` +Returns: + +[FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) + +### documentId() {:#documentid} + +Returns a special sentinel `FieldPath` to refer to the ID of a document. It can be used in queries to sort or filter by the document ID. Signature: ```typescript -export declare function mapGet(mapField: string, subField: string): MapGet; +export declare function documentId(): FieldPath; ``` +Returns: -#### Parameters +[FieldPath](./firestore_.fieldpath.md#fieldpath_class) -| Parameter | Type | Description | -| --- | --- | --- | -| mapField | string | The field name of the map field. | -| subField | string | The key to access in the map. A new representing the value associated with the given key in the map. | +### getFirestore() {:#getfirestore} -Returns: +Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. -[MapGet](./firestore_.mapget.md#mapget_class) +Signature: -## function(n, ...) +```typescript +export declare function getFirestore(): Firestore; +``` +Returns: -### increment(n) {:#increment_5685735} +[Firestore](./firestore_.firestore.md#firestore_class) -Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to increment the field's current value by the given value. +The default [Firestore](./firestore_.firestore.md#firestore_class) instance of the default app. -If either the operand or the current field value uses floating point precision, all arithmetic follows IEEE 754 semantics. If both values are integers, values outside of JavaScript's safe number range (`Number.MIN_SAFE_INTEGER` to `Number.MAX_SAFE_INTEGER`) are also subject to precision loss. Furthermore, once processed by the Firestore backend, all integer operations are capped between -2^63 and 2^63-1. +### memoryEagerGarbageCollector() {:#memoryeagergarbagecollector} -If the current field value is not of type `number`, or if the field does not yet exist, the transformation sets the field to the given value. +Creates an instance of `MemoryEagerGarbageCollector`. This is also the default garbage collector unless it is explicitly specified otherwise. Signature: ```typescript -export declare function increment(n: number): FieldValue; +export declare function memoryEagerGarbageCollector(): MemoryEagerGarbageCollector; ``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| n | number | The value to increment by. | - Returns: -[FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) +[MemoryEagerGarbageCollector](./firestore_.memoryeagergarbagecollector.md#memoryeagergarbagecollector_interface) -The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()` +### persistentMultipleTabManager() {:#persistentmultipletabmanager} -## function(name, ...) +Creates an instance of `PersistentMultipleTabManager`. -### genericFunction(name, params) {:#genericfunction_b886545} +Signature: -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +```typescript +export declare function persistentMultipleTabManager(): PersistentMultipleTabManager; +``` +Returns: -Creates functions that work on the backend but do not exist in the SDK yet. +[PersistentMultipleTabManager](./firestore_.persistentmultipletabmanager.md#persistentmultipletabmanager_interface) -```typescript -// Call a user defined function named "myFunc" with the arguments 10 and 20 -// This is the same of the 'sum(Field.of("price"))', if it did not exist -genericFunction("sum", [Field.of("price")]); +### serverTimestamp() {:#servertimestamp} -``` +Returns a sentinel used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) to include a server-generated timestamp in the written data. Signature: ```typescript -export declare function genericFunction(name: string, params: Constant[]): FirestoreFunction; +export declare function serverTimestamp(): FieldValue; ``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | The name of the user defined function. | -| params | [Constant](./firestore_.constant.md#constant_class)\[\] | The arguments to pass to the function. A new representing the function call. | - Returns: -[FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) +[FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) -## function(pipeline, ...) +## function(databaseId, ...) -### execute(pipeline) {:#execute_86486e6} +### getFirestore(databaseId) {:#getfirestore_53dc891} > This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. > -Modular API for console experimentation. +Returns the existing named [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. Signature: ```typescript -export declare function execute(pipeline: Pipeline): Promise>>; +export declare function getFirestore(databaseId: string): Firestore; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| pipeline | [Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> | Execute this pipeline. | +| databaseId | string | The name of the database. | Returns: -Promise<Array<[PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class)<AppModelType>>> - -## function(query, ...) +[Firestore](./firestore_.firestore.md#firestore_class) -### getAggregateFromServer(query, aggregateSpec) {:#getaggregatefromserver_2073a74} +The named [Firestore](./firestore_.firestore.md#firestore_class) instance of the default app. -Calculates the specified aggregations over the documents in the result set of the given query without actually downloading the documents. +## function(elements, ...) -Using this function to perform aggregations is efficient because only the final aggregation values, not the documents' data, are downloaded. This function can perform aggregations of the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). +### arrayRemove(elements) {:#arrayremove_7d853aa} -The result received from the server is presented, unaltered, without considering any local state. That is, documents in the local cache are not taken into consideration, neither are local modifications not yet synchronized with the server. Previously-downloaded results, if any, are not used. Every invocation of this function necessarily involves a round trip to the server. +Returns a special value that can be used with [setDoc()](./firestore_.md#setdoc_ee215ad) or that tells the server to remove the given elements from any array value that already exists on the server. All instances of each element specified will be removed from the array. If the field being modified is not already an array it will be overwritten with an empty array. Signature: ```typescript -export declare function getAggregateFromServer(query: Query, aggregateSpec: AggregateSpecType): Promise>; +export declare function arrayRemove(...elements: unknown[]): FieldValue; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query whose result set is aggregated over. | -| aggregateSpec | AggregateSpecType | An AggregateSpec object that specifies the aggregates to perform over the result set. The AggregateSpec specifies aliases for each aggregate, which can be used to retrieve the aggregate result. | +| elements | unknown\[\] | The elements to remove from the array. | Returns: -Promise<[AggregateQuerySnapshot](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType>> - -### Example - - -```typescript -const aggregateSnapshot = await getAggregateFromServer(query, { - countOfDocs: count(), - totalHours: sum('hours'), - averageScore: average('score') -}); - -const countOfDocs: number = aggregateSnapshot.data().countOfDocs; -const totalHours: number = aggregateSnapshot.data().totalHours; -const averageScore: number | null = aggregateSnapshot.data().averageScore; - -``` - -### getCountFromServer(query) {:#getcountfromserver_4e56953} +[FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) -Calculates the number of documents in the result set of the given query without actually downloading the documents. +The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()` -Using this function to count the documents is efficient because only the final count, not the documents' data, is downloaded. This function can count the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). +### arrayUnion(elements) {:#arrayunion_7d853aa} -The result received from the server is presented, unaltered, without considering any local state. That is, documents in the local cache are not taken into consideration, neither are local modifications not yet synchronized with the server. Previously-downloaded results, if any, are not used. Every invocation of this function necessarily involves a round trip to the server. +Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to union the given elements with any array value that already exists on the server. Each specified element that doesn't already exist in the array will be added to the end. If the field being modified is not already an array it will be overwritten with an array containing exactly the specified elements. Signature: ```typescript -export declare function getCountFromServer(query: Query): Promise; -}, AppModelType, DbModelType>>; +export declare function arrayUnion(...elements: unknown[]): FieldValue; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query whose result set size is calculated. | +| elements | unknown\[\] | The elements to union into the array. | Returns: -Promise<[AggregateQuerySnapshot](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<{ count: [AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<number>; }, AppModelType, DbModelType>> +[FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) -A Promise that will be resolved with the count; the count can be retrieved from `snapshot.data().count`, where `snapshot` is the `AggregateQuerySnapshot` to which the returned Promise resolves. +The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()`. -### getDocs(query) {:#getdocs_4e56953} +## function(field, ...) -Executes the query and returns the results as a `QuerySnapshot`. +### average(field) {:#average_aacc3a9} -Note: `getDocs()` attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. To specify this behavior, invoke [getDocsFromCache()](./firestore_.md#getdocsfromcache_4e56953) or [getDocsFromServer()](./firestore_.md#getdocsfromserver_4e56953). +Create an AggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query. Signature: ```typescript -export declare function getDocs(query: Query): Promise>; +export declare function average(field: string | FieldPath): AggregateField; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | | +| field | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | Specifies the field to average across the result set. | Returns: -Promise<[QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>> - -A `Promise` that will be resolved with the results of the query. +[AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<number \| null> -### getDocsFromCache(query) {:#getdocsfromcache_4e56953} +### sum(field) {:#sum_aacc3a9} -Executes the query and returns the results as a `QuerySnapshot` from cache. Returns an empty result set if no documents matching the query are currently cached. +Create an AggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query. Signature: ```typescript -export declare function getDocsFromCache(query: Query): Promise>; +export declare function sum(field: string | FieldPath): AggregateField; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | | +| field | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | Specifies the field to sum across the result set. | Returns: -Promise<[QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>> +[AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<number> -A `Promise` that will be resolved with the results of the query. +## function(fieldPath, ...) -### getDocsFromServer(query) {:#getdocsfromserver_4e56953} +### orderBy(fieldPath, directionStr) {:#orderby_006d61f} -Executes the query and returns the results as a `QuerySnapshot` from the server. Returns an error if the network is not available. +Creates a [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) that sorts the query result by the specified field, optionally in descending order instead of ascending. + +Note: Documents that do not contain the specified field will not be present in the query result. Signature: ```typescript -export declare function getDocsFromServer(query: Query): Promise>; +export declare function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryOrderByConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | | +| fieldPath | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | The field to sort by. | +| directionStr | [OrderByDirection](./firestore_.md#orderbydirection) | Optional direction to sort by ('asc' or 'desc'). If not specified, order will be ascending. | Returns: -Promise<[QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>> - -A `Promise` that will be resolved with the results of the query. +[QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) -### onSnapshot(query, observer) {:#onsnapshot_8d14049} +The created [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class). -Attaches a listener for `QuerySnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. +### where(fieldPath, opStr, value) {:#where_0fae4bf} -NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. +Creates a [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) that enforces that documents must contain the specified field and that the value should satisfy the relation constraint provided. Signature: ```typescript -export declare function onSnapshot(query: Query, observer: { - next?: (snapshot: QuerySnapshot) => void; - error?: (error: FirestoreError) => void; - complete?: () => void; -}): Unsubscribe; +export declare function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryFieldFilterConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query to listen to. | -| observer | { next?: (snapshot: [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | +| fieldPath | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | The path to compare | +| opStr | [WhereFilterOp](./firestore_.md#wherefilterop) | The operation string (e.g "&lt;", "&lt;=", "==", "&lt;", "&lt;=", "!="). | +| value | unknown | The value for comparison | Returns: -[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) +[QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) -An unsubscribe function that can be called to cancel the snapshot listener. +The created [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class). -### onSnapshot(query, options, observer) {:#onsnapshot_03dfff5} +## function(fieldValues, ...) -Attaches a listener for `QuerySnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. +### endAt(fieldValues) {:#endat_8b2f2c8} -NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. +Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. Signature: ```typescript -export declare function onSnapshot(query: Query, options: SnapshotListenOptions, observer: { - next?: (snapshot: QuerySnapshot) => void; - error?: (error: FirestoreError) => void; - complete?: () => void; -}): Unsubscribe; +export declare function endAt(...fieldValues: unknown[]): QueryEndAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query to listen to. | -| options | [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | Options controlling the listen behavior. | -| observer | { next?: (snapshot: [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | +| fieldValues | unknown\[\] | The field values to end this query at, in order of the query's order by. | Returns: -[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) - -An unsubscribe function that can be called to cancel the snapshot listener. +[QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) -### onSnapshot(query, onNext, onError, onCompletion) {:#onsnapshot_3ebfbe2} +A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` -Attaches a listener for `QuerySnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. +### endBefore(fieldValues) {:#endbefore_8b2f2c8} -NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. +Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. Signature: ```typescript -export declare function onSnapshot(query: Query, onNext: (snapshot: QuerySnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe; +export declare function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query to listen to. | -| onNext | (snapshot: [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>) => void | A callback to be called every time a new QuerySnapshot is available. | -| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void | A callback to be called if the listen fails or is cancelled. No further callbacks will occur. | -| onCompletion | () => void | Can be provided, but will not be called since streams are never ending. | +| fieldValues | unknown\[\] | The field values to end this query before, in order of the query's order by. | Returns: -[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) - -An unsubscribe function that can be called to cancel the snapshot listener. +[QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) -### onSnapshot(query, options, onNext, onError, onCompletion) {:#onsnapshot_b8f9c47} +A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` -Attaches a listener for `QuerySnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. +### startAfter(fieldValues) {:#startafter_8b2f2c8} -NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. +Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. Signature: ```typescript -export declare function onSnapshot(query: Query, options: SnapshotListenOptions, onNext: (snapshot: QuerySnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe; +export declare function startAfter(...fieldValues: unknown[]): QueryStartAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query to listen to. | -| options | [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | Options controlling the listen behavior. | -| onNext | (snapshot: [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>) => void | A callback to be called every time a new QuerySnapshot is available. | -| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void | A callback to be called if the listen fails or is cancelled. No further callbacks will occur. | -| onCompletion | () => void | Can be provided, but will not be called since streams are never ending. | +| fieldValues | unknown\[\] | The field values to start this query after, in order of the query's order by. | Returns: -[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) +[QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) -An unsubscribe function that can be called to cancel the snapshot listener. +A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()` -### pipeline(query) {:#pipeline_20b2416} +### startAt(fieldValues) {:#startat_8b2f2c8} -Experimental Modular API for console testing. +Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. Signature: ```typescript -export declare function pipeline(query: Query): Pipeline; +export declare function startAt(...fieldValues: unknown[]): QueryStartAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class) | | +| fieldValues | unknown\[\] | The field values to start this query at, in order of the query's order by. | Returns: -[Pipeline](./firestore_.pipeline.md#pipeline_class) +[QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) -### query(query, compositeFilter, queryConstraints) {:#query_9f7b0f4} +A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()`. -Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. +## function(indexManager, ...) + +### deleteAllPersistentCacheIndexes(indexManager) {:#deleteallpersistentcacheindexes_98b2645} + +Removes all persistent cache indexes. + +Please note this function will also deletes indexes generated by `setIndexConfiguration()`, which is deprecated. Signature: ```typescript -export declare function query(query: Query, compositeFilter: QueryCompositeFilterConstraint, ...queryConstraints: QueryNonFilterConstraint[]): Query; +export declare function deleteAllPersistentCacheIndexes(indexManager: PersistentCacheIndexManager): void; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The [Query](./firestore_.query.md#query_class) instance to use as a base for the new constraints. | -| compositeFilter | [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) | The [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) to apply. Create [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) using or . | -| queryConstraints | [QueryNonFilterConstraint](./firestore_.md#querynonfilterconstraint)\[\] | Additional [QueryNonFilterConstraint](./firestore_.md#querynonfilterconstraint)s to apply (e.g. [orderBy()](./firestore_.md#orderby_006d61f), [limit()](./firestore_.md#limit_ec46c78)). | +| indexManager | [PersistentCacheIndexManager](./firestore_.persistentcacheindexmanager.md#persistentcacheindexmanager_class) | | Returns: -[Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> - -#### Exceptions - -if any of the provided query constraints cannot be combined with the existing or new constraints. +void -### query(query, queryConstraints) {:#query_0f46da1} +### disablePersistentCacheIndexAutoCreation(indexManager) {:#disablepersistentcacheindexautocreation_98b2645} -Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. +Stops creating persistent cache indexes automatically for local query execution. The indexes which have been created by calling `enablePersistentCacheIndexAutoCreation()` still take effect. Signature: ```typescript -export declare function query(query: Query, ...queryConstraints: QueryConstraint[]): Query; +export declare function disablePersistentCacheIndexAutoCreation(indexManager: PersistentCacheIndexManager): void; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The [Query](./firestore_.query.md#query_class) instance to use as a base for the new constraints. | -| queryConstraints | [QueryConstraint](./firestore_.queryconstraint.md#queryconstraint_class)\[\] | The list of [QueryConstraint](./firestore_.queryconstraint.md#queryconstraint_class)s to apply. | +| indexManager | [PersistentCacheIndexManager](./firestore_.persistentcacheindexmanager.md#persistentcacheindexmanager_class) | | Returns: -[Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> - -#### Exceptions - -if any of the provided query constraints cannot be combined with the existing or new constraints. +void -## function(queryConstraints, ...) +### enablePersistentCacheIndexAutoCreation(indexManager) {:#enablepersistentcacheindexautocreation_98b2645} -### and(queryConstraints) {:#and_e72c712} +Enables the SDK to create persistent cache indexes automatically for local query execution when the SDK believes cache indexes can help improve performance. -Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a conjunction of the given filter constraints. A conjunction filter includes a document if it satisfies all of the given filters. +This feature is disabled by default. Signature: ```typescript -export declare function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; +export declare function enablePersistentCacheIndexAutoCreation(indexManager: PersistentCacheIndexManager): void; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| queryConstraints | [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)\[\] | Optional. The list of [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)s to perform a conjunction for. These must be created with calls to [where()](./firestore_.md#where_0fae4bf), , or . | +| indexManager | [PersistentCacheIndexManager](./firestore_.persistentcacheindexmanager.md#persistentcacheindexmanager_class) | | Returns: -[QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) +void -The newly created [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). +## function(left, ...) -### or(queryConstraints) {:#or_e72c712} +### aggregateFieldEqual(left, right) {:#aggregatefieldequal_e80a2b2} -Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a disjunction of the given filter constraints. A disjunction filter includes a document if it satisfies any of the given filters. +Compares two 'AggregateField\` instances for equality. Signature: ```typescript -export declare function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; +export declare function aggregateFieldEqual(left: AggregateField, right: AggregateField): boolean; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| queryConstraints | [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)\[\] | Optional. The list of [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)s to perform a disjunction for. These must be created with calls to [where()](./firestore_.md#where_0fae4bf), , or . | +| left | [AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<unknown> | Compare this AggregateField to the right. | +| right | [AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<unknown> | Compare this AggregateField to the left. | Returns: -[QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) - -The newly created [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). +boolean -## function(reference, ...) +### aggregateQuerySnapshotEqual(left, right) {:#aggregatequerysnapshotequal_1529a20} -### addDoc(reference, data) {:#adddoc_6e783ff} +Compares two `AggregateQuerySnapshot` instances for equality. -Add a new document to specified `CollectionReference` with the given data, assigning it a document ID automatically. +Two `AggregateQuerySnapshot` instances are considered "equal" if they have underlying queries that compare equal, and the same data. Signature: ```typescript -export declare function addDoc(reference: CollectionReference, data: WithFieldValue): Promise>; +export declare function aggregateQuerySnapshotEqual(left: AggregateQuerySnapshot, right: AggregateQuerySnapshot): boolean; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to the collection to add this document to. | -| data | [WithFieldValue](./firestore_.md#withfieldvalue)<AppModelType> | An Object containing the data for the new document. | +| left | [AggregateQuerySnapshot](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType> | The first AggregateQuerySnapshot to compare. | +| right | [AggregateQuerySnapshot](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType> | The second AggregateQuerySnapshot to compare. | Returns: -Promise<[DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType>> +boolean -A `Promise` resolved with a `DocumentReference` pointing to the newly created document after it has been written to the backend (Note that it won't resolve while you're offline). +`true` if the objects are "equal", as defined above, or `false` otherwise. -### collection(reference, path, pathSegments) {:#collection_568f98d} +### queryEqual(left, right) {:#queryequal_7a1f045} -Gets a `CollectionReference` instance that refers to a subcollection of `reference` at the specified relative path. +Returns true if the provided queries point to the same collection and apply the same constraints. Signature: ```typescript -export declare function collection(reference: CollectionReference, path: string, ...pathSegments: string[]): CollectionReference; +export declare function queryEqual(left: Query, right: Query): boolean; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to a collection. | -| path | string | A slash-separated path to a collection. | -| pathSegments | string\[\] | Additional path segments to apply relative to the first argument. | +| left | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | A Query to compare. | +| right | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | A Query to compare. | Returns: -[CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> - -The `CollectionReference` instance. - -#### Exceptions +boolean -If the final path has an even number of segments and does not point to a collection. +true if the references point to the same location in the same Firestore database. -### collection(reference, path, pathSegments) {:#collection_70b4396} +### refEqual(left, right) {:#refequal_598b780} -Gets a `CollectionReference` instance that refers to a subcollection of `reference` at the specified relative path. +Returns true if the provided references are equal. Signature: ```typescript -export declare function collection(reference: DocumentReference, path: string, ...pathSegments: string[]): CollectionReference; +export declare function refEqual(left: DocumentReference | CollectionReference, right: DocumentReference | CollectionReference): boolean; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to a Firestore document. | -| path | string | A slash-separated path to a collection. | -| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | +| left | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> \| [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to compare. | +| right | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> \| [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to compare. | Returns: -[CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> - -The `CollectionReference` instance. - -#### Exceptions +boolean -If the final path has an even number of segments and does not point to a collection. +true if the references point to the same location in the same Firestore database. -### deleteDoc(reference) {:#deletedoc_4569087} +### snapshotEqual(left, right) {:#snapshotequal_5109204} -Deletes the document referred to by the specified `DocumentReference`. +Returns true if the provided snapshots are equal. Signature: ```typescript -export declare function deleteDoc(reference: DocumentReference): Promise; +export declare function snapshotEqual(left: DocumentSnapshot | QuerySnapshot, right: DocumentSnapshot | QuerySnapshot): boolean; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to delete. | +| left | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> \| [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType> | A snapshot to compare. | +| right | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> \| [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType> | A snapshot to compare. | Returns: -Promise<void> +boolean -A Promise resolved once the document has been successfully deleted from the backend (note that it won't resolve while you're offline). +true if the snapshots are equal. -### doc(reference, path, pathSegments) {:#doc_568f98d} +## function(limit, ...) -Gets a `DocumentReference` instance that refers to a document within `reference` at the specified relative path. If no path is specified, an automatically-generated unique ID will be used for the returned `DocumentReference`. +### limit(limit) {:#limit_ec46c78} + +Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the first matching documents. Signature: ```typescript -export declare function doc(reference: CollectionReference, path?: string, ...pathSegments: string[]): DocumentReference; +export declare function limit(limit: number): QueryLimitConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to a collection. | -| path | string | A slash-separated path to a document. Has to be omitted to use auto-generated IDs. | -| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | +| limit | number | The maximum number of items to return. | Returns: -[DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> - -The `DocumentReference` instance. +[QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) -#### Exceptions +The created [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class). -If the final path has an odd number of segments and does not point to a document. +### limitToLast(limit) {:#limittolast_ec46c78} -### doc(reference, path, pathSegments) {:#doc_70b4396} +Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the last matching documents. -Gets a `DocumentReference` instance that refers to a document within `reference` at the specified relative path. +You must specify at least one `orderBy` clause for `limitToLast` queries, otherwise an exception will be thrown during execution. Signature: ```typescript -export declare function doc(reference: DocumentReference, path: string, ...pathSegments: string[]): DocumentReference; +export declare function limitToLast(limit: number): QueryLimitConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to a Firestore document. | -| path | string | A slash-separated path to a document. | -| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | +| limit | number | The maximum number of items to return. | Returns: -[DocumentReference](./firestore_.documentreference.md#documentreference_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> - -The `DocumentReference` instance. - -#### Exceptions +[QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) -If the final path has an odd number of segments and does not point to a document. +The created [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class). -### getDoc(reference) {:#getdoc_4569087} +## function(logLevel, ...) -Reads the document referred to by this `DocumentReference`. +### setLogLevel(logLevel) {:#setloglevel_d02fda2} -Note: `getDoc()` attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. To specify this behavior, invoke [getDocFromCache()](./firestore_.md#getdocfromcache_4569087) or [getDocFromServer()](./firestore_.md#getdocfromserver_4569087). +Sets the verbosity of Cloud Firestore logs (debug, error, or silent). Signature: ```typescript -export declare function getDoc(reference: DocumentReference): Promise>; +export declare function setLogLevel(logLevel: LogLevel): void; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | The reference of the document to fetch. | +| logLevel | LogLevel | The verbosity you set for activity and error logging. Can be any of the following values:
  • debug for the most verbose logging level, primarily for debugging.
  • error to log errors only.
  • silent to turn off logging.
| Returns: -Promise<[DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>> +void -A Promise resolved with a `DocumentSnapshot` containing the current document contents. +## function(n, ...) -### getDocFromCache(reference) {:#getdocfromcache_4569087} +### increment(n) {:#increment_5685735} -Reads the document referred to by this `DocumentReference` from cache. Returns an error if the document is not currently cached. +Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to increment the field's current value by the given value. + +If either the operand or the current field value uses floating point precision, all arithmetic follows IEEE 754 semantics. If both values are integers, values outside of JavaScript's safe number range (`Number.MIN_SAFE_INTEGER` to `Number.MAX_SAFE_INTEGER`) are also subject to precision loss. Furthermore, once processed by the Firestore backend, all integer operations are capped between -2^63 and 2^63-1. + +If the current field value is not of type `number`, or if the field does not yet exist, the transformation sets the field to the given value. Signature: ```typescript -export declare function getDocFromCache(reference: DocumentReference): Promise>; +export declare function increment(n: number): FieldValue; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | | +| n | number | The value to increment by. | Returns: -Promise<[DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>> +[FieldValue](./firestore_.fieldvalue.md#fieldvalue_class) -A `Promise` resolved with a `DocumentSnapshot` containing the current document contents. +The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()` -### getDocFromServer(reference) {:#getdocfromserver_4569087} +## function(query, ...) -Reads the document referred to by this `DocumentReference` from the server. Returns an error if the network is not available. +### getAggregateFromServer(query, aggregateSpec) {:#getaggregatefromserver_2073a74} + +Calculates the specified aggregations over the documents in the result set of the given query without actually downloading the documents. + +Using this function to perform aggregations is efficient because only the final aggregation values, not the documents' data, are downloaded. This function can perform aggregations of the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). + +The result received from the server is presented, unaltered, without considering any local state. That is, documents in the local cache are not taken into consideration, neither are local modifications not yet synchronized with the server. Previously-downloaded results, if any, are not used. Every invocation of this function necessarily involves a round trip to the server. Signature: ```typescript -export declare function getDocFromServer(reference: DocumentReference): Promise>; +export declare function getAggregateFromServer(query: Query, aggregateSpec: AggregateSpecType): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query whose result set is aggregated over. | +| aggregateSpec | AggregateSpecType | An AggregateSpec object that specifies the aggregates to perform over the result set. The AggregateSpec specifies aliases for each aggregate, which can be used to retrieve the aggregate result. | Returns: -Promise<[DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>> +Promise<[AggregateQuerySnapshot](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType>> -A `Promise` resolved with a `DocumentSnapshot` containing the current document contents. +### Example -### onSnapshot(reference, observer) {:#onsnapshot_0312fd7} -Attaches a listener for `DocumentSnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. +```typescript +const aggregateSnapshot = await getAggregateFromServer(query, { + countOfDocs: count(), + totalHours: sum('hours'), + averageScore: average('score') +}); -NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. +const countOfDocs: number = aggregateSnapshot.data().countOfDocs; +const totalHours: number = aggregateSnapshot.data().totalHours; +const averageScore: number | null = aggregateSnapshot.data().averageScore; + +``` + +### getCountFromServer(query) {:#getcountfromserver_4e56953} + +Calculates the number of documents in the result set of the given query without actually downloading the documents. + +Using this function to count the documents is efficient because only the final count, not the documents' data, is downloaded. This function can count the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). + +The result received from the server is presented, unaltered, without considering any local state. That is, documents in the local cache are not taken into consideration, neither are local modifications not yet synchronized with the server. Previously-downloaded results, if any, are not used. Every invocation of this function necessarily involves a round trip to the server. Signature: ```typescript -export declare function onSnapshot(reference: DocumentReference, observer: { - next?: (snapshot: DocumentSnapshot) => void; - error?: (error: FirestoreError) => void; - complete?: () => void; -}): Unsubscribe; +export declare function getCountFromServer(query: Query): Promise; +}, AppModelType, DbModelType>>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to listen to. | -| observer | { next?: (snapshot: [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query whose result set size is calculated. | Returns: -[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) +Promise<[AggregateQuerySnapshot](./firestore_.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<{ count: [AggregateField](./firestore_.aggregatefield.md#aggregatefield_class)<number>; }, AppModelType, DbModelType>> -An unsubscribe function that can be called to cancel the snapshot listener. +A Promise that will be resolved with the count; the count can be retrieved from `snapshot.data().count`, where `snapshot` is the `AggregateQuerySnapshot` to which the returned Promise resolves. -### onSnapshot(reference, options, observer) {:#onsnapshot_86b6b9e} +### getDocs(query) {:#getdocs_4e56953} -Attaches a listener for `DocumentSnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. +Executes the query and returns the results as a `QuerySnapshot`. -NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. +Note: `getDocs()` attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. To specify this behavior, invoke [getDocsFromCache()](./firestore_.md#getdocsfromcache_4e56953) or [getDocsFromServer()](./firestore_.md#getdocsfromserver_4e56953). Signature: ```typescript -export declare function onSnapshot(reference: DocumentReference, options: SnapshotListenOptions, observer: { - next?: (snapshot: DocumentSnapshot) => void; - error?: (error: FirestoreError) => void; - complete?: () => void; -}): Unsubscribe; +export declare function getDocs(query: Query): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to listen to. | -| options | [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | Options controlling the listen behavior. | -| observer | { next?: (snapshot: [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | | Returns: -[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) - -An unsubscribe function that can be called to cancel the snapshot listener. +Promise<[QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>> -### onSnapshot(reference, onNext, onError, onCompletion) {:#onsnapshot_905f42c} +A `Promise` that will be resolved with the results of the query. -Attaches a listener for `DocumentSnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. +### getDocsFromCache(query) {:#getdocsfromcache_4e56953} -NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. +Executes the query and returns the results as a `QuerySnapshot` from cache. Returns an empty result set if no documents matching the query are currently cached. Signature: ```typescript -export declare function onSnapshot(reference: DocumentReference, onNext: (snapshot: DocumentSnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe; +export declare function getDocsFromCache(query: Query): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to listen to. | -| onNext | (snapshot: [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>) => void | A callback to be called every time a new DocumentSnapshot is available. | -| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void | A callback to be called if the listen fails or is cancelled. No further callbacks will occur. | -| onCompletion | () => void | Can be provided, but will not be called since streams are never ending. | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | | Returns: -[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) - -An unsubscribe function that can be called to cancel the snapshot listener. +Promise<[QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>> -### onSnapshot(reference, options, onNext, onError, onCompletion) {:#onsnapshot_0c39991} +A `Promise` that will be resolved with the results of the query. -Attaches a listener for `DocumentSnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. +### getDocsFromServer(query) {:#getdocsfromserver_4e56953} -NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. +Executes the query and returns the results as a `QuerySnapshot` from the server. Returns an error if the network is not available. Signature: ```typescript -export declare function onSnapshot(reference: DocumentReference, options: SnapshotListenOptions, onNext: (snapshot: DocumentSnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe; +export declare function getDocsFromServer(query: Query): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to listen to. | -| options | [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | Options controlling the listen behavior. | -| onNext | (snapshot: [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>) => void | A callback to be called every time a new DocumentSnapshot is available. | -| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void | A callback to be called if the listen fails or is cancelled. No further callbacks will occur. | -| onCompletion | () => void | Can be provided, but will not be called since streams are never ending. | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | | Returns: -[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) +Promise<[QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>> -An unsubscribe function that can be called to cancel the snapshot listener. +A `Promise` that will be resolved with the results of the query. -### setDoc(reference, data) {:#setdoc_ee215ad} +### onSnapshot(query, observer) {:#onsnapshot_8d14049} -Writes to the document referred to by this `DocumentReference`. If the document does not yet exist, it will be created. +Attaches a listener for `QuerySnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. + +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. Signature: ```typescript -export declare function setDoc(reference: DocumentReference, data: WithFieldValue): Promise; +export declare function onSnapshot(query: Query, observer: { + next?: (snapshot: QuerySnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; +}): Unsubscribe; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to write. | -| data | [WithFieldValue](./firestore_.md#withfieldvalue)<AppModelType> | A map of the fields and values for the document. | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query to listen to. | +| observer | { next?: (snapshot: [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | Returns: -Promise<void> +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) + +An unsubscribe function that can be called to cancel the snapshot listener. -A `Promise` resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline). +### onSnapshot(query, options, observer) {:#onsnapshot_03dfff5} -### setDoc(reference, data, options) {:#setdoc_ff80739} +Attaches a listener for `QuerySnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. -Writes to the document referred to by the specified `DocumentReference`. If the document does not yet exist, it will be created. If you provide `merge` or `mergeFields`, the provided data can be merged into an existing document. +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. Signature: ```typescript -export declare function setDoc(reference: DocumentReference, data: PartialWithFieldValue, options: SetOptions): Promise; +export declare function onSnapshot(query: Query, options: SnapshotListenOptions, observer: { + next?: (snapshot: QuerySnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; +}): Unsubscribe; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to write. | -| data | [PartialWithFieldValue](./firestore_.md#partialwithfieldvalue)<AppModelType> | A map of the fields and values for the document. | -| options | [SetOptions](./firestore_.md#setoptions) | An object to configure the set behavior. | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query to listen to. | +| options | [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | Options controlling the listen behavior. | +| observer | { next?: (snapshot: [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | Returns: -Promise<void> +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) -A Promise resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline). +An unsubscribe function that can be called to cancel the snapshot listener. -### updateDoc(reference, data) {:#updatedoc_51a65e3} +### onSnapshot(query, onNext, onError, onCompletion) {:#onsnapshot_3ebfbe2} -Updates fields in the document referred to by the specified `DocumentReference`. The update will fail if applied to a document that does not exist. +Attaches a listener for `QuerySnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. + +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. Signature: ```typescript -export declare function updateDoc(reference: DocumentReference, data: UpdateData): Promise; +export declare function onSnapshot(query: Query, onNext: (snapshot: QuerySnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to update. | -| data | [UpdateData](./firestore_.md#updatedata)<DbModelType> | An object containing the fields and values with which to update the document. Fields can contain dots to reference nested fields within the document. | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query to listen to. | +| onNext | (snapshot: [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>) => void | A callback to be called every time a new QuerySnapshot is available. | +| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void | A callback to be called if the listen fails or is cancelled. No further callbacks will occur. | +| onCompletion | () => void | Can be provided, but will not be called since streams are never ending. | Returns: -Promise<void> +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) -A `Promise` resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline). +An unsubscribe function that can be called to cancel the snapshot listener. -### updateDoc(reference, field, value, moreFieldsAndValues) {:#updatedoc_7c28659} +### onSnapshot(query, options, onNext, onError, onCompletion) {:#onsnapshot_b8f9c47} -Updates fields in the document referred to by the specified `DocumentReference` The update will fail if applied to a document that does not exist. +Attaches a listener for `QuerySnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. The listener can be cancelled by calling the function that is returned when `onSnapshot` is called. -Nested fields can be updated by providing dot-separated field path strings or by providing `FieldPath` objects. +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. Signature: ```typescript -export declare function updateDoc(reference: DocumentReference, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise; +export declare function onSnapshot(query: Query, options: SnapshotListenOptions, onNext: (snapshot: QuerySnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to update. | -| field | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | The first field to update. | -| value | unknown | The first value. | -| moreFieldsAndValues | unknown\[\] | Additional key value pairs. | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The query to listen to. | +| options | [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | Options controlling the listen behavior. | +| onNext | (snapshot: [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>) => void | A callback to be called every time a new QuerySnapshot is available. | +| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void | A callback to be called if the listen fails or is cancelled. No further callbacks will occur. | +| onCompletion | () => void | Can be provided, but will not be called since streams are never ending. | Returns: -Promise<void> - -A `Promise` resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline). +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) -## function(settings, ...) +An unsubscribe function that can be called to cancel the snapshot listener. -### memoryLocalCache(settings) {:#memorylocalcache_05f4bf2} +### query(query, compositeFilter, queryConstraints) {:#query_9f7b0f4} -Creates an instance of `MemoryLocalCache`. The instance can be set to `FirestoreSettings.cache` to tell the SDK which cache layer to use. +Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. Signature: ```typescript -export declare function memoryLocalCache(settings?: MemoryCacheSettings): MemoryLocalCache; +export declare function query(query: Query, compositeFilter: QueryCompositeFilterConstraint, ...queryConstraints: QueryNonFilterConstraint[]): Query; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| settings | [MemoryCacheSettings](./firestore_.memorycachesettings.md#memorycachesettings_interface) | | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The [Query](./firestore_.query.md#query_class) instance to use as a base for the new constraints. | +| compositeFilter | [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) | The [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) to apply. Create [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) using [and()](./firestore_.md#and_e72c712) or [or()](./firestore_.md#or_e72c712). | +| queryConstraints | [QueryNonFilterConstraint](./firestore_.md#querynonfilterconstraint)\[\] | Additional [QueryNonFilterConstraint](./firestore_.md#querynonfilterconstraint)s to apply (e.g. [orderBy()](./firestore_.md#orderby_006d61f), [limit()](./firestore_.md#limit_ec46c78)). | Returns: -[MemoryLocalCache](./firestore_.memorylocalcache.md#memorylocalcache_interface) +[Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> -### memoryLruGarbageCollector(settings) {:#memorylrugarbagecollector_5ee014c} +#### Exceptions -Creates an instance of `MemoryLruGarbageCollector`. +if any of the provided query constraints cannot be combined with the existing or new constraints. -A target size can be specified as part of the setting parameter. The collector will start deleting documents once the cache size exceeds the given size. The default cache size is 40MB (40 \* 1024 \* 1024 bytes). +### query(query, queryConstraints) {:#query_0f46da1} + +Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. Signature: ```typescript -export declare function memoryLruGarbageCollector(settings?: { - cacheSizeBytes?: number; -}): MemoryLruGarbageCollector; +export declare function query(query: Query, ...queryConstraints: QueryConstraint[]): Query; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| settings | { cacheSizeBytes?: number; } | | +| query | [Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> | The [Query](./firestore_.query.md#query_class) instance to use as a base for the new constraints. | +| queryConstraints | [QueryConstraint](./firestore_.queryconstraint.md#queryconstraint_class)\[\] | The list of [QueryConstraint](./firestore_.queryconstraint.md#queryconstraint_class)s to apply. | Returns: -[MemoryLruGarbageCollector](./firestore_.memorylrugarbagecollector.md#memorylrugarbagecollector_interface) +[Query](./firestore_.query.md#query_class)<AppModelType, DbModelType> -### persistentLocalCache(settings) {:#persistentlocalcache_d312f71} +#### Exceptions -Creates an instance of `PersistentLocalCache`. The instance can be set to `FirestoreSettings.cache` to tell the SDK which cache layer to use. +if any of the provided query constraints cannot be combined with the existing or new constraints. -Persistent cache cannot be used in a Node.js environment. +## function(queryConstraints, ...) + +### and(queryConstraints) {:#and_e72c712} + +Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a conjunction of the given filter constraints. A conjunction filter includes a document if it satisfies all of the given filters. Signature: ```typescript -export declare function persistentLocalCache(settings?: PersistentCacheSettings): PersistentLocalCache; +export declare function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| settings | [PersistentCacheSettings](./firestore_.persistentcachesettings.md#persistentcachesettings_interface) | | +| queryConstraints | [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)\[\] | Optional. The list of [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)s to perform a conjunction for. These must be created with calls to [where()](./firestore_.md#where_0fae4bf), [or()](./firestore_.md#or_e72c712), or [and()](./firestore_.md#and_e72c712). | Returns: -[PersistentLocalCache](./firestore_.persistentlocalcache.md#persistentlocalcache_interface) +[QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) -### persistentSingleTabManager(settings) {:#persistentsingletabmanager_c99c68d} +The newly created [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). -Creates an instance of `PersistentSingleTabManager`. +### or(queryConstraints) {:#or_e72c712} + +Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a disjunction of the given filter constraints. A disjunction filter includes a document if it satisfies any of the given filters. Signature: ```typescript -export declare function persistentSingleTabManager(settings: PersistentSingleTabManagerSettings | undefined): PersistentSingleTabManager; +export declare function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| settings | [PersistentSingleTabManagerSettings](./firestore_.persistentsingletabmanagersettings.md#persistentsingletabmanagersettings_interface) \| undefined | Configures the created tab manager. | +| queryConstraints | [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)\[\] | Optional. The list of [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)s to perform a disjunction for. These must be created with calls to [where()](./firestore_.md#where_0fae4bf), [or()](./firestore_.md#or_e72c712), or [and()](./firestore_.md#and_e72c712). | Returns: -[PersistentSingleTabManager](./firestore_.persistentsingletabmanager.md#persistentsingletabmanager_interface) +[QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) -## function(snapshot, ...) +The newly created [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). -### endAt(snapshot) {:#endat_9a4477f} +## function(reference, ...) -Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided document (inclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. +### addDoc(reference, data) {:#adddoc_6e783ff} + +Add a new document to specified `CollectionReference` with the given data, assigning it a document ID automatically. Signature: ```typescript -export declare function endAt(snapshot: DocumentSnapshot): QueryEndAtConstraint; +export declare function addDoc(reference: CollectionReference, data: WithFieldValue): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| snapshot | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to end at. | +| reference | [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to the collection to add this document to. | +| data | [WithFieldValue](./firestore_.md#withfieldvalue)<AppModelType> | An Object containing the data for the new document. | Returns: -[QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) +Promise<[DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType>> -A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` +A `Promise` resolved with a `DocumentReference` pointing to the newly created document after it has been written to the backend (Note that it won't resolve while you're offline). -### endBefore(snapshot) {:#endbefore_9a4477f} +### collection(reference, path, pathSegments) {:#collection_568f98d} -Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided document (exclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. +Gets a `CollectionReference` instance that refers to a subcollection of `reference` at the specified relative path. Signature: ```typescript -export declare function endBefore(snapshot: DocumentSnapshot): QueryEndAtConstraint; +export declare function collection(reference: CollectionReference, path: string, ...pathSegments: string[]): CollectionReference; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| snapshot | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to end before. | +| reference | [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to a collection. | +| path | string | A slash-separated path to a collection. | +| pathSegments | string\[\] | Additional path segments to apply relative to the first argument. | Returns: -[QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) +[CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> -A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` +The `CollectionReference` instance. -### startAfter(snapshot) {:#startafter_9a4477f} +#### Exceptions -Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided document (exclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. +If the final path has an even number of segments and does not point to a collection. + +### collection(reference, path, pathSegments) {:#collection_70b4396} + +Gets a `CollectionReference` instance that refers to a subcollection of `reference` at the specified relative path. Signature: ```typescript -export declare function startAfter(snapshot: DocumentSnapshot): QueryStartAtConstraint; +export declare function collection(reference: DocumentReference, path: string, ...pathSegments: string[]): CollectionReference; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| snapshot | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to start after. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to a Firestore document. | +| path | string | A slash-separated path to a collection. | +| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | Returns: -[QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) +[CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> -A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()` +The `CollectionReference` instance. -### startAt(snapshot) {:#startat_9a4477f} +#### Exceptions -Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided document (inclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the `orderBy` of this query. +If the final path has an even number of segments and does not point to a collection. + +### deleteDoc(reference) {:#deletedoc_4569087} + +Deletes the document referred to by the specified `DocumentReference`. Signature: ```typescript -export declare function startAt(snapshot: DocumentSnapshot): QueryStartAtConstraint; +export declare function deleteDoc(reference: DocumentReference): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| snapshot | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to start at. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to delete. | Returns: -[QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) - -A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()`. - -## function(timestamp, ...) - -### timestampAdd(timestamp, unit, amount) {:#timestampadd_87db576} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +Promise<void> -Creates an expression that adds a specified amount of time to a timestamp. +A Promise resolved once the document has been successfully deleted from the backend (note that it won't resolve while you're offline). -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -timestampAdd(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); +### doc(reference, path, pathSegments) {:#doc_568f98d} -``` +Gets a `DocumentReference` instance that refers to a document within `reference` at the specified relative path. If no path is specified, an automatically-generated unique ID will be used for the returned `DocumentReference`. Signature: ```typescript -export declare function timestampAdd(timestamp: Constant, unit: Constant, amount: Constant): TimestampAdd; +export declare function doc(reference: CollectionReference, path?: string, ...pathSegments: string[]): DocumentReference; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| timestamp | [Constant](./firestore_.constant.md#constant_class) | The expression representing the timestamp. | -| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | +| reference | [CollectionReference](./firestore_.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to a collection. | +| path | string | A slash-separated path to a document. Has to be omitted to use auto-generated IDs. | +| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | Returns: -[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) +[DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> -### timestampAdd(timestamp, unit, amount) {:#timestampadd_46a2d7e} +The `DocumentReference` instance. -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +#### Exceptions -Creates an expression that adds a specified amount of time to a timestamp. +If the final path has an odd number of segments and does not point to a document. -```typescript -// Add 1 day to the 'timestamp' field. -timestampAdd(Field.of("timestamp"), "day", 1); +### doc(reference, path, pathSegments) {:#doc_70b4396} -``` +Gets a `DocumentReference` instance that refers to a document within `reference` at the specified relative path. Signature: ```typescript -export declare function timestampAdd(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; +export declare function doc(reference: DocumentReference, path: string, ...pathSegments: string[]): DocumentReference; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| timestamp | [Constant](./firestore_.constant.md#constant_class) | The expression representing the timestamp. | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | -| amount | number | The amount of time to add. A new representing the resulting timestamp. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to a Firestore document. | +| path | string | A slash-separated path to a document. | +| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | Returns: -[TimestampAdd](./firestore_.timestampadd.md#timestampadd_class) +[DocumentReference](./firestore_.documentreference.md#documentreference_class)<[DocumentData](./firestore_.documentdata.md#documentdata_interface), [DocumentData](./firestore_.documentdata.md#documentdata_interface)> -### timestampSub(timestamp, unit, amount) {:#timestampsub_87db576} +The `DocumentReference` instance. -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +#### Exceptions -Creates an expression that subtracts a specified amount of time from a timestamp. +If the final path has an odd number of segments and does not point to a document. -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -timestampSub(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); +### getDoc(reference) {:#getdoc_4569087} -``` +Reads the document referred to by this `DocumentReference`. + +Note: `getDoc()` attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. To specify this behavior, invoke [getDocFromCache()](./firestore_.md#getdocfromcache_4569087) or [getDocFromServer()](./firestore_.md#getdocfromserver_4569087). Signature: ```typescript -export declare function timestampSub(timestamp: Constant, unit: Constant, amount: Constant): TimestampSub; +export declare function getDoc(reference: DocumentReference): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| timestamp | [Constant](./firestore_.constant.md#constant_class) | The expression representing the timestamp. | -| unit | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | The reference of the document to fetch. | Returns: -[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) - -### timestampSub(timestamp, unit, amount) {:#timestampsub_46a2d7e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +Promise<[DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>> -Creates an expression that subtracts a specified amount of time from a timestamp. +A Promise resolved with a `DocumentSnapshot` containing the current document contents. -```typescript -// Subtract 1 day from the 'timestamp' field. -timestampSub(Field.of("timestamp"), "day", 1); +### getDocFromCache(reference) {:#getdocfromcache_4569087} -``` +Reads the document referred to by this `DocumentReference` from cache. Returns an error if the document is not currently cached. Signature: ```typescript -export declare function timestampSub(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; +export declare function getDocFromCache(reference: DocumentReference): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| timestamp | [Constant](./firestore_.constant.md#constant_class) | The expression representing the timestamp. | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | -| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | | Returns: -[TimestampSub](./firestore_.timestampsub.md#timestampsub_class) - -## function(value, ...) - -### avg(value) {:#avg_f83680a} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +Promise<[DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>> -Creates an aggregation that calculates the average (mean) of values from an expression across multiple stage inputs. +A `Promise` resolved with a `DocumentSnapshot` containing the current document contents. -```typescript -// Calculate the average age of users -avg(Field.of("age")).as("averageAge"); +### getDocFromServer(reference) {:#getdocfromserver_4569087} -``` +Reads the document referred to by this `DocumentReference` from the server. Returns an error if the network is not available. Signature: ```typescript -export declare function avg(value: Constant): Avg; +export declare function getDocFromServer(reference: DocumentReference): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) | The expression representing the values to average. A new representing the 'avg' aggregation. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | | Returns: -[Avg](./firestore_.avg.md#avg_class) - -### avg(value) {:#avg_7c807cd} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +Promise<[DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>> -Creates an aggregation that calculates the average (mean) of a field's values across multiple stage inputs. +A `Promise` resolved with a `DocumentSnapshot` containing the current document contents. -```typescript -// Calculate the average age of users -avg("age").as("averageAge"); +### onSnapshot(reference, observer) {:#onsnapshot_0312fd7} -``` +Attaches a listener for `DocumentSnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. + +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. Signature: ```typescript -export declare function avg(value: string): Avg; +export declare function onSnapshot(reference: DocumentReference, observer: { + next?: (snapshot: DocumentSnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; +}): Unsubscribe; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | string | The name of the field containing numeric values to average. A new representing the 'avg' aggregation. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to listen to. | +| observer | { next?: (snapshot: [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | Returns: -[Avg](./firestore_.avg.md#avg_class) - -### countExpression(value) {:#countexpression_f83680a} +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +An unsubscribe function that can be called to cancel the snapshot listener. -Creates an aggregation that counts the number of stage inputs with valid evaluations of the provided expression. +### onSnapshot(reference, options, observer) {:#onsnapshot_86b6b9e} -```typescript -// Count the number of items where the price is greater than 10 -count(Field.of("price").gt(10)).as("expensiveItemCount"); +Attaches a listener for `DocumentSnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. -``` +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. Signature: ```typescript -export declare function countExpression(value: Constant): Count; +export declare function onSnapshot(reference: DocumentReference, options: SnapshotListenOptions, observer: { + next?: (snapshot: DocumentSnapshot) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; +}): Unsubscribe; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) | The expression to count. A new representing the 'count' aggregation. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to listen to. | +| options | [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | Options controlling the listen behavior. | +| observer | { next?: (snapshot: [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>) => void; error?: (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void; complete?: () => void; } | A single object containing next and error callbacks. | Returns: -[Count](./firestore_.count.md#count_class) +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) -### countExpression(value) {:#countexpression_7c807cd} +An unsubscribe function that can be called to cancel the snapshot listener. -Creates an aggregation that counts the number of stage inputs with valid evaluations of the provided field. +### onSnapshot(reference, onNext, onError, onCompletion) {:#onsnapshot_905f42c} -```typescript -// Count the total number of products -count("productId").as("totalProducts"); +Attaches a listener for `DocumentSnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. -``` +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. Signature: ```typescript -export declare function countExpression(value: string): Count; +export declare function onSnapshot(reference: DocumentReference, onNext: (snapshot: DocumentSnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | string | The name of the field to count. A new representing the 'count' aggregation. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to listen to. | +| onNext | (snapshot: [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>) => void | A callback to be called every time a new DocumentSnapshot is available. | +| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void | A callback to be called if the listen fails or is cancelled. No further callbacks will occur. | +| onCompletion | () => void | Can be provided, but will not be called since streams are never ending. | Returns: -[Count](./firestore_.count.md#count_class) - -### exists(value) {:#exists_f83680a} +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +An unsubscribe function that can be called to cancel the snapshot listener. -Creates an expression that checks if a field exists. +### onSnapshot(reference, options, onNext, onError, onCompletion) {:#onsnapshot_0c39991} -```typescript -// Check if the document has a field named "phoneNumber" -exists(Field.of("phoneNumber")); +Attaches a listener for `DocumentSnapshot` events. You may either pass individual `onNext` and `onError` callbacks or pass a single observer object with `next` and `error` callbacks. -``` +NOTE: Although an `onCompletion` callback can be provided, it will never be called because the snapshot stream is never-ending. Signature: ```typescript -export declare function exists(value: Constant): Exists; +export declare function onSnapshot(reference: DocumentReference, options: SnapshotListenOptions, onNext: (snapshot: DocumentSnapshot) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) | An expression evaluates to the name of the field to check. A new representing the 'exists' check. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to listen to. | +| options | [SnapshotListenOptions](./firestore_.snapshotlistenoptions.md#snapshotlistenoptions_interface) | Options controlling the listen behavior. | +| onNext | (snapshot: [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>) => void | A callback to be called every time a new DocumentSnapshot is available. | +| onError | (error: [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class)) => void | A callback to be called if the listen fails or is cancelled. No further callbacks will occur. | +| onCompletion | () => void | Can be provided, but will not be called since streams are never ending. | Returns: -[Exists](./firestore_.exists.md#exists_class) - -### isNan(value) {:#isnan_f83680a} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +[Unsubscribe](./firestore_.unsubscribe.md#unsubscribe_interface) -Creates an expression that checks if an expression evaluates to 'NaN' (Not a Number). +An unsubscribe function that can be called to cancel the snapshot listener. -```typescript -// Check if the result of a calculation is NaN -isNaN(Field.of("value").divide(0)); +### setDoc(reference, data) {:#setdoc_ee215ad} -``` +Writes to the document referred to by this `DocumentReference`. If the document does not yet exist, it will be created. Signature: ```typescript -export declare function isNan(value: Constant): IsNan; +export declare function setDoc(reference: DocumentReference, data: WithFieldValue): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) | The expression to check. A new representing the 'isNaN' check. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to write. | +| data | [WithFieldValue](./firestore_.md#withfieldvalue)<AppModelType> | A map of the fields and values for the document. | Returns: -[IsNan](./firestore_.isnan.md#isnan_class) - -### isNan(value) {:#isnan_7c807cd} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +Promise<void> -Creates an expression that checks if a field's value evaluates to 'NaN' (Not a Number). +A `Promise` resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline). -```typescript -// Check if the result of a calculation is NaN -isNaN("value"); +### setDoc(reference, data, options) {:#setdoc_ff80739} -``` +Writes to the document referred to by the specified `DocumentReference`. If the document does not yet exist, it will be created. If you provide `merge` or `mergeFields`, the provided data can be merged into an existing document. Signature: ```typescript -export declare function isNan(value: string): IsNan; +export declare function setDoc(reference: DocumentReference, data: PartialWithFieldValue, options: SetOptions): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | string | The name of the field to check. A new representing the 'isNaN' check. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to write. | +| data | [PartialWithFieldValue](./firestore_.md#partialwithfieldvalue)<AppModelType> | A map of the fields and values for the document. | +| options | [SetOptions](./firestore_.md#setoptions) | An object to configure the set behavior. | Returns: -[IsNan](./firestore_.isnan.md#isnan_class) - -### max(value) {:#max_f83680a} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +Promise<void> -Creates an aggregation that finds the maximum value of an expression across multiple stage inputs. +A Promise resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline). -```typescript -// Find the highest score in a leaderboard -max(Field.of("score")).as("highestScore"); +### updateDoc(reference, data) {:#updatedoc_51a65e3} -``` +Updates fields in the document referred to by the specified `DocumentReference`. The update will fail if applied to a document that does not exist. Signature: ```typescript -export declare function max(value: Constant): Max; +export declare function updateDoc(reference: DocumentReference, data: UpdateData): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) | The expression to find the maximum value of. A new representing the 'max' aggregation. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to update. | +| data | [UpdateData](./firestore_.md#updatedata)<DbModelType> | An object containing the fields and values with which to update the document. Fields can contain dots to reference nested fields within the document. | Returns: -[Max](./firestore_.max.md#max_class) - -### max(value) {:#max_7c807cd} +Promise<void> -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +A `Promise` resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline). -Creates an aggregation that finds the maximum value of a field across multiple stage inputs. +### updateDoc(reference, field, value, moreFieldsAndValues) {:#updatedoc_7c28659} -```typescript -// Find the highest score in a leaderboard -max("score").as("highestScore"); +Updates fields in the document referred to by the specified `DocumentReference` The update will fail if applied to a document that does not exist. -``` +Nested fields can be updated by providing dot-separated field path strings or by providing `FieldPath` objects. Signature: ```typescript -export declare function max(value: string): Max; +export declare function updateDoc(reference: DocumentReference, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | string | The name of the field to find the maximum value of. A new representing the 'max' aggregation. | +| reference | [DocumentReference](./firestore_.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to update. | +| field | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | The first field to update. | +| value | unknown | The first value. | +| moreFieldsAndValues | unknown\[\] | Additional key value pairs. | Returns: -[Max](./firestore_.max.md#max_class) - -### min(value) {:#min_f83680a} +Promise<void> -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +A `Promise` resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline). -Creates an aggregation that finds the minimum value of an expression across multiple stage inputs. +## function(settings, ...) -```typescript -// Find the lowest price of all products -min(Field.of("price")).as("lowestPrice"); +### memoryLocalCache(settings) {:#memorylocalcache_05f4bf2} -``` +Creates an instance of `MemoryLocalCache`. The instance can be set to `FirestoreSettings.cache` to tell the SDK which cache layer to use. Signature: ```typescript -export declare function min(value: Constant): Min; +export declare function memoryLocalCache(settings?: MemoryCacheSettings): MemoryLocalCache; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) | The expression to find the minimum value of. A new representing the 'min' aggregation. | +| settings | [MemoryCacheSettings](./firestore_.memorycachesettings.md#memorycachesettings_interface) | | Returns: -[Min](./firestore_.min.md#min_class) - -### min(value) {:#min_7c807cd} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +[MemoryLocalCache](./firestore_.memorylocalcache.md#memorylocalcache_interface) -Creates an aggregation that finds the minimum value of a field across multiple stage inputs. +### memoryLruGarbageCollector(settings) {:#memorylrugarbagecollector_5ee014c} -```typescript -// Find the lowest price of all products -min("price").as("lowestPrice"); +Creates an instance of `MemoryLruGarbageCollector`. -``` +A target size can be specified as part of the setting parameter. The collector will start deleting documents once the cache size exceeds the given size. The default cache size is 40MB (40 \* 1024 \* 1024 bytes). Signature: ```typescript -export declare function min(value: string): Min; +export declare function memoryLruGarbageCollector(settings?: { + cacheSizeBytes?: number; +}): MemoryLruGarbageCollector; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | string | The name of the field to find the minimum value of. A new representing the 'min' aggregation. | +| settings | { cacheSizeBytes?: number; } | | Returns: -[Min](./firestore_.min.md#min_class) - -### replaceAll(value, find, replace) {:#replaceall_f06d323} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +[MemoryLruGarbageCollector](./firestore_.memorylrugarbagecollector.md#memorylrugarbagecollector_interface) -Creates an expression that replaces all occurrences of a substring within a string with another substring. +### persistentLocalCache(settings) {:#persistentlocalcache_d312f71} -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field. -replaceAll(Field.of("message"), "hello", "hi"); +Creates an instance of `PersistentLocalCache`. The instance can be set to `FirestoreSettings.cache` to tell the SDK which cache layer to use. -``` +Persistent cache cannot be used in a Node.js environment. Signature: ```typescript -export declare function replaceAll(value: Constant, find: string, replace: string): ReplaceAll; +export declare function persistentLocalCache(settings?: PersistentCacheSettings): PersistentLocalCache; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to perform the replacement on. | -| find | string | The substring to search for. | -| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | +| settings | [PersistentCacheSettings](./firestore_.persistentcachesettings.md#persistentcachesettings_interface) | | Returns: -[ReplaceAll](./firestore_.replaceall.md#replaceall_class) - -### replaceAll(value, find, replace) {:#replaceall_26a7926} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within a string with another substring, where the substring to find and the replacement substring are specified by expressions. +[PersistentLocalCache](./firestore_.persistentlocalcache.md#persistentlocalcache_interface) -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field. -replaceAll(Field.of("message"), Field.of("findField"), Field.of("replaceField")); +### persistentSingleTabManager(settings) {:#persistentsingletabmanager_c99c68d} -``` +Creates an instance of `PersistentSingleTabManager`. Signature: ```typescript -export declare function replaceAll(value: Constant, find: Constant, replace: Constant): ReplaceAll; +export declare function persistentSingleTabManager(settings: PersistentSingleTabManagerSettings | undefined): PersistentSingleTabManager; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to perform the replacement on. | -| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | +| settings | [PersistentSingleTabManagerSettings](./firestore_.persistentsingletabmanagersettings.md#persistentsingletabmanagersettings_interface) \| undefined | Configures the created tab manager. | Returns: -[ReplaceAll](./firestore_.replaceall.md#replaceall_class) - -### replaceFirst(value, find, replace) {:#replacefirst_f06d323} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +[PersistentSingleTabManager](./firestore_.persistentsingletabmanager.md#persistentsingletabmanager_interface) -Creates an expression that replaces the first occurrence of a substring within a string with another substring. +## function(snapshot, ...) -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field. -replaceFirst(Field.of("message"), "hello", "hi"); +### endAt(snapshot) {:#endat_9a4477f} -``` +Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided document (inclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. Signature: ```typescript -export declare function replaceFirst(value: Constant, find: string, replace: string): ReplaceFirst; +export declare function endAt(snapshot: DocumentSnapshot): QueryEndAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to perform the replacement on. | -| find | string | The substring to search for. | -| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | +| snapshot | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to end at. | Returns: -[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) - -### replaceFirst(value, find, replace) {:#replacefirst_26a7926} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +[QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) -Creates an expression that replaces the first occurrence of a substring within a string with another substring, where the substring to find and the replacement substring are specified by expressions. +A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field. -replaceFirst(Field.of("message"), Field.of("findField"), Field.of("replaceField")); +### endBefore(snapshot) {:#endbefore_9a4477f} -``` +Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided document (exclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. Signature: ```typescript -export declare function replaceFirst(value: Constant, find: Constant, replace: Constant): ReplaceFirst; +export declare function endBefore(snapshot: DocumentSnapshot): QueryEndAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) | The expression representing the string to perform the replacement on. | -| find | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | +| snapshot | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to end before. | Returns: -[ReplaceFirst](./firestore_.replacefirst.md#replacefirst_class) - -### sumExpression(value) {:#sumexpression_f83680a} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +[QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) -Creates an aggregation that calculates the sum of values from an expression across multiple stage inputs. +A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` -```typescript -// Calculate the total revenue from a set of orders -sum(Field.of("orderAmount")).as("totalRevenue"); +### startAfter(snapshot) {:#startafter_9a4477f} -``` +Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided document (exclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. Signature: ```typescript -export declare function sumExpression(value: Constant): Sum; +export declare function startAfter(snapshot: DocumentSnapshot): QueryStartAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) | The expression to sum up. A new representing the 'sum' aggregation. | +| snapshot | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to start after. | Returns: -[Sum](./firestore_.sum.md#sum_class) - -### sumExpression(value) {:#sumexpression_7c807cd} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +[QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) -Creates an aggregation that calculates the sum of a field's values across multiple stage inputs. +A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()` -```typescript -// Calculate the total revenue from a set of orders -sum("orderAmount").as("totalRevenue"); +### startAt(snapshot) {:#startat_9a4477f} -``` +Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided document (inclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the `orderBy` of this query. Signature: ```typescript -export declare function sumExpression(value: string): Sum; +export declare function startAt(snapshot: DocumentSnapshot): QueryStartAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | string | The name of the field containing numeric values to sum up. A new representing the 'sum' aggregation. | +| snapshot | [DocumentSnapshot](./firestore_.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to start at. | Returns: -[Sum](./firestore_.sum.md#sum_class) +[QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) + +A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()`. ## function(values, ...) @@ -9519,19 +2489,6 @@ Constant used to indicate the LRU garbage collection should be disabled. Set thi CACHE_SIZE_UNLIMITED = -1 ``` -## AccumulatorTarget - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -An accumulator target, which is an expression with an alias that also implements the Accumulator interface. - -Signature: - -```typescript -export declare type AccumulatorTarget = ExprWithAlias; -``` - ## AddPrefixToKeys Returns a new map where every key is prefixed with the outer key appended to a dot. @@ -9600,32 +2557,6 @@ The type of a `DocumentChange` may be 'added', 'removed', or 'modified'. export declare type DocumentChangeType = 'added' | 'removed' | 'modified'; ``` -## ExprType - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -An enumeration of the different types of expressions. - -Signature: - -```typescript -export declare type ExprType = 'Field' | 'Constant' | 'Function' | 'ListOfExprs' | 'ExprWithAlias'; -``` - -## FilterExpr - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -A filter expression, which is an expression that also implements the FilterCondition interface. - -Signature: - -```typescript -export declare type FilterExpr = Constant & FilterCondition; -``` - ## FirestoreErrorCode The set of Firestore status codes. The codes are the same at the ones exposed by gRPC here: https://github.com/grpc/grpc/blob/master/doc/statuscodes.md @@ -9754,19 +2685,6 @@ export declare type QueryFilterConstraint = QueryFieldFilterConstraint | QueryCo export declare type QueryNonFilterConstraint = QueryOrderByConstraint | QueryLimitConstraint | QueryStartAtConstraint | QueryEndAtConstraint; ``` -## SelectableExpr - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -A selectable expression, which is an expression that also implements the Selectable interface. - -Signature: - -```typescript -export declare type SelectableExpr = Constant & Selectable; -``` - ## SetOptions An options object that configures the behavior of [setDoc()](./firestore_lite.md#setdoc_ee215ad), and calls. These calls can be configured to perform granular merges instead of overwriting the target documents in their entirety by providing a `SetOptions` with `merge: true`. diff --git a/docs-devsite/firestore_.min.md b/docs-devsite/firestore_.min.md deleted file mode 100644 index 56f71586256..00000000000 --- a/docs-devsite/firestore_.min.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Min class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Min extends FirestoreFunction implements Accumulator -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [Accumulator](./firestore_.accumulator.md#accumulator_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value, distinct)](./firestore_.min.md#minconstructor) | | (BETA) Constructs a new instance of the Min class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [accumulator](./firestore_.min.md#minaccumulator) | | true | (BETA) | - -## Min.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Min` class - -Signature: - -```typescript -constructor(value: Constant, distinct: boolean); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) | | -| distinct | boolean | | - -## Min.accumulator - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -accumulator: true; -``` diff --git a/docs-devsite/firestore_.mod.md b/docs-devsite/firestore_.mod.md deleted file mode 100644 index 205eba4f984..00000000000 --- a/docs-devsite/firestore_.mod.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Mod class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Mod extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_.mod.md#modconstructor) | | (BETA) Constructs a new instance of the Mod class | - -## Mod.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Mod` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | | -| right | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.multiply.md b/docs-devsite/firestore_.multiply.md deleted file mode 100644 index add30cd9359..00000000000 --- a/docs-devsite/firestore_.multiply.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Multiply class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Multiply extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_.multiply.md#multiplyconstructor) | | (BETA) Constructs a new instance of the Multiply class | - -## Multiply.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Multiply` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | | -| right | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.neq.md b/docs-devsite/firestore_.neq.md deleted file mode 100644 index fc44be2b9d7..00000000000 --- a/docs-devsite/firestore_.neq.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Neq class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Neq extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_.neq.md#neqconstructor) | | (BETA) Constructs a new instance of the Neq class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_.neq.md#neqfilterable) | | true | (BETA) | - -## Neq.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Neq` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | | -| right | [Constant](./firestore_.constant.md#constant_class) | | - -## Neq.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_.not.md b/docs-devsite/firestore_.not.md deleted file mode 100644 index 1b1823f75e6..00000000000 --- a/docs-devsite/firestore_.not.md +++ /dev/null @@ -1,66 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Not class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Not extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr)](./firestore_.not.md#notconstructor) | | (BETA) Constructs a new instance of the Not class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_.not.md#notfilterable) | | true | (BETA) | - -## Not.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Not` class - -Signature: - -```typescript -constructor(expr: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | | - -## Not.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_.offset.md b/docs-devsite/firestore_.offset.md deleted file mode 100644 index 5d3431f382d..00000000000 --- a/docs-devsite/firestore_.offset.md +++ /dev/null @@ -1,64 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Offset class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Offset implements Stage -``` -Implements: [Stage](./firestore_.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(offset)](./firestore_.offset.md#offsetconstructor) | | (BETA) Constructs a new instance of the Offset class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_.offset.md#offsetname) | | string | (BETA) | - -## Offset.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Offset` class - -Signature: - -```typescript -constructor(offset: number); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| offset | number | | - -## Offset.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_.or.md b/docs-devsite/firestore_.or.md deleted file mode 100644 index d2c506893a0..00000000000 --- a/docs-devsite/firestore_.or.md +++ /dev/null @@ -1,17 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# or namespace -Signature: - -```typescript -export declare namespace or -``` diff --git a/docs-devsite/firestore_.ordering.md b/docs-devsite/firestore_.ordering.md deleted file mode 100644 index ce673370b28..00000000000 --- a/docs-devsite/firestore_.ordering.md +++ /dev/null @@ -1,51 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Ordering class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Represents an ordering criterion for sorting documents in a Firestore pipeline. - -You create `Ordering` instances using the `ascending` and `descending` helper functions. - -Signature: - -```typescript -export declare class Ordering -``` - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr, direction)](./firestore_.ordering.md#orderingconstructor) | | (BETA) Constructs a new instance of the Ordering class | - -## Ordering.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Ordering` class - -Signature: - -```typescript -constructor(expr: Constant, direction: 'ascending' | 'descending'); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | | -| direction | 'ascending' \| 'descending' | | - diff --git a/docs-devsite/firestore_.pipeline.md b/docs-devsite/firestore_.pipeline.md deleted file mode 100644 index 18c109d2c83..00000000000 --- a/docs-devsite/firestore_.pipeline.md +++ /dev/null @@ -1,609 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Pipeline class -Signature: - -```typescript -export declare class Pipeline -``` - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [converter](./firestore_.pipeline.md#pipelineconverter) | | any | | -| [readUserData](./firestore_.pipeline.md#pipelinereaduserdata) | | any | Reads user data for each expression in the expressionMap. | -| [selectablesToMap](./firestore_.pipeline.md#pipelineselectablestomap) | | any | | -| [stages](./firestore_.pipeline.md#pipelinestages) | | any | | -| [userDataReader](./firestore_.pipeline.md#pipelineuserdatareader) | | any | | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [addFields(fields)](./firestore_.pipeline.md#pipelineaddfields) | | Adds new fields to outputs from previous stages.This stage allows you to compute values on-the-fly based on existing data from previous stages or constants. You can use this to create new fields or overwrite existing ones (if there is name overlaps).The added fields are defined using [Selectable](./firestore_.selectable.md#selectable_interface)s, which can be:- [Field](./firestore_.field.md#field_class): References an existing document field. - : Performs a calculation using functions like add, multiply with assigned aliases using .Example: -```typescript -firestore.pipeline().collection("books") -.addFields( -Field.of("rating").as("bookRating"), // Rename 'rating' to 'bookRating' -add(5, Field.of("quantity")).as("totalCost") // Calculate 'totalCost' -); - -``` - | -| [aggregate(accumulators)](./firestore_.pipeline.md#pipelineaggregate) | | Performs aggregation operations on the documents from previous stages.

This stage allows you to calculate aggregate values over a set of documents. You define the aggregations to perform using [AccumulatorTarget](./firestore_.md#accumulatortarget) expressions which are typically results of calling on [Accumulator](./firestore_.accumulator.md#accumulator_interface) instances.

Example: -```typescript -// Calculate the average rating and the total number of books -firestore.pipeline().collection("books") -.aggregate( -Field.of("rating").avg().as("averageRating"), -countAll().as("totalBooks") -); - -``` - | -| [aggregate(options)](./firestore_.pipeline.md#pipelineaggregate) | | Performs optionally grouped aggregation operations on the documents from previous stages.

This stage allows you to calculate aggregate values over a set of documents, optionally grouped by one or more fields or functions. You can specify:

  • \*\*Grouping Fields or Functions:\*\* One or more fields or functions to group the documents by. For each distinct combination of values in these fields, a separate group is created. If no grouping fields are provided, a single group containing all documents is used. Not specifying groups is the same as putting the entire inputs into one group.
  • \*\*Accumulators:\*\* One or more accumulation operations to perform within each group. These are defined using [AccumulatorTarget](./firestore_.md#accumulatortarget) expressions, which are typically created by calling on [Accumulator](./firestore_.accumulator.md#accumulator_interface) instances. Each aggregation calculates a value (e.g., sum, average, count) based on the documents within its group.

Example: -```typescript -// Calculate the average rating for each genre. -firestore.pipeline().collection("books") -.aggregate({ -accumulators: [avg(Field.of("rating")).as("avg_rating")] -groups: ["genre"] -}); - -``` - | -| [distinct(groups)](./firestore_.pipeline.md#pipelinedistinct) | | Returns a set of distinct values from the inputs to this stage.

This stage run through the results from previous stages to include only results with unique combinations of values ([Field](./firestore_.field.md#field_class), , etc).

The parameters to this stage are defined using [Selectable](./firestore_.selectable.md#selectable_interface) expressions or s:

  • : Name of an existing field
  • [Field](./firestore_.field.md#field_class): References an existing document field.
  • : Represents the result of a function with an assigned alias name using

Example: -```typescript -// Get a list of unique author names in uppercase and genre combinations. -firestore.pipeline().collection("books") -.distinct(toUppercase(Field.of("author")).as("authorName"), Field.of("genre"), "publishedAt") -.select("authorName"); - -``` - | -| [execute()](./firestore_.pipeline.md#pipelineexecute) | | Executes this pipeline and returns a Promise to represent the asynchronous operation.

The returned Promise can be used to track the progress of the pipeline execution and retrieve the results (or handle any errors) asynchronously.

The pipeline results are returned as a list of [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) objects. Each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) typically represents a single key/value map that has passed through all the stages of the pipeline, however this might differ depending on the stages involved in the pipeline. For example:

  • If there are no stages or only transformation stages, each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) represents a single document.
  • If there is an aggregation, only a single [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) is returned, representing the aggregated results over the entire dataset .
  • If there is an aggregation stage with grouping, each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) represents a distinct group and its associated aggregated values.

Example: -```typescript -const futureResults = await firestore.pipeline().collection("books") - .where(gt(Field.of("rating"), 4.5)) - .select("title", "author", "rating") - .execute(); - -``` - A Promise representing the asynchronous pipeline execution. | -| [findNearest(options)](./firestore_.pipeline.md#pipelinefindnearest) | | | -| [genericStage(name, params)](./firestore_.pipeline.md#pipelinegenericstage) | | Adds a generic stage to the pipeline.

This method provides a flexible way to extend the pipeline's functionality by adding custom stages. Each generic stage is defined by a unique name and a set of params that control its behavior.

Example (Assuming there is no "where" stage available in SDK): -```typescript -// Assume we don't have a built-in "where" stage -firestore.pipeline().collection("books") -.genericStage("where", [Field.of("published").lt(1900)]) // Custom "where" stage -.select("title", "author"); - -``` - | -| [limit(limit)](./firestore_.pipeline.md#pipelinelimit) | | Limits the maximum number of documents returned by previous stages to limit.

This stage is particularly useful when you want to retrieve a controlled subset of data from a potentially large result set. It's often used for:

  • \*\*Pagination:\*\* In combination with to retrieve specific pages of results.
  • \*\*Limiting Data Retrieval:\*\* To prevent excessive data transfer and improve performance, especially when dealing with large collections.

Example: -```typescript -// Limit the results to the top 10 highest-rated books -firestore.pipeline().collection("books") -.sort(Field.of("rating").descending()) -.limit(10); - -``` - | -| [offset(offset)](./firestore_.pipeline.md#pipelineoffset) | | Skips the first offset number of documents from the results of previous stages.

This stage is useful for implementing pagination in your pipelines, allowing you to retrieve results in chunks. It is typically used in conjunction with to control the size of each page.

Example: -```typescript -// Retrieve the second page of 20 results -firestore.pipeline().collection("books") -.sort(Field.of("published").descending()) -.offset(20) // Skip the first 20 results -.limit(20); // Take the next 20 results - -``` - | -| [select(selections)](./firestore_.pipeline.md#pipelineselect) | | Selects or creates a set of fields from the outputs of previous stages.

The selected fields are defined using [Selectable](./firestore_.selectable.md#selectable_interface) expressions, which can be:

  • : Name of an existing field
  • [Field](./firestore_.field.md#field_class): References an existing field.
  • : Represents the result of a function with an assigned alias name using

If no selections are provided, the output of this stage is empty. Use instead if only additions are desired.

Example: -```typescript -firestore.pipeline().collection("books") -.select( -"firstName", -Field.of("lastName"), -Field.of("address").toUppercase().as("upperAddress"), -); - -``` - | -| [sort(orderings)](./firestore_.pipeline.md#pipelinesort) | | Sorts the documents from previous stages based on one or more [Ordering](./firestore_.ordering.md#ordering_class) criteria.

This stage allows you to order the results of your pipeline. You can specify multiple [Ordering](./firestore_.ordering.md#ordering_class) instances to sort by multiple fields in ascending or descending order. If documents have the same value for a field used for sorting, the next specified ordering will be used. If all orderings result in equal comparison, the documents are considered equal and the order is unspecified.

Example: -```typescript -// Sort books by rating in descending order, and then by title in ascending order for books -// with the same rating -firestore.pipeline().collection("books") -.sort( -Ordering.of(Field.of("rating")).descending(), -Ordering.of(Field.of("title")) // Ascending order is the default -); - -``` - | -| [sort(options)](./firestore_.pipeline.md#pipelinesort) | | | -| [where(condition)](./firestore_.pipeline.md#pipelinewhere) | | Filters the documents from previous stages to only include those matching the specified [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface).

This stage allows you to apply conditions to the data, similar to a "WHERE" clause in SQL. You can filter documents based on their field values, using implementations of [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface), typically including but not limited to:

  • field comparators: , (less than), (greater than), etc.
  • logical operators: , , , etc.
  • advanced functions: , , etc.

Example: -```typescript -firestore.pipeline().collection("books") -.where( -and( -gt(Field.of("rating"), 4.0), // Filter for ratings greater than 4.0 -Field.of("genre").eq("Science Fiction") // Equivalent to gt("genre", "Science Fiction") -) -); - -``` - | - -## Pipeline.converter - -Signature: - -```typescript -converter: any; -``` - -## Pipeline.readUserData - -Reads user data for each expression in the expressionMap. - -Signature: - -```typescript -readUserData: any; -``` - -## Pipeline.selectablesToMap - -Signature: - -```typescript -selectablesToMap: any; -``` - -## Pipeline.stages - -Signature: - -```typescript -stages: any; -``` - -## Pipeline.userDataReader - -Signature: - -```typescript -userDataReader: any; -``` - -## Pipeline.addFields() - -Adds new fields to outputs from previous stages. - -This stage allows you to compute values on-the-fly based on existing data from previous stages or constants. You can use this to create new fields or overwrite existing ones (if there is name overlaps). - -The added fields are defined using [Selectable](./firestore_.selectable.md#selectable_interface)s, which can be: - -- [Field](./firestore_.field.md#field_class): References an existing document field. - : Performs a calculation using functions like `add`, `multiply` with assigned aliases using . - -Example: - -```typescript -firestore.pipeline().collection("books") -.addFields( -Field.of("rating").as("bookRating"), // Rename 'rating' to 'bookRating' -add(5, Field.of("quantity")).as("totalCost") // Calculate 'totalCost' -); - -``` - -Signature: - -```typescript -addFields(...fields: Selectable[]): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| fields | [Selectable](./firestore_.selectable.md#selectable_interface)\[\] | The fields to add to the documents, specified as [Selectable](./firestore_.selectable.md#selectable_interface)s. A new Pipeline object with this stage appended to the stage list. | - -Returns: - -[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.aggregate() - -Performs aggregation operations on the documents from previous stages. - -

This stage allows you to calculate aggregate values over a set of documents. You define the aggregations to perform using [AccumulatorTarget](./firestore_.md#accumulatortarget) expressions which are typically results of calling on [Accumulator](./firestore_.accumulator.md#accumulator_interface) instances. - -

Example: - -```typescript -// Calculate the average rating and the total number of books -firestore.pipeline().collection("books") -.aggregate( -Field.of("rating").avg().as("averageRating"), -countAll().as("totalBooks") -); - -``` - -Signature: - -```typescript -aggregate(...accumulators: AccumulatorTarget[]): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| accumulators | [AccumulatorTarget](./firestore_.md#accumulatortarget)\[\] | The [AccumulatorTarget](./firestore_.md#accumulatortarget) expressions, each wrapping an [Accumulator](./firestore_.accumulator.md#accumulator_interface) and provide a name for the accumulated results. A new Pipeline object with this stage appended to the stage list. | - -Returns: - -[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.aggregate() - -Performs optionally grouped aggregation operations on the documents from previous stages. - -

This stage allows you to calculate aggregate values over a set of documents, optionally grouped by one or more fields or functions. You can specify: - -

  • \*\*Grouping Fields or Functions:\*\* One or more fields or functions to group the documents by. For each distinct combination of values in these fields, a separate group is created. If no grouping fields are provided, a single group containing all documents is used. Not specifying groups is the same as putting the entire inputs into one group.
  • \*\*Accumulators:\*\* One or more accumulation operations to perform within each group. These are defined using [AccumulatorTarget](./firestore_.md#accumulatortarget) expressions, which are typically created by calling on [Accumulator](./firestore_.accumulator.md#accumulator_interface) instances. Each aggregation calculates a value (e.g., sum, average, count) based on the documents within its group.
- -

Example: - -```typescript -// Calculate the average rating for each genre. -firestore.pipeline().collection("books") -.aggregate({ -accumulators: [avg(Field.of("rating")).as("avg_rating")] -groups: ["genre"] -}); - -``` - -Signature: - -```typescript -aggregate(options: { accumulators: AccumulatorTarget[]; groups?: Array; }): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| options | { accumulators: [AccumulatorTarget](./firestore_.md#accumulatortarget)\[\]; groups?: Array<string \| [Selectable](./firestore_.selectable.md#selectable_interface)>; } | | - -Returns: - -[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.distinct() - -Returns a set of distinct values from the inputs to this stage. - -

This stage run through the results from previous stages to include only results with unique combinations of values ([Field](./firestore_.field.md#field_class), , etc). - -

The parameters to this stage are defined using [Selectable](./firestore_.selectable.md#selectable_interface) expressions or s: - -

  • : Name of an existing field
  • [Field](./firestore_.field.md#field_class): References an existing document field.
  • : Represents the result of a function with an assigned alias name using
- -

Example: - -```typescript -// Get a list of unique author names in uppercase and genre combinations. -firestore.pipeline().collection("books") -.distinct(toUppercase(Field.of("author")).as("authorName"), Field.of("genre"), "publishedAt") -.select("authorName"); - -``` - -Signature: - -```typescript -distinct(...groups: Array): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| groups | Array<string \| [Selectable](./firestore_.selectable.md#selectable_interface)> | | - -Returns: - -[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.execute() - -Executes this pipeline and returns a Promise to represent the asynchronous operation. - -

The returned Promise can be used to track the progress of the pipeline execution and retrieve the results (or handle any errors) asynchronously. - -

The pipeline results are returned as a list of [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) objects. Each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) typically represents a single key/value map that has passed through all the stages of the pipeline, however this might differ depending on the stages involved in the pipeline. For example: - -

  • If there are no stages or only transformation stages, each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) represents a single document.
  • If there is an aggregation, only a single [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) is returned, representing the aggregated results over the entire dataset .
  • If there is an aggregation stage with grouping, each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) represents a distinct group and its associated aggregated values.
- -

Example: - -```typescript -const futureResults = await firestore.pipeline().collection("books") - .where(gt(Field.of("rating"), 4.5)) - .select("title", "author", "rating") - .execute(); - -``` - A Promise representing the asynchronous pipeline execution. - -Signature: - -```typescript -execute(): Promise>>; -``` -Returns: - -Promise<Array<[PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class)<AppModelType>>> - -## Pipeline.findNearest() - -Signature: - -```typescript -findNearest(options: FindNearestOptions): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| options | [FindNearestOptions](./firestore_.findnearestoptions.md#findnearestoptions_interface) | | - -Returns: - -[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.genericStage() - -Adds a generic stage to the pipeline. - -

This method provides a flexible way to extend the pipeline's functionality by adding custom stages. Each generic stage is defined by a unique `name` and a set of `params` that control its behavior. - -

Example (Assuming there is no "where" stage available in SDK): - -```typescript -// Assume we don't have a built-in "where" stage -firestore.pipeline().collection("books") -.genericStage("where", [Field.of("published").lt(1900)]) // Custom "where" stage -.select("title", "author"); - -``` - -Signature: - -```typescript -genericStage(name: string, params: any[]): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | The unique name of the generic stage to add. | -| params | any\[\] | A list of parameters to configure the generic stage's behavior. A new object with this stage appended to the stage list. | - -Returns: - -[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.limit() - -Limits the maximum number of documents returned by previous stages to `limit`. - -

This stage is particularly useful when you want to retrieve a controlled subset of data from a potentially large result set. It's often used for: - -

  • \*\*Pagination:\*\* In combination with to retrieve specific pages of results.
  • \*\*Limiting Data Retrieval:\*\* To prevent excessive data transfer and improve performance, especially when dealing with large collections.
- -

Example: - -```typescript -// Limit the results to the top 10 highest-rated books -firestore.pipeline().collection("books") -.sort(Field.of("rating").descending()) -.limit(10); - -``` - -Signature: - -```typescript -limit(limit: number): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| limit | number | The maximum number of documents to return. A new Pipeline object with this stage appended to the stage list. | - -Returns: - -[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.offset() - -Skips the first `offset` number of documents from the results of previous stages. - -

This stage is useful for implementing pagination in your pipelines, allowing you to retrieve results in chunks. It is typically used in conjunction with to control the size of each page. - -

Example: - -```typescript -// Retrieve the second page of 20 results -firestore.pipeline().collection("books") -.sort(Field.of("published").descending()) -.offset(20) // Skip the first 20 results -.limit(20); // Take the next 20 results - -``` - -Signature: - -```typescript -offset(offset: number): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| offset | number | The number of documents to skip. A new Pipeline object with this stage appended to the stage list. | - -Returns: - -[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.select() - -Selects or creates a set of fields from the outputs of previous stages. - -

The selected fields are defined using [Selectable](./firestore_.selectable.md#selectable_interface) expressions, which can be: - -

  • : Name of an existing field
  • [Field](./firestore_.field.md#field_class): References an existing field.
  • : Represents the result of a function with an assigned alias name using
- -

If no selections are provided, the output of this stage is empty. Use instead if only additions are desired. - -

Example: - -```typescript -firestore.pipeline().collection("books") -.select( -"firstName", -Field.of("lastName"), -Field.of("address").toUppercase().as("upperAddress"), -); - -``` - -Signature: - -```typescript -select(...selections: Array): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| selections | Array<[Selectable](./firestore_.selectable.md#selectable_interface) \| string> | The fields to include in the output documents, specified as [Selectable](./firestore_.selectable.md#selectable_interface) expressions or values representing field names. A new Pipeline object with this stage appended to the stage list. | - -Returns: - -[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.sort() - -Sorts the documents from previous stages based on one or more [Ordering](./firestore_.ordering.md#ordering_class) criteria. - -

This stage allows you to order the results of your pipeline. You can specify multiple [Ordering](./firestore_.ordering.md#ordering_class) instances to sort by multiple fields in ascending or descending order. If documents have the same value for a field used for sorting, the next specified ordering will be used. If all orderings result in equal comparison, the documents are considered equal and the order is unspecified. - -

Example: - -```typescript -// Sort books by rating in descending order, and then by title in ascending order for books -// with the same rating -firestore.pipeline().collection("books") -.sort( -Ordering.of(Field.of("rating")).descending(), -Ordering.of(Field.of("title")) // Ascending order is the default -); - -``` - -Signature: - -```typescript -sort(...orderings: Ordering[]): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| orderings | [Ordering](./firestore_.ordering.md#ordering_class)\[\] | | - -Returns: - -[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.sort() - -Signature: - -```typescript -sort(options: { orderings: Ordering[]; }): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| options | { orderings: [Ordering](./firestore_.ordering.md#ordering_class)\[\]; } | | - -Returns: - -[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.where() - -Filters the documents from previous stages to only include those matching the specified [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface). - -

This stage allows you to apply conditions to the data, similar to a "WHERE" clause in SQL. You can filter documents based on their field values, using implementations of [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface), typically including but not limited to: - -

  • field comparators: , (less than), (greater than), etc.
  • logical operators: , , , etc.
  • advanced functions: , , etc.
- -

Example: - -```typescript -firestore.pipeline().collection("books") -.where( -and( -gt(Field.of("rating"), 4.0), // Filter for ratings greater than 4.0 -Field.of("genre").eq("Science Fiction") // Equivalent to gt("genre", "Science Fiction") -) -); - -``` - -Signature: - -```typescript -where(condition: FilterCondition & Constant): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| condition | [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) & [Constant](./firestore_.constant.md#constant_class) | The [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) to apply. A new Pipeline object with this stage appended to the stage list. | - -Returns: - -[Pipeline](./firestore_.pipeline.md#pipeline_class)<AppModelType> - diff --git a/docs-devsite/firestore_.pipelineresult.md b/docs-devsite/firestore_.pipelineresult.md deleted file mode 100644 index a035e4375ff..00000000000 --- a/docs-devsite/firestore_.pipelineresult.md +++ /dev/null @@ -1,184 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# PipelineResult class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -A PipelineResult contains data read from a Firestore Pipeline. The data can be extracted with the or methods. - -

If the PipelineResult represents a non-document result, `ref` will return a undefined value. - -Signature: - -```typescript -export declare class PipelineResult -``` - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [createTime](./firestore_.pipelineresult.md#pipelineresultcreatetime) | | [Timestamp](./firestore_.timestamp.md#timestamp_class) \| undefined | (BETA) The time the document was created. Undefined if this result is not a document. {Timestamp\|undefined} | -| [executionTime](./firestore_.pipelineresult.md#pipelineresultexecutiontime) | | [Timestamp](./firestore_.timestamp.md#timestamp_class) | (BETA) The time at which the pipeline producing this result is executed. {Timestamp} | -| [id](./firestore_.pipelineresult.md#pipelineresultid) | | string \| undefined | (BETA) The ID of the document for which this PipelineResult contains data, if it is a document; otherwise undefined. {string} | -| [ref](./firestore_.pipelineresult.md#pipelineresultref) | | [DocumentReference](./firestore_.documentreference.md#documentreference_class) \| undefined | (BETA) The reference of the document, if it is a document; otherwise undefined. | -| [updateTime](./firestore_.pipelineresult.md#pipelineresultupdatetime) | | [Timestamp](./firestore_.timestamp.md#timestamp_class) \| undefined | (BETA) The time the document was last updated (at the time the snapshot was generated). Undefined if this result is not a document. {Timestamp\|undefined} | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [data()](./firestore_.pipelineresult.md#pipelineresultdata) | | (BETA) Retrieves all fields in the result as an object. Returns 'undefined' if the document doesn't exist. | -| [get(fieldPath)](./firestore_.pipelineresult.md#pipelineresultget) | | (BETA) Retrieves the field specified by field. | - -## PipelineResult.createTime - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -The time the document was created. Undefined if this result is not a document. - - {Timestamp\|undefined} - -Signature: - -```typescript -get createTime(): Timestamp | undefined; -``` - -## PipelineResult.executionTime - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -The time at which the pipeline producing this result is executed. - - {Timestamp} - -Signature: - -```typescript -get executionTime(): Timestamp; -``` - -## PipelineResult.id - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -The ID of the document for which this PipelineResult contains data, if it is a document; otherwise `undefined`. - - {string} - -Signature: - -```typescript -get id(): string | undefined; -``` - -## PipelineResult.ref - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -The reference of the document, if it is a document; otherwise `undefined`. - -Signature: - -```typescript -get ref(): DocumentReference | undefined; -``` - -## PipelineResult.updateTime - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -The time the document was last updated (at the time the snapshot was generated). Undefined if this result is not a document. - - {Timestamp\|undefined} - -Signature: - -```typescript -get updateTime(): Timestamp | undefined; -``` - -## PipelineResult.data() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Retrieves all fields in the result as an object. Returns 'undefined' if the document doesn't exist. - -Signature: - -```typescript -data(): AppModelType | undefined; -``` -Returns: - -AppModelType \| undefined - -{T\|undefined} An object containing all fields in the document or 'undefined' if the document doesn't exist. - -### Example - - -``` -let p = firestore.pipeline().collection('col'); - -p.execute().then(results => { - let data = results[0].data(); - console.log(`Retrieved data: ${JSON.stringify(data)}`); -}); - -``` - -## PipelineResult.get() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Retrieves the field specified by `field`. - -Signature: - -```typescript -get(fieldPath: string | FieldPath): any; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| fieldPath | string \| [FieldPath](./firestore_.fieldpath.md#fieldpath_class) | | - -Returns: - -any - -{\*} The data at the specified field location or undefined if no such field exists. - -### Example - - -``` -let p = firestore.pipeline().collection('col'); - -p.execute().then(results => { - let field = results[0].get('a.b'); - console.log(`Retrieved field value: ${field}`); -}); - -``` - diff --git a/docs-devsite/firestore_.pipelinesource.md b/docs-devsite/firestore_.pipelinesource.md deleted file mode 100644 index cbe4150b1fe..00000000000 --- a/docs-devsite/firestore_.pipelinesource.md +++ /dev/null @@ -1,109 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# PipelineSource class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Represents the source of a Firestore [Pipeline](./firestore_.pipeline.md#pipeline_class). - -Signature: - -```typescript -export declare class PipelineSource -``` - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [collection(collectionPath)](./firestore_.pipelinesource.md#pipelinesourcecollection) | | (BETA) | -| [collectionGroup(collectionId)](./firestore_.pipelinesource.md#pipelinesourcecollectiongroup) | | (BETA) | -| [database()](./firestore_.pipelinesource.md#pipelinesourcedatabase) | | (BETA) | -| [documents(docs)](./firestore_.pipelinesource.md#pipelinesourcedocuments) | | (BETA) | - -## PipelineSource.collection() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -collection(collectionPath: string): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| collectionPath | string | | - -Returns: - -[Pipeline](./firestore_.pipeline.md#pipeline_class) - -## PipelineSource.collectionGroup() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -collectionGroup(collectionId: string): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| collectionId | string | | - -Returns: - -[Pipeline](./firestore_.pipeline.md#pipeline_class) - -## PipelineSource.database() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -database(): Pipeline; -``` -Returns: - -[Pipeline](./firestore_.pipeline.md#pipeline_class) - -## PipelineSource.documents() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -documents(docs: DocumentReference[]): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| docs | [DocumentReference](./firestore_.documentreference.md#documentreference_class)\[\] | | - -Returns: - -[Pipeline](./firestore_.pipeline.md#pipeline_class) - diff --git a/docs-devsite/firestore_.query.md b/docs-devsite/firestore_.query.md index f4d0c8d20e1..086d117aa1e 100644 --- a/docs-devsite/firestore_.query.md +++ b/docs-devsite/firestore_.query.md @@ -36,7 +36,6 @@ export declare class QueryNewDbModelType and your custom type NewAppModelType. | @@ -80,19 +79,6 @@ The type of this Firestore reference. readonly type: 'query' | 'collection'; ``` -## Query.pipeline() - -Pipeline query. - -Signature: - -```typescript -pipeline(): Pipeline; -``` -Returns: - -[Pipeline](./firestore_.pipeline.md#pipeline_class) - ## Query.withConverter() Removes the current converter. diff --git a/docs-devsite/firestore_.querycompositefilterconstraint.md b/docs-devsite/firestore_.querycompositefilterconstraint.md index 61afef2b6b7..bb00c3bf2b3 100644 --- a/docs-devsite/firestore_.querycompositefilterconstraint.md +++ b/docs-devsite/firestore_.querycompositefilterconstraint.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # QueryCompositeFilterConstraint class -A `QueryCompositeFilterConstraint` is used to narrow the set of documents returned by a Firestore query by performing the logical OR or AND of multiple [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class)s or [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class)s. `QueryCompositeFilterConstraint`s are created by invoking or and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the `QueryCompositeFilterConstraint`. +A `QueryCompositeFilterConstraint` is used to narrow the set of documents returned by a Firestore query by performing the logical OR or AND of multiple [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class)s or [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class)s. `QueryCompositeFilterConstraint`s are created by invoking [or()](./firestore_.md#or_e72c712) or [and()](./firestore_.md#and_e72c712) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the `QueryCompositeFilterConstraint`. Signature: diff --git a/docs-devsite/firestore_.regexcontains.md b/docs-devsite/firestore_.regexcontains.md deleted file mode 100644 index b9be8441054..00000000000 --- a/docs-devsite/firestore_.regexcontains.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# RegexContains class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class RegexContains extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr, pattern)](./firestore_.regexcontains.md#regexcontainsconstructor) | | (BETA) Constructs a new instance of the RegexContains class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_.regexcontains.md#regexcontainsfilterable) | | true | (BETA) | - -## RegexContains.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `RegexContains` class - -Signature: - -```typescript -constructor(expr: Constant, pattern: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | | -| pattern | [Constant](./firestore_.constant.md#constant_class) | | - -## RegexContains.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_.regexmatch.md b/docs-devsite/firestore_.regexmatch.md deleted file mode 100644 index 5a8ccf289aa..00000000000 --- a/docs-devsite/firestore_.regexmatch.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# RegexMatch class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class RegexMatch extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr, pattern)](./firestore_.regexmatch.md#regexmatchconstructor) | | (BETA) Constructs a new instance of the RegexMatch class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_.regexmatch.md#regexmatchfilterable) | | true | (BETA) | - -## RegexMatch.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `RegexMatch` class - -Signature: - -```typescript -constructor(expr: Constant, pattern: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | | -| pattern | [Constant](./firestore_.constant.md#constant_class) | | - -## RegexMatch.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_.replaceall.md b/docs-devsite/firestore_.replaceall.md deleted file mode 100644 index 592c709eac7..00000000000 --- a/docs-devsite/firestore_.replaceall.md +++ /dev/null @@ -1,50 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ReplaceAll class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ReplaceAll extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value, find, replace)](./firestore_.replaceall.md#replaceallconstructor) | | (BETA) Constructs a new instance of the ReplaceAll class | - -## ReplaceAll.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ReplaceAll` class - -Signature: - -```typescript -constructor(value: Constant, find: Constant, replace: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) | | -| find | [Constant](./firestore_.constant.md#constant_class) | | -| replace | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.replacefirst.md b/docs-devsite/firestore_.replacefirst.md deleted file mode 100644 index d79957a1f6b..00000000000 --- a/docs-devsite/firestore_.replacefirst.md +++ /dev/null @@ -1,50 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ReplaceFirst class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ReplaceFirst extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value, find, replace)](./firestore_.replacefirst.md#replacefirstconstructor) | | (BETA) Constructs a new instance of the ReplaceFirst class | - -## ReplaceFirst.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ReplaceFirst` class - -Signature: - -```typescript -constructor(value: Constant, find: Constant, replace: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) | | -| find | [Constant](./firestore_.constant.md#constant_class) | | -| replace | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.reverse.md b/docs-devsite/firestore_.reverse.md deleted file mode 100644 index f6d8f61a312..00000000000 --- a/docs-devsite/firestore_.reverse.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Reverse class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Reverse extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value)](./firestore_.reverse.md#reverseconstructor) | | (BETA) Constructs a new instance of the Reverse class | - -## Reverse.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Reverse` class - -Signature: - -```typescript -constructor(value: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.select.md b/docs-devsite/firestore_.select.md deleted file mode 100644 index 42fe74ce7db..00000000000 --- a/docs-devsite/firestore_.select.md +++ /dev/null @@ -1,64 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Select class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Select implements Stage -``` -Implements: [Stage](./firestore_.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(projections)](./firestore_.select.md#selectconstructor) | | (BETA) Constructs a new instance of the Select class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_.select.md#selectname) | | string | (BETA) | - -## Select.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Select` class - -Signature: - -```typescript -constructor(projections: Map); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| projections | Map<string, [Constant](./firestore_.constant.md#constant_class)> | | - -## Select.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_.selectable.md b/docs-devsite/firestore_.selectable.md deleted file mode 100644 index 0fb32592d4a..00000000000 --- a/docs-devsite/firestore_.selectable.md +++ /dev/null @@ -1,39 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Selectable interface -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -An interface that represents a selectable expression. - -Signature: - -```typescript -export declare interface Selectable -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [selectable](./firestore_.selectable.md#selectableselectable) | true | (BETA) | - -## Selectable.selectable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -selectable: true; -``` diff --git a/docs-devsite/firestore_.sort.md b/docs-devsite/firestore_.sort.md deleted file mode 100644 index fa7e1d119fc..00000000000 --- a/docs-devsite/firestore_.sort.md +++ /dev/null @@ -1,64 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Sort class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Sort implements Stage -``` -Implements: [Stage](./firestore_.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(orders)](./firestore_.sort.md#sortconstructor) | | (BETA) Constructs a new instance of the Sort class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_.sort.md#sortname) | | string | (BETA) | - -## Sort.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Sort` class - -Signature: - -```typescript -constructor(orders: Ordering[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| orders | [Ordering](./firestore_.ordering.md#ordering_class)\[\] | | - -## Sort.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_.stage.md b/docs-devsite/firestore_.stage.md deleted file mode 100644 index 34a94a3d4ba..00000000000 --- a/docs-devsite/firestore_.stage.md +++ /dev/null @@ -1,38 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Stage interface -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare interface Stage -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [name](./firestore_.stage.md#stagename) | string | (BETA) | - -## Stage.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_.startswith.md b/docs-devsite/firestore_.startswith.md deleted file mode 100644 index e12aca31300..00000000000 --- a/docs-devsite/firestore_.startswith.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# StartsWith class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class StartsWith extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr, prefix)](./firestore_.startswith.md#startswithconstructor) | | (BETA) Constructs a new instance of the StartsWith class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_.startswith.md#startswithfilterable) | | true | (BETA) | - -## StartsWith.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `StartsWith` class - -Signature: - -```typescript -constructor(expr: Constant, prefix: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | | -| prefix | [Constant](./firestore_.constant.md#constant_class) | | - -## StartsWith.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_.strconcat.md b/docs-devsite/firestore_.strconcat.md deleted file mode 100644 index 5d044f31561..00000000000 --- a/docs-devsite/firestore_.strconcat.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# StrConcat class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class StrConcat extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(first, rest)](./firestore_.strconcat.md#strconcatconstructor) | | (BETA) Constructs a new instance of the StrConcat class | - -## StrConcat.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `StrConcat` class - -Signature: - -```typescript -constructor(first: Constant, rest: Constant[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| first | [Constant](./firestore_.constant.md#constant_class) | | -| rest | [Constant](./firestore_.constant.md#constant_class)\[\] | | - diff --git a/docs-devsite/firestore_.strcontains.md b/docs-devsite/firestore_.strcontains.md deleted file mode 100644 index a704676ad7a..00000000000 --- a/docs-devsite/firestore_.strcontains.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# StrContains class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class StrContains extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr, substring)](./firestore_.strcontains.md#strcontainsconstructor) | | (BETA) Constructs a new instance of the StrContains class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_.strcontains.md#strcontainsfilterable) | | true | (BETA) | - -## StrContains.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `StrContains` class - -Signature: - -```typescript -constructor(expr: Constant, substring: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | | -| substring | [Constant](./firestore_.constant.md#constant_class) | | - -## StrContains.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_.subtract.md b/docs-devsite/firestore_.subtract.md deleted file mode 100644 index d72563e8471..00000000000 --- a/docs-devsite/firestore_.subtract.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Subtract class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Subtract extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_.subtract.md#subtractconstructor) | | (BETA) Constructs a new instance of the Subtract class | - -## Subtract.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Subtract` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_.constant.md#constant_class) | | -| right | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.sum.md b/docs-devsite/firestore_.sum.md deleted file mode 100644 index 41d11c83b0c..00000000000 --- a/docs-devsite/firestore_.sum.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Sum class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Sum extends FirestoreFunction implements Accumulator -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [Accumulator](./firestore_.accumulator.md#accumulator_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value, distinct)](./firestore_.sum.md#sumconstructor) | | (BETA) Constructs a new instance of the Sum class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [accumulator](./firestore_.sum.md#sumaccumulator) | | true | (BETA) | - -## Sum.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Sum` class - -Signature: - -```typescript -constructor(value: Constant, distinct: boolean); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) | | -| distinct | boolean | | - -## Sum.accumulator - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -accumulator: true; -``` diff --git a/docs-devsite/firestore_.timestampadd.md b/docs-devsite/firestore_.timestampadd.md deleted file mode 100644 index 9e563f5f364..00000000000 --- a/docs-devsite/firestore_.timestampadd.md +++ /dev/null @@ -1,50 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# TimestampAdd class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class TimestampAdd extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(timestamp, unit, amount)](./firestore_.timestampadd.md#timestampaddconstructor) | | (BETA) Constructs a new instance of the TimestampAdd class | - -## TimestampAdd.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `TimestampAdd` class - -Signature: - -```typescript -constructor(timestamp: Constant, unit: Constant, amount: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| timestamp | [Constant](./firestore_.constant.md#constant_class) | | -| unit | [Constant](./firestore_.constant.md#constant_class) | | -| amount | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.timestampsub.md b/docs-devsite/firestore_.timestampsub.md deleted file mode 100644 index a3a28e60c1b..00000000000 --- a/docs-devsite/firestore_.timestampsub.md +++ /dev/null @@ -1,50 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# TimestampSub class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class TimestampSub extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(timestamp, unit, amount)](./firestore_.timestampsub.md#timestampsubconstructor) | | (BETA) Constructs a new instance of the TimestampSub class | - -## TimestampSub.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `TimestampSub` class - -Signature: - -```typescript -constructor(timestamp: Constant, unit: Constant, amount: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| timestamp | [Constant](./firestore_.constant.md#constant_class) | | -| unit | [Constant](./firestore_.constant.md#constant_class) | | -| amount | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.timestamptounixmicros.md b/docs-devsite/firestore_.timestamptounixmicros.md deleted file mode 100644 index 3075048c254..00000000000 --- a/docs-devsite/firestore_.timestamptounixmicros.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# TimestampToUnixMicros class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class TimestampToUnixMicros extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(input)](./firestore_.timestamptounixmicros.md#timestamptounixmicrosconstructor) | | (BETA) Constructs a new instance of the TimestampToUnixMicros class | - -## TimestampToUnixMicros.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `TimestampToUnixMicros` class - -Signature: - -```typescript -constructor(input: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| input | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.timestamptounixmillis.md b/docs-devsite/firestore_.timestamptounixmillis.md deleted file mode 100644 index 0098c5932dd..00000000000 --- a/docs-devsite/firestore_.timestamptounixmillis.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# TimestampToUnixMillis class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class TimestampToUnixMillis extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(input)](./firestore_.timestamptounixmillis.md#timestamptounixmillisconstructor) | | (BETA) Constructs a new instance of the TimestampToUnixMillis class | - -## TimestampToUnixMillis.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `TimestampToUnixMillis` class - -Signature: - -```typescript -constructor(input: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| input | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.timestamptounixseconds.md b/docs-devsite/firestore_.timestamptounixseconds.md deleted file mode 100644 index 49b2dd97664..00000000000 --- a/docs-devsite/firestore_.timestamptounixseconds.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# TimestampToUnixSeconds class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class TimestampToUnixSeconds extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(input)](./firestore_.timestamptounixseconds.md#timestamptounixsecondsconstructor) | | (BETA) Constructs a new instance of the TimestampToUnixSeconds class | - -## TimestampToUnixSeconds.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `TimestampToUnixSeconds` class - -Signature: - -```typescript -constructor(input: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| input | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.tolower.md b/docs-devsite/firestore_.tolower.md deleted file mode 100644 index b5b29215bcd..00000000000 --- a/docs-devsite/firestore_.tolower.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ToLower class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ToLower extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr)](./firestore_.tolower.md#tolowerconstructor) | | (BETA) Constructs a new instance of the ToLower class | - -## ToLower.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ToLower` class - -Signature: - -```typescript -constructor(expr: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.toupper.md b/docs-devsite/firestore_.toupper.md deleted file mode 100644 index bfd5fb607b4..00000000000 --- a/docs-devsite/firestore_.toupper.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ToUpper class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ToUpper extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr)](./firestore_.toupper.md#toupperconstructor) | | (BETA) Constructs a new instance of the ToUpper class | - -## ToUpper.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ToUpper` class - -Signature: - -```typescript -constructor(expr: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.trim.md b/docs-devsite/firestore_.trim.md deleted file mode 100644 index bfbce9afbed..00000000000 --- a/docs-devsite/firestore_.trim.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Trim class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Trim extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr)](./firestore_.trim.md#trimconstructor) | | (BETA) Constructs a new instance of the Trim class | - -## Trim.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Trim` class - -Signature: - -```typescript -constructor(expr: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.unixmicrostotimestamp.md b/docs-devsite/firestore_.unixmicrostotimestamp.md deleted file mode 100644 index cd40de9afb3..00000000000 --- a/docs-devsite/firestore_.unixmicrostotimestamp.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# UnixMicrosToTimestamp class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class UnixMicrosToTimestamp extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(input)](./firestore_.unixmicrostotimestamp.md#unixmicrostotimestampconstructor) | | (BETA) Constructs a new instance of the UnixMicrosToTimestamp class | - -## UnixMicrosToTimestamp.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `UnixMicrosToTimestamp` class - -Signature: - -```typescript -constructor(input: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| input | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.unixmillistotimestamp.md b/docs-devsite/firestore_.unixmillistotimestamp.md deleted file mode 100644 index 554deb16305..00000000000 --- a/docs-devsite/firestore_.unixmillistotimestamp.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# UnixMillisToTimestamp class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class UnixMillisToTimestamp extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(input)](./firestore_.unixmillistotimestamp.md#unixmillistotimestampconstructor) | | (BETA) Constructs a new instance of the UnixMillisToTimestamp class | - -## UnixMillisToTimestamp.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `UnixMillisToTimestamp` class - -Signature: - -```typescript -constructor(input: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| input | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.unixsecondstotimestamp.md b/docs-devsite/firestore_.unixsecondstotimestamp.md deleted file mode 100644 index 935b579ca0b..00000000000 --- a/docs-devsite/firestore_.unixsecondstotimestamp.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# UnixSecondsToTimestamp class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class UnixSecondsToTimestamp extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(input)](./firestore_.unixsecondstotimestamp.md#unixsecondstotimestampconstructor) | | (BETA) Constructs a new instance of the UnixSecondsToTimestamp class | - -## UnixSecondsToTimestamp.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `UnixSecondsToTimestamp` class - -Signature: - -```typescript -constructor(input: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| input | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.vectorlength.md b/docs-devsite/firestore_.vectorlength.md deleted file mode 100644 index 0a7097bdbdd..00000000000 --- a/docs-devsite/firestore_.vectorlength.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# VectorLength class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class VectorLength extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value)](./firestore_.vectorlength.md#vectorlengthconstructor) | | (BETA) Constructs a new instance of the VectorLength class | - -## VectorLength.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `VectorLength` class - -Signature: - -```typescript -constructor(value: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_.where.md b/docs-devsite/firestore_.where.md deleted file mode 100644 index a6cca720fb8..00000000000 --- a/docs-devsite/firestore_.where.md +++ /dev/null @@ -1,64 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Where class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Where implements Stage -``` -Implements: [Stage](./firestore_.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(condition)](./firestore_.where.md#whereconstructor) | | (BETA) Constructs a new instance of the Where class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_.where.md#wherename) | | string | (BETA) | - -## Where.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Where` class - -Signature: - -```typescript -constructor(condition: FilterCondition & Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| condition | [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) & [Constant](./firestore_.constant.md#constant_class) | | - -## Where.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_.xor.md b/docs-devsite/firestore_.xor.md deleted file mode 100644 index b7a9269ed1b..00000000000 --- a/docs-devsite/firestore_.xor.md +++ /dev/null @@ -1,66 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Xor class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Xor extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(conditions)](./firestore_.xor.md#xorconstructor) | | (BETA) Constructs a new instance of the Xor class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_.xor.md#xorfilterable) | | true | (BETA) | - -## Xor.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Xor` class - -Signature: - -```typescript -constructor(conditions: FilterExpr[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| conditions | [FilterExpr](./firestore_.md#filterexpr)\[\] | | - -## Xor.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.accumulator.md b/docs-devsite/firestore_lite.accumulator.md deleted file mode 100644 index 0b26c43d241..00000000000 --- a/docs-devsite/firestore_lite.accumulator.md +++ /dev/null @@ -1,39 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Accumulator interface -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -An interface that represents an accumulator. - -Signature: - -```typescript -export declare interface Accumulator -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [accumulator](./firestore_lite.accumulator.md#accumulatoraccumulator) | true | (BETA) | - -## Accumulator.accumulator - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -accumulator: true; -``` diff --git a/docs-devsite/firestore_lite.add.md b/docs-devsite/firestore_lite.add.md deleted file mode 100644 index a01caad72ca..00000000000 --- a/docs-devsite/firestore_lite.add.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Add class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Add extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_lite.add.md#addconstructor) | | (BETA) Constructs a new instance of the Add class | - -## Add.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Add` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | | -| right | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.addfields.md b/docs-devsite/firestore_lite.addfields.md deleted file mode 100644 index 7cef7ce90a3..00000000000 --- a/docs-devsite/firestore_lite.addfields.md +++ /dev/null @@ -1,64 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# AddFields class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class AddFields implements Stage -``` -Implements: [Stage](./firestore_lite.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(fields)](./firestore_lite.addfields.md#addfieldsconstructor) | | (BETA) Constructs a new instance of the AddFields class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_lite.addfields.md#addfieldsname) | | string | (BETA) | - -## AddFields.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `AddFields` class - -Signature: - -```typescript -constructor(fields: Map); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| fields | Map<string, [Constant](./firestore_lite.constant.md#constant_class)> | | - -## AddFields.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_lite.aggregate.md b/docs-devsite/firestore_lite.aggregate.md deleted file mode 100644 index b5df22e08ab..00000000000 --- a/docs-devsite/firestore_lite.aggregate.md +++ /dev/null @@ -1,65 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Aggregate class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Aggregate implements Stage -``` -Implements: [Stage](./firestore_lite.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(accumulators, groups)](./firestore_lite.aggregate.md#aggregateconstructor) | | (BETA) Constructs a new instance of the Aggregate class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_lite.aggregate.md#aggregatename) | | string | (BETA) | - -## Aggregate.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Aggregate` class - -Signature: - -```typescript -constructor(accumulators: Map, groups: Map); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| accumulators | Map<string, [Accumulator](./firestore_lite.accumulator.md#accumulator_interface)> | | -| groups | Map<string, [Constant](./firestore_lite.constant.md#constant_class)> | | - -## Aggregate.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_lite.and.md b/docs-devsite/firestore_lite.and.md deleted file mode 100644 index 59b0a32b25d..00000000000 --- a/docs-devsite/firestore_lite.and.md +++ /dev/null @@ -1,17 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# and namespace -Signature: - -```typescript -export declare namespace and -``` diff --git a/docs-devsite/firestore_lite.arrayconcat.md b/docs-devsite/firestore_lite.arrayconcat.md deleted file mode 100644 index 2c9bf6bd104..00000000000 --- a/docs-devsite/firestore_lite.arrayconcat.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ArrayConcat class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ArrayConcat extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(array, elements)](./firestore_lite.arrayconcat.md#arrayconcatconstructor) | | (BETA) Constructs a new instance of the ArrayConcat class | - -## ArrayConcat.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ArrayConcat` class - -Signature: - -```typescript -constructor(array: Constant, elements: Constant[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_lite.constant.md#constant_class) | | -| elements | [Constant](./firestore_lite.constant.md#constant_class)\[\] | | - diff --git a/docs-devsite/firestore_lite.arraycontains.md b/docs-devsite/firestore_lite.arraycontains.md deleted file mode 100644 index 9875702d3b9..00000000000 --- a/docs-devsite/firestore_lite.arraycontains.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ArrayContains class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ArrayContains extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(array, element)](./firestore_lite.arraycontains.md#arraycontainsconstructor) | | (BETA) Constructs a new instance of the ArrayContains class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_lite.arraycontains.md#arraycontainsfilterable) | | true | (BETA) | - -## ArrayContains.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ArrayContains` class - -Signature: - -```typescript -constructor(array: Constant, element: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_lite.constant.md#constant_class) | | -| element | [Constant](./firestore_lite.constant.md#constant_class) | | - -## ArrayContains.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.arraycontainsall.md b/docs-devsite/firestore_lite.arraycontainsall.md deleted file mode 100644 index 2d830641779..00000000000 --- a/docs-devsite/firestore_lite.arraycontainsall.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ArrayContainsAll class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ArrayContainsAll extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(array, values)](./firestore_lite.arraycontainsall.md#arraycontainsallconstructor) | | (BETA) Constructs a new instance of the ArrayContainsAll class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_lite.arraycontainsall.md#arraycontainsallfilterable) | | true | (BETA) | - -## ArrayContainsAll.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ArrayContainsAll` class - -Signature: - -```typescript -constructor(array: Constant, values: Constant[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_lite.constant.md#constant_class) | | -| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | | - -## ArrayContainsAll.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.arraycontainsany.md b/docs-devsite/firestore_lite.arraycontainsany.md deleted file mode 100644 index 6c87810c719..00000000000 --- a/docs-devsite/firestore_lite.arraycontainsany.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ArrayContainsAny class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ArrayContainsAny extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(array, values)](./firestore_lite.arraycontainsany.md#arraycontainsanyconstructor) | | (BETA) Constructs a new instance of the ArrayContainsAny class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_lite.arraycontainsany.md#arraycontainsanyfilterable) | | true | (BETA) | - -## ArrayContainsAny.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ArrayContainsAny` class - -Signature: - -```typescript -constructor(array: Constant, values: Constant[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_lite.constant.md#constant_class) | | -| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | | - -## ArrayContainsAny.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.arrayelement.md b/docs-devsite/firestore_lite.arrayelement.md deleted file mode 100644 index 768a623e6d9..00000000000 --- a/docs-devsite/firestore_lite.arrayelement.md +++ /dev/null @@ -1,41 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ArrayElement class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ArrayElement extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)()](./firestore_lite.arrayelement.md#arrayelementconstructor) | | (BETA) Constructs a new instance of the ArrayElement class | - -## ArrayElement.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ArrayElement` class - -Signature: - -```typescript -constructor(); -``` diff --git a/docs-devsite/firestore_lite.arraylength.md b/docs-devsite/firestore_lite.arraylength.md deleted file mode 100644 index d755e7b0e23..00000000000 --- a/docs-devsite/firestore_lite.arraylength.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ArrayLength class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ArrayLength extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(array)](./firestore_lite.arraylength.md#arraylengthconstructor) | | (BETA) Constructs a new instance of the ArrayLength class | - -## ArrayLength.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ArrayLength` class - -Signature: - -```typescript -constructor(array: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.arrayreverse.md b/docs-devsite/firestore_lite.arrayreverse.md deleted file mode 100644 index 0117a8e0971..00000000000 --- a/docs-devsite/firestore_lite.arrayreverse.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ArrayReverse class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ArrayReverse extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(array)](./firestore_lite.arrayreverse.md#arrayreverseconstructor) | | (BETA) Constructs a new instance of the ArrayReverse class | - -## ArrayReverse.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ArrayReverse` class - -Signature: - -```typescript -constructor(array: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.avg.md b/docs-devsite/firestore_lite.avg.md deleted file mode 100644 index de139de6c28..00000000000 --- a/docs-devsite/firestore_lite.avg.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Avg class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Avg extends FirestoreFunction implements Accumulator -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [Accumulator](./firestore_lite.accumulator.md#accumulator_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value, distinct)](./firestore_lite.avg.md#avgconstructor) | | (BETA) Constructs a new instance of the Avg class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [accumulator](./firestore_lite.avg.md#avgaccumulator) | | true | (BETA) | - -## Avg.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Avg` class - -Signature: - -```typescript -constructor(value: Constant, distinct: boolean); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_lite.constant.md#constant_class) | | -| distinct | boolean | | - -## Avg.accumulator - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -accumulator: true; -``` diff --git a/docs-devsite/firestore_lite.bytelength.md b/docs-devsite/firestore_lite.bytelength.md deleted file mode 100644 index 2d8d42dea62..00000000000 --- a/docs-devsite/firestore_lite.bytelength.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ByteLength class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ByteLength extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value)](./firestore_lite.bytelength.md#bytelengthconstructor) | | (BETA) Constructs a new instance of the ByteLength class | - -## ByteLength.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ByteLength` class - -Signature: - -```typescript -constructor(value: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.charlength.md b/docs-devsite/firestore_lite.charlength.md deleted file mode 100644 index c2889640765..00000000000 --- a/docs-devsite/firestore_lite.charlength.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# CharLength class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class CharLength extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value)](./firestore_lite.charlength.md#charlengthconstructor) | | (BETA) Constructs a new instance of the CharLength class | - -## CharLength.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `CharLength` class - -Signature: - -```typescript -constructor(value: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.collectiongroupsource.md b/docs-devsite/firestore_lite.collectiongroupsource.md deleted file mode 100644 index 0d650e6a9b7..00000000000 --- a/docs-devsite/firestore_lite.collectiongroupsource.md +++ /dev/null @@ -1,64 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# CollectionGroupSource class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class CollectionGroupSource implements Stage -``` -Implements: [Stage](./firestore_lite.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(collectionId)](./firestore_lite.collectiongroupsource.md#collectiongroupsourceconstructor) | | (BETA) Constructs a new instance of the CollectionGroupSource class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_lite.collectiongroupsource.md#collectiongroupsourcename) | | string | (BETA) | - -## CollectionGroupSource.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `CollectionGroupSource` class - -Signature: - -```typescript -constructor(collectionId: string); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| collectionId | string | | - -## CollectionGroupSource.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_lite.collectionsource.md b/docs-devsite/firestore_lite.collectionsource.md deleted file mode 100644 index a0c0a44d768..00000000000 --- a/docs-devsite/firestore_lite.collectionsource.md +++ /dev/null @@ -1,64 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# CollectionSource class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class CollectionSource implements Stage -``` -Implements: [Stage](./firestore_lite.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(collectionPath)](./firestore_lite.collectionsource.md#collectionsourceconstructor) | | (BETA) Constructs a new instance of the CollectionSource class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_lite.collectionsource.md#collectionsourcename) | | string | (BETA) | - -## CollectionSource.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `CollectionSource` class - -Signature: - -```typescript -constructor(collectionPath: string); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| collectionPath | string | | - -## CollectionSource.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_lite.constant.md b/docs-devsite/firestore_lite.constant.md deleted file mode 100644 index 8a26c14416c..00000000000 --- a/docs-devsite/firestore_lite.constant.md +++ /dev/null @@ -1,3504 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Constant class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Represents a constant value that can be used in a Firestore pipeline expression. - -You can create a `Constant` instance using the static method: - -```typescript -// Create a Constant instance for the number 10 -const ten = Constant.of(10); - -// Create a Constant instance for the string "hello" -const hello = Constant.of("hello"); - -``` - -Signature: - -```typescript -export declare class Constant -``` - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [exprType](./firestore_lite.constant.md#constantexprtype) | | [ExprType](./firestore_lite.md#exprtype) | (BETA) | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [add(other)](./firestore_lite.constant.md#constantadd) | | (BETA) Creates an expression that adds this expression to another expression. -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -Field.of("quantity").add(Field.of("reserve")); - -``` - | -| [add(other)](./firestore_lite.constant.md#constantadd) | | (BETA) Creates an expression that adds this expression to a constant value. -```typescript -// Add 5 to the value of the 'age' field -Field.of("age").add(5); - -``` - | -| [arrayConcat(arrays)](./firestore_lite.constant.md#constantarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. -```typescript -// Combine the 'items' array with another array field. -Field.of("items").arrayConcat(Field.of("otherItems")); - -``` - | -| [arrayConcat(arrays)](./firestore_lite.constant.md#constantarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. -```typescript -// Combine the 'tags' array with a new array and an array field -Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); - -``` - | -| [arrayContains(element)](./firestore_lite.constant.md#constantarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific element. -```typescript -// Check if the 'sizes' array contains the value from the 'selectedSize' field -Field.of("sizes").arrayContains(Field.of("selectedSize")); - -``` - | -| [arrayContains(element)](./firestore_lite.constant.md#constantarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific value. -```typescript -// Check if the 'colors' array contains "red" -Field.of("colors").arrayContains("red"); - -``` - | -| [arrayContainsAll(values)](./firestore_lite.constant.md#constantarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. -```typescript -// Check if the 'tags' array contains both "news" and "sports" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - | -| [arrayContainsAll(values)](./firestore_lite.constant.md#constantarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - | -| [arrayContainsAny(values)](./firestore_lite.constant.md#constantarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "cate2" -Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); - -``` - | -| [arrayContainsAny(values)](./firestore_lite.constant.md#constantarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); - -``` - | -| [arrayLength()](./firestore_lite.constant.md#constantarraylength) | | (BETA) Creates an expression that calculates the length of an array. -```typescript -// Get the number of items in the 'cart' array -Field.of("cart").arrayLength(); - -``` - A new Expr representing the length of the array. | -| [as(name)](./firestore_lite.constant.md#constantas) | | (BETA) Assigns an alias to this expression.Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. -```typescript -// Calculate the total price and assign it the alias "totalPrice" and add it to the output. -firestore.pipeline().collection("items") -.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); - -``` - | -| [ascending()](./firestore_lite.constant.md#constantascending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. -```typescript -// Sort documents by the 'name' field in ascending order -pipeline().collection("users") -.sort(Field.of("name").ascending()); - -``` - A new Ordering for ascending sorting. | -| [avg()](./firestore_lite.constant.md#constantavg) | | (BETA) Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. -```typescript -// Calculate the average age of users -Field.of("age").avg().as("averageAge"); - -``` - A new Accumulator representing the 'avg' aggregation. | -| [byteLength()](./firestore_lite.constant.md#constantbytelength) | | (BETA) Creates an expression that calculates the length of this string expression in bytes. -```typescript -// Calculate the length of the 'myString' field in bytes. -Field.of("myString").byteLength(); - -``` - A new representing the length of the string in bytes. | -| [charLength()](./firestore_lite.constant.md#constantcharlength) | | (BETA) Creates an expression that calculates the character length of a string in UTF-8. -```typescript -// Get the character length of the 'name' field in its UTF-8 form. -Field.of("name").charLength(); - -``` - A new Expr representing the length of the string. | -| [cosineDistance(other)](./firestore_lite.constant.md#constantcosinedistance) | | (BETA) Calculates the cosine distance between two vectors. -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -Field.of("userVector").cosineDistance(Field.of("itemVector")); - -``` - | -| [cosineDistance(other)](./firestore_lite.constant.md#constantcosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); - -``` - | -| [cosineDistance(other)](./firestore_lite.constant.md#constantcosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance([37.7749, -122.4194]); - -``` - | -| [count()](./firestore_lite.constant.md#constantcount) | | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. -```typescript -// Count the total number of products -Field.of("productId").count().as("totalProducts"); - -``` - A new Accumulator representing the 'count' aggregation. | -| [descending()](./firestore_lite.constant.md#constantdescending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") -.sort(Field.of("createdAt").descending()); - -``` - A new Ordering for descending sorting. | -| [divide(other)](./firestore_lite.constant.md#constantdivide) | | (BETA) Creates an expression that divides this expression by another expression. -```typescript -// Divide the 'total' field by the 'count' field -Field.of("total").divide(Field.of("count")); - -``` - | -| [divide(other)](./firestore_lite.constant.md#constantdivide) | | (BETA) Creates an expression that divides this expression by a constant value. -```typescript -// Divide the 'value' field by 10 -Field.of("value").divide(10); - -``` - | -| [dotProduct(other)](./firestore_lite.constant.md#constantdotproduct) | | (BETA) Calculates the dot product between two vectors. -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct([0.5, 0.8, 0.2]); - -``` - | -| [dotProduct(other)](./firestore_lite.constant.md#constantdotproduct) | | (BETA) Calculates the dot product between two vectors. -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); - -``` - | -| [dotProduct(other)](./firestore_lite.constant.md#constantdotproduct) | | (BETA) | -| [endsWith(suffix)](./firestore_lite.constant.md#constantendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix. -```typescript -// Check if the 'filename' field ends with ".txt" -Field.of("filename").endsWith(".txt"); - -``` - | -| [endsWith(suffix)](./firestore_lite.constant.md#constantendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix (represented as an expression). -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -Field.of("url").endsWith(Field.of("extension")); - -``` - | -| [eq(other)](./firestore_lite.constant.md#constanteq) | | (BETA) Creates an expression that checks if this expression is equal to another expression. -```typescript -// Check if the 'age' field is equal to 21 -Field.of("age").eq(21); - -``` - | -| [eq(other)](./firestore_lite.constant.md#constanteq) | | (BETA) Creates an expression that checks if this expression is equal to a constant value. -```typescript -// Check if the 'city' field is equal to "London" -Field.of("city").eq("London"); - -``` - | -| [euclideanDistance(other)](./firestore_lite.constant.md#constanteuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance([37.7749, -122.4194]); - -``` - | -| [euclideanDistance(other)](./firestore_lite.constant.md#constanteuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); - -``` - | -| [euclideanDistance(other)](./firestore_lite.constant.md#constanteuclideandistance) | | (BETA) | -| [exists()](./firestore_lite.constant.md#constantexists) | | (BETA) Creates an expression that checks if a field exists in the document. -```typescript -// Check if the document has a field named "phoneNumber" -Field.of("phoneNumber").exists(); - -``` - A new Expr representing the 'exists' check. | -| [gt(other)](./firestore_lite.constant.md#constantgt) | | (BETA) Creates an expression that checks if this expression is greater than another expression. -```typescript -// Check if the 'age' field is greater than the 'limit' field -Field.of("age").gt(Field.of("limit")); - -``` - | -| [gt(other)](./firestore_lite.constant.md#constantgt) | | (BETA) Creates an expression that checks if this expression is greater than a constant value. -```typescript -// Check if the 'price' field is greater than 100 -Field.of("price").gt(100); - -``` - | -| [gte(other)](./firestore_lite.constant.md#constantgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to another expression. -```typescript -// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 -Field.of("quantity").gte(Field.of('requirement').add(1)); - -``` - | -| [gte(other)](./firestore_lite.constant.md#constantgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to a constant value. -```typescript -// Check if the 'score' field is greater than or equal to 80 -Field.of("score").gte(80); - -``` - | -| [in(others)](./firestore_lite.constant.md#constantin) | | (BETA) Creates an expression that checks if this expression is equal to any of the provided values or expressions. -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -Field.of("category").in("Electronics", Field.of("primaryType")); - -``` - | -| [in(others)](./firestore_lite.constant.md#constantin) | | (BETA) | -| [isNaN()](./firestore_lite.constant.md#constantisnan) | | (BETA) Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). -```typescript -// Check if the result of a calculation is NaN -Field.of("value").divide(0).isNaN(); - -``` - A new Expr representing the 'isNaN' check. | -| [like(pattern)](./firestore_lite.constant.md#constantlike) | | (BETA) Creates an expression that performs a case-sensitive string comparison. -```typescript -// Check if the 'title' field contains the word "guide" (case-sensitive) -Field.of("title").like("%guide%"); - -``` - | -| [like(pattern)](./firestore_lite.constant.md#constantlike) | | (BETA) | -| [logicalMax(other)](./firestore_lite.constant.md#constantlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMax(Function.currentTimestamp()); - -``` - | -| [logicalMax(other)](./firestore_lite.constant.md#constantlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'value' field and 10. -Field.of("value").logicalMax(10); - -``` - | -| [logicalMin(other)](./firestore_lite.constant.md#constantlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMin(Function.currentTimestamp()); - -``` - | -| [logicalMin(other)](./firestore_lite.constant.md#constantlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'value' field and 10. -Field.of("value").logicalMin(10); - -``` - | -| [lt(other)](./firestore_lite.constant.md#constantlt) | | (BETA) Creates an expression that checks if this expression is less than another expression. -```typescript -// Check if the 'age' field is less than 'limit' -Field.of("age").lt(Field.of('limit')); - -``` - | -| [lt(other)](./firestore_lite.constant.md#constantlt) | | (BETA) Creates an expression that checks if this expression is less than a constant value. -```typescript -// Check if the 'price' field is less than 50 -Field.of("price").lt(50); - -``` - | -| [lte(other)](./firestore_lite.constant.md#constantlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to another expression. -```typescript -// Check if the 'quantity' field is less than or equal to 20 -Field.of("quantity").lte(Constant.of(20)); - -``` - | -| [lte(other)](./firestore_lite.constant.md#constantlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to a constant value. -```typescript -// Check if the 'score' field is less than or equal to 70 -Field.of("score").lte(70); - -``` - | -| [mapGet(subfield)](./firestore_lite.constant.md#constantmapget) | | (BETA) Accesses a value from a map (object) field using the provided key. -```typescript -// Get the 'city' value from the 'address' map field -Field.of("address").mapGet("city"); - -``` - | -| [max()](./firestore_lite.constant.md#constantmax) | | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. -```typescript -// Find the highest score in a leaderboard -Field.of("score").max().as("highestScore"); - -``` - A new Accumulator representing the 'max' aggregation. | -| [min()](./firestore_lite.constant.md#constantmin) | | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. -```typescript -// Find the lowest price of all products -Field.of("price").min().as("lowestPrice"); - -``` - A new Accumulator representing the 'min' aggregation. | -| [mod(other)](./firestore_lite.constant.md#constantmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. -```typescript -// Calculate the remainder of dividing the 'value' field by the 'divisor' field -Field.of("value").mod(Field.of("divisor")); - -``` - | -| [mod(other)](./firestore_lite.constant.md#constantmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. -```typescript -// Calculate the remainder of dividing the 'value' field by 10 -Field.of("value").mod(10); - -``` - | -| [multiply(other)](./firestore_lite.constant.md#constantmultiply) | | (BETA) Creates an expression that multiplies this expression by another expression. -```typescript -// Multiply the 'quantity' field by the 'price' field -Field.of("quantity").multiply(Field.of("price")); - -``` - | -| [multiply(other)](./firestore_lite.constant.md#constantmultiply) | | (BETA) Creates an expression that multiplies this expression by a constant value. -```typescript -// Multiply the 'value' field by 2 -Field.of("value").multiply(2); - -``` - | -| [neq(other)](./firestore_lite.constant.md#constantneq) | | (BETA) Creates an expression that checks if this expression is not equal to another expression. -```typescript -// Check if the 'status' field is not equal to "completed" -Field.of("status").neq("completed"); - -``` - | -| [neq(other)](./firestore_lite.constant.md#constantneq) | | (BETA) Creates an expression that checks if this expression is not equal to a constant value. -```typescript -// Check if the 'country' field is not equal to "USA" -Field.of("country").neq("USA"); - -``` - | -| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a number value. | -| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a DocumentReference value. | -| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for an array value. | -| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a map value. | -| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a VectorValue value. | -| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a string value. | -| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a boolean value. | -| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a null value. | -| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for an undefined value. | -| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a GeoPoint value. | -| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a Timestamp value. | -| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a Date value. | -| [of(value)](./firestore_lite.constant.md#constantof) | static | (BETA) Creates a Constant instance for a Uint8Array value. | -| [regexContains(pattern)](./firestore_lite.constant.md#constantregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -Field.of("description").regexContains("(?i)example"); - -``` - | -| [regexContains(pattern)](./firestore_lite.constant.md#constantregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains the regular expression stored in field 'regex' -Field.of("description").regexContains(Field.of("regex")); - -``` - | -| [regexMatch(pattern)](./firestore_lite.constant.md#constantregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. -```typescript -// Check if the 'email' field matches a valid email pattern -Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - | -| [regexMatch(pattern)](./firestore_lite.constant.md#constantregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. -```typescript -// Check if the 'email' field matches a regular expression stored in field 'regex' -Field.of("email").regexMatch(Field.of("regex")); - -``` - | -| [replaceAll(find, replace)](./firestore_lite.constant.md#constantreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring. -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field -Field.of("message").replaceAll("hello", "hi"); - -``` - | -| [replaceAll(find, replace)](./firestore_lite.constant.md#constantreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); - -``` - | -| [replaceFirst(find, replace)](./firestore_lite.constant.md#constantreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field -Field.of("message").replaceFirst("hello", "hi"); - -``` - | -| [replaceFirst(find, replace)](./firestore_lite.constant.md#constantreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); - -``` - | -| [reverse()](./firestore_lite.constant.md#constantreverse) | | (BETA) Creates an expression that reverses this string expression. -```typescript -// Reverse the value of the 'myString' field. -Field.of("myString").reverse(); - -``` - A new representing the reversed string. | -| [startsWith(prefix)](./firestore_lite.constant.md#constantstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix. -```typescript -// Check if the 'name' field starts with "Mr." -Field.of("name").startsWith("Mr."); - -``` - | -| [startsWith(prefix)](./firestore_lite.constant.md#constantstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix (represented as an expression). -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -Field.of("fullName").startsWith(Field.of("firstName")); - -``` - | -| [strConcat(elements)](./firestore_lite.constant.md#constantstrconcat) | | (BETA) Creates an expression that concatenates string expressions together. -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); - -``` - | -| [strContains(substring)](./firestore_lite.constant.md#constantstrcontains) | | (BETA) Creates an expression that checks if a string contains a specified substring. -```typescript -// Check if the 'description' field contains "example". -Field.of("description").strContains("example"); - -``` - | -| [strContains(expr)](./firestore_lite.constant.md#constantstrcontains) | | (BETA) Creates an expression that checks if a string contains the string represented by another expression. -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -Field.of("description").strContains(Field.of("keyword")); - -``` - | -| [subtract(other)](./firestore_lite.constant.md#constantsubtract) | | (BETA) Creates an expression that subtracts another expression from this expression. -```typescript -// Subtract the 'discount' field from the 'price' field -Field.of("price").subtract(Field.of("discount")); - -``` - | -| [subtract(other)](./firestore_lite.constant.md#constantsubtract) | | (BETA) Creates an expression that subtracts a constant value from this expression. -```typescript -// Subtract 20 from the value of the 'total' field -Field.of("total").subtract(20); - -``` - | -| [sum()](./firestore_lite.constant.md#constantsum) | | (BETA) Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. -```typescript -// Calculate the total revenue from a set of orders -Field.of("orderAmount").sum().as("totalRevenue"); - -``` - A new Accumulator representing the 'sum' aggregation. | -| [timestampAdd(unit, amount)](./firestore_lite.constant.md#constanttimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampAdd(unit, amount)](./firestore_lite.constant.md#constanttimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. -```typescript -// Add 1 day to the 'timestamp' field. -Field.of("timestamp").timestampAdd("day", 1); - -``` - | -| [timestampSub(unit, amount)](./firestore_lite.constant.md#constanttimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampSub(unit, amount)](./firestore_lite.constant.md#constanttimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. -```typescript -// Subtract 1 day from the 'timestamp' field. -Field.of("timestamp").timestampSub("day", 1); - -``` - | -| [timestampToUnixMicros()](./firestore_lite.constant.md#constanttimestamptounixmicros) | | (BETA) Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -Field.of("timestamp").timestampToUnixMicros(); - -``` - A new representing the number of microseconds since epoch. | -| [timestampToUnixMillis()](./firestore_lite.constant.md#constanttimestamptounixmillis) | | (BETA) Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -Field.of("timestamp").timestampToUnixMillis(); - -``` - A new representing the number of milliseconds since epoch. | -| [timestampToUnixSeconds()](./firestore_lite.constant.md#constanttimestamptounixseconds) | | (BETA) Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to seconds since epoch. -Field.of("timestamp").timestampToUnixSeconds(); - -``` - A new representing the number of seconds since epoch. | -| [toLower()](./firestore_lite.constant.md#constanttolower) | | (BETA) Creates an expression that converts a string to lowercase. -```typescript -// Convert the 'name' field to lowercase -Field.of("name").toLower(); - -``` - A new Expr representing the lowercase string. | -| [toUpper()](./firestore_lite.constant.md#constanttoupper) | | (BETA) Creates an expression that converts a string to uppercase. -```typescript -// Convert the 'title' field to uppercase -Field.of("title").toUpper(); - -``` - A new Expr representing the uppercase string. | -| [trim()](./firestore_lite.constant.md#constanttrim) | | (BETA) Creates an expression that removes leading and trailing whitespace from a string. -```typescript -// Trim whitespace from the 'userInput' field -Field.of("userInput").trim(); - -``` - A new Expr representing the trimmed string. | -| [unixMicrosToTimestamp()](./firestore_lite.constant.md#constantunixmicrostotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -Field.of("microseconds").unixMicrosToTimestamp(); - -``` - A new representing the timestamp. | -| [unixMillisToTimestamp()](./firestore_lite.constant.md#constantunixmillistotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -Field.of("milliseconds").unixMillisToTimestamp(); - -``` - A new representing the timestamp. | -| [unixSecondsToTimestamp()](./firestore_lite.constant.md#constantunixsecondstotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'seconds' field as seconds since epoch. -Field.of("seconds").unixSecondsToTimestamp(); - -``` - A new representing the timestamp. | -| [vector(value)](./firestore_lite.constant.md#constantvector) | static | (BETA) Creates a Constant instance for a VectorValue value. -```typescript -// Create a Constant instance for a vector value -const vectorConstant = Constant.ofVector([1, 2, 3]); - -``` - | -| [vectorLength()](./firestore_lite.constant.md#constantvectorlength) | | (BETA) Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. -```typescript -// Get the vector length (dimension) of the field 'embedding'. -Field.of("embedding").vectorLength(); - -``` - A new representing the length of the vector. | - -## Constant.exprType - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -exprType: ExprType; -``` - -## Constant.add() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds this expression to another expression. - -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -Field.of("quantity").add(Field.of("reserve")); - -``` - -Signature: - -```typescript -add(other: Constant): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to add to this expression. A new Expr representing the addition operation. | - -Returns: - -[Add](./firestore_lite.add.md#add_class) - -## Constant.add() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds this expression to a constant value. - -```typescript -// Add 5 to the value of the 'age' field -Field.of("age").add(5); - -``` - -Signature: - -```typescript -add(other: any): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to add. A new Expr representing the addition operation. | - -Returns: - -[Add](./firestore_lite.add.md#add_class) - -## Constant.arrayConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with one or more other arrays. - -```typescript -// Combine the 'items' array with another array field. -Field.of("items").arrayConcat(Field.of("otherItems")); - -``` - -Signature: - -```typescript -arrayConcat(arrays: Constant[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| arrays | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The array expressions to concatenate. A new Expr representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) - -## Constant.arrayConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with one or more other arrays. - -```typescript -// Combine the 'tags' array with a new array and an array field -Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); - -``` - -Signature: - -```typescript -arrayConcat(arrays: any[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| arrays | any\[\] | The array expressions or values to concatenate. A new Expr representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) - -## Constant.arrayContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains a specific element. - -```typescript -// Check if the 'sizes' array contains the value from the 'selectedSize' field -Field.of("sizes").arrayContains(Field.of("selectedSize")); - -``` - -Signature: - -```typescript -arrayContains(element: Constant): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | [Constant](./firestore_lite.constant.md#constant_class) | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) - -## Constant.arrayContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains a specific value. - -```typescript -// Check if the 'colors' array contains "red" -Field.of("colors").arrayContains("red"); - -``` - -Signature: - -```typescript -arrayContains(element: any): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | any | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) - -## Constant.arrayContainsAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both "news" and "sports" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - -Signature: - -```typescript -arrayContainsAll(...values: Constant[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) - -## Constant.arrayContainsAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - -Signature: - -```typescript -arrayContainsAll(...values: any[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) - -## Constant.arrayContainsAny() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains any of the specified elements. - -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "cate2" -Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); - -``` - -Signature: - -```typescript -arrayContainsAny(...values: Constant[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) - -## Constant.arrayContainsAny() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains any of the specified elements. - -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); - -``` - -Signature: - -```typescript -arrayContainsAny(...values: any[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) - -## Constant.arrayLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of an array. - -```typescript -// Get the number of items in the 'cart' array -Field.of("cart").arrayLength(); - -``` - A new `Expr` representing the length of the array. - -Signature: - -```typescript -arrayLength(): ArrayLength; -``` -Returns: - -[ArrayLength](./firestore_lite.arraylength.md#arraylength_class) - -## Constant.as() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Assigns an alias to this expression. - -Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. - -```typescript -// Calculate the total price and assign it the alias "totalPrice" and add it to the output. -firestore.pipeline().collection("items") -.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); - -``` - -Signature: - -```typescript -as(name: string): ExprWithAlias; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | The alias to assign to this expression. A new [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) that wraps this expression and associates it with the provided alias. | - -Returns: - -[ExprWithAlias](./firestore_lite.exprwithalias.md#exprwithalias_class)<this> - -## Constant.ascending() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. - -```typescript -// Sort documents by the 'name' field in ascending order -pipeline().collection("users") -.sort(Field.of("name").ascending()); - -``` - A new `Ordering` for ascending sorting. - -Signature: - -```typescript -ascending(): Ordering; -``` -Returns: - -[Ordering](./firestore_lite.ordering.md#ordering_class) - -## Constant.avg() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. - -```typescript -// Calculate the average age of users -Field.of("age").avg().as("averageAge"); - -``` - A new `Accumulator` representing the 'avg' aggregation. - -Signature: - -```typescript -avg(): Avg; -``` -Returns: - -[Avg](./firestore_lite.avg.md#avg_class) - -## Constant.byteLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of this string expression in bytes. - -```typescript -// Calculate the length of the 'myString' field in bytes. -Field.of("myString").byteLength(); - -``` - A new representing the length of the string in bytes. - -Signature: - -```typescript -byteLength(): ByteLength; -``` -Returns: - -[ByteLength](./firestore_lite.bytelength.md#bytelength_class) - -## Constant.charLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the character length of a string in UTF-8. - -```typescript -// Get the character length of the 'name' field in its UTF-8 form. -Field.of("name").charLength(); - -``` - A new `Expr` representing the length of the string. - -Signature: - -```typescript -charLength(): CharLength; -``` -Returns: - -[CharLength](./firestore_lite.charlength.md#charlength_class) - -## Constant.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the cosine distance between two vectors. - -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -Field.of("userVector").cosineDistance(Field.of("itemVector")); - -``` - -Signature: - -```typescript -cosineDistance(other: Constant): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new Expr representing the cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) - -## Constant.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vectors. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -cosineDistance(other: VectorValue): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) - -## Constant.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vectors. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance([37.7749, -122.4194]); - -``` - -Signature: - -```typescript -cosineDistance(other: number[]): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | The other vector (as an array of numbers) to compare against. A new Expr representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) - -## Constant.count() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. - -```typescript -// Count the total number of products -Field.of("productId").count().as("totalProducts"); - -``` - A new `Accumulator` representing the 'count' aggregation. - -Signature: - -```typescript -count(): Count; -``` -Returns: - -[Count](./firestore_lite.count.md#count_class) - -## Constant.descending() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. - -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") -.sort(Field.of("createdAt").descending()); - -``` - A new `Ordering` for descending sorting. - -Signature: - -```typescript -descending(): Ordering; -``` -Returns: - -[Ordering](./firestore_lite.ordering.md#ordering_class) - -## Constant.divide() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides this expression by another expression. - -```typescript -// Divide the 'total' field by the 'count' field -Field.of("total").divide(Field.of("count")); - -``` - -Signature: - -```typescript -divide(other: Constant): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new Expr representing the division operation. | - -Returns: - -[Divide](./firestore_lite.divide.md#divide_class) - -## Constant.divide() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides this expression by a constant value. - -```typescript -// Divide the 'value' field by 10 -Field.of("value").divide(10); - -``` - -Signature: - -```typescript -divide(other: any): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to divide by. A new Expr representing the division operation. | - -Returns: - -[Divide](./firestore_lite.divide.md#divide_class) - -## Constant.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vectors. - -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct([0.5, 0.8, 0.2]); - -``` - -Signature: - -```typescript -dotProduct(other: Constant): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) - -## Constant.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vectors. - -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); - -``` - -Signature: - -```typescript -dotProduct(other: VectorValue): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) - -## Constant.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -dotProduct(other: number[]): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | | - -Returns: - -[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) - -## Constant.endsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string ends with a given postfix. - -```typescript -// Check if the 'filename' field ends with ".txt" -Field.of("filename").endsWith(".txt"); - -``` - -Signature: - -```typescript -endsWith(suffix: string): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| suffix | string | The postfix to check for. A new Expr representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_lite.endswith.md#endswith_class) - -## Constant.endsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string ends with a given postfix (represented as an expression). - -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -Field.of("url").endsWith(Field.of("extension")); - -``` - -Signature: - -```typescript -endsWith(suffix: Constant): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| suffix | [Constant](./firestore_lite.constant.md#constant_class) | The postfix expression to check for. A new Expr representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_lite.endswith.md#endswith_class) - -## Constant.eq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to another expression. - -```typescript -// Check if the 'age' field is equal to 21 -Field.of("age").eq(21); - -``` - -Signature: - -```typescript -eq(other: Constant): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for equality. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_lite.eq.md#eq_class) - -## Constant.eq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to a constant value. - -```typescript -// Check if the 'city' field is equal to "London" -Field.of("city").eq("London"); - -``` - -Signature: - -```typescript -eq(other: any): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for equality. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_lite.eq.md#eq_class) - -## Constant.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vectors. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance([37.7749, -122.4194]); - -``` - -Signature: - -```typescript -euclideanDistance(other: Constant): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) - -## Constant.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vectors. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -euclideanDistance(other: VectorValue): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) - -## Constant.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -euclideanDistance(other: number[]): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | | - -Returns: - -[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) - -## Constant.exists() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field exists in the document. - -```typescript -// Check if the document has a field named "phoneNumber" -Field.of("phoneNumber").exists(); - -``` - A new `Expr` representing the 'exists' check. - -Signature: - -```typescript -exists(): Exists; -``` -Returns: - -[Exists](./firestore_lite.exists.md#exists_class) - -## Constant.gt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than another expression. - -```typescript -// Check if the 'age' field is greater than the 'limit' field -Field.of("age").gt(Field.of("limit")); - -``` - -Signature: - -```typescript -gt(other: Constant): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for greater than. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_lite.gt.md#gt_class) - -## Constant.gt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than a constant value. - -```typescript -// Check if the 'price' field is greater than 100 -Field.of("price").gt(100); - -``` - -Signature: - -```typescript -gt(other: any): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for greater than. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_lite.gt.md#gt_class) - -## Constant.gte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than or equal to another expression. - -```typescript -// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 -Field.of("quantity").gte(Field.of('requirement').add(1)); - -``` - -Signature: - -```typescript -gte(other: Constant): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_lite.gte.md#gte_class) - -## Constant.gte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than or equal to a constant value. - -```typescript -// Check if the 'score' field is greater than or equal to 80 -Field.of("score").gte(80); - -``` - -Signature: - -```typescript -gte(other: any): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_lite.gte.md#gte_class) - -## Constant.in() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to any of the provided values or expressions. - -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -Field.of("category").in("Electronics", Field.of("primaryType")); - -``` - -Signature: - -```typescript -in(...others: Constant[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| others | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The values or expressions to check against. A new Expr representing the 'IN' comparison. | - -Returns: - -[In](./firestore_lite.in.md#in_class) - -## Constant.in() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -in(...others: any[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| others | any\[\] | | - -Returns: - -[In](./firestore_lite.in.md#in_class) - -## Constant.isNaN() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). - -```typescript -// Check if the result of a calculation is NaN -Field.of("value").divide(0).isNaN(); - -``` - A new `Expr` representing the 'isNaN' check. - -Signature: - -```typescript -isNaN(): IsNan; -``` -Returns: - -[IsNan](./firestore_lite.isnan.md#isnan_class) - -## Constant.like() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that performs a case-sensitive string comparison. - -```typescript -// Check if the 'title' field contains the word "guide" (case-sensitive) -Field.of("title").like("%guide%"); - -``` - -Signature: - -```typescript -like(pattern: string): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new Expr representing the 'like' comparison. | - -Returns: - -[Like](./firestore_lite.like.md#like_class) - -## Constant.like() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -like(pattern: Constant): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | | - -Returns: - -[Like](./firestore_lite.like.md#like_class) - -## Constant.logicalMax() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMax(Function.currentTimestamp()); - -``` - -Signature: - -```typescript -logicalMax(other: Constant): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare with. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) - -## Constant.logicalMax() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'value' field and 10. -Field.of("value").logicalMax(10); - -``` - -Signature: - -```typescript -logicalMax(other: any): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare with. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) - -## Constant.logicalMin() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMin(Function.currentTimestamp()); - -``` - -Signature: - -```typescript -logicalMin(other: Constant): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare with. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) - -## Constant.logicalMin() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'value' field and 10. -Field.of("value").logicalMin(10); - -``` - -Signature: - -```typescript -logicalMin(other: any): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare with. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) - -## Constant.lt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than another expression. - -```typescript -// Check if the 'age' field is less than 'limit' -Field.of("age").lt(Field.of('limit')); - -``` - -Signature: - -```typescript -lt(other: Constant): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for less than. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_lite.lt.md#lt_class) - -## Constant.lt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than a constant value. - -```typescript -// Check if the 'price' field is less than 50 -Field.of("price").lt(50); - -``` - -Signature: - -```typescript -lt(other: any): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for less than. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_lite.lt.md#lt_class) - -## Constant.lte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than or equal to another expression. - -```typescript -// Check if the 'quantity' field is less than or equal to 20 -Field.of("quantity").lte(Constant.of(20)); - -``` - -Signature: - -```typescript -lte(other: Constant): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_lite.lte.md#lte_class) - -## Constant.lte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than or equal to a constant value. - -```typescript -// Check if the 'score' field is less than or equal to 70 -Field.of("score").lte(70); - -``` - -Signature: - -```typescript -lte(other: any): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_lite.lte.md#lte_class) - -## Constant.mapGet() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Accesses a value from a map (object) field using the provided key. - -```typescript -// Get the 'city' value from the 'address' map field -Field.of("address").mapGet("city"); - -``` - -Signature: - -```typescript -mapGet(subfield: string): MapGet; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| subfield | string | The key to access in the map. A new Expr representing the value associated with the given key in the map. | - -Returns: - -[MapGet](./firestore_lite.mapget.md#mapget_class) - -## Constant.max() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that finds the maximum value of a field across multiple stage inputs. - -```typescript -// Find the highest score in a leaderboard -Field.of("score").max().as("highestScore"); - -``` - A new `Accumulator` representing the 'max' aggregation. - -Signature: - -```typescript -max(): Max; -``` -Returns: - -[Max](./firestore_lite.max.md#max_class) - -## Constant.min() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that finds the minimum value of a field across multiple stage inputs. - -```typescript -// Find the lowest price of all products -Field.of("price").min().as("lowestPrice"); - -``` - A new `Accumulator` representing the 'min' aggregation. - -Signature: - -```typescript -min(): Min; -``` -Returns: - -[Min](./firestore_lite.min.md#min_class) - -## Constant.mod() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. - -```typescript -// Calculate the remainder of dividing the 'value' field by the 'divisor' field -Field.of("value").mod(Field.of("divisor")); - -``` - -Signature: - -```typescript -mod(other: Constant): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new Expr representing the modulo operation. | - -Returns: - -[Mod](./firestore_lite.mod.md#mod_class) - -## Constant.mod() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. - -```typescript -// Calculate the remainder of dividing the 'value' field by 10 -Field.of("value").mod(10); - -``` - -Signature: - -```typescript -mod(other: any): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to divide by. A new Expr representing the modulo operation. | - -Returns: - -[Mod](./firestore_lite.mod.md#mod_class) - -## Constant.multiply() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies this expression by another expression. - -```typescript -// Multiply the 'quantity' field by the 'price' field -Field.of("quantity").multiply(Field.of("price")); - -``` - -Signature: - -```typescript -multiply(other: Constant): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to multiply by. A new Expr representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_lite.multiply.md#multiply_class) - -## Constant.multiply() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies this expression by a constant value. - -```typescript -// Multiply the 'value' field by 2 -Field.of("value").multiply(2); - -``` - -Signature: - -```typescript -multiply(other: any): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to multiply by. A new Expr representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_lite.multiply.md#multiply_class) - -## Constant.neq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is not equal to another expression. - -```typescript -// Check if the 'status' field is not equal to "completed" -Field.of("status").neq("completed"); - -``` - -Signature: - -```typescript -neq(other: Constant): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for inequality. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_lite.neq.md#neq_class) - -## Constant.neq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is not equal to a constant value. - -```typescript -// Check if the 'country' field is not equal to "USA" -Field.of("country").neq("USA"); - -``` - -Signature: - -```typescript -neq(other: any): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for inequality. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_lite.neq.md#neq_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a number value. - -Signature: - -```typescript -static of(value: number): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | number | The number value. A new Constant instance. | - -Returns: - -[Constant](./firestore_lite.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a DocumentReference value. - -Signature: - -```typescript -static of(value: DocumentReference): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class) | The DocumentReference value. A new Constant instance. | - -Returns: - -[Constant](./firestore_lite.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for an array value. - -Signature: - -```typescript -static of(value: any[]): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | any\[\] | The array value. A new Constant instance. | - -Returns: - -[Constant](./firestore_lite.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a map value. - -Signature: - -```typescript -static of(value: Map): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | Map<string, any> | The map value. A new Constant instance. | - -Returns: - -[Constant](./firestore_lite.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a VectorValue value. - -Signature: - -```typescript -static of(value: VectorValue): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The VectorValue value. A new Constant instance. | - -Returns: - -[Constant](./firestore_lite.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a string value. - -Signature: - -```typescript -static of(value: string): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | string | The string value. A new Constant instance. | - -Returns: - -[Constant](./firestore_lite.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a boolean value. - -Signature: - -```typescript -static of(value: boolean): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | boolean | The boolean value. A new Constant instance. | - -Returns: - -[Constant](./firestore_lite.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a null value. - -Signature: - -```typescript -static of(value: null): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | null | The null value. A new Constant instance. | - -Returns: - -[Constant](./firestore_lite.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for an undefined value. - -Signature: - -```typescript -static of(value: undefined): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | undefined | The undefined value. A new Constant instance. | - -Returns: - -[Constant](./firestore_lite.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a GeoPoint value. - -Signature: - -```typescript -static of(value: GeoPoint): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [GeoPoint](./firestore_lite.geopoint.md#geopoint_class) | The GeoPoint value. A new Constant instance. | - -Returns: - -[Constant](./firestore_lite.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a Timestamp value. - -Signature: - -```typescript -static of(value: Timestamp): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Timestamp](./firestore_lite.timestamp.md#timestamp_class) | The Timestamp value. A new Constant instance. | - -Returns: - -[Constant](./firestore_lite.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a Date value. - -Signature: - -```typescript -static of(value: Date): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | Date | The Date value. A new Constant instance. | - -Returns: - -[Constant](./firestore_lite.constant.md#constant_class) - -## Constant.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a Uint8Array value. - -Signature: - -```typescript -static of(value: Uint8Array): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | Uint8Array | The Uint8Array value. A new Constant instance. | - -Returns: - -[Constant](./firestore_lite.constant.md#constant_class) - -## Constant.regexContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -Field.of("description").regexContains("(?i)example"); - -``` - -Signature: - -```typescript -regexContains(pattern: string): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) - -## Constant.regexContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains the regular expression stored in field 'regex' -Field.of("description").regexContains(Field.of("regex")); - -``` - -Signature: - -```typescript -regexContains(pattern: Constant): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) - -## Constant.regexMatch() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a valid email pattern -Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - -Signature: - -```typescript -regexMatch(pattern: string): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The regular expression to use for the match. A new Expr representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) - -## Constant.regexMatch() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a regular expression stored in field 'regex' -Field.of("email").regexMatch(Field.of("regex")); - -``` - -Signature: - -```typescript -regexMatch(pattern: Constant): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the match. A new Expr representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) - -## Constant.replaceAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within this string expression with another substring. - -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field -Field.of("message").replaceAll("hello", "hi"); - -``` - -Signature: - -```typescript -replaceAll(find: string, replace: string): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | string | The substring to search for. | -| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) - -## Constant.replaceAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. - -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); - -``` - -Signature: - -```typescript -replaceAll(find: Constant, replace: Constant): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) - -## Constant.replaceFirst() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. - -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field -Field.of("message").replaceFirst("hello", "hi"); - -``` - -Signature: - -```typescript -replaceFirst(find: string, replace: string): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | string | The substring to search for. | -| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) - -## Constant.replaceFirst() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. - -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); - -``` - -Signature: - -```typescript -replaceFirst(find: Constant, replace: Constant): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) - -## Constant.reverse() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that reverses this string expression. - -```typescript -// Reverse the value of the 'myString' field. -Field.of("myString").reverse(); - -``` - A new representing the reversed string. - -Signature: - -```typescript -reverse(): Reverse; -``` -Returns: - -[Reverse](./firestore_lite.reverse.md#reverse_class) - -## Constant.startsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string starts with a given prefix. - -```typescript -// Check if the 'name' field starts with "Mr." -Field.of("name").startsWith("Mr."); - -``` - -Signature: - -```typescript -startsWith(prefix: string): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| prefix | string | The prefix to check for. A new Expr representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_lite.startswith.md#startswith_class) - -## Constant.startsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string starts with a given prefix (represented as an expression). - -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -Field.of("fullName").startsWith(Field.of("firstName")); - -``` - -Signature: - -```typescript -startsWith(prefix: Constant): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| prefix | [Constant](./firestore_lite.constant.md#constant_class) | The prefix expression to check for. A new Expr representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_lite.startswith.md#startswith_class) - -## Constant.strConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates string expressions together. - -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); - -``` - -Signature: - -```typescript -strConcat(...elements: Array): StrConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| elements | Array<string \| [Constant](./firestore_lite.constant.md#constant_class)> | The expressions (typically strings) to concatenate. A new Expr representing the concatenated string. | - -Returns: - -[StrConcat](./firestore_lite.strconcat.md#strconcat_class) - -## Constant.strContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified substring. - -```typescript -// Check if the 'description' field contains "example". -Field.of("description").strContains("example"); - -``` - -Signature: - -```typescript -strContains(substring: string): StrContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| substring | string | The substring to search for. A new Expr representing the 'contains' comparison. | - -Returns: - -[StrContains](./firestore_lite.strcontains.md#strcontains_class) - -## Constant.strContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains the string represented by another expression. - -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -Field.of("description").strContains(Field.of("keyword")); - -``` - -Signature: - -```typescript -strContains(expr: Constant): StrContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. A new Expr representing the 'contains' comparison. | - -Returns: - -[StrContains](./firestore_lite.strcontains.md#strcontains_class) - -## Constant.subtract() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts another expression from this expression. - -```typescript -// Subtract the 'discount' field from the 'price' field -Field.of("price").subtract(Field.of("discount")); - -``` - -Signature: - -```typescript -subtract(other: Constant): Subtract; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to subtract from this expression. A new Expr representing the subtraction operation. | - -Returns: - -[Subtract](./firestore_lite.subtract.md#subtract_class) - -## Constant.subtract() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a constant value from this expression. - -```typescript -// Subtract 20 from the value of the 'total' field -Field.of("total").subtract(20); - -``` - -Signature: - -```typescript -subtract(other: any): Subtract; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to subtract. A new Expr representing the subtraction operation. | - -Returns: - -[Subtract](./firestore_lite.subtract.md#subtract_class) - -## Constant.sum() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. - -```typescript -// Calculate the total revenue from a set of orders -Field.of("orderAmount").sum().as("totalRevenue"); - -``` - A new `Accumulator` representing the 'sum' aggregation. - -Signature: - -```typescript -sum(): Sum; -``` -Returns: - -[Sum](./firestore_lite.sum.md#sum_class) - -## Constant.timestampAdd() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to this timestamp expression. - -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); - -``` - -Signature: - -```typescript -timestampAdd(unit: Constant, amount: Constant): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) - -## Constant.timestampAdd() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to this timestamp expression. - -```typescript -// Add 1 day to the 'timestamp' field. -Field.of("timestamp").timestampAdd("day", 1); - -``` - -Signature: - -```typescript -timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | -| amount | number | The amount of time to add. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) - -## Constant.timestampSub() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from this timestamp expression. - -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); - -``` - -Signature: - -```typescript -timestampSub(unit: Constant, amount: Constant): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) - -## Constant.timestampSub() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from this timestamp expression. - -```typescript -// Subtract 1 day from the 'timestamp' field. -Field.of("timestamp").timestampSub("day", 1); - -``` - -Signature: - -```typescript -timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | -| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) - -## Constant.timestampToUnixMicros() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -Field.of("timestamp").timestampToUnixMicros(); - -``` - A new representing the number of microseconds since epoch. - -Signature: - -```typescript -timestampToUnixMicros(): TimestampToUnixMicros; -``` -Returns: - -[TimestampToUnixMicros](./firestore_lite.timestamptounixmicros.md#timestamptounixmicros_class) - -## Constant.timestampToUnixMillis() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -Field.of("timestamp").timestampToUnixMillis(); - -``` - A new representing the number of milliseconds since epoch. - -Signature: - -```typescript -timestampToUnixMillis(): TimestampToUnixMillis; -``` -Returns: - -[TimestampToUnixMillis](./firestore_lite.timestamptounixmillis.md#timestamptounixmillis_class) - -## Constant.timestampToUnixSeconds() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to seconds since epoch. -Field.of("timestamp").timestampToUnixSeconds(); - -``` - A new representing the number of seconds since epoch. - -Signature: - -```typescript -timestampToUnixSeconds(): TimestampToUnixSeconds; -``` -Returns: - -[TimestampToUnixSeconds](./firestore_lite.timestamptounixseconds.md#timestamptounixseconds_class) - -## Constant.toLower() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string to lowercase. - -```typescript -// Convert the 'name' field to lowercase -Field.of("name").toLower(); - -``` - A new `Expr` representing the lowercase string. - -Signature: - -```typescript -toLower(): ToLower; -``` -Returns: - -[ToLower](./firestore_lite.tolower.md#tolower_class) - -## Constant.toUpper() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string to uppercase. - -```typescript -// Convert the 'title' field to uppercase -Field.of("title").toUpper(); - -``` - A new `Expr` representing the uppercase string. - -Signature: - -```typescript -toUpper(): ToUpper; -``` -Returns: - -[ToUpper](./firestore_lite.toupper.md#toupper_class) - -## Constant.trim() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that removes leading and trailing whitespace from a string. - -```typescript -// Trim whitespace from the 'userInput' field -Field.of("userInput").trim(); - -``` - A new `Expr` representing the trimmed string. - -Signature: - -```typescript -trim(): Trim; -``` -Returns: - -[Trim](./firestore_lite.trim.md#trim_class) - -## Constant.unixMicrosToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -Field.of("microseconds").unixMicrosToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixMicrosToTimestamp(): UnixMicrosToTimestamp; -``` -Returns: - -[UnixMicrosToTimestamp](./firestore_lite.unixmicrostotimestamp.md#unixmicrostotimestamp_class) - -## Constant.unixMillisToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -Field.of("milliseconds").unixMillisToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixMillisToTimestamp(): UnixMillisToTimestamp; -``` -Returns: - -[UnixMillisToTimestamp](./firestore_lite.unixmillistotimestamp.md#unixmillistotimestamp_class) - -## Constant.unixSecondsToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'seconds' field as seconds since epoch. -Field.of("seconds").unixSecondsToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixSecondsToTimestamp(): UnixSecondsToTimestamp; -``` -Returns: - -[UnixSecondsToTimestamp](./firestore_lite.unixsecondstotimestamp.md#unixsecondstotimestamp_class) - -## Constant.vector() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a `Constant` instance for a VectorValue value. - -```typescript -// Create a Constant instance for a vector value -const vectorConstant = Constant.ofVector([1, 2, 3]); - -``` - -Signature: - -```typescript -static vector(value: number[] | VectorValue): Constant; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | number\[\] \| [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The VectorValue value. A new Constant instance. | - -Returns: - -[Constant](./firestore_lite.constant.md#constant_class) - -## Constant.vectorLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. - -```typescript -// Get the vector length (dimension) of the field 'embedding'. -Field.of("embedding").vectorLength(); - -``` - A new representing the length of the vector. - -Signature: - -```typescript -vectorLength(): VectorLength; -``` -Returns: - -[VectorLength](./firestore_lite.vectorlength.md#vectorlength_class) - diff --git a/docs-devsite/firestore_lite.cosinedistance.md b/docs-devsite/firestore_lite.cosinedistance.md deleted file mode 100644 index d8642f784ee..00000000000 --- a/docs-devsite/firestore_lite.cosinedistance.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# CosineDistance class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class CosineDistance extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(vector1, vector2)](./firestore_lite.cosinedistance.md#cosinedistanceconstructor) | | (BETA) Constructs a new instance of the CosineDistance class | - -## CosineDistance.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `CosineDistance` class - -Signature: - -```typescript -constructor(vector1: Constant, vector2: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| vector1 | [Constant](./firestore_lite.constant.md#constant_class) | | -| vector2 | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.count.md b/docs-devsite/firestore_lite.count.md deleted file mode 100644 index 3de2d0585a7..00000000000 --- a/docs-devsite/firestore_lite.count.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Count class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Count extends FirestoreFunction implements Accumulator -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [Accumulator](./firestore_lite.accumulator.md#accumulator_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value, distinct)](./firestore_lite.count.md#countconstructor) | | (BETA) Constructs a new instance of the Count class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [accumulator](./firestore_lite.count.md#countaccumulator) | | true | (BETA) | - -## Count.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Count` class - -Signature: - -```typescript -constructor(value: Constant | undefined, distinct: boolean); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_lite.constant.md#constant_class) \| undefined | | -| distinct | boolean | | - -## Count.accumulator - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -accumulator: true; -``` diff --git a/docs-devsite/firestore_lite.databasesource.md b/docs-devsite/firestore_lite.databasesource.md deleted file mode 100644 index c837f93ba36..00000000000 --- a/docs-devsite/firestore_lite.databasesource.md +++ /dev/null @@ -1,39 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# DatabaseSource class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class DatabaseSource implements Stage -``` -Implements: [Stage](./firestore_lite.stage.md#stage_interface) - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_lite.databasesource.md#databasesourcename) | | string | (BETA) | - -## DatabaseSource.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_lite.distinct.md b/docs-devsite/firestore_lite.distinct.md deleted file mode 100644 index 37d2385de22..00000000000 --- a/docs-devsite/firestore_lite.distinct.md +++ /dev/null @@ -1,64 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Distinct class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Distinct implements Stage -``` -Implements: [Stage](./firestore_lite.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(groups)](./firestore_lite.distinct.md#distinctconstructor) | | (BETA) Constructs a new instance of the Distinct class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_lite.distinct.md#distinctname) | | string | (BETA) | - -## Distinct.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Distinct` class - -Signature: - -```typescript -constructor(groups: Map); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| groups | Map<string, [Constant](./firestore_lite.constant.md#constant_class)> | | - -## Distinct.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_lite.divide.md b/docs-devsite/firestore_lite.divide.md deleted file mode 100644 index ae2ed8410a4..00000000000 --- a/docs-devsite/firestore_lite.divide.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Divide class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Divide extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_lite.divide.md#divideconstructor) | | (BETA) Constructs a new instance of the Divide class | - -## Divide.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Divide` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | | -| right | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.documentssource.md b/docs-devsite/firestore_lite.documentssource.md deleted file mode 100644 index 5444a06ee6a..00000000000 --- a/docs-devsite/firestore_lite.documentssource.md +++ /dev/null @@ -1,92 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# DocumentsSource class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class DocumentsSource implements Stage -``` -Implements: [Stage](./firestore_lite.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(docPaths)](./firestore_lite.documentssource.md#documentssourceconstructor) | | (BETA) Constructs a new instance of the DocumentsSource class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_lite.documentssource.md#documentssourcename) | | string | (BETA) | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [of(refs)](./firestore_lite.documentssource.md#documentssourceof) | static | (BETA) | - -## DocumentsSource.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `DocumentsSource` class - -Signature: - -```typescript -constructor(docPaths: string[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| docPaths | string\[\] | | - -## DocumentsSource.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` - -## DocumentsSource.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -static of(refs: DocumentReference[]): DocumentsSource; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| refs | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)\[\] | | - -Returns: - -[DocumentsSource](./firestore_lite.documentssource.md#documentssource_class) - diff --git a/docs-devsite/firestore_lite.dotproduct.md b/docs-devsite/firestore_lite.dotproduct.md deleted file mode 100644 index ad91f78f92d..00000000000 --- a/docs-devsite/firestore_lite.dotproduct.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# DotProduct class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class DotProduct extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(vector1, vector2)](./firestore_lite.dotproduct.md#dotproductconstructor) | | (BETA) Constructs a new instance of the DotProduct class | - -## DotProduct.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `DotProduct` class - -Signature: - -```typescript -constructor(vector1: Constant, vector2: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| vector1 | [Constant](./firestore_lite.constant.md#constant_class) | | -| vector2 | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.endswith.md b/docs-devsite/firestore_lite.endswith.md deleted file mode 100644 index d34c4f3dc83..00000000000 --- a/docs-devsite/firestore_lite.endswith.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# EndsWith class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class EndsWith extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr, suffix)](./firestore_lite.endswith.md#endswithconstructor) | | (BETA) Constructs a new instance of the EndsWith class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_lite.endswith.md#endswithfilterable) | | true | (BETA) | - -## EndsWith.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `EndsWith` class - -Signature: - -```typescript -constructor(expr: Constant, suffix: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | | -| suffix | [Constant](./firestore_lite.constant.md#constant_class) | | - -## EndsWith.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.eq.md b/docs-devsite/firestore_lite.eq.md deleted file mode 100644 index 02fa728f481..00000000000 --- a/docs-devsite/firestore_lite.eq.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Eq class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Eq extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_lite.eq.md#eqconstructor) | | (BETA) Constructs a new instance of the Eq class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_lite.eq.md#eqfilterable) | | true | (BETA) | - -## Eq.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Eq` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | | -| right | [Constant](./firestore_lite.constant.md#constant_class) | | - -## Eq.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.euclideandistance.md b/docs-devsite/firestore_lite.euclideandistance.md deleted file mode 100644 index 860057fc9d7..00000000000 --- a/docs-devsite/firestore_lite.euclideandistance.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# EuclideanDistance class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class EuclideanDistance extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(vector1, vector2)](./firestore_lite.euclideandistance.md#euclideandistanceconstructor) | | (BETA) Constructs a new instance of the EuclideanDistance class | - -## EuclideanDistance.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `EuclideanDistance` class - -Signature: - -```typescript -constructor(vector1: Constant, vector2: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| vector1 | [Constant](./firestore_lite.constant.md#constant_class) | | -| vector2 | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.exists.md b/docs-devsite/firestore_lite.exists.md deleted file mode 100644 index 50ef86f9fec..00000000000 --- a/docs-devsite/firestore_lite.exists.md +++ /dev/null @@ -1,66 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Exists class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Exists extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr)](./firestore_lite.exists.md#existsconstructor) | | (BETA) Constructs a new instance of the Exists class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_lite.exists.md#existsfilterable) | | true | (BETA) | - -## Exists.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Exists` class - -Signature: - -```typescript -constructor(expr: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | | - -## Exists.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.exprwithalias.md b/docs-devsite/firestore_lite.exprwithalias.md deleted file mode 100644 index a7c47c19b4f..00000000000 --- a/docs-devsite/firestore_lite.exprwithalias.md +++ /dev/null @@ -1,3207 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ExprWithAlias class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ExprWithAlias implements Selectable -``` -Implements: [Selectable](./firestore_lite.selectable.md#selectable_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr, alias)](./firestore_lite.exprwithalias.md#exprwithaliasconstructor) | | (BETA) Constructs a new instance of the ExprWithAlias class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [alias](./firestore_lite.exprwithalias.md#exprwithaliasalias) | | string | (BETA) | -| [expr](./firestore_lite.exprwithalias.md#exprwithaliasexpr) | | T | (BETA) | -| [exprType](./firestore_lite.exprwithalias.md#exprwithaliasexprtype) | | [ExprType](./firestore_lite.md#exprtype) | (BETA) | -| [selectable](./firestore_lite.exprwithalias.md#exprwithaliasselectable) | | true | (BETA) | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [add(other)](./firestore_lite.exprwithalias.md#exprwithaliasadd) | | (BETA) Creates an expression that adds this expression to another expression. -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -Field.of("quantity").add(Field.of("reserve")); - -``` - | -| [add(other)](./firestore_lite.exprwithalias.md#exprwithaliasadd) | | (BETA) Creates an expression that adds this expression to a constant value. -```typescript -// Add 5 to the value of the 'age' field -Field.of("age").add(5); - -``` - | -| [arrayConcat(arrays)](./firestore_lite.exprwithalias.md#exprwithaliasarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. -```typescript -// Combine the 'items' array with another array field. -Field.of("items").arrayConcat(Field.of("otherItems")); - -``` - | -| [arrayConcat(arrays)](./firestore_lite.exprwithalias.md#exprwithaliasarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. -```typescript -// Combine the 'tags' array with a new array and an array field -Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); - -``` - | -| [arrayContains(element)](./firestore_lite.exprwithalias.md#exprwithaliasarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific element. -```typescript -// Check if the 'sizes' array contains the value from the 'selectedSize' field -Field.of("sizes").arrayContains(Field.of("selectedSize")); - -``` - | -| [arrayContains(element)](./firestore_lite.exprwithalias.md#exprwithaliasarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific value. -```typescript -// Check if the 'colors' array contains "red" -Field.of("colors").arrayContains("red"); - -``` - | -| [arrayContainsAll(values)](./firestore_lite.exprwithalias.md#exprwithaliasarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. -```typescript -// Check if the 'tags' array contains both "news" and "sports" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - | -| [arrayContainsAll(values)](./firestore_lite.exprwithalias.md#exprwithaliasarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - | -| [arrayContainsAny(values)](./firestore_lite.exprwithalias.md#exprwithaliasarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "cate2" -Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); - -``` - | -| [arrayContainsAny(values)](./firestore_lite.exprwithalias.md#exprwithaliasarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); - -``` - | -| [arrayLength()](./firestore_lite.exprwithalias.md#exprwithaliasarraylength) | | (BETA) Creates an expression that calculates the length of an array. -```typescript -// Get the number of items in the 'cart' array -Field.of("cart").arrayLength(); - -``` - A new Expr representing the length of the array. | -| [as(name)](./firestore_lite.exprwithalias.md#exprwithaliasas) | | (BETA) Assigns an alias to this expression.Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. -```typescript -// Calculate the total price and assign it the alias "totalPrice" and add it to the output. -firestore.pipeline().collection("items") -.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); - -``` - | -| [ascending()](./firestore_lite.exprwithalias.md#exprwithaliasascending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. -```typescript -// Sort documents by the 'name' field in ascending order -pipeline().collection("users") -.sort(Field.of("name").ascending()); - -``` - A new Ordering for ascending sorting. | -| [avg()](./firestore_lite.exprwithalias.md#exprwithaliasavg) | | (BETA) Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. -```typescript -// Calculate the average age of users -Field.of("age").avg().as("averageAge"); - -``` - A new Accumulator representing the 'avg' aggregation. | -| [byteLength()](./firestore_lite.exprwithalias.md#exprwithaliasbytelength) | | (BETA) Creates an expression that calculates the length of this string expression in bytes. -```typescript -// Calculate the length of the 'myString' field in bytes. -Field.of("myString").byteLength(); - -``` - A new representing the length of the string in bytes. | -| [charLength()](./firestore_lite.exprwithalias.md#exprwithaliascharlength) | | (BETA) Creates an expression that calculates the character length of a string in UTF-8. -```typescript -// Get the character length of the 'name' field in its UTF-8 form. -Field.of("name").charLength(); - -``` - A new Expr representing the length of the string. | -| [cosineDistance(other)](./firestore_lite.exprwithalias.md#exprwithaliascosinedistance) | | (BETA) Calculates the cosine distance between two vectors. -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -Field.of("userVector").cosineDistance(Field.of("itemVector")); - -``` - | -| [cosineDistance(other)](./firestore_lite.exprwithalias.md#exprwithaliascosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); - -``` - | -| [cosineDistance(other)](./firestore_lite.exprwithalias.md#exprwithaliascosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance([37.7749, -122.4194]); - -``` - | -| [count()](./firestore_lite.exprwithalias.md#exprwithaliascount) | | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. -```typescript -// Count the total number of products -Field.of("productId").count().as("totalProducts"); - -``` - A new Accumulator representing the 'count' aggregation. | -| [descending()](./firestore_lite.exprwithalias.md#exprwithaliasdescending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") -.sort(Field.of("createdAt").descending()); - -``` - A new Ordering for descending sorting. | -| [divide(other)](./firestore_lite.exprwithalias.md#exprwithaliasdivide) | | (BETA) Creates an expression that divides this expression by another expression. -```typescript -// Divide the 'total' field by the 'count' field -Field.of("total").divide(Field.of("count")); - -``` - | -| [divide(other)](./firestore_lite.exprwithalias.md#exprwithaliasdivide) | | (BETA) Creates an expression that divides this expression by a constant value. -```typescript -// Divide the 'value' field by 10 -Field.of("value").divide(10); - -``` - | -| [dotProduct(other)](./firestore_lite.exprwithalias.md#exprwithaliasdotproduct) | | (BETA) Calculates the dot product between two vectors. -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct([0.5, 0.8, 0.2]); - -``` - | -| [dotProduct(other)](./firestore_lite.exprwithalias.md#exprwithaliasdotproduct) | | (BETA) Calculates the dot product between two vectors. -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); - -``` - | -| [dotProduct(other)](./firestore_lite.exprwithalias.md#exprwithaliasdotproduct) | | (BETA) | -| [endsWith(suffix)](./firestore_lite.exprwithalias.md#exprwithaliasendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix. -```typescript -// Check if the 'filename' field ends with ".txt" -Field.of("filename").endsWith(".txt"); - -``` - | -| [endsWith(suffix)](./firestore_lite.exprwithalias.md#exprwithaliasendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix (represented as an expression). -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -Field.of("url").endsWith(Field.of("extension")); - -``` - | -| [eq(other)](./firestore_lite.exprwithalias.md#exprwithaliaseq) | | (BETA) Creates an expression that checks if this expression is equal to another expression. -```typescript -// Check if the 'age' field is equal to 21 -Field.of("age").eq(21); - -``` - | -| [eq(other)](./firestore_lite.exprwithalias.md#exprwithaliaseq) | | (BETA) Creates an expression that checks if this expression is equal to a constant value. -```typescript -// Check if the 'city' field is equal to "London" -Field.of("city").eq("London"); - -``` - | -| [euclideanDistance(other)](./firestore_lite.exprwithalias.md#exprwithaliaseuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance([37.7749, -122.4194]); - -``` - | -| [euclideanDistance(other)](./firestore_lite.exprwithalias.md#exprwithaliaseuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); - -``` - | -| [euclideanDistance(other)](./firestore_lite.exprwithalias.md#exprwithaliaseuclideandistance) | | (BETA) | -| [exists()](./firestore_lite.exprwithalias.md#exprwithaliasexists) | | (BETA) Creates an expression that checks if a field exists in the document. -```typescript -// Check if the document has a field named "phoneNumber" -Field.of("phoneNumber").exists(); - -``` - A new Expr representing the 'exists' check. | -| [gt(other)](./firestore_lite.exprwithalias.md#exprwithaliasgt) | | (BETA) Creates an expression that checks if this expression is greater than another expression. -```typescript -// Check if the 'age' field is greater than the 'limit' field -Field.of("age").gt(Field.of("limit")); - -``` - | -| [gt(other)](./firestore_lite.exprwithalias.md#exprwithaliasgt) | | (BETA) Creates an expression that checks if this expression is greater than a constant value. -```typescript -// Check if the 'price' field is greater than 100 -Field.of("price").gt(100); - -``` - | -| [gte(other)](./firestore_lite.exprwithalias.md#exprwithaliasgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to another expression. -```typescript -// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 -Field.of("quantity").gte(Field.of('requirement').add(1)); - -``` - | -| [gte(other)](./firestore_lite.exprwithalias.md#exprwithaliasgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to a constant value. -```typescript -// Check if the 'score' field is greater than or equal to 80 -Field.of("score").gte(80); - -``` - | -| [in(others)](./firestore_lite.exprwithalias.md#exprwithaliasin) | | (BETA) Creates an expression that checks if this expression is equal to any of the provided values or expressions. -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -Field.of("category").in("Electronics", Field.of("primaryType")); - -``` - | -| [in(others)](./firestore_lite.exprwithalias.md#exprwithaliasin) | | (BETA) | -| [isNaN()](./firestore_lite.exprwithalias.md#exprwithaliasisnan) | | (BETA) Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). -```typescript -// Check if the result of a calculation is NaN -Field.of("value").divide(0).isNaN(); - -``` - A new Expr representing the 'isNaN' check. | -| [like(pattern)](./firestore_lite.exprwithalias.md#exprwithaliaslike) | | (BETA) Creates an expression that performs a case-sensitive string comparison. -```typescript -// Check if the 'title' field contains the word "guide" (case-sensitive) -Field.of("title").like("%guide%"); - -``` - | -| [like(pattern)](./firestore_lite.exprwithalias.md#exprwithaliaslike) | | (BETA) | -| [logicalMax(other)](./firestore_lite.exprwithalias.md#exprwithaliaslogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMax(Function.currentTimestamp()); - -``` - | -| [logicalMax(other)](./firestore_lite.exprwithalias.md#exprwithaliaslogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'value' field and 10. -Field.of("value").logicalMax(10); - -``` - | -| [logicalMin(other)](./firestore_lite.exprwithalias.md#exprwithaliaslogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMin(Function.currentTimestamp()); - -``` - | -| [logicalMin(other)](./firestore_lite.exprwithalias.md#exprwithaliaslogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'value' field and 10. -Field.of("value").logicalMin(10); - -``` - | -| [lt(other)](./firestore_lite.exprwithalias.md#exprwithaliaslt) | | (BETA) Creates an expression that checks if this expression is less than another expression. -```typescript -// Check if the 'age' field is less than 'limit' -Field.of("age").lt(Field.of('limit')); - -``` - | -| [lt(other)](./firestore_lite.exprwithalias.md#exprwithaliaslt) | | (BETA) Creates an expression that checks if this expression is less than a constant value. -```typescript -// Check if the 'price' field is less than 50 -Field.of("price").lt(50); - -``` - | -| [lte(other)](./firestore_lite.exprwithalias.md#exprwithaliaslte) | | (BETA) Creates an expression that checks if this expression is less than or equal to another expression. -```typescript -// Check if the 'quantity' field is less than or equal to 20 -Field.of("quantity").lte(Constant.of(20)); - -``` - | -| [lte(other)](./firestore_lite.exprwithalias.md#exprwithaliaslte) | | (BETA) Creates an expression that checks if this expression is less than or equal to a constant value. -```typescript -// Check if the 'score' field is less than or equal to 70 -Field.of("score").lte(70); - -``` - | -| [mapGet(subfield)](./firestore_lite.exprwithalias.md#exprwithaliasmapget) | | (BETA) Accesses a value from a map (object) field using the provided key. -```typescript -// Get the 'city' value from the 'address' map field -Field.of("address").mapGet("city"); - -``` - | -| [max()](./firestore_lite.exprwithalias.md#exprwithaliasmax) | | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. -```typescript -// Find the highest score in a leaderboard -Field.of("score").max().as("highestScore"); - -``` - A new Accumulator representing the 'max' aggregation. | -| [min()](./firestore_lite.exprwithalias.md#exprwithaliasmin) | | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. -```typescript -// Find the lowest price of all products -Field.of("price").min().as("lowestPrice"); - -``` - A new Accumulator representing the 'min' aggregation. | -| [mod(other)](./firestore_lite.exprwithalias.md#exprwithaliasmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. -```typescript -// Calculate the remainder of dividing the 'value' field by the 'divisor' field -Field.of("value").mod(Field.of("divisor")); - -``` - | -| [mod(other)](./firestore_lite.exprwithalias.md#exprwithaliasmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. -```typescript -// Calculate the remainder of dividing the 'value' field by 10 -Field.of("value").mod(10); - -``` - | -| [multiply(other)](./firestore_lite.exprwithalias.md#exprwithaliasmultiply) | | (BETA) Creates an expression that multiplies this expression by another expression. -```typescript -// Multiply the 'quantity' field by the 'price' field -Field.of("quantity").multiply(Field.of("price")); - -``` - | -| [multiply(other)](./firestore_lite.exprwithalias.md#exprwithaliasmultiply) | | (BETA) Creates an expression that multiplies this expression by a constant value. -```typescript -// Multiply the 'value' field by 2 -Field.of("value").multiply(2); - -``` - | -| [neq(other)](./firestore_lite.exprwithalias.md#exprwithaliasneq) | | (BETA) Creates an expression that checks if this expression is not equal to another expression. -```typescript -// Check if the 'status' field is not equal to "completed" -Field.of("status").neq("completed"); - -``` - | -| [neq(other)](./firestore_lite.exprwithalias.md#exprwithaliasneq) | | (BETA) Creates an expression that checks if this expression is not equal to a constant value. -```typescript -// Check if the 'country' field is not equal to "USA" -Field.of("country").neq("USA"); - -``` - | -| [regexContains(pattern)](./firestore_lite.exprwithalias.md#exprwithaliasregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -Field.of("description").regexContains("(?i)example"); - -``` - | -| [regexContains(pattern)](./firestore_lite.exprwithalias.md#exprwithaliasregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains the regular expression stored in field 'regex' -Field.of("description").regexContains(Field.of("regex")); - -``` - | -| [regexMatch(pattern)](./firestore_lite.exprwithalias.md#exprwithaliasregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. -```typescript -// Check if the 'email' field matches a valid email pattern -Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - | -| [regexMatch(pattern)](./firestore_lite.exprwithalias.md#exprwithaliasregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. -```typescript -// Check if the 'email' field matches a regular expression stored in field 'regex' -Field.of("email").regexMatch(Field.of("regex")); - -``` - | -| [replaceAll(find, replace)](./firestore_lite.exprwithalias.md#exprwithaliasreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring. -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field -Field.of("message").replaceAll("hello", "hi"); - -``` - | -| [replaceAll(find, replace)](./firestore_lite.exprwithalias.md#exprwithaliasreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); - -``` - | -| [replaceFirst(find, replace)](./firestore_lite.exprwithalias.md#exprwithaliasreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field -Field.of("message").replaceFirst("hello", "hi"); - -``` - | -| [replaceFirst(find, replace)](./firestore_lite.exprwithalias.md#exprwithaliasreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); - -``` - | -| [reverse()](./firestore_lite.exprwithalias.md#exprwithaliasreverse) | | (BETA) Creates an expression that reverses this string expression. -```typescript -// Reverse the value of the 'myString' field. -Field.of("myString").reverse(); - -``` - A new representing the reversed string. | -| [startsWith(prefix)](./firestore_lite.exprwithalias.md#exprwithaliasstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix. -```typescript -// Check if the 'name' field starts with "Mr." -Field.of("name").startsWith("Mr."); - -``` - | -| [startsWith(prefix)](./firestore_lite.exprwithalias.md#exprwithaliasstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix (represented as an expression). -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -Field.of("fullName").startsWith(Field.of("firstName")); - -``` - | -| [strConcat(elements)](./firestore_lite.exprwithalias.md#exprwithaliasstrconcat) | | (BETA) Creates an expression that concatenates string expressions together. -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); - -``` - | -| [strContains(substring)](./firestore_lite.exprwithalias.md#exprwithaliasstrcontains) | | (BETA) Creates an expression that checks if a string contains a specified substring. -```typescript -// Check if the 'description' field contains "example". -Field.of("description").strContains("example"); - -``` - | -| [strContains(expr)](./firestore_lite.exprwithalias.md#exprwithaliasstrcontains) | | (BETA) Creates an expression that checks if a string contains the string represented by another expression. -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -Field.of("description").strContains(Field.of("keyword")); - -``` - | -| [subtract(other)](./firestore_lite.exprwithalias.md#exprwithaliassubtract) | | (BETA) Creates an expression that subtracts another expression from this expression. -```typescript -// Subtract the 'discount' field from the 'price' field -Field.of("price").subtract(Field.of("discount")); - -``` - | -| [subtract(other)](./firestore_lite.exprwithalias.md#exprwithaliassubtract) | | (BETA) Creates an expression that subtracts a constant value from this expression. -```typescript -// Subtract 20 from the value of the 'total' field -Field.of("total").subtract(20); - -``` - | -| [sum()](./firestore_lite.exprwithalias.md#exprwithaliassum) | | (BETA) Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. -```typescript -// Calculate the total revenue from a set of orders -Field.of("orderAmount").sum().as("totalRevenue"); - -``` - A new Accumulator representing the 'sum' aggregation. | -| [timestampAdd(unit, amount)](./firestore_lite.exprwithalias.md#exprwithaliastimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampAdd(unit, amount)](./firestore_lite.exprwithalias.md#exprwithaliastimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. -```typescript -// Add 1 day to the 'timestamp' field. -Field.of("timestamp").timestampAdd("day", 1); - -``` - | -| [timestampSub(unit, amount)](./firestore_lite.exprwithalias.md#exprwithaliastimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampSub(unit, amount)](./firestore_lite.exprwithalias.md#exprwithaliastimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. -```typescript -// Subtract 1 day from the 'timestamp' field. -Field.of("timestamp").timestampSub("day", 1); - -``` - | -| [timestampToUnixMicros()](./firestore_lite.exprwithalias.md#exprwithaliastimestamptounixmicros) | | (BETA) Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -Field.of("timestamp").timestampToUnixMicros(); - -``` - A new representing the number of microseconds since epoch. | -| [timestampToUnixMillis()](./firestore_lite.exprwithalias.md#exprwithaliastimestamptounixmillis) | | (BETA) Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -Field.of("timestamp").timestampToUnixMillis(); - -``` - A new representing the number of milliseconds since epoch. | -| [timestampToUnixSeconds()](./firestore_lite.exprwithalias.md#exprwithaliastimestamptounixseconds) | | (BETA) Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to seconds since epoch. -Field.of("timestamp").timestampToUnixSeconds(); - -``` - A new representing the number of seconds since epoch. | -| [toLower()](./firestore_lite.exprwithalias.md#exprwithaliastolower) | | (BETA) Creates an expression that converts a string to lowercase. -```typescript -// Convert the 'name' field to lowercase -Field.of("name").toLower(); - -``` - A new Expr representing the lowercase string. | -| [toUpper()](./firestore_lite.exprwithalias.md#exprwithaliastoupper) | | (BETA) Creates an expression that converts a string to uppercase. -```typescript -// Convert the 'title' field to uppercase -Field.of("title").toUpper(); - -``` - A new Expr representing the uppercase string. | -| [trim()](./firestore_lite.exprwithalias.md#exprwithaliastrim) | | (BETA) Creates an expression that removes leading and trailing whitespace from a string. -```typescript -// Trim whitespace from the 'userInput' field -Field.of("userInput").trim(); - -``` - A new Expr representing the trimmed string. | -| [unixMicrosToTimestamp()](./firestore_lite.exprwithalias.md#exprwithaliasunixmicrostotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -Field.of("microseconds").unixMicrosToTimestamp(); - -``` - A new representing the timestamp. | -| [unixMillisToTimestamp()](./firestore_lite.exprwithalias.md#exprwithaliasunixmillistotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -Field.of("milliseconds").unixMillisToTimestamp(); - -``` - A new representing the timestamp. | -| [unixSecondsToTimestamp()](./firestore_lite.exprwithalias.md#exprwithaliasunixsecondstotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'seconds' field as seconds since epoch. -Field.of("seconds").unixSecondsToTimestamp(); - -``` - A new representing the timestamp. | -| [vectorLength()](./firestore_lite.exprwithalias.md#exprwithaliasvectorlength) | | (BETA) Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. -```typescript -// Get the vector length (dimension) of the field 'embedding'. -Field.of("embedding").vectorLength(); - -``` - A new representing the length of the vector. | - -## ExprWithAlias.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ExprWithAlias` class - -Signature: - -```typescript -constructor(expr: T, alias: string); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | T | | -| alias | string | | - -## ExprWithAlias.alias - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -alias: string; -``` - -## ExprWithAlias.expr - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -expr: T; -``` - -## ExprWithAlias.exprType - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -exprType: ExprType; -``` - -## ExprWithAlias.selectable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -selectable: true; -``` - -## ExprWithAlias.add() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds this expression to another expression. - -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -Field.of("quantity").add(Field.of("reserve")); - -``` - -Signature: - -```typescript -add(other: Constant): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to add to this expression. A new Expr representing the addition operation. | - -Returns: - -[Add](./firestore_lite.add.md#add_class) - -## ExprWithAlias.add() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds this expression to a constant value. - -```typescript -// Add 5 to the value of the 'age' field -Field.of("age").add(5); - -``` - -Signature: - -```typescript -add(other: any): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to add. A new Expr representing the addition operation. | - -Returns: - -[Add](./firestore_lite.add.md#add_class) - -## ExprWithAlias.arrayConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with one or more other arrays. - -```typescript -// Combine the 'items' array with another array field. -Field.of("items").arrayConcat(Field.of("otherItems")); - -``` - -Signature: - -```typescript -arrayConcat(arrays: Constant[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| arrays | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The array expressions to concatenate. A new Expr representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) - -## ExprWithAlias.arrayConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with one or more other arrays. - -```typescript -// Combine the 'tags' array with a new array and an array field -Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); - -``` - -Signature: - -```typescript -arrayConcat(arrays: any[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| arrays | any\[\] | The array expressions or values to concatenate. A new Expr representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) - -## ExprWithAlias.arrayContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains a specific element. - -```typescript -// Check if the 'sizes' array contains the value from the 'selectedSize' field -Field.of("sizes").arrayContains(Field.of("selectedSize")); - -``` - -Signature: - -```typescript -arrayContains(element: Constant): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | [Constant](./firestore_lite.constant.md#constant_class) | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) - -## ExprWithAlias.arrayContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains a specific value. - -```typescript -// Check if the 'colors' array contains "red" -Field.of("colors").arrayContains("red"); - -``` - -Signature: - -```typescript -arrayContains(element: any): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | any | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) - -## ExprWithAlias.arrayContainsAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both "news" and "sports" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - -Signature: - -```typescript -arrayContainsAll(...values: Constant[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) - -## ExprWithAlias.arrayContainsAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - -Signature: - -```typescript -arrayContainsAll(...values: any[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) - -## ExprWithAlias.arrayContainsAny() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains any of the specified elements. - -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "cate2" -Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); - -``` - -Signature: - -```typescript -arrayContainsAny(...values: Constant[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) - -## ExprWithAlias.arrayContainsAny() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains any of the specified elements. - -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); - -``` - -Signature: - -```typescript -arrayContainsAny(...values: any[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) - -## ExprWithAlias.arrayLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of an array. - -```typescript -// Get the number of items in the 'cart' array -Field.of("cart").arrayLength(); - -``` - A new `Expr` representing the length of the array. - -Signature: - -```typescript -arrayLength(): ArrayLength; -``` -Returns: - -[ArrayLength](./firestore_lite.arraylength.md#arraylength_class) - -## ExprWithAlias.as() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Assigns an alias to this expression. - -Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. - -```typescript -// Calculate the total price and assign it the alias "totalPrice" and add it to the output. -firestore.pipeline().collection("items") -.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); - -``` - -Signature: - -```typescript -as(name: string): ExprWithAlias; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | The alias to assign to this expression. A new [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) that wraps this expression and associates it with the provided alias. | - -Returns: - -[ExprWithAlias](./firestore_lite.exprwithalias.md#exprwithalias_class)<this> - -## ExprWithAlias.ascending() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. - -```typescript -// Sort documents by the 'name' field in ascending order -pipeline().collection("users") -.sort(Field.of("name").ascending()); - -``` - A new `Ordering` for ascending sorting. - -Signature: - -```typescript -ascending(): Ordering; -``` -Returns: - -[Ordering](./firestore_lite.ordering.md#ordering_class) - -## ExprWithAlias.avg() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. - -```typescript -// Calculate the average age of users -Field.of("age").avg().as("averageAge"); - -``` - A new `Accumulator` representing the 'avg' aggregation. - -Signature: - -```typescript -avg(): Avg; -``` -Returns: - -[Avg](./firestore_lite.avg.md#avg_class) - -## ExprWithAlias.byteLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of this string expression in bytes. - -```typescript -// Calculate the length of the 'myString' field in bytes. -Field.of("myString").byteLength(); - -``` - A new representing the length of the string in bytes. - -Signature: - -```typescript -byteLength(): ByteLength; -``` -Returns: - -[ByteLength](./firestore_lite.bytelength.md#bytelength_class) - -## ExprWithAlias.charLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the character length of a string in UTF-8. - -```typescript -// Get the character length of the 'name' field in its UTF-8 form. -Field.of("name").charLength(); - -``` - A new `Expr` representing the length of the string. - -Signature: - -```typescript -charLength(): CharLength; -``` -Returns: - -[CharLength](./firestore_lite.charlength.md#charlength_class) - -## ExprWithAlias.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the cosine distance between two vectors. - -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -Field.of("userVector").cosineDistance(Field.of("itemVector")); - -``` - -Signature: - -```typescript -cosineDistance(other: Constant): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new Expr representing the cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) - -## ExprWithAlias.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vectors. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -cosineDistance(other: VectorValue): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) - -## ExprWithAlias.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vectors. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance([37.7749, -122.4194]); - -``` - -Signature: - -```typescript -cosineDistance(other: number[]): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | The other vector (as an array of numbers) to compare against. A new Expr representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) - -## ExprWithAlias.count() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. - -```typescript -// Count the total number of products -Field.of("productId").count().as("totalProducts"); - -``` - A new `Accumulator` representing the 'count' aggregation. - -Signature: - -```typescript -count(): Count; -``` -Returns: - -[Count](./firestore_lite.count.md#count_class) - -## ExprWithAlias.descending() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. - -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") -.sort(Field.of("createdAt").descending()); - -``` - A new `Ordering` for descending sorting. - -Signature: - -```typescript -descending(): Ordering; -``` -Returns: - -[Ordering](./firestore_lite.ordering.md#ordering_class) - -## ExprWithAlias.divide() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides this expression by another expression. - -```typescript -// Divide the 'total' field by the 'count' field -Field.of("total").divide(Field.of("count")); - -``` - -Signature: - -```typescript -divide(other: Constant): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new Expr representing the division operation. | - -Returns: - -[Divide](./firestore_lite.divide.md#divide_class) - -## ExprWithAlias.divide() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides this expression by a constant value. - -```typescript -// Divide the 'value' field by 10 -Field.of("value").divide(10); - -``` - -Signature: - -```typescript -divide(other: any): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to divide by. A new Expr representing the division operation. | - -Returns: - -[Divide](./firestore_lite.divide.md#divide_class) - -## ExprWithAlias.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vectors. - -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct([0.5, 0.8, 0.2]); - -``` - -Signature: - -```typescript -dotProduct(other: Constant): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) - -## ExprWithAlias.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vectors. - -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); - -``` - -Signature: - -```typescript -dotProduct(other: VectorValue): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) - -## ExprWithAlias.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -dotProduct(other: number[]): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | | - -Returns: - -[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) - -## ExprWithAlias.endsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string ends with a given postfix. - -```typescript -// Check if the 'filename' field ends with ".txt" -Field.of("filename").endsWith(".txt"); - -``` - -Signature: - -```typescript -endsWith(suffix: string): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| suffix | string | The postfix to check for. A new Expr representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_lite.endswith.md#endswith_class) - -## ExprWithAlias.endsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string ends with a given postfix (represented as an expression). - -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -Field.of("url").endsWith(Field.of("extension")); - -``` - -Signature: - -```typescript -endsWith(suffix: Constant): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| suffix | [Constant](./firestore_lite.constant.md#constant_class) | The postfix expression to check for. A new Expr representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_lite.endswith.md#endswith_class) - -## ExprWithAlias.eq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to another expression. - -```typescript -// Check if the 'age' field is equal to 21 -Field.of("age").eq(21); - -``` - -Signature: - -```typescript -eq(other: Constant): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for equality. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_lite.eq.md#eq_class) - -## ExprWithAlias.eq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to a constant value. - -```typescript -// Check if the 'city' field is equal to "London" -Field.of("city").eq("London"); - -``` - -Signature: - -```typescript -eq(other: any): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for equality. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_lite.eq.md#eq_class) - -## ExprWithAlias.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vectors. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance([37.7749, -122.4194]); - -``` - -Signature: - -```typescript -euclideanDistance(other: Constant): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) - -## ExprWithAlias.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vectors. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -euclideanDistance(other: VectorValue): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) - -## ExprWithAlias.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -euclideanDistance(other: number[]): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | | - -Returns: - -[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) - -## ExprWithAlias.exists() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field exists in the document. - -```typescript -// Check if the document has a field named "phoneNumber" -Field.of("phoneNumber").exists(); - -``` - A new `Expr` representing the 'exists' check. - -Signature: - -```typescript -exists(): Exists; -``` -Returns: - -[Exists](./firestore_lite.exists.md#exists_class) - -## ExprWithAlias.gt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than another expression. - -```typescript -// Check if the 'age' field is greater than the 'limit' field -Field.of("age").gt(Field.of("limit")); - -``` - -Signature: - -```typescript -gt(other: Constant): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for greater than. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_lite.gt.md#gt_class) - -## ExprWithAlias.gt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than a constant value. - -```typescript -// Check if the 'price' field is greater than 100 -Field.of("price").gt(100); - -``` - -Signature: - -```typescript -gt(other: any): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for greater than. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_lite.gt.md#gt_class) - -## ExprWithAlias.gte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than or equal to another expression. - -```typescript -// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 -Field.of("quantity").gte(Field.of('requirement').add(1)); - -``` - -Signature: - -```typescript -gte(other: Constant): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_lite.gte.md#gte_class) - -## ExprWithAlias.gte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than or equal to a constant value. - -```typescript -// Check if the 'score' field is greater than or equal to 80 -Field.of("score").gte(80); - -``` - -Signature: - -```typescript -gte(other: any): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_lite.gte.md#gte_class) - -## ExprWithAlias.in() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to any of the provided values or expressions. - -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -Field.of("category").in("Electronics", Field.of("primaryType")); - -``` - -Signature: - -```typescript -in(...others: Constant[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| others | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The values or expressions to check against. A new Expr representing the 'IN' comparison. | - -Returns: - -[In](./firestore_lite.in.md#in_class) - -## ExprWithAlias.in() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -in(...others: any[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| others | any\[\] | | - -Returns: - -[In](./firestore_lite.in.md#in_class) - -## ExprWithAlias.isNaN() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). - -```typescript -// Check if the result of a calculation is NaN -Field.of("value").divide(0).isNaN(); - -``` - A new `Expr` representing the 'isNaN' check. - -Signature: - -```typescript -isNaN(): IsNan; -``` -Returns: - -[IsNan](./firestore_lite.isnan.md#isnan_class) - -## ExprWithAlias.like() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that performs a case-sensitive string comparison. - -```typescript -// Check if the 'title' field contains the word "guide" (case-sensitive) -Field.of("title").like("%guide%"); - -``` - -Signature: - -```typescript -like(pattern: string): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new Expr representing the 'like' comparison. | - -Returns: - -[Like](./firestore_lite.like.md#like_class) - -## ExprWithAlias.like() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -like(pattern: Constant): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | | - -Returns: - -[Like](./firestore_lite.like.md#like_class) - -## ExprWithAlias.logicalMax() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMax(Function.currentTimestamp()); - -``` - -Signature: - -```typescript -logicalMax(other: Constant): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare with. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) - -## ExprWithAlias.logicalMax() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'value' field and 10. -Field.of("value").logicalMax(10); - -``` - -Signature: - -```typescript -logicalMax(other: any): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare with. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) - -## ExprWithAlias.logicalMin() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMin(Function.currentTimestamp()); - -``` - -Signature: - -```typescript -logicalMin(other: Constant): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare with. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) - -## ExprWithAlias.logicalMin() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'value' field and 10. -Field.of("value").logicalMin(10); - -``` - -Signature: - -```typescript -logicalMin(other: any): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare with. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) - -## ExprWithAlias.lt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than another expression. - -```typescript -// Check if the 'age' field is less than 'limit' -Field.of("age").lt(Field.of('limit')); - -``` - -Signature: - -```typescript -lt(other: Constant): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for less than. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_lite.lt.md#lt_class) - -## ExprWithAlias.lt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than a constant value. - -```typescript -// Check if the 'price' field is less than 50 -Field.of("price").lt(50); - -``` - -Signature: - -```typescript -lt(other: any): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for less than. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_lite.lt.md#lt_class) - -## ExprWithAlias.lte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than or equal to another expression. - -```typescript -// Check if the 'quantity' field is less than or equal to 20 -Field.of("quantity").lte(Constant.of(20)); - -``` - -Signature: - -```typescript -lte(other: Constant): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_lite.lte.md#lte_class) - -## ExprWithAlias.lte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than or equal to a constant value. - -```typescript -// Check if the 'score' field is less than or equal to 70 -Field.of("score").lte(70); - -``` - -Signature: - -```typescript -lte(other: any): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_lite.lte.md#lte_class) - -## ExprWithAlias.mapGet() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Accesses a value from a map (object) field using the provided key. - -```typescript -// Get the 'city' value from the 'address' map field -Field.of("address").mapGet("city"); - -``` - -Signature: - -```typescript -mapGet(subfield: string): MapGet; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| subfield | string | The key to access in the map. A new Expr representing the value associated with the given key in the map. | - -Returns: - -[MapGet](./firestore_lite.mapget.md#mapget_class) - -## ExprWithAlias.max() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that finds the maximum value of a field across multiple stage inputs. - -```typescript -// Find the highest score in a leaderboard -Field.of("score").max().as("highestScore"); - -``` - A new `Accumulator` representing the 'max' aggregation. - -Signature: - -```typescript -max(): Max; -``` -Returns: - -[Max](./firestore_lite.max.md#max_class) - -## ExprWithAlias.min() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that finds the minimum value of a field across multiple stage inputs. - -```typescript -// Find the lowest price of all products -Field.of("price").min().as("lowestPrice"); - -``` - A new `Accumulator` representing the 'min' aggregation. - -Signature: - -```typescript -min(): Min; -``` -Returns: - -[Min](./firestore_lite.min.md#min_class) - -## ExprWithAlias.mod() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. - -```typescript -// Calculate the remainder of dividing the 'value' field by the 'divisor' field -Field.of("value").mod(Field.of("divisor")); - -``` - -Signature: - -```typescript -mod(other: Constant): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new Expr representing the modulo operation. | - -Returns: - -[Mod](./firestore_lite.mod.md#mod_class) - -## ExprWithAlias.mod() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. - -```typescript -// Calculate the remainder of dividing the 'value' field by 10 -Field.of("value").mod(10); - -``` - -Signature: - -```typescript -mod(other: any): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to divide by. A new Expr representing the modulo operation. | - -Returns: - -[Mod](./firestore_lite.mod.md#mod_class) - -## ExprWithAlias.multiply() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies this expression by another expression. - -```typescript -// Multiply the 'quantity' field by the 'price' field -Field.of("quantity").multiply(Field.of("price")); - -``` - -Signature: - -```typescript -multiply(other: Constant): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to multiply by. A new Expr representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_lite.multiply.md#multiply_class) - -## ExprWithAlias.multiply() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies this expression by a constant value. - -```typescript -// Multiply the 'value' field by 2 -Field.of("value").multiply(2); - -``` - -Signature: - -```typescript -multiply(other: any): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to multiply by. A new Expr representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_lite.multiply.md#multiply_class) - -## ExprWithAlias.neq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is not equal to another expression. - -```typescript -// Check if the 'status' field is not equal to "completed" -Field.of("status").neq("completed"); - -``` - -Signature: - -```typescript -neq(other: Constant): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for inequality. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_lite.neq.md#neq_class) - -## ExprWithAlias.neq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is not equal to a constant value. - -```typescript -// Check if the 'country' field is not equal to "USA" -Field.of("country").neq("USA"); - -``` - -Signature: - -```typescript -neq(other: any): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for inequality. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_lite.neq.md#neq_class) - -## ExprWithAlias.regexContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -Field.of("description").regexContains("(?i)example"); - -``` - -Signature: - -```typescript -regexContains(pattern: string): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) - -## ExprWithAlias.regexContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains the regular expression stored in field 'regex' -Field.of("description").regexContains(Field.of("regex")); - -``` - -Signature: - -```typescript -regexContains(pattern: Constant): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) - -## ExprWithAlias.regexMatch() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a valid email pattern -Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - -Signature: - -```typescript -regexMatch(pattern: string): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The regular expression to use for the match. A new Expr representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) - -## ExprWithAlias.regexMatch() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a regular expression stored in field 'regex' -Field.of("email").regexMatch(Field.of("regex")); - -``` - -Signature: - -```typescript -regexMatch(pattern: Constant): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the match. A new Expr representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) - -## ExprWithAlias.replaceAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within this string expression with another substring. - -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field -Field.of("message").replaceAll("hello", "hi"); - -``` - -Signature: - -```typescript -replaceAll(find: string, replace: string): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | string | The substring to search for. | -| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) - -## ExprWithAlias.replaceAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. - -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); - -``` - -Signature: - -```typescript -replaceAll(find: Constant, replace: Constant): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) - -## ExprWithAlias.replaceFirst() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. - -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field -Field.of("message").replaceFirst("hello", "hi"); - -``` - -Signature: - -```typescript -replaceFirst(find: string, replace: string): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | string | The substring to search for. | -| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) - -## ExprWithAlias.replaceFirst() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. - -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); - -``` - -Signature: - -```typescript -replaceFirst(find: Constant, replace: Constant): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) - -## ExprWithAlias.reverse() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that reverses this string expression. - -```typescript -// Reverse the value of the 'myString' field. -Field.of("myString").reverse(); - -``` - A new representing the reversed string. - -Signature: - -```typescript -reverse(): Reverse; -``` -Returns: - -[Reverse](./firestore_lite.reverse.md#reverse_class) - -## ExprWithAlias.startsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string starts with a given prefix. - -```typescript -// Check if the 'name' field starts with "Mr." -Field.of("name").startsWith("Mr."); - -``` - -Signature: - -```typescript -startsWith(prefix: string): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| prefix | string | The prefix to check for. A new Expr representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_lite.startswith.md#startswith_class) - -## ExprWithAlias.startsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string starts with a given prefix (represented as an expression). - -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -Field.of("fullName").startsWith(Field.of("firstName")); - -``` - -Signature: - -```typescript -startsWith(prefix: Constant): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| prefix | [Constant](./firestore_lite.constant.md#constant_class) | The prefix expression to check for. A new Expr representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_lite.startswith.md#startswith_class) - -## ExprWithAlias.strConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates string expressions together. - -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); - -``` - -Signature: - -```typescript -strConcat(...elements: Array): StrConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| elements | Array<string \| [Constant](./firestore_lite.constant.md#constant_class)> | The expressions (typically strings) to concatenate. A new Expr representing the concatenated string. | - -Returns: - -[StrConcat](./firestore_lite.strconcat.md#strconcat_class) - -## ExprWithAlias.strContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified substring. - -```typescript -// Check if the 'description' field contains "example". -Field.of("description").strContains("example"); - -``` - -Signature: - -```typescript -strContains(substring: string): StrContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| substring | string | The substring to search for. A new Expr representing the 'contains' comparison. | - -Returns: - -[StrContains](./firestore_lite.strcontains.md#strcontains_class) - -## ExprWithAlias.strContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains the string represented by another expression. - -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -Field.of("description").strContains(Field.of("keyword")); - -``` - -Signature: - -```typescript -strContains(expr: Constant): StrContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. A new Expr representing the 'contains' comparison. | - -Returns: - -[StrContains](./firestore_lite.strcontains.md#strcontains_class) - -## ExprWithAlias.subtract() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts another expression from this expression. - -```typescript -// Subtract the 'discount' field from the 'price' field -Field.of("price").subtract(Field.of("discount")); - -``` - -Signature: - -```typescript -subtract(other: Constant): Subtract; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to subtract from this expression. A new Expr representing the subtraction operation. | - -Returns: - -[Subtract](./firestore_lite.subtract.md#subtract_class) - -## ExprWithAlias.subtract() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a constant value from this expression. - -```typescript -// Subtract 20 from the value of the 'total' field -Field.of("total").subtract(20); - -``` - -Signature: - -```typescript -subtract(other: any): Subtract; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to subtract. A new Expr representing the subtraction operation. | - -Returns: - -[Subtract](./firestore_lite.subtract.md#subtract_class) - -## ExprWithAlias.sum() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. - -```typescript -// Calculate the total revenue from a set of orders -Field.of("orderAmount").sum().as("totalRevenue"); - -``` - A new `Accumulator` representing the 'sum' aggregation. - -Signature: - -```typescript -sum(): Sum; -``` -Returns: - -[Sum](./firestore_lite.sum.md#sum_class) - -## ExprWithAlias.timestampAdd() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to this timestamp expression. - -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); - -``` - -Signature: - -```typescript -timestampAdd(unit: Constant, amount: Constant): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) - -## ExprWithAlias.timestampAdd() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to this timestamp expression. - -```typescript -// Add 1 day to the 'timestamp' field. -Field.of("timestamp").timestampAdd("day", 1); - -``` - -Signature: - -```typescript -timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | -| amount | number | The amount of time to add. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) - -## ExprWithAlias.timestampSub() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from this timestamp expression. - -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); - -``` - -Signature: - -```typescript -timestampSub(unit: Constant, amount: Constant): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) - -## ExprWithAlias.timestampSub() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from this timestamp expression. - -```typescript -// Subtract 1 day from the 'timestamp' field. -Field.of("timestamp").timestampSub("day", 1); - -``` - -Signature: - -```typescript -timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | -| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) - -## ExprWithAlias.timestampToUnixMicros() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -Field.of("timestamp").timestampToUnixMicros(); - -``` - A new representing the number of microseconds since epoch. - -Signature: - -```typescript -timestampToUnixMicros(): TimestampToUnixMicros; -``` -Returns: - -[TimestampToUnixMicros](./firestore_lite.timestamptounixmicros.md#timestamptounixmicros_class) - -## ExprWithAlias.timestampToUnixMillis() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -Field.of("timestamp").timestampToUnixMillis(); - -``` - A new representing the number of milliseconds since epoch. - -Signature: - -```typescript -timestampToUnixMillis(): TimestampToUnixMillis; -``` -Returns: - -[TimestampToUnixMillis](./firestore_lite.timestamptounixmillis.md#timestamptounixmillis_class) - -## ExprWithAlias.timestampToUnixSeconds() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to seconds since epoch. -Field.of("timestamp").timestampToUnixSeconds(); - -``` - A new representing the number of seconds since epoch. - -Signature: - -```typescript -timestampToUnixSeconds(): TimestampToUnixSeconds; -``` -Returns: - -[TimestampToUnixSeconds](./firestore_lite.timestamptounixseconds.md#timestamptounixseconds_class) - -## ExprWithAlias.toLower() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string to lowercase. - -```typescript -// Convert the 'name' field to lowercase -Field.of("name").toLower(); - -``` - A new `Expr` representing the lowercase string. - -Signature: - -```typescript -toLower(): ToLower; -``` -Returns: - -[ToLower](./firestore_lite.tolower.md#tolower_class) - -## ExprWithAlias.toUpper() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string to uppercase. - -```typescript -// Convert the 'title' field to uppercase -Field.of("title").toUpper(); - -``` - A new `Expr` representing the uppercase string. - -Signature: - -```typescript -toUpper(): ToUpper; -``` -Returns: - -[ToUpper](./firestore_lite.toupper.md#toupper_class) - -## ExprWithAlias.trim() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that removes leading and trailing whitespace from a string. - -```typescript -// Trim whitespace from the 'userInput' field -Field.of("userInput").trim(); - -``` - A new `Expr` representing the trimmed string. - -Signature: - -```typescript -trim(): Trim; -``` -Returns: - -[Trim](./firestore_lite.trim.md#trim_class) - -## ExprWithAlias.unixMicrosToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -Field.of("microseconds").unixMicrosToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixMicrosToTimestamp(): UnixMicrosToTimestamp; -``` -Returns: - -[UnixMicrosToTimestamp](./firestore_lite.unixmicrostotimestamp.md#unixmicrostotimestamp_class) - -## ExprWithAlias.unixMillisToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -Field.of("milliseconds").unixMillisToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixMillisToTimestamp(): UnixMillisToTimestamp; -``` -Returns: - -[UnixMillisToTimestamp](./firestore_lite.unixmillistotimestamp.md#unixmillistotimestamp_class) - -## ExprWithAlias.unixSecondsToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'seconds' field as seconds since epoch. -Field.of("seconds").unixSecondsToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixSecondsToTimestamp(): UnixSecondsToTimestamp; -``` -Returns: - -[UnixSecondsToTimestamp](./firestore_lite.unixsecondstotimestamp.md#unixsecondstotimestamp_class) - -## ExprWithAlias.vectorLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. - -```typescript -// Get the vector length (dimension) of the field 'embedding'. -Field.of("embedding").vectorLength(); - -``` - A new representing the length of the vector. - -Signature: - -```typescript -vectorLength(): VectorLength; -``` -Returns: - -[VectorLength](./firestore_lite.vectorlength.md#vectorlength_class) - diff --git a/docs-devsite/firestore_lite.field.md b/docs-devsite/firestore_lite.field.md deleted file mode 100644 index 0619a19d6bb..00000000000 --- a/docs-devsite/firestore_lite.field.md +++ /dev/null @@ -1,3275 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Field class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Represents a reference to a field in a Firestore document, or outputs of a [Pipeline](./firestore_.pipeline.md#pipeline_class) stage. - -

Field references are used to access document field values in expressions and to specify fields for sorting, filtering, and projecting data in Firestore pipelines. - -

You can create a `Field` instance using the static method: - -```typescript -// Create a Field instance for the 'name' field -const nameField = Field.of("name"); - -// Create a Field instance for a nested field 'address.city' -const cityField = Field.of("address.city"); - -``` - -Signature: - -```typescript -export declare class Field implements Selectable -``` -Implements: [Selectable](./firestore_lite.selectable.md#selectable_interface) - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [exprType](./firestore_lite.field.md#fieldexprtype) | | [ExprType](./firestore_lite.md#exprtype) | (BETA) | -| [selectable](./firestore_lite.field.md#fieldselectable) | | true | (BETA) | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [add(other)](./firestore_lite.field.md#fieldadd) | | (BETA) Creates an expression that adds this expression to another expression. -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -Field.of("quantity").add(Field.of("reserve")); - -``` - | -| [add(other)](./firestore_lite.field.md#fieldadd) | | (BETA) Creates an expression that adds this expression to a constant value. -```typescript -// Add 5 to the value of the 'age' field -Field.of("age").add(5); - -``` - | -| [arrayConcat(arrays)](./firestore_lite.field.md#fieldarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. -```typescript -// Combine the 'items' array with another array field. -Field.of("items").arrayConcat(Field.of("otherItems")); - -``` - | -| [arrayConcat(arrays)](./firestore_lite.field.md#fieldarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. -```typescript -// Combine the 'tags' array with a new array and an array field -Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); - -``` - | -| [arrayContains(element)](./firestore_lite.field.md#fieldarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific element. -```typescript -// Check if the 'sizes' array contains the value from the 'selectedSize' field -Field.of("sizes").arrayContains(Field.of("selectedSize")); - -``` - | -| [arrayContains(element)](./firestore_lite.field.md#fieldarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific value. -```typescript -// Check if the 'colors' array contains "red" -Field.of("colors").arrayContains("red"); - -``` - | -| [arrayContainsAll(values)](./firestore_lite.field.md#fieldarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. -```typescript -// Check if the 'tags' array contains both "news" and "sports" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - | -| [arrayContainsAll(values)](./firestore_lite.field.md#fieldarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - | -| [arrayContainsAny(values)](./firestore_lite.field.md#fieldarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "cate2" -Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); - -``` - | -| [arrayContainsAny(values)](./firestore_lite.field.md#fieldarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); - -``` - | -| [arrayLength()](./firestore_lite.field.md#fieldarraylength) | | (BETA) Creates an expression that calculates the length of an array. -```typescript -// Get the number of items in the 'cart' array -Field.of("cart").arrayLength(); - -``` - A new Expr representing the length of the array. | -| [as(name)](./firestore_lite.field.md#fieldas) | | (BETA) Assigns an alias to this expression.Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. -```typescript -// Calculate the total price and assign it the alias "totalPrice" and add it to the output. -firestore.pipeline().collection("items") -.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); - -``` - | -| [ascending()](./firestore_lite.field.md#fieldascending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. -```typescript -// Sort documents by the 'name' field in ascending order -pipeline().collection("users") -.sort(Field.of("name").ascending()); - -``` - A new Ordering for ascending sorting. | -| [avg()](./firestore_lite.field.md#fieldavg) | | (BETA) Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. -```typescript -// Calculate the average age of users -Field.of("age").avg().as("averageAge"); - -``` - A new Accumulator representing the 'avg' aggregation. | -| [byteLength()](./firestore_lite.field.md#fieldbytelength) | | (BETA) Creates an expression that calculates the length of this string expression in bytes. -```typescript -// Calculate the length of the 'myString' field in bytes. -Field.of("myString").byteLength(); - -``` - A new representing the length of the string in bytes. | -| [charLength()](./firestore_lite.field.md#fieldcharlength) | | (BETA) Creates an expression that calculates the character length of a string in UTF-8. -```typescript -// Get the character length of the 'name' field in its UTF-8 form. -Field.of("name").charLength(); - -``` - A new Expr representing the length of the string. | -| [cosineDistance(other)](./firestore_lite.field.md#fieldcosinedistance) | | (BETA) Calculates the cosine distance between two vectors. -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -Field.of("userVector").cosineDistance(Field.of("itemVector")); - -``` - | -| [cosineDistance(other)](./firestore_lite.field.md#fieldcosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); - -``` - | -| [cosineDistance(other)](./firestore_lite.field.md#fieldcosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance([37.7749, -122.4194]); - -``` - | -| [count()](./firestore_lite.field.md#fieldcount) | | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. -```typescript -// Count the total number of products -Field.of("productId").count().as("totalProducts"); - -``` - A new Accumulator representing the 'count' aggregation. | -| [descending()](./firestore_lite.field.md#fielddescending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") -.sort(Field.of("createdAt").descending()); - -``` - A new Ordering for descending sorting. | -| [divide(other)](./firestore_lite.field.md#fielddivide) | | (BETA) Creates an expression that divides this expression by another expression. -```typescript -// Divide the 'total' field by the 'count' field -Field.of("total").divide(Field.of("count")); - -``` - | -| [divide(other)](./firestore_lite.field.md#fielddivide) | | (BETA) Creates an expression that divides this expression by a constant value. -```typescript -// Divide the 'value' field by 10 -Field.of("value").divide(10); - -``` - | -| [dotProduct(other)](./firestore_lite.field.md#fielddotproduct) | | (BETA) Calculates the dot product between two vectors. -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct([0.5, 0.8, 0.2]); - -``` - | -| [dotProduct(other)](./firestore_lite.field.md#fielddotproduct) | | (BETA) Calculates the dot product between two vectors. -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); - -``` - | -| [dotProduct(other)](./firestore_lite.field.md#fielddotproduct) | | (BETA) | -| [endsWith(suffix)](./firestore_lite.field.md#fieldendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix. -```typescript -// Check if the 'filename' field ends with ".txt" -Field.of("filename").endsWith(".txt"); - -``` - | -| [endsWith(suffix)](./firestore_lite.field.md#fieldendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix (represented as an expression). -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -Field.of("url").endsWith(Field.of("extension")); - -``` - | -| [eq(other)](./firestore_lite.field.md#fieldeq) | | (BETA) Creates an expression that checks if this expression is equal to another expression. -```typescript -// Check if the 'age' field is equal to 21 -Field.of("age").eq(21); - -``` - | -| [eq(other)](./firestore_lite.field.md#fieldeq) | | (BETA) Creates an expression that checks if this expression is equal to a constant value. -```typescript -// Check if the 'city' field is equal to "London" -Field.of("city").eq("London"); - -``` - | -| [euclideanDistance(other)](./firestore_lite.field.md#fieldeuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance([37.7749, -122.4194]); - -``` - | -| [euclideanDistance(other)](./firestore_lite.field.md#fieldeuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); - -``` - | -| [euclideanDistance(other)](./firestore_lite.field.md#fieldeuclideandistance) | | (BETA) | -| [exists()](./firestore_lite.field.md#fieldexists) | | (BETA) Creates an expression that checks if a field exists in the document. -```typescript -// Check if the document has a field named "phoneNumber" -Field.of("phoneNumber").exists(); - -``` - A new Expr representing the 'exists' check. | -| [fieldName()](./firestore_lite.field.md#fieldfieldname) | | (BETA) | -| [gt(other)](./firestore_lite.field.md#fieldgt) | | (BETA) Creates an expression that checks if this expression is greater than another expression. -```typescript -// Check if the 'age' field is greater than the 'limit' field -Field.of("age").gt(Field.of("limit")); - -``` - | -| [gt(other)](./firestore_lite.field.md#fieldgt) | | (BETA) Creates an expression that checks if this expression is greater than a constant value. -```typescript -// Check if the 'price' field is greater than 100 -Field.of("price").gt(100); - -``` - | -| [gte(other)](./firestore_lite.field.md#fieldgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to another expression. -```typescript -// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 -Field.of("quantity").gte(Field.of('requirement').add(1)); - -``` - | -| [gte(other)](./firestore_lite.field.md#fieldgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to a constant value. -```typescript -// Check if the 'score' field is greater than or equal to 80 -Field.of("score").gte(80); - -``` - | -| [in(others)](./firestore_lite.field.md#fieldin) | | (BETA) Creates an expression that checks if this expression is equal to any of the provided values or expressions. -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -Field.of("category").in("Electronics", Field.of("primaryType")); - -``` - | -| [in(others)](./firestore_lite.field.md#fieldin) | | (BETA) | -| [isNaN()](./firestore_lite.field.md#fieldisnan) | | (BETA) Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). -```typescript -// Check if the result of a calculation is NaN -Field.of("value").divide(0).isNaN(); - -``` - A new Expr representing the 'isNaN' check. | -| [like(pattern)](./firestore_lite.field.md#fieldlike) | | (BETA) Creates an expression that performs a case-sensitive string comparison. -```typescript -// Check if the 'title' field contains the word "guide" (case-sensitive) -Field.of("title").like("%guide%"); - -``` - | -| [like(pattern)](./firestore_lite.field.md#fieldlike) | | (BETA) | -| [logicalMax(other)](./firestore_lite.field.md#fieldlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMax(Function.currentTimestamp()); - -``` - | -| [logicalMax(other)](./firestore_lite.field.md#fieldlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'value' field and 10. -Field.of("value").logicalMax(10); - -``` - | -| [logicalMin(other)](./firestore_lite.field.md#fieldlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMin(Function.currentTimestamp()); - -``` - | -| [logicalMin(other)](./firestore_lite.field.md#fieldlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'value' field and 10. -Field.of("value").logicalMin(10); - -``` - | -| [lt(other)](./firestore_lite.field.md#fieldlt) | | (BETA) Creates an expression that checks if this expression is less than another expression. -```typescript -// Check if the 'age' field is less than 'limit' -Field.of("age").lt(Field.of('limit')); - -``` - | -| [lt(other)](./firestore_lite.field.md#fieldlt) | | (BETA) Creates an expression that checks if this expression is less than a constant value. -```typescript -// Check if the 'price' field is less than 50 -Field.of("price").lt(50); - -``` - | -| [lte(other)](./firestore_lite.field.md#fieldlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to another expression. -```typescript -// Check if the 'quantity' field is less than or equal to 20 -Field.of("quantity").lte(Constant.of(20)); - -``` - | -| [lte(other)](./firestore_lite.field.md#fieldlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to a constant value. -```typescript -// Check if the 'score' field is less than or equal to 70 -Field.of("score").lte(70); - -``` - | -| [mapGet(subfield)](./firestore_lite.field.md#fieldmapget) | | (BETA) Accesses a value from a map (object) field using the provided key. -```typescript -// Get the 'city' value from the 'address' map field -Field.of("address").mapGet("city"); - -``` - | -| [max()](./firestore_lite.field.md#fieldmax) | | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. -```typescript -// Find the highest score in a leaderboard -Field.of("score").max().as("highestScore"); - -``` - A new Accumulator representing the 'max' aggregation. | -| [min()](./firestore_lite.field.md#fieldmin) | | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. -```typescript -// Find the lowest price of all products -Field.of("price").min().as("lowestPrice"); - -``` - A new Accumulator representing the 'min' aggregation. | -| [mod(other)](./firestore_lite.field.md#fieldmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. -```typescript -// Calculate the remainder of dividing the 'value' field by the 'divisor' field -Field.of("value").mod(Field.of("divisor")); - -``` - | -| [mod(other)](./firestore_lite.field.md#fieldmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. -```typescript -// Calculate the remainder of dividing the 'value' field by 10 -Field.of("value").mod(10); - -``` - | -| [multiply(other)](./firestore_lite.field.md#fieldmultiply) | | (BETA) Creates an expression that multiplies this expression by another expression. -```typescript -// Multiply the 'quantity' field by the 'price' field -Field.of("quantity").multiply(Field.of("price")); - -``` - | -| [multiply(other)](./firestore_lite.field.md#fieldmultiply) | | (BETA) Creates an expression that multiplies this expression by a constant value. -```typescript -// Multiply the 'value' field by 2 -Field.of("value").multiply(2); - -``` - | -| [neq(other)](./firestore_lite.field.md#fieldneq) | | (BETA) Creates an expression that checks if this expression is not equal to another expression. -```typescript -// Check if the 'status' field is not equal to "completed" -Field.of("status").neq("completed"); - -``` - | -| [neq(other)](./firestore_lite.field.md#fieldneq) | | (BETA) Creates an expression that checks if this expression is not equal to a constant value. -```typescript -// Check if the 'country' field is not equal to "USA" -Field.of("country").neq("USA"); - -``` - | -| [of(name)](./firestore_lite.field.md#fieldof) | static | (BETA) Creates a instance representing the field at the given path.The path can be a simple field name (e.g., "name") or a dot-separated path to a nested field (e.g., "address.city"). -```typescript -// Create a Field instance for the 'title' field -const titleField = Field.of("title"); - -// Create a Field instance for a nested field 'author.firstName' -const authorFirstNameField = Field.of("author.firstName"); - -``` - | -| [of(path)](./firestore_lite.field.md#fieldof) | static | (BETA) | -| [of(pipeline, name)](./firestore_lite.field.md#fieldof) | static | (BETA) | -| [regexContains(pattern)](./firestore_lite.field.md#fieldregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -Field.of("description").regexContains("(?i)example"); - -``` - | -| [regexContains(pattern)](./firestore_lite.field.md#fieldregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains the regular expression stored in field 'regex' -Field.of("description").regexContains(Field.of("regex")); - -``` - | -| [regexMatch(pattern)](./firestore_lite.field.md#fieldregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. -```typescript -// Check if the 'email' field matches a valid email pattern -Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - | -| [regexMatch(pattern)](./firestore_lite.field.md#fieldregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. -```typescript -// Check if the 'email' field matches a regular expression stored in field 'regex' -Field.of("email").regexMatch(Field.of("regex")); - -``` - | -| [replaceAll(find, replace)](./firestore_lite.field.md#fieldreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring. -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field -Field.of("message").replaceAll("hello", "hi"); - -``` - | -| [replaceAll(find, replace)](./firestore_lite.field.md#fieldreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); - -``` - | -| [replaceFirst(find, replace)](./firestore_lite.field.md#fieldreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field -Field.of("message").replaceFirst("hello", "hi"); - -``` - | -| [replaceFirst(find, replace)](./firestore_lite.field.md#fieldreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); - -``` - | -| [reverse()](./firestore_lite.field.md#fieldreverse) | | (BETA) Creates an expression that reverses this string expression. -```typescript -// Reverse the value of the 'myString' field. -Field.of("myString").reverse(); - -``` - A new representing the reversed string. | -| [startsWith(prefix)](./firestore_lite.field.md#fieldstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix. -```typescript -// Check if the 'name' field starts with "Mr." -Field.of("name").startsWith("Mr."); - -``` - | -| [startsWith(prefix)](./firestore_lite.field.md#fieldstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix (represented as an expression). -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -Field.of("fullName").startsWith(Field.of("firstName")); - -``` - | -| [strConcat(elements)](./firestore_lite.field.md#fieldstrconcat) | | (BETA) Creates an expression that concatenates string expressions together. -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); - -``` - | -| [strContains(substring)](./firestore_lite.field.md#fieldstrcontains) | | (BETA) Creates an expression that checks if a string contains a specified substring. -```typescript -// Check if the 'description' field contains "example". -Field.of("description").strContains("example"); - -``` - | -| [strContains(expr)](./firestore_lite.field.md#fieldstrcontains) | | (BETA) Creates an expression that checks if a string contains the string represented by another expression. -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -Field.of("description").strContains(Field.of("keyword")); - -``` - | -| [subtract(other)](./firestore_lite.field.md#fieldsubtract) | | (BETA) Creates an expression that subtracts another expression from this expression. -```typescript -// Subtract the 'discount' field from the 'price' field -Field.of("price").subtract(Field.of("discount")); - -``` - | -| [subtract(other)](./firestore_lite.field.md#fieldsubtract) | | (BETA) Creates an expression that subtracts a constant value from this expression. -```typescript -// Subtract 20 from the value of the 'total' field -Field.of("total").subtract(20); - -``` - | -| [sum()](./firestore_lite.field.md#fieldsum) | | (BETA) Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. -```typescript -// Calculate the total revenue from a set of orders -Field.of("orderAmount").sum().as("totalRevenue"); - -``` - A new Accumulator representing the 'sum' aggregation. | -| [timestampAdd(unit, amount)](./firestore_lite.field.md#fieldtimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampAdd(unit, amount)](./firestore_lite.field.md#fieldtimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. -```typescript -// Add 1 day to the 'timestamp' field. -Field.of("timestamp").timestampAdd("day", 1); - -``` - | -| [timestampSub(unit, amount)](./firestore_lite.field.md#fieldtimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampSub(unit, amount)](./firestore_lite.field.md#fieldtimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. -```typescript -// Subtract 1 day from the 'timestamp' field. -Field.of("timestamp").timestampSub("day", 1); - -``` - | -| [timestampToUnixMicros()](./firestore_lite.field.md#fieldtimestamptounixmicros) | | (BETA) Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -Field.of("timestamp").timestampToUnixMicros(); - -``` - A new representing the number of microseconds since epoch. | -| [timestampToUnixMillis()](./firestore_lite.field.md#fieldtimestamptounixmillis) | | (BETA) Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -Field.of("timestamp").timestampToUnixMillis(); - -``` - A new representing the number of milliseconds since epoch. | -| [timestampToUnixSeconds()](./firestore_lite.field.md#fieldtimestamptounixseconds) | | (BETA) Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to seconds since epoch. -Field.of("timestamp").timestampToUnixSeconds(); - -``` - A new representing the number of seconds since epoch. | -| [toLower()](./firestore_lite.field.md#fieldtolower) | | (BETA) Creates an expression that converts a string to lowercase. -```typescript -// Convert the 'name' field to lowercase -Field.of("name").toLower(); - -``` - A new Expr representing the lowercase string. | -| [toUpper()](./firestore_lite.field.md#fieldtoupper) | | (BETA) Creates an expression that converts a string to uppercase. -```typescript -// Convert the 'title' field to uppercase -Field.of("title").toUpper(); - -``` - A new Expr representing the uppercase string. | -| [trim()](./firestore_lite.field.md#fieldtrim) | | (BETA) Creates an expression that removes leading and trailing whitespace from a string. -```typescript -// Trim whitespace from the 'userInput' field -Field.of("userInput").trim(); - -``` - A new Expr representing the trimmed string. | -| [unixMicrosToTimestamp()](./firestore_lite.field.md#fieldunixmicrostotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -Field.of("microseconds").unixMicrosToTimestamp(); - -``` - A new representing the timestamp. | -| [unixMillisToTimestamp()](./firestore_lite.field.md#fieldunixmillistotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -Field.of("milliseconds").unixMillisToTimestamp(); - -``` - A new representing the timestamp. | -| [unixSecondsToTimestamp()](./firestore_lite.field.md#fieldunixsecondstotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'seconds' field as seconds since epoch. -Field.of("seconds").unixSecondsToTimestamp(); - -``` - A new representing the timestamp. | -| [vectorLength()](./firestore_lite.field.md#fieldvectorlength) | | (BETA) Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. -```typescript -// Get the vector length (dimension) of the field 'embedding'. -Field.of("embedding").vectorLength(); - -``` - A new representing the length of the vector. | - -## Field.exprType - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -exprType: ExprType; -``` - -## Field.selectable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -selectable: true; -``` - -## Field.add() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds this expression to another expression. - -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -Field.of("quantity").add(Field.of("reserve")); - -``` - -Signature: - -```typescript -add(other: Constant): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to add to this expression. A new Expr representing the addition operation. | - -Returns: - -[Add](./firestore_lite.add.md#add_class) - -## Field.add() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds this expression to a constant value. - -```typescript -// Add 5 to the value of the 'age' field -Field.of("age").add(5); - -``` - -Signature: - -```typescript -add(other: any): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to add. A new Expr representing the addition operation. | - -Returns: - -[Add](./firestore_lite.add.md#add_class) - -## Field.arrayConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with one or more other arrays. - -```typescript -// Combine the 'items' array with another array field. -Field.of("items").arrayConcat(Field.of("otherItems")); - -``` - -Signature: - -```typescript -arrayConcat(arrays: Constant[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| arrays | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The array expressions to concatenate. A new Expr representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) - -## Field.arrayConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with one or more other arrays. - -```typescript -// Combine the 'tags' array with a new array and an array field -Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); - -``` - -Signature: - -```typescript -arrayConcat(arrays: any[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| arrays | any\[\] | The array expressions or values to concatenate. A new Expr representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) - -## Field.arrayContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains a specific element. - -```typescript -// Check if the 'sizes' array contains the value from the 'selectedSize' field -Field.of("sizes").arrayContains(Field.of("selectedSize")); - -``` - -Signature: - -```typescript -arrayContains(element: Constant): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | [Constant](./firestore_lite.constant.md#constant_class) | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) - -## Field.arrayContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains a specific value. - -```typescript -// Check if the 'colors' array contains "red" -Field.of("colors").arrayContains("red"); - -``` - -Signature: - -```typescript -arrayContains(element: any): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | any | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) - -## Field.arrayContainsAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both "news" and "sports" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - -Signature: - -```typescript -arrayContainsAll(...values: Constant[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) - -## Field.arrayContainsAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - -Signature: - -```typescript -arrayContainsAll(...values: any[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) - -## Field.arrayContainsAny() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains any of the specified elements. - -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "cate2" -Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); - -``` - -Signature: - -```typescript -arrayContainsAny(...values: Constant[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) - -## Field.arrayContainsAny() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains any of the specified elements. - -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); - -``` - -Signature: - -```typescript -arrayContainsAny(...values: any[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) - -## Field.arrayLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of an array. - -```typescript -// Get the number of items in the 'cart' array -Field.of("cart").arrayLength(); - -``` - A new `Expr` representing the length of the array. - -Signature: - -```typescript -arrayLength(): ArrayLength; -``` -Returns: - -[ArrayLength](./firestore_lite.arraylength.md#arraylength_class) - -## Field.as() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Assigns an alias to this expression. - -Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. - -```typescript -// Calculate the total price and assign it the alias "totalPrice" and add it to the output. -firestore.pipeline().collection("items") -.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); - -``` - -Signature: - -```typescript -as(name: string): ExprWithAlias; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | The alias to assign to this expression. A new [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) that wraps this expression and associates it with the provided alias. | - -Returns: - -[ExprWithAlias](./firestore_lite.exprwithalias.md#exprwithalias_class)<this> - -## Field.ascending() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. - -```typescript -// Sort documents by the 'name' field in ascending order -pipeline().collection("users") -.sort(Field.of("name").ascending()); - -``` - A new `Ordering` for ascending sorting. - -Signature: - -```typescript -ascending(): Ordering; -``` -Returns: - -[Ordering](./firestore_lite.ordering.md#ordering_class) - -## Field.avg() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. - -```typescript -// Calculate the average age of users -Field.of("age").avg().as("averageAge"); - -``` - A new `Accumulator` representing the 'avg' aggregation. - -Signature: - -```typescript -avg(): Avg; -``` -Returns: - -[Avg](./firestore_lite.avg.md#avg_class) - -## Field.byteLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of this string expression in bytes. - -```typescript -// Calculate the length of the 'myString' field in bytes. -Field.of("myString").byteLength(); - -``` - A new representing the length of the string in bytes. - -Signature: - -```typescript -byteLength(): ByteLength; -``` -Returns: - -[ByteLength](./firestore_lite.bytelength.md#bytelength_class) - -## Field.charLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the character length of a string in UTF-8. - -```typescript -// Get the character length of the 'name' field in its UTF-8 form. -Field.of("name").charLength(); - -``` - A new `Expr` representing the length of the string. - -Signature: - -```typescript -charLength(): CharLength; -``` -Returns: - -[CharLength](./firestore_lite.charlength.md#charlength_class) - -## Field.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the cosine distance between two vectors. - -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -Field.of("userVector").cosineDistance(Field.of("itemVector")); - -``` - -Signature: - -```typescript -cosineDistance(other: Constant): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new Expr representing the cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) - -## Field.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vectors. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -cosineDistance(other: VectorValue): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) - -## Field.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vectors. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance([37.7749, -122.4194]); - -``` - -Signature: - -```typescript -cosineDistance(other: number[]): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | The other vector (as an array of numbers) to compare against. A new Expr representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) - -## Field.count() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. - -```typescript -// Count the total number of products -Field.of("productId").count().as("totalProducts"); - -``` - A new `Accumulator` representing the 'count' aggregation. - -Signature: - -```typescript -count(): Count; -``` -Returns: - -[Count](./firestore_lite.count.md#count_class) - -## Field.descending() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. - -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") -.sort(Field.of("createdAt").descending()); - -``` - A new `Ordering` for descending sorting. - -Signature: - -```typescript -descending(): Ordering; -``` -Returns: - -[Ordering](./firestore_lite.ordering.md#ordering_class) - -## Field.divide() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides this expression by another expression. - -```typescript -// Divide the 'total' field by the 'count' field -Field.of("total").divide(Field.of("count")); - -``` - -Signature: - -```typescript -divide(other: Constant): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new Expr representing the division operation. | - -Returns: - -[Divide](./firestore_lite.divide.md#divide_class) - -## Field.divide() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides this expression by a constant value. - -```typescript -// Divide the 'value' field by 10 -Field.of("value").divide(10); - -``` - -Signature: - -```typescript -divide(other: any): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to divide by. A new Expr representing the division operation. | - -Returns: - -[Divide](./firestore_lite.divide.md#divide_class) - -## Field.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vectors. - -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct([0.5, 0.8, 0.2]); - -``` - -Signature: - -```typescript -dotProduct(other: Constant): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) - -## Field.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vectors. - -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); - -``` - -Signature: - -```typescript -dotProduct(other: VectorValue): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) - -## Field.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -dotProduct(other: number[]): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | | - -Returns: - -[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) - -## Field.endsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string ends with a given postfix. - -```typescript -// Check if the 'filename' field ends with ".txt" -Field.of("filename").endsWith(".txt"); - -``` - -Signature: - -```typescript -endsWith(suffix: string): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| suffix | string | The postfix to check for. A new Expr representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_lite.endswith.md#endswith_class) - -## Field.endsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string ends with a given postfix (represented as an expression). - -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -Field.of("url").endsWith(Field.of("extension")); - -``` - -Signature: - -```typescript -endsWith(suffix: Constant): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| suffix | [Constant](./firestore_lite.constant.md#constant_class) | The postfix expression to check for. A new Expr representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_lite.endswith.md#endswith_class) - -## Field.eq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to another expression. - -```typescript -// Check if the 'age' field is equal to 21 -Field.of("age").eq(21); - -``` - -Signature: - -```typescript -eq(other: Constant): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for equality. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_lite.eq.md#eq_class) - -## Field.eq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to a constant value. - -```typescript -// Check if the 'city' field is equal to "London" -Field.of("city").eq("London"); - -``` - -Signature: - -```typescript -eq(other: any): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for equality. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_lite.eq.md#eq_class) - -## Field.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vectors. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance([37.7749, -122.4194]); - -``` - -Signature: - -```typescript -euclideanDistance(other: Constant): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) - -## Field.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vectors. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -euclideanDistance(other: VectorValue): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) - -## Field.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -euclideanDistance(other: number[]): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | | - -Returns: - -[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) - -## Field.exists() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field exists in the document. - -```typescript -// Check if the document has a field named "phoneNumber" -Field.of("phoneNumber").exists(); - -``` - A new `Expr` representing the 'exists' check. - -Signature: - -```typescript -exists(): Exists; -``` -Returns: - -[Exists](./firestore_lite.exists.md#exists_class) - -## Field.fieldName() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -fieldName(): string; -``` -Returns: - -string - -## Field.gt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than another expression. - -```typescript -// Check if the 'age' field is greater than the 'limit' field -Field.of("age").gt(Field.of("limit")); - -``` - -Signature: - -```typescript -gt(other: Constant): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for greater than. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_lite.gt.md#gt_class) - -## Field.gt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than a constant value. - -```typescript -// Check if the 'price' field is greater than 100 -Field.of("price").gt(100); - -``` - -Signature: - -```typescript -gt(other: any): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for greater than. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_lite.gt.md#gt_class) - -## Field.gte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than or equal to another expression. - -```typescript -// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 -Field.of("quantity").gte(Field.of('requirement').add(1)); - -``` - -Signature: - -```typescript -gte(other: Constant): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_lite.gte.md#gte_class) - -## Field.gte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than or equal to a constant value. - -```typescript -// Check if the 'score' field is greater than or equal to 80 -Field.of("score").gte(80); - -``` - -Signature: - -```typescript -gte(other: any): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_lite.gte.md#gte_class) - -## Field.in() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to any of the provided values or expressions. - -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -Field.of("category").in("Electronics", Field.of("primaryType")); - -``` - -Signature: - -```typescript -in(...others: Constant[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| others | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The values or expressions to check against. A new Expr representing the 'IN' comparison. | - -Returns: - -[In](./firestore_lite.in.md#in_class) - -## Field.in() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -in(...others: any[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| others | any\[\] | | - -Returns: - -[In](./firestore_lite.in.md#in_class) - -## Field.isNaN() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). - -```typescript -// Check if the result of a calculation is NaN -Field.of("value").divide(0).isNaN(); - -``` - A new `Expr` representing the 'isNaN' check. - -Signature: - -```typescript -isNaN(): IsNan; -``` -Returns: - -[IsNan](./firestore_lite.isnan.md#isnan_class) - -## Field.like() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that performs a case-sensitive string comparison. - -```typescript -// Check if the 'title' field contains the word "guide" (case-sensitive) -Field.of("title").like("%guide%"); - -``` - -Signature: - -```typescript -like(pattern: string): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new Expr representing the 'like' comparison. | - -Returns: - -[Like](./firestore_lite.like.md#like_class) - -## Field.like() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -like(pattern: Constant): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | | - -Returns: - -[Like](./firestore_lite.like.md#like_class) - -## Field.logicalMax() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMax(Function.currentTimestamp()); - -``` - -Signature: - -```typescript -logicalMax(other: Constant): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare with. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) - -## Field.logicalMax() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'value' field and 10. -Field.of("value").logicalMax(10); - -``` - -Signature: - -```typescript -logicalMax(other: any): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare with. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) - -## Field.logicalMin() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMin(Function.currentTimestamp()); - -``` - -Signature: - -```typescript -logicalMin(other: Constant): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare with. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) - -## Field.logicalMin() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'value' field and 10. -Field.of("value").logicalMin(10); - -``` - -Signature: - -```typescript -logicalMin(other: any): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare with. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) - -## Field.lt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than another expression. - -```typescript -// Check if the 'age' field is less than 'limit' -Field.of("age").lt(Field.of('limit')); - -``` - -Signature: - -```typescript -lt(other: Constant): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for less than. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_lite.lt.md#lt_class) - -## Field.lt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than a constant value. - -```typescript -// Check if the 'price' field is less than 50 -Field.of("price").lt(50); - -``` - -Signature: - -```typescript -lt(other: any): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for less than. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_lite.lt.md#lt_class) - -## Field.lte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than or equal to another expression. - -```typescript -// Check if the 'quantity' field is less than or equal to 20 -Field.of("quantity").lte(Constant.of(20)); - -``` - -Signature: - -```typescript -lte(other: Constant): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_lite.lte.md#lte_class) - -## Field.lte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than or equal to a constant value. - -```typescript -// Check if the 'score' field is less than or equal to 70 -Field.of("score").lte(70); - -``` - -Signature: - -```typescript -lte(other: any): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_lite.lte.md#lte_class) - -## Field.mapGet() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Accesses a value from a map (object) field using the provided key. - -```typescript -// Get the 'city' value from the 'address' map field -Field.of("address").mapGet("city"); - -``` - -Signature: - -```typescript -mapGet(subfield: string): MapGet; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| subfield | string | The key to access in the map. A new Expr representing the value associated with the given key in the map. | - -Returns: - -[MapGet](./firestore_lite.mapget.md#mapget_class) - -## Field.max() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that finds the maximum value of a field across multiple stage inputs. - -```typescript -// Find the highest score in a leaderboard -Field.of("score").max().as("highestScore"); - -``` - A new `Accumulator` representing the 'max' aggregation. - -Signature: - -```typescript -max(): Max; -``` -Returns: - -[Max](./firestore_lite.max.md#max_class) - -## Field.min() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that finds the minimum value of a field across multiple stage inputs. - -```typescript -// Find the lowest price of all products -Field.of("price").min().as("lowestPrice"); - -``` - A new `Accumulator` representing the 'min' aggregation. - -Signature: - -```typescript -min(): Min; -``` -Returns: - -[Min](./firestore_lite.min.md#min_class) - -## Field.mod() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. - -```typescript -// Calculate the remainder of dividing the 'value' field by the 'divisor' field -Field.of("value").mod(Field.of("divisor")); - -``` - -Signature: - -```typescript -mod(other: Constant): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new Expr representing the modulo operation. | - -Returns: - -[Mod](./firestore_lite.mod.md#mod_class) - -## Field.mod() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. - -```typescript -// Calculate the remainder of dividing the 'value' field by 10 -Field.of("value").mod(10); - -``` - -Signature: - -```typescript -mod(other: any): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to divide by. A new Expr representing the modulo operation. | - -Returns: - -[Mod](./firestore_lite.mod.md#mod_class) - -## Field.multiply() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies this expression by another expression. - -```typescript -// Multiply the 'quantity' field by the 'price' field -Field.of("quantity").multiply(Field.of("price")); - -``` - -Signature: - -```typescript -multiply(other: Constant): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to multiply by. A new Expr representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_lite.multiply.md#multiply_class) - -## Field.multiply() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies this expression by a constant value. - -```typescript -// Multiply the 'value' field by 2 -Field.of("value").multiply(2); - -``` - -Signature: - -```typescript -multiply(other: any): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to multiply by. A new Expr representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_lite.multiply.md#multiply_class) - -## Field.neq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is not equal to another expression. - -```typescript -// Check if the 'status' field is not equal to "completed" -Field.of("status").neq("completed"); - -``` - -Signature: - -```typescript -neq(other: Constant): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for inequality. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_lite.neq.md#neq_class) - -## Field.neq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is not equal to a constant value. - -```typescript -// Check if the 'country' field is not equal to "USA" -Field.of("country").neq("USA"); - -``` - -Signature: - -```typescript -neq(other: any): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for inequality. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_lite.neq.md#neq_class) - -## Field.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a instance representing the field at the given path. - -The path can be a simple field name (e.g., "name") or a dot-separated path to a nested field (e.g., "address.city"). - -```typescript -// Create a Field instance for the 'title' field -const titleField = Field.of("title"); - -// Create a Field instance for a nested field 'author.firstName' -const authorFirstNameField = Field.of("author.firstName"); - -``` - -Signature: - -```typescript -static of(name: string): Field; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | The path to the field. A new instance representing the specified field. | - -Returns: - -[Field](./firestore_lite.field.md#field_class) - -## Field.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -static of(path: FieldPath): Field; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| path | [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | | - -Returns: - -[Field](./firestore_lite.field.md#field_class) - -## Field.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -static of(pipeline: Pipeline, name: string): Field; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pipeline | [Pipeline](./firestore_lite.pipeline.md#pipeline_class) | | -| name | string | | - -Returns: - -[Field](./firestore_lite.field.md#field_class) - -## Field.regexContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -Field.of("description").regexContains("(?i)example"); - -``` - -Signature: - -```typescript -regexContains(pattern: string): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) - -## Field.regexContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains the regular expression stored in field 'regex' -Field.of("description").regexContains(Field.of("regex")); - -``` - -Signature: - -```typescript -regexContains(pattern: Constant): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) - -## Field.regexMatch() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a valid email pattern -Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - -Signature: - -```typescript -regexMatch(pattern: string): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The regular expression to use for the match. A new Expr representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) - -## Field.regexMatch() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a regular expression stored in field 'regex' -Field.of("email").regexMatch(Field.of("regex")); - -``` - -Signature: - -```typescript -regexMatch(pattern: Constant): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the match. A new Expr representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) - -## Field.replaceAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within this string expression with another substring. - -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field -Field.of("message").replaceAll("hello", "hi"); - -``` - -Signature: - -```typescript -replaceAll(find: string, replace: string): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | string | The substring to search for. | -| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) - -## Field.replaceAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. - -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); - -``` - -Signature: - -```typescript -replaceAll(find: Constant, replace: Constant): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) - -## Field.replaceFirst() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. - -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field -Field.of("message").replaceFirst("hello", "hi"); - -``` - -Signature: - -```typescript -replaceFirst(find: string, replace: string): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | string | The substring to search for. | -| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) - -## Field.replaceFirst() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. - -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); - -``` - -Signature: - -```typescript -replaceFirst(find: Constant, replace: Constant): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) - -## Field.reverse() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that reverses this string expression. - -```typescript -// Reverse the value of the 'myString' field. -Field.of("myString").reverse(); - -``` - A new representing the reversed string. - -Signature: - -```typescript -reverse(): Reverse; -``` -Returns: - -[Reverse](./firestore_lite.reverse.md#reverse_class) - -## Field.startsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string starts with a given prefix. - -```typescript -// Check if the 'name' field starts with "Mr." -Field.of("name").startsWith("Mr."); - -``` - -Signature: - -```typescript -startsWith(prefix: string): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| prefix | string | The prefix to check for. A new Expr representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_lite.startswith.md#startswith_class) - -## Field.startsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string starts with a given prefix (represented as an expression). - -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -Field.of("fullName").startsWith(Field.of("firstName")); - -``` - -Signature: - -```typescript -startsWith(prefix: Constant): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| prefix | [Constant](./firestore_lite.constant.md#constant_class) | The prefix expression to check for. A new Expr representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_lite.startswith.md#startswith_class) - -## Field.strConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates string expressions together. - -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); - -``` - -Signature: - -```typescript -strConcat(...elements: Array): StrConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| elements | Array<string \| [Constant](./firestore_lite.constant.md#constant_class)> | The expressions (typically strings) to concatenate. A new Expr representing the concatenated string. | - -Returns: - -[StrConcat](./firestore_lite.strconcat.md#strconcat_class) - -## Field.strContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified substring. - -```typescript -// Check if the 'description' field contains "example". -Field.of("description").strContains("example"); - -``` - -Signature: - -```typescript -strContains(substring: string): StrContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| substring | string | The substring to search for. A new Expr representing the 'contains' comparison. | - -Returns: - -[StrContains](./firestore_lite.strcontains.md#strcontains_class) - -## Field.strContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains the string represented by another expression. - -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -Field.of("description").strContains(Field.of("keyword")); - -``` - -Signature: - -```typescript -strContains(expr: Constant): StrContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. A new Expr representing the 'contains' comparison. | - -Returns: - -[StrContains](./firestore_lite.strcontains.md#strcontains_class) - -## Field.subtract() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts another expression from this expression. - -```typescript -// Subtract the 'discount' field from the 'price' field -Field.of("price").subtract(Field.of("discount")); - -``` - -Signature: - -```typescript -subtract(other: Constant): Subtract; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to subtract from this expression. A new Expr representing the subtraction operation. | - -Returns: - -[Subtract](./firestore_lite.subtract.md#subtract_class) - -## Field.subtract() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a constant value from this expression. - -```typescript -// Subtract 20 from the value of the 'total' field -Field.of("total").subtract(20); - -``` - -Signature: - -```typescript -subtract(other: any): Subtract; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to subtract. A new Expr representing the subtraction operation. | - -Returns: - -[Subtract](./firestore_lite.subtract.md#subtract_class) - -## Field.sum() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. - -```typescript -// Calculate the total revenue from a set of orders -Field.of("orderAmount").sum().as("totalRevenue"); - -``` - A new `Accumulator` representing the 'sum' aggregation. - -Signature: - -```typescript -sum(): Sum; -``` -Returns: - -[Sum](./firestore_lite.sum.md#sum_class) - -## Field.timestampAdd() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to this timestamp expression. - -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); - -``` - -Signature: - -```typescript -timestampAdd(unit: Constant, amount: Constant): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) - -## Field.timestampAdd() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to this timestamp expression. - -```typescript -// Add 1 day to the 'timestamp' field. -Field.of("timestamp").timestampAdd("day", 1); - -``` - -Signature: - -```typescript -timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | -| amount | number | The amount of time to add. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) - -## Field.timestampSub() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from this timestamp expression. - -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); - -``` - -Signature: - -```typescript -timestampSub(unit: Constant, amount: Constant): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) - -## Field.timestampSub() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from this timestamp expression. - -```typescript -// Subtract 1 day from the 'timestamp' field. -Field.of("timestamp").timestampSub("day", 1); - -``` - -Signature: - -```typescript -timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | -| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) - -## Field.timestampToUnixMicros() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -Field.of("timestamp").timestampToUnixMicros(); - -``` - A new representing the number of microseconds since epoch. - -Signature: - -```typescript -timestampToUnixMicros(): TimestampToUnixMicros; -``` -Returns: - -[TimestampToUnixMicros](./firestore_lite.timestamptounixmicros.md#timestamptounixmicros_class) - -## Field.timestampToUnixMillis() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -Field.of("timestamp").timestampToUnixMillis(); - -``` - A new representing the number of milliseconds since epoch. - -Signature: - -```typescript -timestampToUnixMillis(): TimestampToUnixMillis; -``` -Returns: - -[TimestampToUnixMillis](./firestore_lite.timestamptounixmillis.md#timestamptounixmillis_class) - -## Field.timestampToUnixSeconds() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to seconds since epoch. -Field.of("timestamp").timestampToUnixSeconds(); - -``` - A new representing the number of seconds since epoch. - -Signature: - -```typescript -timestampToUnixSeconds(): TimestampToUnixSeconds; -``` -Returns: - -[TimestampToUnixSeconds](./firestore_lite.timestamptounixseconds.md#timestamptounixseconds_class) - -## Field.toLower() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string to lowercase. - -```typescript -// Convert the 'name' field to lowercase -Field.of("name").toLower(); - -``` - A new `Expr` representing the lowercase string. - -Signature: - -```typescript -toLower(): ToLower; -``` -Returns: - -[ToLower](./firestore_lite.tolower.md#tolower_class) - -## Field.toUpper() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string to uppercase. - -```typescript -// Convert the 'title' field to uppercase -Field.of("title").toUpper(); - -``` - A new `Expr` representing the uppercase string. - -Signature: - -```typescript -toUpper(): ToUpper; -``` -Returns: - -[ToUpper](./firestore_lite.toupper.md#toupper_class) - -## Field.trim() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that removes leading and trailing whitespace from a string. - -```typescript -// Trim whitespace from the 'userInput' field -Field.of("userInput").trim(); - -``` - A new `Expr` representing the trimmed string. - -Signature: - -```typescript -trim(): Trim; -``` -Returns: - -[Trim](./firestore_lite.trim.md#trim_class) - -## Field.unixMicrosToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -Field.of("microseconds").unixMicrosToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixMicrosToTimestamp(): UnixMicrosToTimestamp; -``` -Returns: - -[UnixMicrosToTimestamp](./firestore_lite.unixmicrostotimestamp.md#unixmicrostotimestamp_class) - -## Field.unixMillisToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -Field.of("milliseconds").unixMillisToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixMillisToTimestamp(): UnixMillisToTimestamp; -``` -Returns: - -[UnixMillisToTimestamp](./firestore_lite.unixmillistotimestamp.md#unixmillistotimestamp_class) - -## Field.unixSecondsToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'seconds' field as seconds since epoch. -Field.of("seconds").unixSecondsToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixSecondsToTimestamp(): UnixSecondsToTimestamp; -``` -Returns: - -[UnixSecondsToTimestamp](./firestore_lite.unixsecondstotimestamp.md#unixsecondstotimestamp_class) - -## Field.vectorLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. - -```typescript -// Get the vector length (dimension) of the field 'embedding'. -Field.of("embedding").vectorLength(); - -``` - A new representing the length of the vector. - -Signature: - -```typescript -vectorLength(): VectorLength; -``` -Returns: - -[VectorLength](./firestore_lite.vectorlength.md#vectorlength_class) - diff --git a/docs-devsite/firestore_lite.fields.md b/docs-devsite/firestore_lite.fields.md deleted file mode 100644 index 469b9b6b651..00000000000 --- a/docs-devsite/firestore_lite.fields.md +++ /dev/null @@ -1,3210 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Fields class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Fields implements Selectable -``` -Implements: [Selectable](./firestore_lite.selectable.md#selectable_interface) - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [exprType](./firestore_lite.fields.md#fieldsexprtype) | | [ExprType](./firestore_lite.md#exprtype) | (BETA) | -| [selectable](./firestore_lite.fields.md#fieldsselectable) | | true | (BETA) | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [add(other)](./firestore_lite.fields.md#fieldsadd) | | (BETA) Creates an expression that adds this expression to another expression. -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -Field.of("quantity").add(Field.of("reserve")); - -``` - | -| [add(other)](./firestore_lite.fields.md#fieldsadd) | | (BETA) Creates an expression that adds this expression to a constant value. -```typescript -// Add 5 to the value of the 'age' field -Field.of("age").add(5); - -``` - | -| [arrayConcat(arrays)](./firestore_lite.fields.md#fieldsarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. -```typescript -// Combine the 'items' array with another array field. -Field.of("items").arrayConcat(Field.of("otherItems")); - -``` - | -| [arrayConcat(arrays)](./firestore_lite.fields.md#fieldsarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. -```typescript -// Combine the 'tags' array with a new array and an array field -Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); - -``` - | -| [arrayContains(element)](./firestore_lite.fields.md#fieldsarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific element. -```typescript -// Check if the 'sizes' array contains the value from the 'selectedSize' field -Field.of("sizes").arrayContains(Field.of("selectedSize")); - -``` - | -| [arrayContains(element)](./firestore_lite.fields.md#fieldsarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific value. -```typescript -// Check if the 'colors' array contains "red" -Field.of("colors").arrayContains("red"); - -``` - | -| [arrayContainsAll(values)](./firestore_lite.fields.md#fieldsarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. -```typescript -// Check if the 'tags' array contains both "news" and "sports" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - | -| [arrayContainsAll(values)](./firestore_lite.fields.md#fieldsarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - | -| [arrayContainsAny(values)](./firestore_lite.fields.md#fieldsarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "cate2" -Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); - -``` - | -| [arrayContainsAny(values)](./firestore_lite.fields.md#fieldsarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); - -``` - | -| [arrayLength()](./firestore_lite.fields.md#fieldsarraylength) | | (BETA) Creates an expression that calculates the length of an array. -```typescript -// Get the number of items in the 'cart' array -Field.of("cart").arrayLength(); - -``` - A new Expr representing the length of the array. | -| [as(name)](./firestore_lite.fields.md#fieldsas) | | (BETA) Assigns an alias to this expression.Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. -```typescript -// Calculate the total price and assign it the alias "totalPrice" and add it to the output. -firestore.pipeline().collection("items") -.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); - -``` - | -| [ascending()](./firestore_lite.fields.md#fieldsascending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. -```typescript -// Sort documents by the 'name' field in ascending order -pipeline().collection("users") -.sort(Field.of("name").ascending()); - -``` - A new Ordering for ascending sorting. | -| [avg()](./firestore_lite.fields.md#fieldsavg) | | (BETA) Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. -```typescript -// Calculate the average age of users -Field.of("age").avg().as("averageAge"); - -``` - A new Accumulator representing the 'avg' aggregation. | -| [byteLength()](./firestore_lite.fields.md#fieldsbytelength) | | (BETA) Creates an expression that calculates the length of this string expression in bytes. -```typescript -// Calculate the length of the 'myString' field in bytes. -Field.of("myString").byteLength(); - -``` - A new representing the length of the string in bytes. | -| [charLength()](./firestore_lite.fields.md#fieldscharlength) | | (BETA) Creates an expression that calculates the character length of a string in UTF-8. -```typescript -// Get the character length of the 'name' field in its UTF-8 form. -Field.of("name").charLength(); - -``` - A new Expr representing the length of the string. | -| [cosineDistance(other)](./firestore_lite.fields.md#fieldscosinedistance) | | (BETA) Calculates the cosine distance between two vectors. -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -Field.of("userVector").cosineDistance(Field.of("itemVector")); - -``` - | -| [cosineDistance(other)](./firestore_lite.fields.md#fieldscosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); - -``` - | -| [cosineDistance(other)](./firestore_lite.fields.md#fieldscosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance([37.7749, -122.4194]); - -``` - | -| [count()](./firestore_lite.fields.md#fieldscount) | | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. -```typescript -// Count the total number of products -Field.of("productId").count().as("totalProducts"); - -``` - A new Accumulator representing the 'count' aggregation. | -| [descending()](./firestore_lite.fields.md#fieldsdescending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") -.sort(Field.of("createdAt").descending()); - -``` - A new Ordering for descending sorting. | -| [divide(other)](./firestore_lite.fields.md#fieldsdivide) | | (BETA) Creates an expression that divides this expression by another expression. -```typescript -// Divide the 'total' field by the 'count' field -Field.of("total").divide(Field.of("count")); - -``` - | -| [divide(other)](./firestore_lite.fields.md#fieldsdivide) | | (BETA) Creates an expression that divides this expression by a constant value. -```typescript -// Divide the 'value' field by 10 -Field.of("value").divide(10); - -``` - | -| [dotProduct(other)](./firestore_lite.fields.md#fieldsdotproduct) | | (BETA) Calculates the dot product between two vectors. -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct([0.5, 0.8, 0.2]); - -``` - | -| [dotProduct(other)](./firestore_lite.fields.md#fieldsdotproduct) | | (BETA) Calculates the dot product between two vectors. -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); - -``` - | -| [dotProduct(other)](./firestore_lite.fields.md#fieldsdotproduct) | | (BETA) | -| [endsWith(suffix)](./firestore_lite.fields.md#fieldsendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix. -```typescript -// Check if the 'filename' field ends with ".txt" -Field.of("filename").endsWith(".txt"); - -``` - | -| [endsWith(suffix)](./firestore_lite.fields.md#fieldsendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix (represented as an expression). -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -Field.of("url").endsWith(Field.of("extension")); - -``` - | -| [eq(other)](./firestore_lite.fields.md#fieldseq) | | (BETA) Creates an expression that checks if this expression is equal to another expression. -```typescript -// Check if the 'age' field is equal to 21 -Field.of("age").eq(21); - -``` - | -| [eq(other)](./firestore_lite.fields.md#fieldseq) | | (BETA) Creates an expression that checks if this expression is equal to a constant value. -```typescript -// Check if the 'city' field is equal to "London" -Field.of("city").eq("London"); - -``` - | -| [euclideanDistance(other)](./firestore_lite.fields.md#fieldseuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance([37.7749, -122.4194]); - -``` - | -| [euclideanDistance(other)](./firestore_lite.fields.md#fieldseuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); - -``` - | -| [euclideanDistance(other)](./firestore_lite.fields.md#fieldseuclideandistance) | | (BETA) | -| [exists()](./firestore_lite.fields.md#fieldsexists) | | (BETA) Creates an expression that checks if a field exists in the document. -```typescript -// Check if the document has a field named "phoneNumber" -Field.of("phoneNumber").exists(); - -``` - A new Expr representing the 'exists' check. | -| [fieldList()](./firestore_lite.fields.md#fieldsfieldlist) | | (BETA) | -| [gt(other)](./firestore_lite.fields.md#fieldsgt) | | (BETA) Creates an expression that checks if this expression is greater than another expression. -```typescript -// Check if the 'age' field is greater than the 'limit' field -Field.of("age").gt(Field.of("limit")); - -``` - | -| [gt(other)](./firestore_lite.fields.md#fieldsgt) | | (BETA) Creates an expression that checks if this expression is greater than a constant value. -```typescript -// Check if the 'price' field is greater than 100 -Field.of("price").gt(100); - -``` - | -| [gte(other)](./firestore_lite.fields.md#fieldsgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to another expression. -```typescript -// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 -Field.of("quantity").gte(Field.of('requirement').add(1)); - -``` - | -| [gte(other)](./firestore_lite.fields.md#fieldsgte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to a constant value. -```typescript -// Check if the 'score' field is greater than or equal to 80 -Field.of("score").gte(80); - -``` - | -| [in(others)](./firestore_lite.fields.md#fieldsin) | | (BETA) Creates an expression that checks if this expression is equal to any of the provided values or expressions. -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -Field.of("category").in("Electronics", Field.of("primaryType")); - -``` - | -| [in(others)](./firestore_lite.fields.md#fieldsin) | | (BETA) | -| [isNaN()](./firestore_lite.fields.md#fieldsisnan) | | (BETA) Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). -```typescript -// Check if the result of a calculation is NaN -Field.of("value").divide(0).isNaN(); - -``` - A new Expr representing the 'isNaN' check. | -| [like(pattern)](./firestore_lite.fields.md#fieldslike) | | (BETA) Creates an expression that performs a case-sensitive string comparison. -```typescript -// Check if the 'title' field contains the word "guide" (case-sensitive) -Field.of("title").like("%guide%"); - -``` - | -| [like(pattern)](./firestore_lite.fields.md#fieldslike) | | (BETA) | -| [logicalMax(other)](./firestore_lite.fields.md#fieldslogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMax(Function.currentTimestamp()); - -``` - | -| [logicalMax(other)](./firestore_lite.fields.md#fieldslogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'value' field and 10. -Field.of("value").logicalMax(10); - -``` - | -| [logicalMin(other)](./firestore_lite.fields.md#fieldslogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMin(Function.currentTimestamp()); - -``` - | -| [logicalMin(other)](./firestore_lite.fields.md#fieldslogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'value' field and 10. -Field.of("value").logicalMin(10); - -``` - | -| [lt(other)](./firestore_lite.fields.md#fieldslt) | | (BETA) Creates an expression that checks if this expression is less than another expression. -```typescript -// Check if the 'age' field is less than 'limit' -Field.of("age").lt(Field.of('limit')); - -``` - | -| [lt(other)](./firestore_lite.fields.md#fieldslt) | | (BETA) Creates an expression that checks if this expression is less than a constant value. -```typescript -// Check if the 'price' field is less than 50 -Field.of("price").lt(50); - -``` - | -| [lte(other)](./firestore_lite.fields.md#fieldslte) | | (BETA) Creates an expression that checks if this expression is less than or equal to another expression. -```typescript -// Check if the 'quantity' field is less than or equal to 20 -Field.of("quantity").lte(Constant.of(20)); - -``` - | -| [lte(other)](./firestore_lite.fields.md#fieldslte) | | (BETA) Creates an expression that checks if this expression is less than or equal to a constant value. -```typescript -// Check if the 'score' field is less than or equal to 70 -Field.of("score").lte(70); - -``` - | -| [mapGet(subfield)](./firestore_lite.fields.md#fieldsmapget) | | (BETA) Accesses a value from a map (object) field using the provided key. -```typescript -// Get the 'city' value from the 'address' map field -Field.of("address").mapGet("city"); - -``` - | -| [max()](./firestore_lite.fields.md#fieldsmax) | | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. -```typescript -// Find the highest score in a leaderboard -Field.of("score").max().as("highestScore"); - -``` - A new Accumulator representing the 'max' aggregation. | -| [min()](./firestore_lite.fields.md#fieldsmin) | | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. -```typescript -// Find the lowest price of all products -Field.of("price").min().as("lowestPrice"); - -``` - A new Accumulator representing the 'min' aggregation. | -| [mod(other)](./firestore_lite.fields.md#fieldsmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. -```typescript -// Calculate the remainder of dividing the 'value' field by the 'divisor' field -Field.of("value").mod(Field.of("divisor")); - -``` - | -| [mod(other)](./firestore_lite.fields.md#fieldsmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. -```typescript -// Calculate the remainder of dividing the 'value' field by 10 -Field.of("value").mod(10); - -``` - | -| [multiply(other)](./firestore_lite.fields.md#fieldsmultiply) | | (BETA) Creates an expression that multiplies this expression by another expression. -```typescript -// Multiply the 'quantity' field by the 'price' field -Field.of("quantity").multiply(Field.of("price")); - -``` - | -| [multiply(other)](./firestore_lite.fields.md#fieldsmultiply) | | (BETA) Creates an expression that multiplies this expression by a constant value. -```typescript -// Multiply the 'value' field by 2 -Field.of("value").multiply(2); - -``` - | -| [neq(other)](./firestore_lite.fields.md#fieldsneq) | | (BETA) Creates an expression that checks if this expression is not equal to another expression. -```typescript -// Check if the 'status' field is not equal to "completed" -Field.of("status").neq("completed"); - -``` - | -| [neq(other)](./firestore_lite.fields.md#fieldsneq) | | (BETA) Creates an expression that checks if this expression is not equal to a constant value. -```typescript -// Check if the 'country' field is not equal to "USA" -Field.of("country").neq("USA"); - -``` - | -| [of(name, others)](./firestore_lite.fields.md#fieldsof) | static | (BETA) | -| [ofAll()](./firestore_lite.fields.md#fieldsofall) | static | (BETA) | -| [regexContains(pattern)](./firestore_lite.fields.md#fieldsregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -Field.of("description").regexContains("(?i)example"); - -``` - | -| [regexContains(pattern)](./firestore_lite.fields.md#fieldsregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains the regular expression stored in field 'regex' -Field.of("description").regexContains(Field.of("regex")); - -``` - | -| [regexMatch(pattern)](./firestore_lite.fields.md#fieldsregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. -```typescript -// Check if the 'email' field matches a valid email pattern -Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - | -| [regexMatch(pattern)](./firestore_lite.fields.md#fieldsregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. -```typescript -// Check if the 'email' field matches a regular expression stored in field 'regex' -Field.of("email").regexMatch(Field.of("regex")); - -``` - | -| [replaceAll(find, replace)](./firestore_lite.fields.md#fieldsreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring. -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field -Field.of("message").replaceAll("hello", "hi"); - -``` - | -| [replaceAll(find, replace)](./firestore_lite.fields.md#fieldsreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); - -``` - | -| [replaceFirst(find, replace)](./firestore_lite.fields.md#fieldsreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field -Field.of("message").replaceFirst("hello", "hi"); - -``` - | -| [replaceFirst(find, replace)](./firestore_lite.fields.md#fieldsreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); - -``` - | -| [reverse()](./firestore_lite.fields.md#fieldsreverse) | | (BETA) Creates an expression that reverses this string expression. -```typescript -// Reverse the value of the 'myString' field. -Field.of("myString").reverse(); - -``` - A new representing the reversed string. | -| [startsWith(prefix)](./firestore_lite.fields.md#fieldsstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix. -```typescript -// Check if the 'name' field starts with "Mr." -Field.of("name").startsWith("Mr."); - -``` - | -| [startsWith(prefix)](./firestore_lite.fields.md#fieldsstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix (represented as an expression). -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -Field.of("fullName").startsWith(Field.of("firstName")); - -``` - | -| [strConcat(elements)](./firestore_lite.fields.md#fieldsstrconcat) | | (BETA) Creates an expression that concatenates string expressions together. -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); - -``` - | -| [strContains(substring)](./firestore_lite.fields.md#fieldsstrcontains) | | (BETA) Creates an expression that checks if a string contains a specified substring. -```typescript -// Check if the 'description' field contains "example". -Field.of("description").strContains("example"); - -``` - | -| [strContains(expr)](./firestore_lite.fields.md#fieldsstrcontains) | | (BETA) Creates an expression that checks if a string contains the string represented by another expression. -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -Field.of("description").strContains(Field.of("keyword")); - -``` - | -| [subtract(other)](./firestore_lite.fields.md#fieldssubtract) | | (BETA) Creates an expression that subtracts another expression from this expression. -```typescript -// Subtract the 'discount' field from the 'price' field -Field.of("price").subtract(Field.of("discount")); - -``` - | -| [subtract(other)](./firestore_lite.fields.md#fieldssubtract) | | (BETA) Creates an expression that subtracts a constant value from this expression. -```typescript -// Subtract 20 from the value of the 'total' field -Field.of("total").subtract(20); - -``` - | -| [sum()](./firestore_lite.fields.md#fieldssum) | | (BETA) Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. -```typescript -// Calculate the total revenue from a set of orders -Field.of("orderAmount").sum().as("totalRevenue"); - -``` - A new Accumulator representing the 'sum' aggregation. | -| [timestampAdd(unit, amount)](./firestore_lite.fields.md#fieldstimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampAdd(unit, amount)](./firestore_lite.fields.md#fieldstimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. -```typescript -// Add 1 day to the 'timestamp' field. -Field.of("timestamp").timestampAdd("day", 1); - -``` - | -| [timestampSub(unit, amount)](./firestore_lite.fields.md#fieldstimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampSub(unit, amount)](./firestore_lite.fields.md#fieldstimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. -```typescript -// Subtract 1 day from the 'timestamp' field. -Field.of("timestamp").timestampSub("day", 1); - -``` - | -| [timestampToUnixMicros()](./firestore_lite.fields.md#fieldstimestamptounixmicros) | | (BETA) Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -Field.of("timestamp").timestampToUnixMicros(); - -``` - A new representing the number of microseconds since epoch. | -| [timestampToUnixMillis()](./firestore_lite.fields.md#fieldstimestamptounixmillis) | | (BETA) Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -Field.of("timestamp").timestampToUnixMillis(); - -``` - A new representing the number of milliseconds since epoch. | -| [timestampToUnixSeconds()](./firestore_lite.fields.md#fieldstimestamptounixseconds) | | (BETA) Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to seconds since epoch. -Field.of("timestamp").timestampToUnixSeconds(); - -``` - A new representing the number of seconds since epoch. | -| [toLower()](./firestore_lite.fields.md#fieldstolower) | | (BETA) Creates an expression that converts a string to lowercase. -```typescript -// Convert the 'name' field to lowercase -Field.of("name").toLower(); - -``` - A new Expr representing the lowercase string. | -| [toUpper()](./firestore_lite.fields.md#fieldstoupper) | | (BETA) Creates an expression that converts a string to uppercase. -```typescript -// Convert the 'title' field to uppercase -Field.of("title").toUpper(); - -``` - A new Expr representing the uppercase string. | -| [trim()](./firestore_lite.fields.md#fieldstrim) | | (BETA) Creates an expression that removes leading and trailing whitespace from a string. -```typescript -// Trim whitespace from the 'userInput' field -Field.of("userInput").trim(); - -``` - A new Expr representing the trimmed string. | -| [unixMicrosToTimestamp()](./firestore_lite.fields.md#fieldsunixmicrostotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -Field.of("microseconds").unixMicrosToTimestamp(); - -``` - A new representing the timestamp. | -| [unixMillisToTimestamp()](./firestore_lite.fields.md#fieldsunixmillistotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -Field.of("milliseconds").unixMillisToTimestamp(); - -``` - A new representing the timestamp. | -| [unixSecondsToTimestamp()](./firestore_lite.fields.md#fieldsunixsecondstotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'seconds' field as seconds since epoch. -Field.of("seconds").unixSecondsToTimestamp(); - -``` - A new representing the timestamp. | -| [vectorLength()](./firestore_lite.fields.md#fieldsvectorlength) | | (BETA) Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. -```typescript -// Get the vector length (dimension) of the field 'embedding'. -Field.of("embedding").vectorLength(); - -``` - A new representing the length of the vector. | - -## Fields.exprType - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -exprType: ExprType; -``` - -## Fields.selectable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -selectable: true; -``` - -## Fields.add() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds this expression to another expression. - -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -Field.of("quantity").add(Field.of("reserve")); - -``` - -Signature: - -```typescript -add(other: Constant): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to add to this expression. A new Expr representing the addition operation. | - -Returns: - -[Add](./firestore_lite.add.md#add_class) - -## Fields.add() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds this expression to a constant value. - -```typescript -// Add 5 to the value of the 'age' field -Field.of("age").add(5); - -``` - -Signature: - -```typescript -add(other: any): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to add. A new Expr representing the addition operation. | - -Returns: - -[Add](./firestore_lite.add.md#add_class) - -## Fields.arrayConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with one or more other arrays. - -```typescript -// Combine the 'items' array with another array field. -Field.of("items").arrayConcat(Field.of("otherItems")); - -``` - -Signature: - -```typescript -arrayConcat(arrays: Constant[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| arrays | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The array expressions to concatenate. A new Expr representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) - -## Fields.arrayConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with one or more other arrays. - -```typescript -// Combine the 'tags' array with a new array and an array field -Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); - -``` - -Signature: - -```typescript -arrayConcat(arrays: any[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| arrays | any\[\] | The array expressions or values to concatenate. A new Expr representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) - -## Fields.arrayContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains a specific element. - -```typescript -// Check if the 'sizes' array contains the value from the 'selectedSize' field -Field.of("sizes").arrayContains(Field.of("selectedSize")); - -``` - -Signature: - -```typescript -arrayContains(element: Constant): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | [Constant](./firestore_lite.constant.md#constant_class) | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) - -## Fields.arrayContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains a specific value. - -```typescript -// Check if the 'colors' array contains "red" -Field.of("colors").arrayContains("red"); - -``` - -Signature: - -```typescript -arrayContains(element: any): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | any | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) - -## Fields.arrayContainsAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both "news" and "sports" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - -Signature: - -```typescript -arrayContainsAll(...values: Constant[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) - -## Fields.arrayContainsAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - -Signature: - -```typescript -arrayContainsAll(...values: any[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) - -## Fields.arrayContainsAny() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains any of the specified elements. - -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "cate2" -Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); - -``` - -Signature: - -```typescript -arrayContainsAny(...values: Constant[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) - -## Fields.arrayContainsAny() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains any of the specified elements. - -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); - -``` - -Signature: - -```typescript -arrayContainsAny(...values: any[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) - -## Fields.arrayLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of an array. - -```typescript -// Get the number of items in the 'cart' array -Field.of("cart").arrayLength(); - -``` - A new `Expr` representing the length of the array. - -Signature: - -```typescript -arrayLength(): ArrayLength; -``` -Returns: - -[ArrayLength](./firestore_lite.arraylength.md#arraylength_class) - -## Fields.as() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Assigns an alias to this expression. - -Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. - -```typescript -// Calculate the total price and assign it the alias "totalPrice" and add it to the output. -firestore.pipeline().collection("items") -.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); - -``` - -Signature: - -```typescript -as(name: string): ExprWithAlias; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | The alias to assign to this expression. A new [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) that wraps this expression and associates it with the provided alias. | - -Returns: - -[ExprWithAlias](./firestore_lite.exprwithalias.md#exprwithalias_class)<this> - -## Fields.ascending() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. - -```typescript -// Sort documents by the 'name' field in ascending order -pipeline().collection("users") -.sort(Field.of("name").ascending()); - -``` - A new `Ordering` for ascending sorting. - -Signature: - -```typescript -ascending(): Ordering; -``` -Returns: - -[Ordering](./firestore_lite.ordering.md#ordering_class) - -## Fields.avg() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. - -```typescript -// Calculate the average age of users -Field.of("age").avg().as("averageAge"); - -``` - A new `Accumulator` representing the 'avg' aggregation. - -Signature: - -```typescript -avg(): Avg; -``` -Returns: - -[Avg](./firestore_lite.avg.md#avg_class) - -## Fields.byteLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of this string expression in bytes. - -```typescript -// Calculate the length of the 'myString' field in bytes. -Field.of("myString").byteLength(); - -``` - A new representing the length of the string in bytes. - -Signature: - -```typescript -byteLength(): ByteLength; -``` -Returns: - -[ByteLength](./firestore_lite.bytelength.md#bytelength_class) - -## Fields.charLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the character length of a string in UTF-8. - -```typescript -// Get the character length of the 'name' field in its UTF-8 form. -Field.of("name").charLength(); - -``` - A new `Expr` representing the length of the string. - -Signature: - -```typescript -charLength(): CharLength; -``` -Returns: - -[CharLength](./firestore_lite.charlength.md#charlength_class) - -## Fields.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the cosine distance between two vectors. - -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -Field.of("userVector").cosineDistance(Field.of("itemVector")); - -``` - -Signature: - -```typescript -cosineDistance(other: Constant): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new Expr representing the cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) - -## Fields.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vectors. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -cosineDistance(other: VectorValue): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) - -## Fields.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vectors. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance([37.7749, -122.4194]); - -``` - -Signature: - -```typescript -cosineDistance(other: number[]): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | The other vector (as an array of numbers) to compare against. A new Expr representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) - -## Fields.count() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. - -```typescript -// Count the total number of products -Field.of("productId").count().as("totalProducts"); - -``` - A new `Accumulator` representing the 'count' aggregation. - -Signature: - -```typescript -count(): Count; -``` -Returns: - -[Count](./firestore_lite.count.md#count_class) - -## Fields.descending() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. - -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") -.sort(Field.of("createdAt").descending()); - -``` - A new `Ordering` for descending sorting. - -Signature: - -```typescript -descending(): Ordering; -``` -Returns: - -[Ordering](./firestore_lite.ordering.md#ordering_class) - -## Fields.divide() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides this expression by another expression. - -```typescript -// Divide the 'total' field by the 'count' field -Field.of("total").divide(Field.of("count")); - -``` - -Signature: - -```typescript -divide(other: Constant): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new Expr representing the division operation. | - -Returns: - -[Divide](./firestore_lite.divide.md#divide_class) - -## Fields.divide() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides this expression by a constant value. - -```typescript -// Divide the 'value' field by 10 -Field.of("value").divide(10); - -``` - -Signature: - -```typescript -divide(other: any): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to divide by. A new Expr representing the division operation. | - -Returns: - -[Divide](./firestore_lite.divide.md#divide_class) - -## Fields.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vectors. - -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct([0.5, 0.8, 0.2]); - -``` - -Signature: - -```typescript -dotProduct(other: Constant): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) - -## Fields.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vectors. - -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); - -``` - -Signature: - -```typescript -dotProduct(other: VectorValue): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) - -## Fields.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -dotProduct(other: number[]): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | | - -Returns: - -[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) - -## Fields.endsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string ends with a given postfix. - -```typescript -// Check if the 'filename' field ends with ".txt" -Field.of("filename").endsWith(".txt"); - -``` - -Signature: - -```typescript -endsWith(suffix: string): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| suffix | string | The postfix to check for. A new Expr representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_lite.endswith.md#endswith_class) - -## Fields.endsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string ends with a given postfix (represented as an expression). - -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -Field.of("url").endsWith(Field.of("extension")); - -``` - -Signature: - -```typescript -endsWith(suffix: Constant): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| suffix | [Constant](./firestore_lite.constant.md#constant_class) | The postfix expression to check for. A new Expr representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_lite.endswith.md#endswith_class) - -## Fields.eq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to another expression. - -```typescript -// Check if the 'age' field is equal to 21 -Field.of("age").eq(21); - -``` - -Signature: - -```typescript -eq(other: Constant): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for equality. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_lite.eq.md#eq_class) - -## Fields.eq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to a constant value. - -```typescript -// Check if the 'city' field is equal to "London" -Field.of("city").eq("London"); - -``` - -Signature: - -```typescript -eq(other: any): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for equality. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_lite.eq.md#eq_class) - -## Fields.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vectors. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance([37.7749, -122.4194]); - -``` - -Signature: - -```typescript -euclideanDistance(other: Constant): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) - -## Fields.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vectors. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -euclideanDistance(other: VectorValue): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) - -## Fields.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -euclideanDistance(other: number[]): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | | - -Returns: - -[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) - -## Fields.exists() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field exists in the document. - -```typescript -// Check if the document has a field named "phoneNumber" -Field.of("phoneNumber").exists(); - -``` - A new `Expr` representing the 'exists' check. - -Signature: - -```typescript -exists(): Exists; -``` -Returns: - -[Exists](./firestore_lite.exists.md#exists_class) - -## Fields.fieldList() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -fieldList(): Field[]; -``` -Returns: - -[Field](./firestore_lite.field.md#field_class)\[\] - -## Fields.gt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than another expression. - -```typescript -// Check if the 'age' field is greater than the 'limit' field -Field.of("age").gt(Field.of("limit")); - -``` - -Signature: - -```typescript -gt(other: Constant): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for greater than. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_lite.gt.md#gt_class) - -## Fields.gt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than a constant value. - -```typescript -// Check if the 'price' field is greater than 100 -Field.of("price").gt(100); - -``` - -Signature: - -```typescript -gt(other: any): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for greater than. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_lite.gt.md#gt_class) - -## Fields.gte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than or equal to another expression. - -```typescript -// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 -Field.of("quantity").gte(Field.of('requirement').add(1)); - -``` - -Signature: - -```typescript -gte(other: Constant): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_lite.gte.md#gte_class) - -## Fields.gte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than or equal to a constant value. - -```typescript -// Check if the 'score' field is greater than or equal to 80 -Field.of("score").gte(80); - -``` - -Signature: - -```typescript -gte(other: any): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_lite.gte.md#gte_class) - -## Fields.in() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to any of the provided values or expressions. - -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -Field.of("category").in("Electronics", Field.of("primaryType")); - -``` - -Signature: - -```typescript -in(...others: Constant[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| others | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The values or expressions to check against. A new Expr representing the 'IN' comparison. | - -Returns: - -[In](./firestore_lite.in.md#in_class) - -## Fields.in() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -in(...others: any[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| others | any\[\] | | - -Returns: - -[In](./firestore_lite.in.md#in_class) - -## Fields.isNaN() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). - -```typescript -// Check if the result of a calculation is NaN -Field.of("value").divide(0).isNaN(); - -``` - A new `Expr` representing the 'isNaN' check. - -Signature: - -```typescript -isNaN(): IsNan; -``` -Returns: - -[IsNan](./firestore_lite.isnan.md#isnan_class) - -## Fields.like() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that performs a case-sensitive string comparison. - -```typescript -// Check if the 'title' field contains the word "guide" (case-sensitive) -Field.of("title").like("%guide%"); - -``` - -Signature: - -```typescript -like(pattern: string): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new Expr representing the 'like' comparison. | - -Returns: - -[Like](./firestore_lite.like.md#like_class) - -## Fields.like() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -like(pattern: Constant): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | | - -Returns: - -[Like](./firestore_lite.like.md#like_class) - -## Fields.logicalMax() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMax(Function.currentTimestamp()); - -``` - -Signature: - -```typescript -logicalMax(other: Constant): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare with. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) - -## Fields.logicalMax() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'value' field and 10. -Field.of("value").logicalMax(10); - -``` - -Signature: - -```typescript -logicalMax(other: any): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare with. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) - -## Fields.logicalMin() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMin(Function.currentTimestamp()); - -``` - -Signature: - -```typescript -logicalMin(other: Constant): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare with. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) - -## Fields.logicalMin() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'value' field and 10. -Field.of("value").logicalMin(10); - -``` - -Signature: - -```typescript -logicalMin(other: any): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare with. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) - -## Fields.lt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than another expression. - -```typescript -// Check if the 'age' field is less than 'limit' -Field.of("age").lt(Field.of('limit')); - -``` - -Signature: - -```typescript -lt(other: Constant): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for less than. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_lite.lt.md#lt_class) - -## Fields.lt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than a constant value. - -```typescript -// Check if the 'price' field is less than 50 -Field.of("price").lt(50); - -``` - -Signature: - -```typescript -lt(other: any): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for less than. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_lite.lt.md#lt_class) - -## Fields.lte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than or equal to another expression. - -```typescript -// Check if the 'quantity' field is less than or equal to 20 -Field.of("quantity").lte(Constant.of(20)); - -``` - -Signature: - -```typescript -lte(other: Constant): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_lite.lte.md#lte_class) - -## Fields.lte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than or equal to a constant value. - -```typescript -// Check if the 'score' field is less than or equal to 70 -Field.of("score").lte(70); - -``` - -Signature: - -```typescript -lte(other: any): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_lite.lte.md#lte_class) - -## Fields.mapGet() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Accesses a value from a map (object) field using the provided key. - -```typescript -// Get the 'city' value from the 'address' map field -Field.of("address").mapGet("city"); - -``` - -Signature: - -```typescript -mapGet(subfield: string): MapGet; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| subfield | string | The key to access in the map. A new Expr representing the value associated with the given key in the map. | - -Returns: - -[MapGet](./firestore_lite.mapget.md#mapget_class) - -## Fields.max() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that finds the maximum value of a field across multiple stage inputs. - -```typescript -// Find the highest score in a leaderboard -Field.of("score").max().as("highestScore"); - -``` - A new `Accumulator` representing the 'max' aggregation. - -Signature: - -```typescript -max(): Max; -``` -Returns: - -[Max](./firestore_lite.max.md#max_class) - -## Fields.min() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that finds the minimum value of a field across multiple stage inputs. - -```typescript -// Find the lowest price of all products -Field.of("price").min().as("lowestPrice"); - -``` - A new `Accumulator` representing the 'min' aggregation. - -Signature: - -```typescript -min(): Min; -``` -Returns: - -[Min](./firestore_lite.min.md#min_class) - -## Fields.mod() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. - -```typescript -// Calculate the remainder of dividing the 'value' field by the 'divisor' field -Field.of("value").mod(Field.of("divisor")); - -``` - -Signature: - -```typescript -mod(other: Constant): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new Expr representing the modulo operation. | - -Returns: - -[Mod](./firestore_lite.mod.md#mod_class) - -## Fields.mod() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. - -```typescript -// Calculate the remainder of dividing the 'value' field by 10 -Field.of("value").mod(10); - -``` - -Signature: - -```typescript -mod(other: any): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to divide by. A new Expr representing the modulo operation. | - -Returns: - -[Mod](./firestore_lite.mod.md#mod_class) - -## Fields.multiply() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies this expression by another expression. - -```typescript -// Multiply the 'quantity' field by the 'price' field -Field.of("quantity").multiply(Field.of("price")); - -``` - -Signature: - -```typescript -multiply(other: Constant): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to multiply by. A new Expr representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_lite.multiply.md#multiply_class) - -## Fields.multiply() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies this expression by a constant value. - -```typescript -// Multiply the 'value' field by 2 -Field.of("value").multiply(2); - -``` - -Signature: - -```typescript -multiply(other: any): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to multiply by. A new Expr representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_lite.multiply.md#multiply_class) - -## Fields.neq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is not equal to another expression. - -```typescript -// Check if the 'status' field is not equal to "completed" -Field.of("status").neq("completed"); - -``` - -Signature: - -```typescript -neq(other: Constant): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for inequality. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_lite.neq.md#neq_class) - -## Fields.neq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is not equal to a constant value. - -```typescript -// Check if the 'country' field is not equal to "USA" -Field.of("country").neq("USA"); - -``` - -Signature: - -```typescript -neq(other: any): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for inequality. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_lite.neq.md#neq_class) - -## Fields.of() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -static of(name: string, ...others: string[]): Fields; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | | -| others | string\[\] | | - -Returns: - -[Fields](./firestore_lite.fields.md#fields_class) - -## Fields.ofAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -static ofAll(): Fields; -``` -Returns: - -[Fields](./firestore_lite.fields.md#fields_class) - -## Fields.regexContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -Field.of("description").regexContains("(?i)example"); - -``` - -Signature: - -```typescript -regexContains(pattern: string): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) - -## Fields.regexContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains the regular expression stored in field 'regex' -Field.of("description").regexContains(Field.of("regex")); - -``` - -Signature: - -```typescript -regexContains(pattern: Constant): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) - -## Fields.regexMatch() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a valid email pattern -Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - -Signature: - -```typescript -regexMatch(pattern: string): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The regular expression to use for the match. A new Expr representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) - -## Fields.regexMatch() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a regular expression stored in field 'regex' -Field.of("email").regexMatch(Field.of("regex")); - -``` - -Signature: - -```typescript -regexMatch(pattern: Constant): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the match. A new Expr representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) - -## Fields.replaceAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within this string expression with another substring. - -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field -Field.of("message").replaceAll("hello", "hi"); - -``` - -Signature: - -```typescript -replaceAll(find: string, replace: string): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | string | The substring to search for. | -| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) - -## Fields.replaceAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. - -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); - -``` - -Signature: - -```typescript -replaceAll(find: Constant, replace: Constant): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) - -## Fields.replaceFirst() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. - -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field -Field.of("message").replaceFirst("hello", "hi"); - -``` - -Signature: - -```typescript -replaceFirst(find: string, replace: string): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | string | The substring to search for. | -| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) - -## Fields.replaceFirst() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. - -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); - -``` - -Signature: - -```typescript -replaceFirst(find: Constant, replace: Constant): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) - -## Fields.reverse() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that reverses this string expression. - -```typescript -// Reverse the value of the 'myString' field. -Field.of("myString").reverse(); - -``` - A new representing the reversed string. - -Signature: - -```typescript -reverse(): Reverse; -``` -Returns: - -[Reverse](./firestore_lite.reverse.md#reverse_class) - -## Fields.startsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string starts with a given prefix. - -```typescript -// Check if the 'name' field starts with "Mr." -Field.of("name").startsWith("Mr."); - -``` - -Signature: - -```typescript -startsWith(prefix: string): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| prefix | string | The prefix to check for. A new Expr representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_lite.startswith.md#startswith_class) - -## Fields.startsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string starts with a given prefix (represented as an expression). - -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -Field.of("fullName").startsWith(Field.of("firstName")); - -``` - -Signature: - -```typescript -startsWith(prefix: Constant): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| prefix | [Constant](./firestore_lite.constant.md#constant_class) | The prefix expression to check for. A new Expr representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_lite.startswith.md#startswith_class) - -## Fields.strConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates string expressions together. - -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); - -``` - -Signature: - -```typescript -strConcat(...elements: Array): StrConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| elements | Array<string \| [Constant](./firestore_lite.constant.md#constant_class)> | The expressions (typically strings) to concatenate. A new Expr representing the concatenated string. | - -Returns: - -[StrConcat](./firestore_lite.strconcat.md#strconcat_class) - -## Fields.strContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified substring. - -```typescript -// Check if the 'description' field contains "example". -Field.of("description").strContains("example"); - -``` - -Signature: - -```typescript -strContains(substring: string): StrContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| substring | string | The substring to search for. A new Expr representing the 'contains' comparison. | - -Returns: - -[StrContains](./firestore_lite.strcontains.md#strcontains_class) - -## Fields.strContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains the string represented by another expression. - -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -Field.of("description").strContains(Field.of("keyword")); - -``` - -Signature: - -```typescript -strContains(expr: Constant): StrContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. A new Expr representing the 'contains' comparison. | - -Returns: - -[StrContains](./firestore_lite.strcontains.md#strcontains_class) - -## Fields.subtract() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts another expression from this expression. - -```typescript -// Subtract the 'discount' field from the 'price' field -Field.of("price").subtract(Field.of("discount")); - -``` - -Signature: - -```typescript -subtract(other: Constant): Subtract; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to subtract from this expression. A new Expr representing the subtraction operation. | - -Returns: - -[Subtract](./firestore_lite.subtract.md#subtract_class) - -## Fields.subtract() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a constant value from this expression. - -```typescript -// Subtract 20 from the value of the 'total' field -Field.of("total").subtract(20); - -``` - -Signature: - -```typescript -subtract(other: any): Subtract; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to subtract. A new Expr representing the subtraction operation. | - -Returns: - -[Subtract](./firestore_lite.subtract.md#subtract_class) - -## Fields.sum() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. - -```typescript -// Calculate the total revenue from a set of orders -Field.of("orderAmount").sum().as("totalRevenue"); - -``` - A new `Accumulator` representing the 'sum' aggregation. - -Signature: - -```typescript -sum(): Sum; -``` -Returns: - -[Sum](./firestore_lite.sum.md#sum_class) - -## Fields.timestampAdd() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to this timestamp expression. - -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); - -``` - -Signature: - -```typescript -timestampAdd(unit: Constant, amount: Constant): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) - -## Fields.timestampAdd() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to this timestamp expression. - -```typescript -// Add 1 day to the 'timestamp' field. -Field.of("timestamp").timestampAdd("day", 1); - -``` - -Signature: - -```typescript -timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | -| amount | number | The amount of time to add. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) - -## Fields.timestampSub() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from this timestamp expression. - -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); - -``` - -Signature: - -```typescript -timestampSub(unit: Constant, amount: Constant): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) - -## Fields.timestampSub() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from this timestamp expression. - -```typescript -// Subtract 1 day from the 'timestamp' field. -Field.of("timestamp").timestampSub("day", 1); - -``` - -Signature: - -```typescript -timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | -| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) - -## Fields.timestampToUnixMicros() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -Field.of("timestamp").timestampToUnixMicros(); - -``` - A new representing the number of microseconds since epoch. - -Signature: - -```typescript -timestampToUnixMicros(): TimestampToUnixMicros; -``` -Returns: - -[TimestampToUnixMicros](./firestore_lite.timestamptounixmicros.md#timestamptounixmicros_class) - -## Fields.timestampToUnixMillis() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -Field.of("timestamp").timestampToUnixMillis(); - -``` - A new representing the number of milliseconds since epoch. - -Signature: - -```typescript -timestampToUnixMillis(): TimestampToUnixMillis; -``` -Returns: - -[TimestampToUnixMillis](./firestore_lite.timestamptounixmillis.md#timestamptounixmillis_class) - -## Fields.timestampToUnixSeconds() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to seconds since epoch. -Field.of("timestamp").timestampToUnixSeconds(); - -``` - A new representing the number of seconds since epoch. - -Signature: - -```typescript -timestampToUnixSeconds(): TimestampToUnixSeconds; -``` -Returns: - -[TimestampToUnixSeconds](./firestore_lite.timestamptounixseconds.md#timestamptounixseconds_class) - -## Fields.toLower() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string to lowercase. - -```typescript -// Convert the 'name' field to lowercase -Field.of("name").toLower(); - -``` - A new `Expr` representing the lowercase string. - -Signature: - -```typescript -toLower(): ToLower; -``` -Returns: - -[ToLower](./firestore_lite.tolower.md#tolower_class) - -## Fields.toUpper() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string to uppercase. - -```typescript -// Convert the 'title' field to uppercase -Field.of("title").toUpper(); - -``` - A new `Expr` representing the uppercase string. - -Signature: - -```typescript -toUpper(): ToUpper; -``` -Returns: - -[ToUpper](./firestore_lite.toupper.md#toupper_class) - -## Fields.trim() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that removes leading and trailing whitespace from a string. - -```typescript -// Trim whitespace from the 'userInput' field -Field.of("userInput").trim(); - -``` - A new `Expr` representing the trimmed string. - -Signature: - -```typescript -trim(): Trim; -``` -Returns: - -[Trim](./firestore_lite.trim.md#trim_class) - -## Fields.unixMicrosToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -Field.of("microseconds").unixMicrosToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixMicrosToTimestamp(): UnixMicrosToTimestamp; -``` -Returns: - -[UnixMicrosToTimestamp](./firestore_lite.unixmicrostotimestamp.md#unixmicrostotimestamp_class) - -## Fields.unixMillisToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -Field.of("milliseconds").unixMillisToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixMillisToTimestamp(): UnixMillisToTimestamp; -``` -Returns: - -[UnixMillisToTimestamp](./firestore_lite.unixmillistotimestamp.md#unixmillistotimestamp_class) - -## Fields.unixSecondsToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'seconds' field as seconds since epoch. -Field.of("seconds").unixSecondsToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixSecondsToTimestamp(): UnixSecondsToTimestamp; -``` -Returns: - -[UnixSecondsToTimestamp](./firestore_lite.unixsecondstotimestamp.md#unixsecondstotimestamp_class) - -## Fields.vectorLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. - -```typescript -// Get the vector length (dimension) of the field 'embedding'. -Field.of("embedding").vectorLength(); - -``` - A new representing the length of the vector. - -Signature: - -```typescript -vectorLength(): VectorLength; -``` -Returns: - -[VectorLength](./firestore_lite.vectorlength.md#vectorlength_class) - diff --git a/docs-devsite/firestore_lite.filtercondition.md b/docs-devsite/firestore_lite.filtercondition.md deleted file mode 100644 index 3f638859319..00000000000 --- a/docs-devsite/firestore_lite.filtercondition.md +++ /dev/null @@ -1,39 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# FilterCondition interface -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -An interface that represents a filter condition. - -Signature: - -```typescript -export declare interface FilterCondition -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [filterable](./firestore_lite.filtercondition.md#filterconditionfilterable) | true | (BETA) | - -## FilterCondition.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.findnearest.md b/docs-devsite/firestore_lite.findnearest.md deleted file mode 100644 index a0fe60cb31e..00000000000 --- a/docs-devsite/firestore_lite.findnearest.md +++ /dev/null @@ -1,39 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# FindNearest class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class FindNearest implements Stage -``` -Implements: [Stage](./firestore_lite.stage.md#stage_interface) - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_lite.findnearest.md#findnearestname) | | string | (BETA) | - -## FindNearest.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_lite.findnearestoptions.md b/docs-devsite/firestore_lite.findnearestoptions.md deleted file mode 100644 index fe142b4a8d4..00000000000 --- a/docs-devsite/firestore_lite.findnearestoptions.md +++ /dev/null @@ -1,86 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# FindNearestOptions interface -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare interface FindNearestOptions -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [distanceField](./firestore_lite.findnearestoptions.md#findnearestoptionsdistancefield) | string | (BETA) | -| [distanceMeasure](./firestore_lite.findnearestoptions.md#findnearestoptionsdistancemeasure) | 'euclidean' \| 'cosine' \| 'dot\_product' | (BETA) | -| [field](./firestore_lite.findnearestoptions.md#findnearestoptionsfield) | [Field](./firestore_lite.field.md#field_class) | (BETA) | -| [limit](./firestore_lite.findnearestoptions.md#findnearestoptionslimit) | number | (BETA) | -| [vectorValue](./firestore_lite.findnearestoptions.md#findnearestoptionsvectorvalue) | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) \| number\[\] | (BETA) | - -## FindNearestOptions.distanceField - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -distanceField?: string; -``` - -## FindNearestOptions.distanceMeasure - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -distanceMeasure: 'euclidean' | 'cosine' | 'dot_product'; -``` - -## FindNearestOptions.field - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -field: Field; -``` - -## FindNearestOptions.limit - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -limit?: number; -``` - -## FindNearestOptions.vectorValue - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -vectorValue: VectorValue | number[]; -``` diff --git a/docs-devsite/firestore_lite.firestore.md b/docs-devsite/firestore_lite.firestore.md index cfbb412ed25..2edac7aa130 100644 --- a/docs-devsite/firestore_lite.firestore.md +++ b/docs-devsite/firestore_lite.firestore.md @@ -31,7 +31,6 @@ export declare class Firestore | Method | Modifiers | Description | | --- | --- | --- | -| [pipeline()](./firestore_lite.firestore.md#firestorepipeline) | | Pipeline query. | | [toJSON()](./firestore_lite.firestore.md#firestoretojson) | | Returns a JSON-serializable representation of this Firestore instance. | ## Firestore.app @@ -54,19 +53,6 @@ Whether it's a Firestore or Firestore Lite instance. type: 'firestore-lite' | 'firestore'; ``` -## Firestore.pipeline() - -Pipeline query. - -Signature: - -```typescript -pipeline(): PipelineSource; -``` -Returns: - -[PipelineSource](./firestore_lite.pipelinesource.md#pipelinesource_class) - ## Firestore.toJSON() Returns a JSON-serializable representation of this `Firestore` instance. diff --git a/docs-devsite/firestore_lite.firestorefunction.md b/docs-devsite/firestore_lite.firestorefunction.md deleted file mode 100644 index 04bf9e874f8..00000000000 --- a/docs-devsite/firestore_lite.firestorefunction.md +++ /dev/null @@ -1,3173 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# FirestoreFunction class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -This class defines the base class for Firestore [Pipeline](./firestore_.pipeline.md#pipeline_class) functions, which can be evaluated within pipeline execution. - -Typically, you would not use this class or its children directly. Use either the functions like , , or the methods on (, , etc) to construct new Function instances. - -Signature: - -```typescript -export declare class FirestoreFunction -``` - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(name, params)](./firestore_lite.firestorefunction.md#firestorefunctionconstructor) | | (BETA) Constructs a new instance of the FirestoreFunction class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [exprType](./firestore_lite.firestorefunction.md#firestorefunctionexprtype) | | [ExprType](./firestore_lite.md#exprtype) | (BETA) | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [add(other)](./firestore_lite.firestorefunction.md#firestorefunctionadd) | | (BETA) Creates an expression that adds this expression to another expression. -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -Field.of("quantity").add(Field.of("reserve")); - -``` - | -| [add(other)](./firestore_lite.firestorefunction.md#firestorefunctionadd) | | (BETA) Creates an expression that adds this expression to a constant value. -```typescript -// Add 5 to the value of the 'age' field -Field.of("age").add(5); - -``` - | -| [arrayConcat(arrays)](./firestore_lite.firestorefunction.md#firestorefunctionarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. -```typescript -// Combine the 'items' array with another array field. -Field.of("items").arrayConcat(Field.of("otherItems")); - -``` - | -| [arrayConcat(arrays)](./firestore_lite.firestorefunction.md#firestorefunctionarrayconcat) | | (BETA) Creates an expression that concatenates an array expression with one or more other arrays. -```typescript -// Combine the 'tags' array with a new array and an array field -Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); - -``` - | -| [arrayContains(element)](./firestore_lite.firestorefunction.md#firestorefunctionarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific element. -```typescript -// Check if the 'sizes' array contains the value from the 'selectedSize' field -Field.of("sizes").arrayContains(Field.of("selectedSize")); - -``` - | -| [arrayContains(element)](./firestore_lite.firestorefunction.md#firestorefunctionarraycontains) | | (BETA) Creates an expression that checks if an array contains a specific value. -```typescript -// Check if the 'colors' array contains "red" -Field.of("colors").arrayContains("red"); - -``` - | -| [arrayContainsAll(values)](./firestore_lite.firestorefunction.md#firestorefunctionarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. -```typescript -// Check if the 'tags' array contains both "news" and "sports" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - | -| [arrayContainsAll(values)](./firestore_lite.firestorefunction.md#firestorefunctionarraycontainsall) | | (BETA) Creates an expression that checks if an array contains all the specified elements. -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - | -| [arrayContainsAny(values)](./firestore_lite.firestorefunction.md#firestorefunctionarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "cate2" -Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); - -``` - | -| [arrayContainsAny(values)](./firestore_lite.firestorefunction.md#firestorefunctionarraycontainsany) | | (BETA) Creates an expression that checks if an array contains any of the specified elements. -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); - -``` - | -| [arrayLength()](./firestore_lite.firestorefunction.md#firestorefunctionarraylength) | | (BETA) Creates an expression that calculates the length of an array. -```typescript -// Get the number of items in the 'cart' array -Field.of("cart").arrayLength(); - -``` - A new Expr representing the length of the array. | -| [as(name)](./firestore_lite.firestorefunction.md#firestorefunctionas) | | (BETA) Assigns an alias to this expression.Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. -```typescript -// Calculate the total price and assign it the alias "totalPrice" and add it to the output. -firestore.pipeline().collection("items") -.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); - -``` - | -| [ascending()](./firestore_lite.firestorefunction.md#firestorefunctionascending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. -```typescript -// Sort documents by the 'name' field in ascending order -pipeline().collection("users") -.sort(Field.of("name").ascending()); - -``` - A new Ordering for ascending sorting. | -| [avg()](./firestore_lite.firestorefunction.md#firestorefunctionavg) | | (BETA) Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. -```typescript -// Calculate the average age of users -Field.of("age").avg().as("averageAge"); - -``` - A new Accumulator representing the 'avg' aggregation. | -| [byteLength()](./firestore_lite.firestorefunction.md#firestorefunctionbytelength) | | (BETA) Creates an expression that calculates the length of this string expression in bytes. -```typescript -// Calculate the length of the 'myString' field in bytes. -Field.of("myString").byteLength(); - -``` - A new representing the length of the string in bytes. | -| [charLength()](./firestore_lite.firestorefunction.md#firestorefunctioncharlength) | | (BETA) Creates an expression that calculates the character length of a string in UTF-8. -```typescript -// Get the character length of the 'name' field in its UTF-8 form. -Field.of("name").charLength(); - -``` - A new Expr representing the length of the string. | -| [cosineDistance(other)](./firestore_lite.firestorefunction.md#firestorefunctioncosinedistance) | | (BETA) Calculates the cosine distance between two vectors. -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -Field.of("userVector").cosineDistance(Field.of("itemVector")); - -``` - | -| [cosineDistance(other)](./firestore_lite.firestorefunction.md#firestorefunctioncosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); - -``` - | -| [cosineDistance(other)](./firestore_lite.firestorefunction.md#firestorefunctioncosinedistance) | | (BETA) Calculates the Cosine distance between two vectors. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance([37.7749, -122.4194]); - -``` - | -| [count()](./firestore_lite.firestorefunction.md#firestorefunctioncount) | | (BETA) Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. -```typescript -// Count the total number of products -Field.of("productId").count().as("totalProducts"); - -``` - A new Accumulator representing the 'count' aggregation. | -| [descending()](./firestore_lite.firestorefunction.md#firestorefunctiondescending) | | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") -.sort(Field.of("createdAt").descending()); - -``` - A new Ordering for descending sorting. | -| [divide(other)](./firestore_lite.firestorefunction.md#firestorefunctiondivide) | | (BETA) Creates an expression that divides this expression by another expression. -```typescript -// Divide the 'total' field by the 'count' field -Field.of("total").divide(Field.of("count")); - -``` - | -| [divide(other)](./firestore_lite.firestorefunction.md#firestorefunctiondivide) | | (BETA) Creates an expression that divides this expression by a constant value. -```typescript -// Divide the 'value' field by 10 -Field.of("value").divide(10); - -``` - | -| [dotProduct(other)](./firestore_lite.firestorefunction.md#firestorefunctiondotproduct) | | (BETA) Calculates the dot product between two vectors. -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct([0.5, 0.8, 0.2]); - -``` - | -| [dotProduct(other)](./firestore_lite.firestorefunction.md#firestorefunctiondotproduct) | | (BETA) Calculates the dot product between two vectors. -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); - -``` - | -| [dotProduct(other)](./firestore_lite.firestorefunction.md#firestorefunctiondotproduct) | | (BETA) | -| [endsWith(suffix)](./firestore_lite.firestorefunction.md#firestorefunctionendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix. -```typescript -// Check if the 'filename' field ends with ".txt" -Field.of("filename").endsWith(".txt"); - -``` - | -| [endsWith(suffix)](./firestore_lite.firestorefunction.md#firestorefunctionendswith) | | (BETA) Creates an expression that checks if a string ends with a given postfix (represented as an expression). -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -Field.of("url").endsWith(Field.of("extension")); - -``` - | -| [eq(other)](./firestore_lite.firestorefunction.md#firestorefunctioneq) | | (BETA) Creates an expression that checks if this expression is equal to another expression. -```typescript -// Check if the 'age' field is equal to 21 -Field.of("age").eq(21); - -``` - | -| [eq(other)](./firestore_lite.firestorefunction.md#firestorefunctioneq) | | (BETA) Creates an expression that checks if this expression is equal to a constant value. -```typescript -// Check if the 'city' field is equal to "London" -Field.of("city").eq("London"); - -``` - | -| [euclideanDistance(other)](./firestore_lite.firestorefunction.md#firestorefunctioneuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance([37.7749, -122.4194]); - -``` - | -| [euclideanDistance(other)](./firestore_lite.firestorefunction.md#firestorefunctioneuclideandistance) | | (BETA) Calculates the Euclidean distance between two vectors. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); - -``` - | -| [euclideanDistance(other)](./firestore_lite.firestorefunction.md#firestorefunctioneuclideandistance) | | (BETA) | -| [exists()](./firestore_lite.firestorefunction.md#firestorefunctionexists) | | (BETA) Creates an expression that checks if a field exists in the document. -```typescript -// Check if the document has a field named "phoneNumber" -Field.of("phoneNumber").exists(); - -``` - A new Expr representing the 'exists' check. | -| [gt(other)](./firestore_lite.firestorefunction.md#firestorefunctiongt) | | (BETA) Creates an expression that checks if this expression is greater than another expression. -```typescript -// Check if the 'age' field is greater than the 'limit' field -Field.of("age").gt(Field.of("limit")); - -``` - | -| [gt(other)](./firestore_lite.firestorefunction.md#firestorefunctiongt) | | (BETA) Creates an expression that checks if this expression is greater than a constant value. -```typescript -// Check if the 'price' field is greater than 100 -Field.of("price").gt(100); - -``` - | -| [gte(other)](./firestore_lite.firestorefunction.md#firestorefunctiongte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to another expression. -```typescript -// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 -Field.of("quantity").gte(Field.of('requirement').add(1)); - -``` - | -| [gte(other)](./firestore_lite.firestorefunction.md#firestorefunctiongte) | | (BETA) Creates an expression that checks if this expression is greater than or equal to a constant value. -```typescript -// Check if the 'score' field is greater than or equal to 80 -Field.of("score").gte(80); - -``` - | -| [in(others)](./firestore_lite.firestorefunction.md#firestorefunctionin) | | (BETA) Creates an expression that checks if this expression is equal to any of the provided values or expressions. -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -Field.of("category").in("Electronics", Field.of("primaryType")); - -``` - | -| [in(others)](./firestore_lite.firestorefunction.md#firestorefunctionin) | | (BETA) | -| [isNaN()](./firestore_lite.firestorefunction.md#firestorefunctionisnan) | | (BETA) Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). -```typescript -// Check if the result of a calculation is NaN -Field.of("value").divide(0).isNaN(); - -``` - A new Expr representing the 'isNaN' check. | -| [like(pattern)](./firestore_lite.firestorefunction.md#firestorefunctionlike) | | (BETA) Creates an expression that performs a case-sensitive string comparison. -```typescript -// Check if the 'title' field contains the word "guide" (case-sensitive) -Field.of("title").like("%guide%"); - -``` - | -| [like(pattern)](./firestore_lite.firestorefunction.md#firestorefunctionlike) | | (BETA) | -| [logicalMax(other)](./firestore_lite.firestorefunction.md#firestorefunctionlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMax(Function.currentTimestamp()); - -``` - | -| [logicalMax(other)](./firestore_lite.firestorefunction.md#firestorefunctionlogicalmax) | | (BETA) Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'value' field and 10. -Field.of("value").logicalMax(10); - -``` - | -| [logicalMin(other)](./firestore_lite.firestorefunction.md#firestorefunctionlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMin(Function.currentTimestamp()); - -``` - | -| [logicalMin(other)](./firestore_lite.firestorefunction.md#firestorefunctionlogicalmin) | | (BETA) Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'value' field and 10. -Field.of("value").logicalMin(10); - -``` - | -| [lt(other)](./firestore_lite.firestorefunction.md#firestorefunctionlt) | | (BETA) Creates an expression that checks if this expression is less than another expression. -```typescript -// Check if the 'age' field is less than 'limit' -Field.of("age").lt(Field.of('limit')); - -``` - | -| [lt(other)](./firestore_lite.firestorefunction.md#firestorefunctionlt) | | (BETA) Creates an expression that checks if this expression is less than a constant value. -```typescript -// Check if the 'price' field is less than 50 -Field.of("price").lt(50); - -``` - | -| [lte(other)](./firestore_lite.firestorefunction.md#firestorefunctionlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to another expression. -```typescript -// Check if the 'quantity' field is less than or equal to 20 -Field.of("quantity").lte(Constant.of(20)); - -``` - | -| [lte(other)](./firestore_lite.firestorefunction.md#firestorefunctionlte) | | (BETA) Creates an expression that checks if this expression is less than or equal to a constant value. -```typescript -// Check if the 'score' field is less than or equal to 70 -Field.of("score").lte(70); - -``` - | -| [mapGet(subfield)](./firestore_lite.firestorefunction.md#firestorefunctionmapget) | | (BETA) Accesses a value from a map (object) field using the provided key. -```typescript -// Get the 'city' value from the 'address' map field -Field.of("address").mapGet("city"); - -``` - | -| [max()](./firestore_lite.firestorefunction.md#firestorefunctionmax) | | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. -```typescript -// Find the highest score in a leaderboard -Field.of("score").max().as("highestScore"); - -``` - A new Accumulator representing the 'max' aggregation. | -| [min()](./firestore_lite.firestorefunction.md#firestorefunctionmin) | | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. -```typescript -// Find the lowest price of all products -Field.of("price").min().as("lowestPrice"); - -``` - A new Accumulator representing the 'min' aggregation. | -| [mod(other)](./firestore_lite.firestorefunction.md#firestorefunctionmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. -```typescript -// Calculate the remainder of dividing the 'value' field by the 'divisor' field -Field.of("value").mod(Field.of("divisor")); - -``` - | -| [mod(other)](./firestore_lite.firestorefunction.md#firestorefunctionmod) | | (BETA) Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. -```typescript -// Calculate the remainder of dividing the 'value' field by 10 -Field.of("value").mod(10); - -``` - | -| [multiply(other)](./firestore_lite.firestorefunction.md#firestorefunctionmultiply) | | (BETA) Creates an expression that multiplies this expression by another expression. -```typescript -// Multiply the 'quantity' field by the 'price' field -Field.of("quantity").multiply(Field.of("price")); - -``` - | -| [multiply(other)](./firestore_lite.firestorefunction.md#firestorefunctionmultiply) | | (BETA) Creates an expression that multiplies this expression by a constant value. -```typescript -// Multiply the 'value' field by 2 -Field.of("value").multiply(2); - -``` - | -| [neq(other)](./firestore_lite.firestorefunction.md#firestorefunctionneq) | | (BETA) Creates an expression that checks if this expression is not equal to another expression. -```typescript -// Check if the 'status' field is not equal to "completed" -Field.of("status").neq("completed"); - -``` - | -| [neq(other)](./firestore_lite.firestorefunction.md#firestorefunctionneq) | | (BETA) Creates an expression that checks if this expression is not equal to a constant value. -```typescript -// Check if the 'country' field is not equal to "USA" -Field.of("country").neq("USA"); - -``` - | -| [regexContains(pattern)](./firestore_lite.firestorefunction.md#firestorefunctionregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -Field.of("description").regexContains("(?i)example"); - -``` - | -| [regexContains(pattern)](./firestore_lite.firestorefunction.md#firestorefunctionregexcontains) | | (BETA) Creates an expression that checks if a string contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains the regular expression stored in field 'regex' -Field.of("description").regexContains(Field.of("regex")); - -``` - | -| [regexMatch(pattern)](./firestore_lite.firestorefunction.md#firestorefunctionregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. -```typescript -// Check if the 'email' field matches a valid email pattern -Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - | -| [regexMatch(pattern)](./firestore_lite.firestorefunction.md#firestorefunctionregexmatch) | | (BETA) Creates an expression that checks if a string matches a specified regular expression. -```typescript -// Check if the 'email' field matches a regular expression stored in field 'regex' -Field.of("email").regexMatch(Field.of("regex")); - -``` - | -| [replaceAll(find, replace)](./firestore_lite.firestorefunction.md#firestorefunctionreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring. -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field -Field.of("message").replaceAll("hello", "hi"); - -``` - | -| [replaceAll(find, replace)](./firestore_lite.firestorefunction.md#firestorefunctionreplaceall) | | (BETA) Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); - -``` - | -| [replaceFirst(find, replace)](./firestore_lite.firestorefunction.md#firestorefunctionreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field -Field.of("message").replaceFirst("hello", "hi"); - -``` - | -| [replaceFirst(find, replace)](./firestore_lite.firestorefunction.md#firestorefunctionreplacefirst) | | (BETA) Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); - -``` - | -| [reverse()](./firestore_lite.firestorefunction.md#firestorefunctionreverse) | | (BETA) Creates an expression that reverses this string expression. -```typescript -// Reverse the value of the 'myString' field. -Field.of("myString").reverse(); - -``` - A new representing the reversed string. | -| [startsWith(prefix)](./firestore_lite.firestorefunction.md#firestorefunctionstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix. -```typescript -// Check if the 'name' field starts with "Mr." -Field.of("name").startsWith("Mr."); - -``` - | -| [startsWith(prefix)](./firestore_lite.firestorefunction.md#firestorefunctionstartswith) | | (BETA) Creates an expression that checks if a string starts with a given prefix (represented as an expression). -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -Field.of("fullName").startsWith(Field.of("firstName")); - -``` - | -| [strConcat(elements)](./firestore_lite.firestorefunction.md#firestorefunctionstrconcat) | | (BETA) Creates an expression that concatenates string expressions together. -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); - -``` - | -| [strContains(substring)](./firestore_lite.firestorefunction.md#firestorefunctionstrcontains) | | (BETA) Creates an expression that checks if a string contains a specified substring. -```typescript -// Check if the 'description' field contains "example". -Field.of("description").strContains("example"); - -``` - | -| [strContains(expr)](./firestore_lite.firestorefunction.md#firestorefunctionstrcontains) | | (BETA) Creates an expression that checks if a string contains the string represented by another expression. -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -Field.of("description").strContains(Field.of("keyword")); - -``` - | -| [subtract(other)](./firestore_lite.firestorefunction.md#firestorefunctionsubtract) | | (BETA) Creates an expression that subtracts another expression from this expression. -```typescript -// Subtract the 'discount' field from the 'price' field -Field.of("price").subtract(Field.of("discount")); - -``` - | -| [subtract(other)](./firestore_lite.firestorefunction.md#firestorefunctionsubtract) | | (BETA) Creates an expression that subtracts a constant value from this expression. -```typescript -// Subtract 20 from the value of the 'total' field -Field.of("total").subtract(20); - -``` - | -| [sum()](./firestore_lite.firestorefunction.md#firestorefunctionsum) | | (BETA) Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. -```typescript -// Calculate the total revenue from a set of orders -Field.of("orderAmount").sum().as("totalRevenue"); - -``` - A new Accumulator representing the 'sum' aggregation. | -| [timestampAdd(unit, amount)](./firestore_lite.firestorefunction.md#firestorefunctiontimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampAdd(unit, amount)](./firestore_lite.firestorefunction.md#firestorefunctiontimestampadd) | | (BETA) Creates an expression that adds a specified amount of time to this timestamp expression. -```typescript -// Add 1 day to the 'timestamp' field. -Field.of("timestamp").timestampAdd("day", 1); - -``` - | -| [timestampSub(unit, amount)](./firestore_lite.firestorefunction.md#firestorefunctiontimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampSub(unit, amount)](./firestore_lite.firestorefunction.md#firestorefunctiontimestampsub) | | (BETA) Creates an expression that subtracts a specified amount of time from this timestamp expression. -```typescript -// Subtract 1 day from the 'timestamp' field. -Field.of("timestamp").timestampSub("day", 1); - -``` - | -| [timestampToUnixMicros()](./firestore_lite.firestorefunction.md#firestorefunctiontimestamptounixmicros) | | (BETA) Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -Field.of("timestamp").timestampToUnixMicros(); - -``` - A new representing the number of microseconds since epoch. | -| [timestampToUnixMillis()](./firestore_lite.firestorefunction.md#firestorefunctiontimestamptounixmillis) | | (BETA) Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -Field.of("timestamp").timestampToUnixMillis(); - -``` - A new representing the number of milliseconds since epoch. | -| [timestampToUnixSeconds()](./firestore_lite.firestorefunction.md#firestorefunctiontimestamptounixseconds) | | (BETA) Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to seconds since epoch. -Field.of("timestamp").timestampToUnixSeconds(); - -``` - A new representing the number of seconds since epoch. | -| [toLower()](./firestore_lite.firestorefunction.md#firestorefunctiontolower) | | (BETA) Creates an expression that converts a string to lowercase. -```typescript -// Convert the 'name' field to lowercase -Field.of("name").toLower(); - -``` - A new Expr representing the lowercase string. | -| [toUpper()](./firestore_lite.firestorefunction.md#firestorefunctiontoupper) | | (BETA) Creates an expression that converts a string to uppercase. -```typescript -// Convert the 'title' field to uppercase -Field.of("title").toUpper(); - -``` - A new Expr representing the uppercase string. | -| [trim()](./firestore_lite.firestorefunction.md#firestorefunctiontrim) | | (BETA) Creates an expression that removes leading and trailing whitespace from a string. -```typescript -// Trim whitespace from the 'userInput' field -Field.of("userInput").trim(); - -``` - A new Expr representing the trimmed string. | -| [unixMicrosToTimestamp()](./firestore_lite.firestorefunction.md#firestorefunctionunixmicrostotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -Field.of("microseconds").unixMicrosToTimestamp(); - -``` - A new representing the timestamp. | -| [unixMillisToTimestamp()](./firestore_lite.firestorefunction.md#firestorefunctionunixmillistotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -Field.of("milliseconds").unixMillisToTimestamp(); - -``` - A new representing the timestamp. | -| [unixSecondsToTimestamp()](./firestore_lite.firestorefunction.md#firestorefunctionunixsecondstotimestamp) | | (BETA) Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'seconds' field as seconds since epoch. -Field.of("seconds").unixSecondsToTimestamp(); - -``` - A new representing the timestamp. | -| [vectorLength()](./firestore_lite.firestorefunction.md#firestorefunctionvectorlength) | | (BETA) Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. -```typescript -// Get the vector length (dimension) of the field 'embedding'. -Field.of("embedding").vectorLength(); - -``` - A new representing the length of the vector. | - -## FirestoreFunction.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `FirestoreFunction` class - -Signature: - -```typescript -constructor(name: string, params: Constant[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | | -| params | [Constant](./firestore_lite.constant.md#constant_class)\[\] | | - -## FirestoreFunction.exprType - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -exprType: ExprType; -``` - -## FirestoreFunction.add() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds this expression to another expression. - -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -Field.of("quantity").add(Field.of("reserve")); - -``` - -Signature: - -```typescript -add(other: Constant): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to add to this expression. A new Expr representing the addition operation. | - -Returns: - -[Add](./firestore_lite.add.md#add_class) - -## FirestoreFunction.add() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds this expression to a constant value. - -```typescript -// Add 5 to the value of the 'age' field -Field.of("age").add(5); - -``` - -Signature: - -```typescript -add(other: any): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to add. A new Expr representing the addition operation. | - -Returns: - -[Add](./firestore_lite.add.md#add_class) - -## FirestoreFunction.arrayConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with one or more other arrays. - -```typescript -// Combine the 'items' array with another array field. -Field.of("items").arrayConcat(Field.of("otherItems")); - -``` - -Signature: - -```typescript -arrayConcat(arrays: Constant[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| arrays | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The array expressions to concatenate. A new Expr representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) - -## FirestoreFunction.arrayConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with one or more other arrays. - -```typescript -// Combine the 'tags' array with a new array and an array field -Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); - -``` - -Signature: - -```typescript -arrayConcat(arrays: any[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| arrays | any\[\] | The array expressions or values to concatenate. A new Expr representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) - -## FirestoreFunction.arrayContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains a specific element. - -```typescript -// Check if the 'sizes' array contains the value from the 'selectedSize' field -Field.of("sizes").arrayContains(Field.of("selectedSize")); - -``` - -Signature: - -```typescript -arrayContains(element: Constant): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | [Constant](./firestore_lite.constant.md#constant_class) | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) - -## FirestoreFunction.arrayContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains a specific value. - -```typescript -// Check if the 'colors' array contains "red" -Field.of("colors").arrayContains("red"); - -``` - -Signature: - -```typescript -arrayContains(element: any): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | any | The element to search for in the array. A new Expr representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) - -## FirestoreFunction.arrayContainsAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both "news" and "sports" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - -Signature: - -```typescript -arrayContainsAll(...values: Constant[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) - -## FirestoreFunction.arrayContainsAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); - -``` - -Signature: - -```typescript -arrayContainsAll(...values: any[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) - -## FirestoreFunction.arrayContainsAny() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains any of the specified elements. - -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "cate2" -Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); - -``` - -Signature: - -```typescript -arrayContainsAny(...values: Constant[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) - -## FirestoreFunction.arrayContainsAny() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array contains any of the specified elements. - -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); - -``` - -Signature: - -```typescript -arrayContainsAny(...values: any[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| values | any\[\] | The elements to check for in the array. A new Expr representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) - -## FirestoreFunction.arrayLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of an array. - -```typescript -// Get the number of items in the 'cart' array -Field.of("cart").arrayLength(); - -``` - A new `Expr` representing the length of the array. - -Signature: - -```typescript -arrayLength(): ArrayLength; -``` -Returns: - -[ArrayLength](./firestore_lite.arraylength.md#arraylength_class) - -## FirestoreFunction.as() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Assigns an alias to this expression. - -Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values. - -```typescript -// Calculate the total price and assign it the alias "totalPrice" and add it to the output. -firestore.pipeline().collection("items") -.addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); - -``` - -Signature: - -```typescript -as(name: string): ExprWithAlias; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | The alias to assign to this expression. A new [ExprWithAlias](./firestore_.exprwithalias.md#exprwithalias_class) that wraps this expression and associates it with the provided alias. | - -Returns: - -[ExprWithAlias](./firestore_lite.exprwithalias.md#exprwithalias_class)<this> - -## FirestoreFunction.ascending() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. - -```typescript -// Sort documents by the 'name' field in ascending order -pipeline().collection("users") -.sort(Field.of("name").ascending()); - -``` - A new `Ordering` for ascending sorting. - -Signature: - -```typescript -ascending(): Ordering; -``` -Returns: - -[Ordering](./firestore_lite.ordering.md#ordering_class) - -## FirestoreFunction.avg() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that calculates the average (mean) of a numeric field across multiple stage inputs. - -```typescript -// Calculate the average age of users -Field.of("age").avg().as("averageAge"); - -``` - A new `Accumulator` representing the 'avg' aggregation. - -Signature: - -```typescript -avg(): Avg; -``` -Returns: - -[Avg](./firestore_lite.avg.md#avg_class) - -## FirestoreFunction.byteLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of this string expression in bytes. - -```typescript -// Calculate the length of the 'myString' field in bytes. -Field.of("myString").byteLength(); - -``` - A new representing the length of the string in bytes. - -Signature: - -```typescript -byteLength(): ByteLength; -``` -Returns: - -[ByteLength](./firestore_lite.bytelength.md#bytelength_class) - -## FirestoreFunction.charLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the character length of a string in UTF-8. - -```typescript -// Get the character length of the 'name' field in its UTF-8 form. -Field.of("name").charLength(); - -``` - A new `Expr` representing the length of the string. - -Signature: - -```typescript -charLength(): CharLength; -``` -Returns: - -[CharLength](./firestore_lite.charlength.md#charlength_class) - -## FirestoreFunction.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the cosine distance between two vectors. - -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -Field.of("userVector").cosineDistance(Field.of("itemVector")); - -``` - -Signature: - -```typescript -cosineDistance(other: Constant): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new Expr representing the cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) - -## FirestoreFunction.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vectors. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -cosineDistance(other: VectorValue): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) - -## FirestoreFunction.cosineDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vectors. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -Field.of("location").cosineDistance([37.7749, -122.4194]); - -``` - -Signature: - -```typescript -cosineDistance(other: number[]): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | The other vector (as an array of numbers) to compare against. A new Expr representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) - -## FirestoreFunction.count() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that counts the number of stage inputs with valid evaluations of the expression or field. - -```typescript -// Count the total number of products -Field.of("productId").count().as("totalProducts"); - -``` - A new `Accumulator` representing the 'count' aggregation. - -Signature: - -```typescript -count(): Count; -``` -Returns: - -[Count](./firestore_lite.count.md#count_class) - -## FirestoreFunction.descending() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. - -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") -.sort(Field.of("createdAt").descending()); - -``` - A new `Ordering` for descending sorting. - -Signature: - -```typescript -descending(): Ordering; -``` -Returns: - -[Ordering](./firestore_lite.ordering.md#ordering_class) - -## FirestoreFunction.divide() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides this expression by another expression. - -```typescript -// Divide the 'total' field by the 'count' field -Field.of("total").divide(Field.of("count")); - -``` - -Signature: - -```typescript -divide(other: Constant): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new Expr representing the division operation. | - -Returns: - -[Divide](./firestore_lite.divide.md#divide_class) - -## FirestoreFunction.divide() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides this expression by a constant value. - -```typescript -// Divide the 'value' field by 10 -Field.of("value").divide(10); - -``` - -Signature: - -```typescript -divide(other: any): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to divide by. A new Expr representing the division operation. | - -Returns: - -[Divide](./firestore_lite.divide.md#divide_class) - -## FirestoreFunction.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vectors. - -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct([0.5, 0.8, 0.2]); - -``` - -Signature: - -```typescript -dotProduct(other: Constant): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) - -## FirestoreFunction.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vectors. - -```typescript -// Calculate the dot product between a feature vector and a target vector -Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); - -``` - -Signature: - -```typescript -dotProduct(other: VectorValue): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) - -## FirestoreFunction.dotProduct() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -dotProduct(other: number[]): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | | - -Returns: - -[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) - -## FirestoreFunction.endsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string ends with a given postfix. - -```typescript -// Check if the 'filename' field ends with ".txt" -Field.of("filename").endsWith(".txt"); - -``` - -Signature: - -```typescript -endsWith(suffix: string): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| suffix | string | The postfix to check for. A new Expr representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_lite.endswith.md#endswith_class) - -## FirestoreFunction.endsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string ends with a given postfix (represented as an expression). - -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -Field.of("url").endsWith(Field.of("extension")); - -``` - -Signature: - -```typescript -endsWith(suffix: Constant): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| suffix | [Constant](./firestore_lite.constant.md#constant_class) | The postfix expression to check for. A new Expr representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_lite.endswith.md#endswith_class) - -## FirestoreFunction.eq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to another expression. - -```typescript -// Check if the 'age' field is equal to 21 -Field.of("age").eq(21); - -``` - -Signature: - -```typescript -eq(other: Constant): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for equality. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_lite.eq.md#eq_class) - -## FirestoreFunction.eq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to a constant value. - -```typescript -// Check if the 'city' field is equal to "London" -Field.of("city").eq("London"); - -``` - -Signature: - -```typescript -eq(other: any): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for equality. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_lite.eq.md#eq_class) - -## FirestoreFunction.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vectors. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance([37.7749, -122.4194]); - -``` - -Signature: - -```typescript -euclideanDistance(other: Constant): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (as an array of numbers) to calculate with. A new Expr representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) - -## FirestoreFunction.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vectors. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -euclideanDistance(other: VectorValue): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new Expr representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) - -## FirestoreFunction.euclideanDistance() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -euclideanDistance(other: number[]): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | number\[\] | | - -Returns: - -[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) - -## FirestoreFunction.exists() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field exists in the document. - -```typescript -// Check if the document has a field named "phoneNumber" -Field.of("phoneNumber").exists(); - -``` - A new `Expr` representing the 'exists' check. - -Signature: - -```typescript -exists(): Exists; -``` -Returns: - -[Exists](./firestore_lite.exists.md#exists_class) - -## FirestoreFunction.gt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than another expression. - -```typescript -// Check if the 'age' field is greater than the 'limit' field -Field.of("age").gt(Field.of("limit")); - -``` - -Signature: - -```typescript -gt(other: Constant): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for greater than. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_lite.gt.md#gt_class) - -## FirestoreFunction.gt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than a constant value. - -```typescript -// Check if the 'price' field is greater than 100 -Field.of("price").gt(100); - -``` - -Signature: - -```typescript -gt(other: any): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for greater than. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_lite.gt.md#gt_class) - -## FirestoreFunction.gte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than or equal to another expression. - -```typescript -// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 -Field.of("quantity").gte(Field.of('requirement').add(1)); - -``` - -Signature: - -```typescript -gte(other: Constant): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_lite.gte.md#gte_class) - -## FirestoreFunction.gte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is greater than or equal to a constant value. - -```typescript -// Check if the 'score' field is greater than or equal to 80 -Field.of("score").gte(80); - -``` - -Signature: - -```typescript -gte(other: any): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for greater than or equal to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_lite.gte.md#gte_class) - -## FirestoreFunction.in() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is equal to any of the provided values or expressions. - -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -Field.of("category").in("Electronics", Field.of("primaryType")); - -``` - -Signature: - -```typescript -in(...others: Constant[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| others | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The values or expressions to check against. A new Expr representing the 'IN' comparison. | - -Returns: - -[In](./firestore_lite.in.md#in_class) - -## FirestoreFunction.in() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -in(...others: any[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| others | any\[\] | | - -Returns: - -[In](./firestore_lite.in.md#in_class) - -## FirestoreFunction.isNaN() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). - -```typescript -// Check if the result of a calculation is NaN -Field.of("value").divide(0).isNaN(); - -``` - A new `Expr` representing the 'isNaN' check. - -Signature: - -```typescript -isNaN(): IsNan; -``` -Returns: - -[IsNan](./firestore_lite.isnan.md#isnan_class) - -## FirestoreFunction.like() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that performs a case-sensitive string comparison. - -```typescript -// Check if the 'title' field contains the word "guide" (case-sensitive) -Field.of("title").like("%guide%"); - -``` - -Signature: - -```typescript -like(pattern: string): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new Expr representing the 'like' comparison. | - -Returns: - -[Like](./firestore_lite.like.md#like_class) - -## FirestoreFunction.like() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -like(pattern: Constant): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | | - -Returns: - -[Like](./firestore_lite.like.md#like_class) - -## FirestoreFunction.logicalMax() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMax(Function.currentTimestamp()); - -``` - -Signature: - -```typescript -logicalMax(other: Constant): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare with. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) - -## FirestoreFunction.logicalMax() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'value' field and 10. -Field.of("value").logicalMax(10); - -``` - -Signature: - -```typescript -logicalMax(other: any): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare with. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) - -## FirestoreFunction.logicalMin() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'timestamp' field and the current timestamp. -Field.of("timestamp").logicalMin(Function.currentTimestamp()); - -``` - -Signature: - -```typescript -logicalMin(other: Constant): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare with. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) - -## FirestoreFunction.logicalMin() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'value' field and 10. -Field.of("value").logicalMin(10); - -``` - -Signature: - -```typescript -logicalMin(other: any): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare with. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) - -## FirestoreFunction.lt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than another expression. - -```typescript -// Check if the 'age' field is less than 'limit' -Field.of("age").lt(Field.of('limit')); - -``` - -Signature: - -```typescript -lt(other: Constant): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for less than. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_lite.lt.md#lt_class) - -## FirestoreFunction.lt() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than a constant value. - -```typescript -// Check if the 'price' field is less than 50 -Field.of("price").lt(50); - -``` - -Signature: - -```typescript -lt(other: any): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for less than. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_lite.lt.md#lt_class) - -## FirestoreFunction.lte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than or equal to another expression. - -```typescript -// Check if the 'quantity' field is less than or equal to 20 -Field.of("quantity").lte(Constant.of(20)); - -``` - -Signature: - -```typescript -lte(other: Constant): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_lite.lte.md#lte_class) - -## FirestoreFunction.lte() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is less than or equal to a constant value. - -```typescript -// Check if the 'score' field is less than or equal to 70 -Field.of("score").lte(70); - -``` - -Signature: - -```typescript -lte(other: any): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for less than or equal to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_lite.lte.md#lte_class) - -## FirestoreFunction.mapGet() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Accesses a value from a map (object) field using the provided key. - -```typescript -// Get the 'city' value from the 'address' map field -Field.of("address").mapGet("city"); - -``` - -Signature: - -```typescript -mapGet(subfield: string): MapGet; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| subfield | string | The key to access in the map. A new Expr representing the value associated with the given key in the map. | - -Returns: - -[MapGet](./firestore_lite.mapget.md#mapget_class) - -## FirestoreFunction.max() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that finds the maximum value of a field across multiple stage inputs. - -```typescript -// Find the highest score in a leaderboard -Field.of("score").max().as("highestScore"); - -``` - A new `Accumulator` representing the 'max' aggregation. - -Signature: - -```typescript -max(): Max; -``` -Returns: - -[Max](./firestore_lite.max.md#max_class) - -## FirestoreFunction.min() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that finds the minimum value of a field across multiple stage inputs. - -```typescript -// Find the lowest price of all products -Field.of("price").min().as("lowestPrice"); - -``` - A new `Accumulator` representing the 'min' aggregation. - -Signature: - -```typescript -min(): Min; -``` -Returns: - -[Min](./firestore_lite.min.md#min_class) - -## FirestoreFunction.mod() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. - -```typescript -// Calculate the remainder of dividing the 'value' field by the 'divisor' field -Field.of("value").mod(Field.of("divisor")); - -``` - -Signature: - -```typescript -mod(other: Constant): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new Expr representing the modulo operation. | - -Returns: - -[Mod](./firestore_lite.mod.md#mod_class) - -## FirestoreFunction.mod() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. - -```typescript -// Calculate the remainder of dividing the 'value' field by 10 -Field.of("value").mod(10); - -``` - -Signature: - -```typescript -mod(other: any): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to divide by. A new Expr representing the modulo operation. | - -Returns: - -[Mod](./firestore_lite.mod.md#mod_class) - -## FirestoreFunction.multiply() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies this expression by another expression. - -```typescript -// Multiply the 'quantity' field by the 'price' field -Field.of("quantity").multiply(Field.of("price")); - -``` - -Signature: - -```typescript -multiply(other: Constant): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to multiply by. A new Expr representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_lite.multiply.md#multiply_class) - -## FirestoreFunction.multiply() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies this expression by a constant value. - -```typescript -// Multiply the 'value' field by 2 -Field.of("value").multiply(2); - -``` - -Signature: - -```typescript -multiply(other: any): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to multiply by. A new Expr representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_lite.multiply.md#multiply_class) - -## FirestoreFunction.neq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is not equal to another expression. - -```typescript -// Check if the 'status' field is not equal to "completed" -Field.of("status").neq("completed"); - -``` - -Signature: - -```typescript -neq(other: Constant): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare for inequality. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_lite.neq.md#neq_class) - -## FirestoreFunction.neq() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if this expression is not equal to a constant value. - -```typescript -// Check if the 'country' field is not equal to "USA" -Field.of("country").neq("USA"); - -``` - -Signature: - -```typescript -neq(other: any): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to compare for inequality. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_lite.neq.md#neq_class) - -## FirestoreFunction.regexContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -Field.of("description").regexContains("(?i)example"); - -``` - -Signature: - -```typescript -regexContains(pattern: string): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) - -## FirestoreFunction.regexContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains the regular expression stored in field 'regex' -Field.of("description").regexContains(Field.of("regex")); - -``` - -Signature: - -```typescript -regexContains(pattern: Constant): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the search. A new Expr representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) - -## FirestoreFunction.regexMatch() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a valid email pattern -Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - -Signature: - -```typescript -regexMatch(pattern: string): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | string | The regular expression to use for the match. A new Expr representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) - -## FirestoreFunction.regexMatch() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a regular expression stored in field 'regex' -Field.of("email").regexMatch(Field.of("regex")); - -``` - -Signature: - -```typescript -regexMatch(pattern: Constant): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the match. A new Expr representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) - -## FirestoreFunction.replaceAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within this string expression with another substring. - -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field -Field.of("message").replaceAll("hello", "hi"); - -``` - -Signature: - -```typescript -replaceAll(find: string, replace: string): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | string | The substring to search for. | -| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) - -## FirestoreFunction.replaceAll() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. - -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); - -``` - -Signature: - -```typescript -replaceAll(find: Constant, replace: Constant): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) - -## FirestoreFunction.replaceFirst() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. - -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field -Field.of("message").replaceFirst("hello", "hi"); - -``` - -Signature: - -```typescript -replaceFirst(find: string, replace: string): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | string | The substring to search for. | -| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) - -## FirestoreFunction.replaceFirst() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, where the substring to find and the replacement substring are specified by expressions. - -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field -Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); - -``` - -Signature: - -```typescript -replaceFirst(find: Constant, replace: Constant): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) - -## FirestoreFunction.reverse() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that reverses this string expression. - -```typescript -// Reverse the value of the 'myString' field. -Field.of("myString").reverse(); - -``` - A new representing the reversed string. - -Signature: - -```typescript -reverse(): Reverse; -``` -Returns: - -[Reverse](./firestore_lite.reverse.md#reverse_class) - -## FirestoreFunction.startsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string starts with a given prefix. - -```typescript -// Check if the 'name' field starts with "Mr." -Field.of("name").startsWith("Mr."); - -``` - -Signature: - -```typescript -startsWith(prefix: string): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| prefix | string | The prefix to check for. A new Expr representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_lite.startswith.md#startswith_class) - -## FirestoreFunction.startsWith() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string starts with a given prefix (represented as an expression). - -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -Field.of("fullName").startsWith(Field.of("firstName")); - -``` - -Signature: - -```typescript -startsWith(prefix: Constant): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| prefix | [Constant](./firestore_lite.constant.md#constant_class) | The prefix expression to check for. A new Expr representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_lite.startswith.md#startswith_class) - -## FirestoreFunction.strConcat() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates string expressions together. - -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); - -``` - -Signature: - -```typescript -strConcat(...elements: Array): StrConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| elements | Array<string \| [Constant](./firestore_lite.constant.md#constant_class)> | The expressions (typically strings) to concatenate. A new Expr representing the concatenated string. | - -Returns: - -[StrConcat](./firestore_lite.strconcat.md#strconcat_class) - -## FirestoreFunction.strContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains a specified substring. - -```typescript -// Check if the 'description' field contains "example". -Field.of("description").strContains("example"); - -``` - -Signature: - -```typescript -strContains(substring: string): StrContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| substring | string | The substring to search for. A new Expr representing the 'contains' comparison. | - -Returns: - -[StrContains](./firestore_lite.strcontains.md#strcontains_class) - -## FirestoreFunction.strContains() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string contains the string represented by another expression. - -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -Field.of("description").strContains(Field.of("keyword")); - -``` - -Signature: - -```typescript -strContains(expr: Constant): StrContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. A new Expr representing the 'contains' comparison. | - -Returns: - -[StrContains](./firestore_lite.strcontains.md#strcontains_class) - -## FirestoreFunction.subtract() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts another expression from this expression. - -```typescript -// Subtract the 'discount' field from the 'price' field -Field.of("price").subtract(Field.of("discount")); - -``` - -Signature: - -```typescript -subtract(other: Constant): Subtract; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The expression to subtract from this expression. A new Expr representing the subtraction operation. | - -Returns: - -[Subtract](./firestore_lite.subtract.md#subtract_class) - -## FirestoreFunction.subtract() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a constant value from this expression. - -```typescript -// Subtract 20 from the value of the 'total' field -Field.of("total").subtract(20); - -``` - -Signature: - -```typescript -subtract(other: any): Subtract; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| other | any | The constant value to subtract. A new Expr representing the subtraction operation. | - -Returns: - -[Subtract](./firestore_lite.subtract.md#subtract_class) - -## FirestoreFunction.sum() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. - -```typescript -// Calculate the total revenue from a set of orders -Field.of("orderAmount").sum().as("totalRevenue"); - -``` - A new `Accumulator` representing the 'sum' aggregation. - -Signature: - -```typescript -sum(): Sum; -``` -Returns: - -[Sum](./firestore_lite.sum.md#sum_class) - -## FirestoreFunction.timestampAdd() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to this timestamp expression. - -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); - -``` - -Signature: - -```typescript -timestampAdd(unit: Constant, amount: Constant): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) - -## FirestoreFunction.timestampAdd() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to this timestamp expression. - -```typescript -// Add 1 day to the 'timestamp' field. -Field.of("timestamp").timestampAdd("day", 1); - -``` - -Signature: - -```typescript -timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | -| amount | number | The amount of time to add. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) - -## FirestoreFunction.timestampSub() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from this timestamp expression. - -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); - -``` - -Signature: - -```typescript -timestampSub(unit: Constant, amount: Constant): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) - -## FirestoreFunction.timestampSub() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from this timestamp expression. - -```typescript -// Subtract 1 day from the 'timestamp' field. -Field.of("timestamp").timestampSub("day", 1); - -``` - -Signature: - -```typescript -timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | -| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) - -## FirestoreFunction.timestampToUnixMicros() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -Field.of("timestamp").timestampToUnixMicros(); - -``` - A new representing the number of microseconds since epoch. - -Signature: - -```typescript -timestampToUnixMicros(): TimestampToUnixMicros; -``` -Returns: - -[TimestampToUnixMicros](./firestore_lite.timestamptounixmicros.md#timestamptounixmicros_class) - -## FirestoreFunction.timestampToUnixMillis() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -Field.of("timestamp").timestampToUnixMillis(); - -``` - A new representing the number of milliseconds since epoch. - -Signature: - -```typescript -timestampToUnixMillis(): TimestampToUnixMillis; -``` -Returns: - -[TimestampToUnixMillis](./firestore_lite.timestamptounixmillis.md#timestamptounixmillis_class) - -## FirestoreFunction.timestampToUnixSeconds() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to seconds since epoch. -Field.of("timestamp").timestampToUnixSeconds(); - -``` - A new representing the number of seconds since epoch. - -Signature: - -```typescript -timestampToUnixSeconds(): TimestampToUnixSeconds; -``` -Returns: - -[TimestampToUnixSeconds](./firestore_lite.timestamptounixseconds.md#timestamptounixseconds_class) - -## FirestoreFunction.toLower() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string to lowercase. - -```typescript -// Convert the 'name' field to lowercase -Field.of("name").toLower(); - -``` - A new `Expr` representing the lowercase string. - -Signature: - -```typescript -toLower(): ToLower; -``` -Returns: - -[ToLower](./firestore_lite.tolower.md#tolower_class) - -## FirestoreFunction.toUpper() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string to uppercase. - -```typescript -// Convert the 'title' field to uppercase -Field.of("title").toUpper(); - -``` - A new `Expr` representing the uppercase string. - -Signature: - -```typescript -toUpper(): ToUpper; -``` -Returns: - -[ToUpper](./firestore_lite.toupper.md#toupper_class) - -## FirestoreFunction.trim() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that removes leading and trailing whitespace from a string. - -```typescript -// Trim whitespace from the 'userInput' field -Field.of("userInput").trim(); - -``` - A new `Expr` representing the trimmed string. - -Signature: - -```typescript -trim(): Trim; -``` -Returns: - -[Trim](./firestore_lite.trim.md#trim_class) - -## FirestoreFunction.unixMicrosToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -Field.of("microseconds").unixMicrosToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixMicrosToTimestamp(): UnixMicrosToTimestamp; -``` -Returns: - -[UnixMicrosToTimestamp](./firestore_lite.unixmicrostotimestamp.md#unixmicrostotimestamp_class) - -## FirestoreFunction.unixMillisToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -Field.of("milliseconds").unixMillisToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixMillisToTimestamp(): UnixMillisToTimestamp; -``` -Returns: - -[UnixMillisToTimestamp](./firestore_lite.unixmillistotimestamp.md#unixmillistotimestamp_class) - -## FirestoreFunction.unixSecondsToTimestamp() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'seconds' field as seconds since epoch. -Field.of("seconds").unixSecondsToTimestamp(); - -``` - A new representing the timestamp. - -Signature: - -```typescript -unixSecondsToTimestamp(): UnixSecondsToTimestamp; -``` -Returns: - -[UnixSecondsToTimestamp](./firestore_lite.unixsecondstotimestamp.md#unixsecondstotimestamp_class) - -## FirestoreFunction.vectorLength() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. - -```typescript -// Get the vector length (dimension) of the field 'embedding'. -Field.of("embedding").vectorLength(); - -``` - A new representing the length of the vector. - -Signature: - -```typescript -vectorLength(): VectorLength; -``` -Returns: - -[VectorLength](./firestore_lite.vectorlength.md#vectorlength_class) - diff --git a/docs-devsite/firestore_lite.genericstage.md b/docs-devsite/firestore_lite.genericstage.md deleted file mode 100644 index c2f723c8f50..00000000000 --- a/docs-devsite/firestore_lite.genericstage.md +++ /dev/null @@ -1,65 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# GenericStage class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class GenericStage implements Stage -``` -Implements: [Stage](./firestore_lite.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(name, params)](./firestore_lite.genericstage.md#genericstageconstructor) | | (BETA) Constructs a new instance of the GenericStage class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_lite.genericstage.md#genericstagename) | | string | (BETA) | - -## GenericStage.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `GenericStage` class - -Signature: - -```typescript -constructor(name: string, params: unknown[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | | -| params | unknown\[\] | | - -## GenericStage.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_lite.gt.md b/docs-devsite/firestore_lite.gt.md deleted file mode 100644 index 61c217f58ce..00000000000 --- a/docs-devsite/firestore_lite.gt.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Gt class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Gt extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_lite.gt.md#gtconstructor) | | (BETA) Constructs a new instance of the Gt class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_lite.gt.md#gtfilterable) | | true | (BETA) | - -## Gt.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Gt` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | | -| right | [Constant](./firestore_lite.constant.md#constant_class) | | - -## Gt.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.gte.md b/docs-devsite/firestore_lite.gte.md deleted file mode 100644 index 1550dd8daec..00000000000 --- a/docs-devsite/firestore_lite.gte.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Gte class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Gte extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_lite.gte.md#gteconstructor) | | (BETA) Constructs a new instance of the Gte class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_lite.gte.md#gtefilterable) | | true | (BETA) | - -## Gte.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Gte` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | | -| right | [Constant](./firestore_lite.constant.md#constant_class) | | - -## Gte.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.if.md b/docs-devsite/firestore_lite.if.md deleted file mode 100644 index c587b2f1f01..00000000000 --- a/docs-devsite/firestore_lite.if.md +++ /dev/null @@ -1,68 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# If class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class If extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(condition, thenExpr, elseExpr)](./firestore_lite.if.md#ifconstructor) | | (BETA) Constructs a new instance of the If class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_lite.if.md#iffilterable) | | true | (BETA) | - -## If.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `If` class - -Signature: - -```typescript -constructor(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| condition | [FilterExpr](./firestore_lite.md#filterexpr) | | -| thenExpr | [Constant](./firestore_lite.constant.md#constant_class) | | -| elseExpr | [Constant](./firestore_lite.constant.md#constant_class) | | - -## If.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.in.md b/docs-devsite/firestore_lite.in.md deleted file mode 100644 index 83bd0e57107..00000000000 --- a/docs-devsite/firestore_lite.in.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# In class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class In extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, others)](./firestore_lite.in.md#inconstructor) | | (BETA) Constructs a new instance of the In class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_lite.in.md#infilterable) | | true | (BETA) | - -## In.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `In` class - -Signature: - -```typescript -constructor(left: Constant, others: Constant[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | | -| others | [Constant](./firestore_lite.constant.md#constant_class)\[\] | | - -## In.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.isnan.md b/docs-devsite/firestore_lite.isnan.md deleted file mode 100644 index f3be87e7eb8..00000000000 --- a/docs-devsite/firestore_lite.isnan.md +++ /dev/null @@ -1,66 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# IsNan class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class IsNan extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr)](./firestore_lite.isnan.md#isnanconstructor) | | (BETA) Constructs a new instance of the IsNan class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_lite.isnan.md#isnanfilterable) | | true | (BETA) | - -## IsNan.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `IsNan` class - -Signature: - -```typescript -constructor(expr: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | | - -## IsNan.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.like.md b/docs-devsite/firestore_lite.like.md deleted file mode 100644 index 67b00346b88..00000000000 --- a/docs-devsite/firestore_lite.like.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Like class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Like extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr, pattern)](./firestore_lite.like.md#likeconstructor) | | (BETA) Constructs a new instance of the Like class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_lite.like.md#likefilterable) | | true | (BETA) | - -## Like.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Like` class - -Signature: - -```typescript -constructor(expr: Constant, pattern: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | | - -## Like.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.limit.md b/docs-devsite/firestore_lite.limit.md deleted file mode 100644 index 4e559293f2a..00000000000 --- a/docs-devsite/firestore_lite.limit.md +++ /dev/null @@ -1,64 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Limit class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Limit implements Stage -``` -Implements: [Stage](./firestore_lite.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(limit)](./firestore_lite.limit.md#limitconstructor) | | (BETA) Constructs a new instance of the Limit class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_lite.limit.md#limitname) | | string | (BETA) | - -## Limit.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Limit` class - -Signature: - -```typescript -constructor(limit: number); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| limit | number | | - -## Limit.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_lite.logicalmax.md b/docs-devsite/firestore_lite.logicalmax.md deleted file mode 100644 index f992776b068..00000000000 --- a/docs-devsite/firestore_lite.logicalmax.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# LogicalMax class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class LogicalMax extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_lite.logicalmax.md#logicalmaxconstructor) | | (BETA) Constructs a new instance of the LogicalMax class | - -## LogicalMax.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `LogicalMax` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | | -| right | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.logicalmin.md b/docs-devsite/firestore_lite.logicalmin.md deleted file mode 100644 index 686378b7f56..00000000000 --- a/docs-devsite/firestore_lite.logicalmin.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# LogicalMin class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class LogicalMin extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_lite.logicalmin.md#logicalminconstructor) | | (BETA) Constructs a new instance of the LogicalMin class | - -## LogicalMin.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `LogicalMin` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | | -| right | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.lt.md b/docs-devsite/firestore_lite.lt.md deleted file mode 100644 index b44d2f656d0..00000000000 --- a/docs-devsite/firestore_lite.lt.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Lt class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Lt extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_lite.lt.md#ltconstructor) | | (BETA) Constructs a new instance of the Lt class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_lite.lt.md#ltfilterable) | | true | (BETA) | - -## Lt.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Lt` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | | -| right | [Constant](./firestore_lite.constant.md#constant_class) | | - -## Lt.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.lte.md b/docs-devsite/firestore_lite.lte.md deleted file mode 100644 index ddde6a08d93..00000000000 --- a/docs-devsite/firestore_lite.lte.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Lte class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Lte extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_lite.lte.md#lteconstructor) | | (BETA) Constructs a new instance of the Lte class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_lite.lte.md#ltefilterable) | | true | (BETA) | - -## Lte.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Lte` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | | -| right | [Constant](./firestore_lite.constant.md#constant_class) | | - -## Lte.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.mapget.md b/docs-devsite/firestore_lite.mapget.md deleted file mode 100644 index 617b92d4d5a..00000000000 --- a/docs-devsite/firestore_lite.mapget.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# MapGet class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class MapGet extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(map, name)](./firestore_lite.mapget.md#mapgetconstructor) | | (BETA) Constructs a new instance of the MapGet class | - -## MapGet.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `MapGet` class - -Signature: - -```typescript -constructor(map: Constant, name: string); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| map | [Constant](./firestore_lite.constant.md#constant_class) | | -| name | string | | - diff --git a/docs-devsite/firestore_lite.max.md b/docs-devsite/firestore_lite.max.md deleted file mode 100644 index 185fa011d0a..00000000000 --- a/docs-devsite/firestore_lite.max.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Max class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Max extends FirestoreFunction implements Accumulator -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [Accumulator](./firestore_lite.accumulator.md#accumulator_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value, distinct)](./firestore_lite.max.md#maxconstructor) | | (BETA) Constructs a new instance of the Max class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [accumulator](./firestore_lite.max.md#maxaccumulator) | | true | (BETA) | - -## Max.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Max` class - -Signature: - -```typescript -constructor(value: Constant, distinct: boolean); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_lite.constant.md#constant_class) | | -| distinct | boolean | | - -## Max.accumulator - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -accumulator: true; -``` diff --git a/docs-devsite/firestore_lite.md b/docs-devsite/firestore_lite.md index 2a9a2c55801..da7d304e3d5 100644 --- a/docs-devsite/firestore_lite.md +++ b/docs-devsite/firestore_lite.md @@ -25,637 +25,23 @@ https://github.com/firebase/firebase-js-sdk | [collectionGroup(firestore, collectionId)](./firestore_lite.md#collectiongroup_1838fc3) | Creates and returns a new Query instance that includes all documents in the database that are contained in a collection or subcollection with the given collectionId. | | [connectFirestoreEmulator(firestore, host, port, options)](./firestore_lite.md#connectfirestoreemulator_7c247cd) | Modify this instance to communicate with the Cloud Firestore emulator.Note: This must be called before this instance has been used to do any operations. | | [doc(firestore, path, pathSegments)](./firestore_lite.md#doc_1eb4c23) | Gets a DocumentReference instance that refers to the document at the specified absolute path. | -| [pipeline(firestore)](./firestore_lite.md#pipeline_231a8e0) | Experimental Modular API for console testing. | | [runTransaction(firestore, updateFunction, options)](./firestore_lite.md#runtransaction_6f03ec4) | Executes the given updateFunction and then attempts to commit the changes applied within the transaction. If any document read within the transaction has changed, Cloud Firestore retries the updateFunction. If it fails to commit after 5 attempts, the transaction fails.The maximum number of writes allowed in a single transaction is 500. | | [terminate(firestore)](./firestore_lite.md#terminate_231a8e0) | Terminates the provided Firestore instance.After calling terminate() only the clearIndexedDbPersistence() functions may be used. Any other function will throw a FirestoreError. Termination does not cancel any pending writes, and any promises that are awaiting a response from the server will not be resolved.To restart after termination, create a new instance of Firestore with [getFirestore()](./firestore_.md#getfirestore).Note: Under normal circumstances, calling terminate() is not required. This function is useful only when you want to force this instance to release all of its resources or in combination with [clearIndexedDbPersistence()](./firestore_.md#clearindexeddbpersistence_231a8e0) to ensure that all local state is destroyed between test runs. | | [writeBatch(firestore)](./firestore_lite.md#writebatch_231a8e0) | Creates a write batch, used for performing multiple writes as a single atomic operation. The maximum number of writes allowed in a single WriteBatch is 500.The result of these writes will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the write fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. | | function() | | [count()](./firestore_lite.md#count) | Create an AggregateField object that can be used to compute the count of documents in the result set of a query. | -| [countAll()](./firestore_lite.md#countall) | (BETA) Creates an aggregation that counts the total number of stage inputs. -```typescript -// Count the total number of users -countAll().as("totalUsers"); - -``` - A new representing the 'countAll' aggregation. | | [deleteField()](./firestore_lite.md#deletefield) | Returns a sentinel for use with [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) or [setDoc()](./firestore_lite.md#setdoc_ee215ad) with {merge: true} to mark a field for deletion. | | [documentId()](./firestore_lite.md#documentid) | Returns a special sentinel FieldPath to refer to the ID of a document. It can be used in queries to sort or filter by the document ID. | | [getFirestore()](./firestore_lite.md#getfirestore) | Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. | | [serverTimestamp()](./firestore_lite.md#servertimestamp) | Returns a sentinel used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) to include a server-generated timestamp in the written data. | -| [useFirestorePipelines()](./firestore_lite.md#usefirestorepipelines) | Copyright 2024 Google LLCLicensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | -| function(array, ...) | -| [arrayConcat(array, elements)](./firestore_lite.md#arrayconcat_0b3ddb9) | (BETA) Creates an expression that concatenates an array expression with other arrays. -```typescript -// Combine the 'items' array with two new item arrays -arrayConcat(Field.of("items"), [Field.of("newItems"), Field.of("otherItems")]); - -``` - | -| [arrayConcat(array, elements)](./firestore_lite.md#arrayconcat_21991c1) | (BETA) Creates an expression that concatenates an array expression with other arrays and/or values. -```typescript -// Combine the 'tags' array with a new array -arrayConcat(Field.of("tags"), ["newTag1", "newTag2"]); - -``` - | -| [arrayConcat(array, elements)](./firestore_lite.md#arrayconcat_f8d5d5e) | (BETA) Creates an expression that concatenates a field's array value with other arrays. -```typescript -// Combine the 'items' array with two new item arrays -arrayConcat("items", [Field.of("newItems"), Field.of("otherItems")]); - -``` - | -| [arrayConcat(array, elements)](./firestore_lite.md#arrayconcat_5a66d99) | (BETA) Creates an expression that concatenates a field's array value with other arrays and/or values. -```typescript -// Combine the 'tags' array with a new array -arrayConcat("tags", ["newTag1", "newTag2"]); - -``` - | -| [arrayContains(array, element)](./firestore_lite.md#arraycontains_01ea7c0) | (BETA) Creates an expression that checks if an array expression contains a specific element. -```typescript -// Check if the 'colors' array contains the value of field 'selectedColor' -arrayContains(Field.of("colors"), Field.of("selectedColor")); - -``` - | -| [arrayContains(array, element)](./firestore_lite.md#arraycontains_60f8f2f) | (BETA) Creates an expression that checks if an array expression contains a specific element. -```typescript -// Check if the 'colors' array contains "red" -arrayContains(Field.of("colors"), "red"); - -``` - | -| [arrayContains(array, element)](./firestore_lite.md#arraycontains_0ebdbfe) | (BETA) Creates an expression that checks if a field's array value contains a specific element. -```typescript -// Check if the 'colors' array contains the value of field 'selectedColor' -arrayContains("colors", Field.of("selectedColor")); - -``` - | -| [arrayContains(array, element)](./firestore_lite.md#arraycontains_8f718df) | (BETA) Creates an expression that checks if a field's array value contains a specific value. -```typescript -// Check if the 'colors' array contains "red" -arrayContains("colors", "red"); - -``` - | -| [arrayContainsAll(array, values)](./firestore_lite.md#arraycontainsall_7b7433a) | (BETA) Creates an expression that checks if an array expression contains all the specified elements. -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" -arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); - -``` - | -| [arrayContainsAll(array, values)](./firestore_lite.md#arraycontainsall_d919466) | (BETA) Creates an expression that checks if an array expression contains all the specified elements. -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" -arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); - -``` - | -| [arrayContainsAll(array, values)](./firestore_lite.md#arraycontainsall_b40e2df) | (BETA) Creates an expression that checks if a field's array value contains all the specified values or expressions. -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); - -``` - | -| [arrayContainsAll(array, values)](./firestore_lite.md#arraycontainsall_b08efbb) | (BETA) Creates an expression that checks if a field's array value contains all the specified values or expressions. -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); - -``` - | -| [arrayContainsAny(array, values)](./firestore_lite.md#arraycontainsany_7b7433a) | (BETA) Creates an expression that checks if an array expression contains any of the specified elements. -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "Science" -arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); - -``` - | -| [arrayContainsAny(array, values)](./firestore_lite.md#arraycontainsany_d919466) | (BETA) Creates an expression that checks if an array expression contains any of the specified elements. -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "Science" -arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); - -``` - | -| [arrayContainsAny(array, values)](./firestore_lite.md#arraycontainsany_b40e2df) | (BETA) Creates an expression that checks if a field's array value contains any of the specified elements. -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -arrayContainsAny("categories", [Field.of("cate1"), "Science"]); - -``` - | -| [arrayContainsAny(array, values)](./firestore_lite.md#arraycontainsany_b08efbb) | (BETA) Creates an expression that checks if a field's array value contains any of the specified elements. -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -arrayContainsAny("categories", [Field.of("cate1"), "Science"]); - -``` - | -| [arrayLength(array)](./firestore_lite.md#arraylength_0bb5dbb) | (BETA) Creates an expression that calculates the length of an array expression. -```typescript -// Get the number of items in the 'cart' array -arrayLength(Field.of("cart")); - -``` - | -| function(condition, ...) | -| [ifFunction(condition, thenExpr, elseExpr)](./firestore_lite.md#iffunction_f7b2404) | (BETA) Creates a conditional expression that evaluates to a 'then' expression if a condition is true and an 'else' expression if the condition is false. -```typescript -// If 'age' is greater than 18, return "Adult"; otherwise, return "Minor". -ifFunction( - gt("age", 18), Constant.of("Adult"), Constant.of("Minor")); - -``` - | | function(databaseId, ...) | | [getFirestore(databaseId)](./firestore_lite.md#getfirestore_53dc891) | (BETA) Returns the existing [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. | -| function(element, ...) | -| [inAny(element, others)](./firestore_lite.md#inany_a73b259) | (BETA) Creates an expression that checks if an expression is equal to any of the provided values or expressions. -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -inAny(Field.of("category"), [Constant.of("Electronics"), Field.of("primaryType")]); - -``` - | -| [inAny(element, others)](./firestore_lite.md#inany_f5721c6) | (BETA) Creates an expression that checks if an expression is equal to any of the provided values or expressions. -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -inAny(Field.of("category"), ["Electronics", Field.of("primaryType")]); - -``` - | -| [inAny(element, others)](./firestore_lite.md#inany_c6646ea) | (BETA) Creates an expression that checks if a field's value is equal to any of the provided values or expressions. -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -inAny("category", [Constant.of("Electronics"), Field.of("primaryType")]); - -``` - | -| [inAny(element, others)](./firestore_lite.md#inany_e6877aa) | (BETA) Creates an expression that checks if a field's value is equal to any of the provided values or expressions. -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -inAny("category", ["Electronics", Field.of("primaryType")]); - -``` - | -| [notInAny(element, others)](./firestore_lite.md#notinany_a73b259) | (BETA) Creates an expression that checks if an expression is not equal to any of the provided values or expressions. -```typescript -// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' -notInAny(Field.of("status"), [Constant.of("pending"), Field.of("rejectedStatus")]); - -``` - | -| [notInAny(element, others)](./firestore_lite.md#notinany_f5721c6) | (BETA) Creates an expression that checks if an expression is not equal to any of the provided values or expressions. -```typescript -// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' -notInAny(Field.of("status"), ["pending", Field.of("rejectedStatus")]); - -``` - | -| [notInAny(element, others)](./firestore_lite.md#notinany_c6646ea) | (BETA) Creates an expression that checks if a field's value is not equal to any of the provided values or expressions. -```typescript -// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' -notInAny("status", [Constant.of("pending"), Field.of("rejectedStatus")]); - -``` - | -| [notInAny(element, others)](./firestore_lite.md#notinany_e6877aa) | (BETA) Creates an expression that checks if a field's value is not equal to any of the provided values or expressions. -```typescript -// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' -notInAny("status", ["pending", Field.of("rejectedStatus")]); - -``` - | | function(elements, ...) | | [arrayRemove(elements)](./firestore_lite.md#arrayremove_7d853aa) | Returns a special value that can be used with [setDoc()](./firestore_.md#setdoc_ee215ad) or that tells the server to remove the given elements from any array value that already exists on the server. All instances of each element specified will be removed from the array. If the field being modified is not already an array it will be overwritten with an empty array. | | [arrayUnion(elements)](./firestore_lite.md#arrayunion_7d853aa) | Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to union the given elements with any array value that already exists on the server. Each specified element that doesn't already exist in the array will be added to the end. If the field being modified is not already an array it will be overwritten with an array containing exactly the specified elements. | -| function(expr, ...) | -| [ascending(expr)](./firestore_lite.md#ascending_f3fb767) | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. -```typescript -// Sort documents by the 'name' field in ascending order -firestore.pipeline().collection("users") - .sort(ascending(Field.of("name"))); - -``` - | -| [byteLength(expr)](./firestore_lite.md#bytelength_f3fb767) | (BETA) Creates an expression that calculates the byte length of a string in UTF-8, or just the length of a Blob. -```typescript -// Calculate the length of the 'myString' field in bytes. -byteLength(Field.of("myString")); - -``` - | -| [charLength(expr)](./firestore_lite.md#charlength_f3fb767) | (BETA) Creates an expression that calculates the character length of a string expression in UTF-8. -```typescript -// Get the character length of the 'name' field in UTF-8. -strLength(Field.of("name")); - -``` - | -| [cosineDistance(expr, other)](./firestore_lite.md#cosinedistance_b4c7dc2) | (BETA) Calculates the Cosine distance between a field's vector value and a double array. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -cosineDistance("location", [37.7749, -122.4194]); - -``` - | -| [cosineDistance(expr, other)](./firestore_lite.md#cosinedistance_8d2bd9d) | (BETA) Calculates the Cosine distance between a field's vector value and a VectorValue. -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -cosineDistance("location", new VectorValue([37.7749, -122.4194])); - -``` - | -| [cosineDistance(expr, other)](./firestore_lite.md#cosinedistance_c9ae0bc) | (BETA) Calculates the Cosine distance between a field's vector value and a vector expression. -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -cosineDistance("userVector", Field.of("itemVector")); - -``` - | -| [cosineDistance(expr, other)](./firestore_lite.md#cosinedistance_e701952) | (BETA) Calculates the Cosine distance between a vector expression and a double array. -```typescript -// Calculate the cosine distance between the 'location' field and a target location -cosineDistance(Field.of("location"), [37.7749, -122.4194]); - -``` - | -| [cosineDistance(expr, other)](./firestore_lite.md#cosinedistance_cc2e83e) | (BETA) Calculates the Cosine distance between a vector expression and a VectorValue. -```typescript -// Calculate the cosine distance between the 'location' field and a target location -cosineDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); - -``` - | -| [cosineDistance(expr, other)](./firestore_lite.md#cosinedistance_0896fbd) | (BETA) Calculates the Cosine distance between two vector expressions. -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -cosineDistance(Field.of("userVector"), Field.of("itemVector")); - -``` - | -| [descending(expr)](./firestore_lite.md#descending_f3fb767) | (BETA) Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") - .sort(descending(Field.of("createdAt"))); - -``` - | -| [dotProduct(expr, other)](./firestore_lite.md#dotproduct_b4c7dc2) | (BETA) Calculates the dot product between a field's vector value and a double array. -```typescript -// Calculate the dot product distance between a feature vector and a target vector -dotProduct("features", [0.5, 0.8, 0.2]); - -``` - | -| [dotProduct(expr, other)](./firestore_lite.md#dotproduct_8d2bd9d) | (BETA) Calculates the dot product between a field's vector value and a VectorValue. -```typescript -// Calculate the dot product distance between a feature vector and a target vector -dotProduct("features", new VectorValue([0.5, 0.8, 0.2])); - -``` - | -| [dotProduct(expr, other)](./firestore_lite.md#dotproduct_c9ae0bc) | (BETA) Calculates the dot product between a field's vector value and a vector expression. -```typescript -// Calculate the dot product distance between two document vectors: 'docVector1' and 'docVector2' -dotProduct("docVector1", Field.of("docVector2")); - -``` - | -| [dotProduct(expr, other)](./firestore_lite.md#dotproduct_e701952) | (BETA) Calculates the dot product between a vector expression and a double array. -```typescript -// Calculate the dot product between a feature vector and a target vector -dotProduct(Field.of("features"), [0.5, 0.8, 0.2]); - -``` - | -| [dotProduct(expr, other)](./firestore_lite.md#dotproduct_cc2e83e) | (BETA) Calculates the dot product between a vector expression and a VectorValue. -```typescript -// Calculate the dot product between a feature vector and a target vector -dotProduct(Field.of("features"), new VectorValue([0.5, 0.8, 0.2])); - -``` - | -| [dotProduct(expr, other)](./firestore_lite.md#dotproduct_0896fbd) | (BETA) Calculates the dot product between two vector expressions. -```typescript -// Calculate the dot product between two document vectors: 'docVector1' and 'docVector2' -dotProduct(Field.of("docVector1"), Field.of("docVector2")); - -``` - | -| [endsWith(expr, suffix)](./firestore_lite.md#endswith_88569cd) | (BETA) Creates an expression that checks if a field's value ends with a given postfix. -```typescript -// Check if the 'filename' field ends with ".txt" -endsWith("filename", ".txt"); - -``` - | -| [endsWith(expr, suffix)](./firestore_lite.md#endswith_e2e794e) | (BETA) Creates an expression that checks if a field's value ends with a given postfix. -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -endsWith("url", Field.of("extension")); - -``` - | -| [endsWith(expr, suffix)](./firestore_lite.md#endswith_6308b81) | (BETA) Creates an expression that checks if a string expression ends with a given postfix. -```typescript -// Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." -endsWith(Field.of("fullName"), "Jr."); - -``` - | -| [endsWith(expr, suffix)](./firestore_lite.md#endswith_ab1cc39) | (BETA) Creates an expression that checks if a string expression ends with a given postfix. -```typescript -// Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." -endsWith(Field.of("fullName"), Constant.of("Jr.")); - -``` - | -| [euclideanDistance(expr, other)](./firestore_lite.md#euclideandistance_b4c7dc2) | (BETA) Calculates the Euclidean distance between a field's vector value and a double array. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -euclideanDistance("location", [37.7749, -122.4194]); - -``` - | -| [euclideanDistance(expr, other)](./firestore_lite.md#euclideandistance_8d2bd9d) | (BETA) Calculates the Euclidean distance between a field's vector value and a VectorValue. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -euclideanDistance("location", new VectorValue([37.7749, -122.4194])); - -``` - | -| [euclideanDistance(expr, other)](./firestore_lite.md#euclideandistance_c9ae0bc) | (BETA) Calculates the Euclidean distance between a field's vector value and a vector expression. -```typescript -// Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' -euclideanDistance("pointA", Field.of("pointB")); - -``` - | -| [euclideanDistance(expr, other)](./firestore_lite.md#euclideandistance_e701952) | (BETA) Calculates the Euclidean distance between a vector expression and a double array. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location - -euclideanDistance(Field.of("location"), [37.7749, -122.4194]); - -``` - | -| [euclideanDistance(expr, other)](./firestore_lite.md#euclideandistance_cc2e83e) | (BETA) Calculates the Euclidean distance between a vector expression and a VectorValue. -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -euclideanDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); - -``` - | -| [euclideanDistance(expr, other)](./firestore_lite.md#euclideandistance_0896fbd) | (BETA) Calculates the Euclidean distance between two vector expressions. -```typescript -// Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' -euclideanDistance(Field.of("pointA"), Field.of("pointB")); - -``` - | -| [reverse(expr)](./firestore_lite.md#reverse_f3fb767) | (BETA) Creates an expression that reverses a string. -```typescript -// Reverse the value of the 'myString' field. -reverse(Field.of("myString")); - -``` - | -| [startsWith(expr, prefix)](./firestore_lite.md#startswith_484d9f3) | (BETA) Creates an expression that checks if a field's value starts with a given prefix. -```typescript -// Check if the 'name' field starts with "Mr." -startsWith("name", "Mr."); - -``` - | -| [startsWith(expr, prefix)](./firestore_lite.md#startswith_7deb5c7) | (BETA) Creates an expression that checks if a field's value starts with a given prefix. -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -startsWith("fullName", Field.of("firstName")); - -``` - | -| [startsWith(expr, prefix)](./firestore_lite.md#startswith_68300d1) | (BETA) Creates an expression that checks if a string expression starts with a given prefix. -```typescript -// Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." -startsWith(Field.of("fullName"), "Mr."); - -``` - | -| [startsWith(expr, prefix)](./firestore_lite.md#startswith_5774b68) | (BETA) Creates an expression that checks if a string expression starts with a given prefix. -```typescript -// Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." -startsWith(Field.of("fullName"), Field.of("prefix")); - -``` - | -| [timestampToUnixMicros(expr)](./firestore_lite.md#timestamptounixmicros_f3fb767) | (BETA) Creates an expression that converts a timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -timestampToUnixMicros(Field.of("timestamp")); - -``` - | -| [timestampToUnixMillis(expr)](./firestore_lite.md#timestamptounixmillis_f3fb767) | (BETA) Creates an expression that converts a timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -timestampToUnixMillis(Field.of("timestamp")); - -``` - | -| [timestampToUnixSeconds(expr)](./firestore_lite.md#timestamptounixseconds_f3fb767) | (BETA) Creates an expression that converts a timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to seconds since epoch. -timestampToUnixSeconds(Field.of("timestamp")); - -``` - | -| [toLower(expr)](./firestore_lite.md#tolower_1e536ed) | (BETA) Creates an expression that converts a string field to lowercase. -```typescript -// Convert the 'name' field to lowercase -toLower("name"); - -``` - | -| [toLower(expr)](./firestore_lite.md#tolower_f3fb767) | (BETA) Creates an expression that converts a string expression to lowercase. -```typescript -// Convert the 'name' field to lowercase -toLower(Field.of("name")); - -``` - | -| [toUpper(expr)](./firestore_lite.md#toupper_1e536ed) | (BETA) Creates an expression that converts a string field to uppercase. -```typescript -// Convert the 'title' field to uppercase -toUpper("title"); - -``` - | -| [toUpper(expr)](./firestore_lite.md#toupper_f3fb767) | (BETA) Creates an expression that converts a string expression to uppercase. -```typescript -// Convert the 'title' field to uppercase -toUppercase(Field.of("title")); - -``` - | -| [trim(expr)](./firestore_lite.md#trim_1e536ed) | (BETA) Creates an expression that removes leading and trailing whitespace from a string field. -```typescript -// Trim whitespace from the 'userInput' field -trim("userInput"); - -``` - | -| [trim(expr)](./firestore_lite.md#trim_f3fb767) | (BETA) Creates an expression that removes leading and trailing whitespace from a string expression. -```typescript -// Trim whitespace from the 'userInput' field -trim(Field.of("userInput")); - -``` - | -| [unixMicrosToTimestamp(expr)](./firestore_lite.md#unixmicrostotimestamp_f3fb767) | (BETA) Creates an expression that interprets an expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -unixMicrosToTimestamp(Field.of("microseconds")); - -``` - | -| [unixMillisToTimestamp(expr)](./firestore_lite.md#unixmillistotimestamp_f3fb767) | (BETA) Creates an expression that interprets an expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -unixMillisToTimestamp(Field.of("milliseconds")); - -``` - | -| [unixSecondsToTimestamp(expr)](./firestore_lite.md#unixsecondstotimestamp_f3fb767) | (BETA) Creates an expression that interprets an expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'seconds' field as seconds since epoch. -unixSecondsToTimestamp(Field.of("seconds")); - -``` - | -| [vectorLength(expr)](./firestore_lite.md#vectorlength_f3fb767) | (BETA) Creates an expression that calculates the length of a Firestore Vector. -```typescript -// Get the vector length (dimension) of the field 'embedding'. -vectorLength(Field.of("embedding")); - -``` - | | function(field, ...) | | [average(field)](./firestore_lite.md#average_aacc3a9) | Create an AggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query. | -| [byteLength(field)](./firestore_lite.md#bytelength_0fb8cd4) | (BETA) Creates an expression that calculates the length of a string represented by a field in UTF-8 bytes, or just the length of a Blob. -```typescript -// Calculate the length of the 'myString' field in bytes. -byteLength("myString"); - -``` - | -| [charLength(field)](./firestore_lite.md#charlength_0fb8cd4) | (BETA) Creates an expression that calculates the character length of a string field in UTF8. -```typescript -// Get the character length of the 'name' field in UTF-8. -strLength("name"); - -``` - | -| [exists(field)](./firestore_lite.md#exists_0fb8cd4) | (BETA) Creates an expression that checks if a field exists. -```typescript -// Check if the document has a field named "phoneNumber" -exists("phoneNumber"); - -``` - | -| [replaceAll(field, find, replace)](./firestore_lite.md#replaceall_b257ab0) | (BETA) Creates an expression that replaces all occurrences of a substring within a string represented by a field with another substring. -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field. -replaceAll("message", "hello", "hi"); - -``` - | -| [replaceFirst(field, find, replace)](./firestore_lite.md#replacefirst_b257ab0) | (BETA) Creates an expression that replaces the first occurrence of a substring within a string represented by a field with another substring. -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field. -replaceFirst("message", "hello", "hi"); - -``` - | -| [reverse(field)](./firestore_lite.md#reverse_0fb8cd4) | (BETA) Creates an expression that reverses a string represented by a field. -```typescript -// Reverse the value of the 'myString' field. -reverse("myString"); - -``` - | | [sum(field)](./firestore_lite.md#sum_aacc3a9) | Create an AggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query. | -| [timestampAdd(field, unit, amount)](./firestore_lite.md#timestampadd_565792c) | (BETA) Creates an expression that adds a specified amount of time to a timestamp represented by a field. -```typescript -// Add 1 day to the 'timestamp' field. -timestampAdd("timestamp", "day", 1); - -``` - | -| [timestampSub(field, unit, amount)](./firestore_lite.md#timestampsub_565792c) | (BETA) Creates an expression that subtracts a specified amount of time from a timestamp represented by a field. -```typescript -// Subtract 1 day from the 'timestamp' field. -timestampSub("timestamp", "day", 1); - -``` - | -| [timestampToUnixMicros(field)](./firestore_lite.md#timestamptounixmicros_0fb8cd4) | (BETA) Creates an expression that converts a timestamp field to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -timestampToUnixMicros("timestamp"); - -``` - | -| [timestampToUnixMillis(field)](./firestore_lite.md#timestamptounixmillis_0fb8cd4) | (BETA) Creates an expression that converts a timestamp field to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -timestampToUnixMillis("timestamp"); - -``` - | -| [timestampToUnixSeconds(field)](./firestore_lite.md#timestamptounixseconds_0fb8cd4) | (BETA) Creates an expression that converts a timestamp field to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). -```typescript -// Convert the 'timestamp' field to seconds since epoch. -timestampToUnixSeconds("timestamp"); - -``` - | -| [unixMicrosToTimestamp(field)](./firestore_lite.md#unixmicrostotimestamp_0fb8cd4) | (BETA) Creates an expression that interprets a field's value as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -unixMicrosToTimestamp("microseconds"); - -``` - | -| [unixMillisToTimestamp(field)](./firestore_lite.md#unixmillistotimestamp_0fb8cd4) | (BETA) Creates an expression that interprets a field's value as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -unixMillisToTimestamp("milliseconds"); - -``` - | -| [unixSecondsToTimestamp(field)](./firestore_lite.md#unixsecondstotimestamp_0fb8cd4) | (BETA) Creates an expression that interprets a field's value as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. -```typescript -// Interpret the 'seconds' field as seconds since epoch. -unixSecondsToTimestamp("seconds"); - -``` - | -| [vectorLength(field)](./firestore_lite.md#vectorlength_0fb8cd4) | (BETA) Creates an expression that calculates the length of a Firestore Vector represented by a field. -```typescript -// Get the vector length (dimension) of the field 'embedding'. -vectorLength("embedding"); - -``` - | | function(fieldPath, ...) | | [orderBy(fieldPath, directionStr)](./firestore_lite.md#orderby_006d61f) | Creates a [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) that sorts the query result by the specified field, optionally in descending order instead of ascending.Note: Documents that do not contain the specified field will not be present in the query result. | | [where(fieldPath, opStr, value)](./firestore_lite.md#where_0fae4bf) | Creates a [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) that enforces that documents must contain the specified field and that the value should satisfy the relation constraint provided. | @@ -664,577 +50,23 @@ vectorLength("embedding"); | [endBefore(fieldValues)](./firestore_lite.md#endbefore_8b2f2c8) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | | [startAfter(fieldValues)](./firestore_lite.md#startafter_8b2f2c8) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | | [startAt(fieldValues)](./firestore_lite.md#startat_8b2f2c8) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. | -| function(filter, ...) | -| [not(filter)](./firestore_lite.md#not_5520849) | (BETA) Creates an expression that negates a filter condition. -```typescript -// Find documents where the 'completed' field is NOT true -not(eq("completed", true)); - -``` - | -| function(first, ...) | -| [strConcat(first, elements)](./firestore_lite.md#strconcat_0f1bdbf) | (BETA) Creates an expression that concatenates string functions, fields or constants together. -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -strConcat("firstName", " ", Field.of("lastName")); - -``` - | -| [strConcat(first, elements)](./firestore_lite.md#strconcat_1eb0ac1) | (BETA) Creates an expression that concatenates string expressions together. -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -strConcat(Field.of("firstName"), " ", Field.of("lastName")); - -``` - | | function(left, ...) | -| [add(left, right)](./firestore_lite.md#add_be96f75) | (BETA) Creates an expression that adds two expressions together. -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -add(Field.of("quantity"), Field.of("reserve")); - -``` - | -| [add(left, right)](./firestore_lite.md#add_010ba9e) | (BETA) Creates an expression that adds an expression to a constant value. -```typescript -// Add 5 to the value of the 'age' field -add(Field.of("age"), 5); - -``` - | -| [add(left, right)](./firestore_lite.md#add_674c63f) | (BETA) Creates an expression that adds a field's value to an expression. -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -add("quantity", Field.of("reserve")); - -``` - | -| [add(left, right)](./firestore_lite.md#add_1f46a76) | (BETA) Creates an expression that adds a field's value to a constant value. -```typescript -// Add 5 to the value of the 'age' field -add("age", 5); - -``` - | | [aggregateFieldEqual(left, right)](./firestore_lite.md#aggregatefieldequal_e80a2b2) | Compares two 'AggregateField\` instances for equality. | | [aggregateQuerySnapshotEqual(left, right)](./firestore_lite.md#aggregatequerysnapshotequal_1529a20) | Compares two AggregateQuerySnapshot instances for equality.Two AggregateQuerySnapshot instances are considered "equal" if they have underlying queries that compare equal, and the same data. | -| [and(left, right)](./firestore_lite.md#and_eba7e36) | (BETA) Creates an expression that performs a logical 'AND' operation on multiple filter conditions. -```typescript -// Check if the 'age' field is greater than 18 AND the 'city' field is "London" AND -// the 'status' field is "active" -const condition = and(gt("age", 18), eq("city", "London"), eq("status", "active")); - -``` - | -| [divide(left, right)](./firestore_lite.md#divide_be96f75) | (BETA) Creates an expression that divides two expressions. -```typescript -// Divide the 'total' field by the 'count' field -divide(Field.of("total"), Field.of("count")); - -``` - | -| [divide(left, right)](./firestore_lite.md#divide_010ba9e) | (BETA) Creates an expression that divides an expression by a constant value. -```typescript -// Divide the 'value' field by 10 -divide(Field.of("value"), 10); - -``` - | -| [divide(left, right)](./firestore_lite.md#divide_674c63f) | (BETA) Creates an expression that divides a field's value by an expression. -```typescript -// Divide the 'total' field by the 'count' field -divide("total", Field.of("count")); - -``` - | -| [divide(left, right)](./firestore_lite.md#divide_1f46a76) | (BETA) Creates an expression that divides a field's value by a constant value. -```typescript -// Divide the 'value' field by 10 -divide("value", 10); - -``` - | -| [eq(left, right)](./firestore_lite.md#eq_be96f75) | (BETA) Creates an expression that checks if two expressions are equal. -```typescript -// Check if the 'age' field is equal to an expression -eq(Field.of("age"), Field.of("minAge").add(10)); - -``` - | -| [eq(left, right)](./firestore_lite.md#eq_010ba9e) | (BETA) Creates an expression that checks if an expression is equal to a constant value. -```typescript -// Check if the 'age' field is equal to 21 -eq(Field.of("age"), 21); - -``` - | -| [eq(left, right)](./firestore_lite.md#eq_674c63f) | (BETA) Creates an expression that checks if a field's value is equal to an expression. -```typescript -// Check if the 'age' field is equal to the 'limit' field -eq("age", Field.of("limit")); - -``` - | -| [eq(left, right)](./firestore_lite.md#eq_1f46a76) | (BETA) Creates an expression that checks if a field's value is equal to a constant value. -```typescript -// Check if the 'city' field is equal to string constant "London" -eq("city", "London"); - -``` - | -| [gt(left, right)](./firestore_lite.md#gt_be96f75) | (BETA) Creates an expression that checks if the first expression is greater than the second expression. -```typescript -// Check if the 'age' field is greater than 18 -gt(Field.of("age"), Constant(9).add(9)); - -``` - | -| [gt(left, right)](./firestore_lite.md#gt_010ba9e) | (BETA) Creates an expression that checks if an expression is greater than a constant value. -```typescript -// Check if the 'age' field is greater than 18 -gt(Field.of("age"), 18); - -``` - | -| [gt(left, right)](./firestore_lite.md#gt_674c63f) | (BETA) Creates an expression that checks if a field's value is greater than an expression. -```typescript -// Check if the value of field 'age' is greater than the value of field 'limit' -gt("age", Field.of("limit")); - -``` - | -| [gt(left, right)](./firestore_lite.md#gt_1f46a76) | (BETA) Creates an expression that checks if a field's value is greater than a constant value. -```typescript -// Check if the 'price' field is greater than 100 -gt("price", 100); - -``` - | -| [gte(left, right)](./firestore_lite.md#gte_be96f75) | (BETA) Creates an expression that checks if the first expression is greater than or equal to the second expression. -```typescript -// Check if the 'quantity' field is greater than or equal to the field "threshold" -gte(Field.of("quantity"), Field.of("threshold")); - -``` - | -| [gte(left, right)](./firestore_lite.md#gte_010ba9e) | (BETA) Creates an expression that checks if an expression is greater than or equal to a constant value. -```typescript -// Check if the 'quantity' field is greater than or equal to 10 -gte(Field.of("quantity"), 10); - -``` - | -| [gte(left, right)](./firestore_lite.md#gte_674c63f) | (BETA) Creates an expression that checks if a field's value is greater than or equal to an expression. -```typescript -// Check if the value of field 'age' is greater than or equal to the value of field 'limit' -gte("age", Field.of("limit")); - -``` - | -| [gte(left, right)](./firestore_lite.md#gte_1f46a76) | (BETA) Creates an expression that checks if a field's value is greater than or equal to a constant value. -```typescript -// Check if the 'score' field is greater than or equal to 80 -gte("score", 80); - -``` - | -| [like(left, pattern)](./firestore_lite.md#like_33ec01b) | (BETA) Creates an expression that performs a case-sensitive wildcard string comparison against a field. -```typescript -// Check if the 'title' field contains the string "guide" -like("title", "%guide%"); - -``` - | -| [like(left, pattern)](./firestore_lite.md#like_dd84184) | (BETA) Creates an expression that performs a case-sensitive wildcard string comparison against a field. -```typescript -// Check if the 'title' field contains the string "guide" -like("title", Field.of("pattern")); - -``` - | -| [like(left, pattern)](./firestore_lite.md#like_3aaffe0) | (BETA) Creates an expression that performs a case-sensitive wildcard string comparison. -```typescript -// Check if the 'title' field contains the string "guide" -like(Field.of("title"), "%guide%"); - -``` - | -| [like(left, pattern)](./firestore_lite.md#like_a2c3e8b) | (BETA) Creates an expression that performs a case-sensitive wildcard string comparison. -```typescript -// Check if the 'title' field contains the string "guide" -like(Field.of("title"), Field.of("pattern")); - -``` - | -| [logicalMax(left, right)](./firestore_lite.md#logicalmax_be96f75) | (BETA) Creates an expression that returns the larger value between two expressions, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'field1' field and the 'field2' field. -logicalMax(Field.of("field1"), Field.of("field2")); - -``` - | -| [logicalMax(left, right)](./firestore_lite.md#logicalmax_010ba9e) | (BETA) Creates an expression that returns the larger value between an expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'value' field and 10. -logicalMax(Field.of("value"), 10); - -``` - | -| [logicalMax(left, right)](./firestore_lite.md#logicalmax_674c63f) | (BETA) Creates an expression that returns the larger value between a field and an expression, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'field1' field and the 'field2' field. -logicalMax("field1", Field.of('field2')); - -``` - | -| [logicalMax(left, right)](./firestore_lite.md#logicalmax_1f46a76) | (BETA) Creates an expression that returns the larger value between a field and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the larger value between the 'value' field and 10. -logicalMax("value", 10); - -``` - | -| [logicalMin(left, right)](./firestore_lite.md#logicalmin_be96f75) | (BETA) Creates an expression that returns the smaller value between two expressions, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'field1' field and the 'field2' field. -logicalMin(Field.of("field1"), Field.of("field2")); - -``` - | -| [logicalMin(left, right)](./firestore_lite.md#logicalmin_010ba9e) | (BETA) Creates an expression that returns the smaller value between an expression and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'value' field and 10. -logicalMin(Field.of("value"), 10); - -``` - | -| [logicalMin(left, right)](./firestore_lite.md#logicalmin_674c63f) | (BETA) Creates an expression that returns the smaller value between a field and an expression, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'field1' field and the 'field2' field. -logicalMin("field1", Field.of("field2")); - -``` - | -| [logicalMin(left, right)](./firestore_lite.md#logicalmin_1f46a76) | (BETA) Creates an expression that returns the smaller value between a field and a constant value, based on Firestore's value type ordering. -```typescript -// Returns the smaller value between the 'value' field and 10. -logicalMin("value", 10); - -``` - | -| [lt(left, right)](./firestore_lite.md#lt_be96f75) | (BETA) Creates an expression that checks if the first expression is less than the second expression. -```typescript -// Check if the 'age' field is less than 30 -lt(Field.of("age"), Field.of("limit")); - -``` - | -| [lt(left, right)](./firestore_lite.md#lt_010ba9e) | (BETA) Creates an expression that checks if an expression is less than a constant value. -```typescript -// Check if the 'age' field is less than 30 -lt(Field.of("age"), 30); - -``` - | -| [lt(left, right)](./firestore_lite.md#lt_674c63f) | (BETA) Creates an expression that checks if a field's value is less than an expression. -```typescript -// Check if the 'age' field is less than the 'limit' field -lt("age", Field.of("limit")); - -``` - | -| [lt(left, right)](./firestore_lite.md#lt_1f46a76) | (BETA) Creates an expression that checks if a field's value is less than a constant value. -```typescript -// Check if the 'price' field is less than 50 -lt("price", 50); - -``` - | -| [lte(left, right)](./firestore_lite.md#lte_be96f75) | (BETA) Creates an expression that checks if the first expression is less than or equal to the second expression. -```typescript -// Check if the 'quantity' field is less than or equal to 20 -lte(Field.of("quantity"), Field.of("limit")); - -``` - | -| [lte(left, right)](./firestore_lite.md#lte_010ba9e) | (BETA) Creates an expression that checks if an expression is less than or equal to a constant value. -```typescript -// Check if the 'quantity' field is less than or equal to 20 -lte(Field.of("quantity"), 20); - -``` - | -| [lte(left, right)](./firestore_lite.md#lte_674c63f) | Creates an expression that checks if a field's value is less than or equal to an expression. -```typescript -// Check if the 'quantity' field is less than or equal to the 'limit' field -lte("quantity", Field.of("limit")); - -``` - | -| [lte(left, right)](./firestore_lite.md#lte_1f46a76) | (BETA) Creates an expression that checks if a field's value is less than or equal to a constant value. -```typescript -// Check if the 'score' field is less than or equal to 70 -lte("score", 70); - -``` - | -| [mod(left, right)](./firestore_lite.md#mod_be96f75) | (BETA) Creates an expression that calculates the modulo (remainder) of dividing two expressions. -```typescript -// Calculate the remainder of dividing 'field1' by 'field2'. -mod(Field.of("field1"), Field.of("field2")); - -``` - | -| [mod(left, right)](./firestore_lite.md#mod_010ba9e) | (BETA) Creates an expression that calculates the modulo (remainder) of dividing an expression by a constant. -```typescript -// Calculate the remainder of dividing 'field1' by 5. -mod(Field.of("field1"), 5); - -``` - | -| [mod(left, right)](./firestore_lite.md#mod_674c63f) | (BETA) Creates an expression that calculates the modulo (remainder) of dividing a field's value by an expression. -```typescript -// Calculate the remainder of dividing 'field1' by 'field2'. -mod("field1", Field.of("field2")); - -``` - | -| [mod(left, right)](./firestore_lite.md#mod_1f46a76) | (BETA) Creates an expression that calculates the modulo (remainder) of dividing a field's value by a constant. -```typescript -// Calculate the remainder of dividing 'field1' by 5. -mod("field1", 5); - -``` - | -| [multiply(left, right)](./firestore_lite.md#multiply_be96f75) | (BETA) Creates an expression that multiplies two expressions together. -```typescript -// Multiply the 'quantity' field by the 'price' field -multiply(Field.of("quantity"), Field.of("price")); - -``` - | -| [multiply(left, right)](./firestore_lite.md#multiply_010ba9e) | (BETA) Creates an expression that multiplies an expression by a constant value. -```typescript -// Multiply the value of the 'price' field by 2 -multiply(Field.of("price"), 2); - -``` - | -| [multiply(left, right)](./firestore_lite.md#multiply_674c63f) | (BETA) Creates an expression that multiplies a field's value by an expression. -```typescript -// Multiply the 'quantity' field by the 'price' field -multiply("quantity", Field.of("price")); - -``` - | -| [multiply(left, right)](./firestore_lite.md#multiply_1f46a76) | (BETA) Creates an expression that multiplies a field's value by a constant value. -```typescript -// Multiply the 'value' field by 2 -multiply("value", 2); - -``` - | -| [neq(left, right)](./firestore_lite.md#neq_be96f75) | (BETA) Creates an expression that checks if two expressions are not equal. -```typescript -// Check if the 'status' field is not equal to field 'finalState' -neq(Field.of("status"), Field.of("finalState")); - -``` - | -| [neq(left, right)](./firestore_lite.md#neq_010ba9e) | (BETA) Creates an expression that checks if an expression is not equal to a constant value. -```typescript -// Check if the 'status' field is not equal to "completed" -neq(Field.of("status"), "completed"); - -``` - | -| [neq(left, right)](./firestore_lite.md#neq_674c63f) | (BETA) Creates an expression that checks if a field's value is not equal to an expression. -```typescript -// Check if the 'status' field is not equal to the value of 'expectedStatus' -neq("status", Field.of("expectedStatus")); - -``` - | -| [neq(left, right)](./firestore_lite.md#neq_1f46a76) | (BETA) Creates an expression that checks if a field's value is not equal to a constant value. -```typescript -// Check if the 'country' field is not equal to "USA" -neq("country", "USA"); - -``` - | -| [or(left, right)](./firestore_lite.md#or_eba7e36) | (BETA) Creates an expression that performs a logical 'OR' operation on multiple filter conditions. -```typescript -// Check if the 'age' field is greater than 18 OR the 'city' field is "London" OR -// the 'status' field is "active" -const condition = or(gt("age", 18), eq("city", "London"), eq("status", "active")); - -``` - | | [queryEqual(left, right)](./firestore_lite.md#queryequal_7a1f045) | Returns true if the provided queries point to the same collection and apply the same constraints. | | [refEqual(left, right)](./firestore_lite.md#refequal_598b780) | Returns true if the provided references are equal. | -| [regexContains(left, pattern)](./firestore_lite.md#regexcontains_33ec01b) | (BETA) Creates an expression that checks if a string field contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -regexContains("description", "(?i)example"); - -``` - | -| [regexContains(left, pattern)](./firestore_lite.md#regexcontains_dd84184) | (BETA) Creates an expression that checks if a string field contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -regexContains("description", Field.of("pattern")); - -``` - | -| [regexContains(left, pattern)](./firestore_lite.md#regexcontains_3aaffe0) | (BETA) Creates an expression that checks if a string expression contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -regexContains(Field.of("description"), "(?i)example"); - -``` - | -| [regexContains(left, pattern)](./firestore_lite.md#regexcontains_a2c3e8b) | (BETA) Creates an expression that checks if a string expression contains a specified regular expression as a substring. -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -regexContains(Field.of("description"), Field.of("pattern")); - -``` - | -| [regexMatch(left, pattern)](./firestore_lite.md#regexmatch_33ec01b) | (BETA) Creates an expression that checks if a string field matches a specified regular expression. -```typescript -// Check if the 'email' field matches a valid email pattern -regexMatch("email", "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - | -| [regexMatch(left, pattern)](./firestore_lite.md#regexmatch_dd84184) | (BETA) Creates an expression that checks if a string field matches a specified regular expression. -```typescript -// Check if the 'email' field matches a valid email pattern -regexMatch("email", Field.of("pattern")); - -``` - | -| [regexMatch(left, pattern)](./firestore_lite.md#regexmatch_3aaffe0) | (BETA) Creates an expression that checks if a string expression matches a specified regular expression. -```typescript -// Check if the 'email' field matches a valid email pattern -regexMatch(Field.of("email"), "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - | -| [regexMatch(left, pattern)](./firestore_lite.md#regexmatch_a2c3e8b) | (BETA) Creates an expression that checks if a string expression matches a specified regular expression. -```typescript -// Check if the 'email' field matches a valid email pattern -regexMatch(Field.of("email"), Field.of("pattern")); - -``` - | | [snapshotEqual(left, right)](./firestore_lite.md#snapshotequal_5109204) | Returns true if the provided snapshots are equal. | -| [strContains(left, substring)](./firestore_lite.md#strcontains_18eaf5d) | (BETA) Creates an expression that checks if a string field contains a specified substring. -```typescript -// Check if the 'description' field contains "example". -strContains("description", "example"); - -``` - | -| [strContains(left, substring)](./firestore_lite.md#strcontains_f0f1f2f) | (BETA) Creates an expression that checks if a string field contains a substring specified by an expression. -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -strContains("description", Field.of("keyword")); - -``` - | -| [strContains(left, substring)](./firestore_lite.md#strcontains_5fdbd29) | (BETA) Creates an expression that checks if a string expression contains a specified substring. -```typescript -// Check if the 'description' field contains "example". -strContains(Field.of("description"), "example"); - -``` - | -| [strContains(left, substring)](./firestore_lite.md#strcontains_d9d749f) | (BETA) Creates an expression that checks if a string expression contains a substring specified by another expression. -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -strContains(Field.of("description"), Field.of("keyword")); - -``` - | -| [subtract(left, right)](./firestore_lite.md#subtract_be96f75) | (BETA) Creates an expression that subtracts two expressions. -```typescript -// Subtract the 'discount' field from the 'price' field -subtract(Field.of("price"), Field.of("discount")); - -``` - | -| [subtract(left, right)](./firestore_lite.md#subtract_010ba9e) | (BETA) Creates an expression that subtracts a constant value from an expression. -```typescript -// Subtract the constant value 2 from the 'value' field -subtract(Field.of("value"), 2); - -``` - | -| [subtract(left, right)](./firestore_lite.md#subtract_674c63f) | (BETA) Creates an expression that subtracts an expression from a field's value. -```typescript -// Subtract the 'discount' field from the 'price' field -subtract("price", Field.of("discount")); - -``` - | -| [subtract(left, right)](./firestore_lite.md#subtract_1f46a76) | (BETA) Creates an expression that subtracts a constant value from a field's value. -```typescript -// Subtract 20 from the value of the 'total' field -subtract("total", 20); - -``` - | -| [xor(left, right)](./firestore_lite.md#xor_eba7e36) | (BETA) Creates an expression that performs a logical 'XOR' (exclusive OR) operation on multiple filter conditions. -```typescript -// Check if only one of the conditions is true: 'age' greater than 18, 'city' is "London", -// or 'status' is "active". -const condition = xor( - gt("age", 18), - eq("city", "London"), - eq("status", "active")); - -``` - | | function(limit, ...) | | [limit(limit)](./firestore_lite.md#limit_ec46c78) | Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the first matching documents. | | [limitToLast(limit)](./firestore_lite.md#limittolast_ec46c78) | Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the last matching documents.You must specify at least one orderBy clause for limitToLast queries, otherwise an exception will be thrown during execution. | | function(logLevel, ...) | | [setLogLevel(logLevel)](./firestore_lite.md#setloglevel_d02fda2) | Sets the verbosity of Cloud Firestore logs (debug, error, or silent). | -| function(mapExpr, ...) | -| [mapGet(mapExpr, subField)](./firestore_lite.md#mapget_9715f90) | (BETA) Accesses a value from a map (object) expression using the provided key. -```typescript -// Get the 'city' value from the 'address' map field -mapGet(Field.of("address"), "city"); - -``` - | -| function(mapField, ...) | -| [mapGet(mapField, subField)](./firestore_lite.md#mapget_b37bbb6) | (BETA) Accesses a value from a map (object) field using the provided key. -```typescript -// Get the 'city' value from the 'address' map field -mapGet("address", "city"); - -``` - | | function(n, ...) | | [increment(n)](./firestore_lite.md#increment_5685735) | Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to increment the field's current value by the given value.If either the operand or the current field value uses floating point precision, all arithmetic follows IEEE 754 semantics. If both values are integers, values outside of JavaScript's safe number range (Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER) are also subject to precision loss. Furthermore, once processed by the Firestore backend, all integer operations are capped between -2^63 and 2^63-1.If the current field value is not of type number, or if the field does not yet exist, the transformation sets the field to the given value. | -| function(name, ...) | -| [genericFunction(name, params)](./firestore_lite.md#genericfunction_b886545) | (BETA) Creates functions that work on the backend but do not exist in the SDK yet. -```typescript -// Call a user defined function named "myFunc" with the arguments 10 and 20 -// This is the same of the 'sum(Field.of("price"))', if it did not exist -genericFunction("sum", [Field.of("price")]); - -``` - | -| function(pipeline, ...) | -| [execute(pipeline)](./firestore_lite.md#execute_86486e6) | (BETA) Modular API for console experimentation. | | function(query, ...) | | [getAggregate(query, aggregateSpec)](./firestore_lite.md#getaggregate_2073a74) | Calculates the specified aggregations over the documents in the result set of the given query without actually downloading the documents.Using this function to perform aggregations is efficient because only the final aggregation values, not the documents' data, are downloaded. This function can perform aggregations of the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). | | [getCount(query)](./firestore_lite.md#getcount_4e56953) | Calculates the number of documents in the result set of the given query without actually downloading the documents.Using this function to count the documents is efficient because only the final count, not the documents' data, is downloaded. This function can count the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). | | [getDocs(query)](./firestore_lite.md#getdocs_4e56953) | Executes the query and returns the results as a [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class).All queries are executed directly by the server, even if the query was previously executed. Recent modifications are only reflected in the retrieved results if they have already been applied by the backend. If the client is offline, the operation fails. To see previously cached result and local modifications, use the full Firestore SDK. | -| [pipeline(query)](./firestore_lite.md#pipeline_20b2416) | Experimental Modular API for console testing. | | [query(query, compositeFilter, queryConstraints)](./firestore_lite.md#query_9f7b0f4) | Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. | | [query(query, queryConstraints)](./firestore_lite.md#query_0f46da1) | Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. | | function(queryConstraints, ...) | @@ -1256,7281 +88,1488 @@ genericFunction("sum", [Field.of("price")]); | [endAt(snapshot)](./firestore_lite.md#endat_9a4477f) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided document (inclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. | | [endBefore(snapshot)](./firestore_lite.md#endbefore_9a4477f) | Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided document (exclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. | | [startAfter(snapshot)](./firestore_lite.md#startafter_9a4477f) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided document (exclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. | -| [startAt(snapshot)](./firestore_lite.md#startat_9a4477f) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided document (inclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of this query. | -| function(timestamp, ...) | -| [timestampAdd(timestamp, unit, amount)](./firestore_lite.md#timestampadd_87db576) | (BETA) Creates an expression that adds a specified amount of time to a timestamp. -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -timestampAdd(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampAdd(timestamp, unit, amount)](./firestore_lite.md#timestampadd_46a2d7e) | (BETA) Creates an expression that adds a specified amount of time to a timestamp. -```typescript -// Add 1 day to the 'timestamp' field. -timestampAdd(Field.of("timestamp"), "day", 1); - -``` - | -| [timestampSub(timestamp, unit, amount)](./firestore_lite.md#timestampsub_87db576) | (BETA) Creates an expression that subtracts a specified amount of time from a timestamp. -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -timestampSub(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); - -``` - | -| [timestampSub(timestamp, unit, amount)](./firestore_lite.md#timestampsub_46a2d7e) | (BETA) Creates an expression that subtracts a specified amount of time from a timestamp. -```typescript -// Subtract 1 day from the 'timestamp' field. -timestampSub(Field.of("timestamp"), "day", 1); - -``` - | -| function(value, ...) | -| [avgFunction(value)](./firestore_lite.md#avgfunction_f83680a) | (BETA) Creates an aggregation that calculates the average (mean) of values from an expression across multiple stage inputs. -```typescript -// Calculate the average age of users -avg(Field.of("age")).as("averageAge"); - -``` - | -| [avgFunction(value)](./firestore_lite.md#avgfunction_7c807cd) | (BETA) Creates an aggregation that calculates the average (mean) of a field's values across multiple stage inputs. -```typescript -// Calculate the average age of users -avg("age").as("averageAge"); - -``` - | -| [exists(value)](./firestore_lite.md#exists_f83680a) | (BETA) Creates an expression that checks if a field exists. -```typescript -// Check if the document has a field named "phoneNumber" -exists(Field.of("phoneNumber")); - -``` - | -| [isNan(value)](./firestore_lite.md#isnan_f83680a) | (BETA) Creates an expression that checks if an expression evaluates to 'NaN' (Not a Number). -```typescript -// Check if the result of a calculation is NaN -isNaN(Field.of("value").divide(0)); - -``` - | -| [isNan(value)](./firestore_lite.md#isnan_7c807cd) | (BETA) Creates an expression that checks if a field's value evaluates to 'NaN' (Not a Number). -```typescript -// Check if the result of a calculation is NaN -isNaN("value"); - -``` - | -| [max(value)](./firestore_lite.md#max_f83680a) | (BETA) Creates an aggregation that finds the maximum value of an expression across multiple stage inputs. -```typescript -// Find the highest score in a leaderboard -max(Field.of("score")).as("highestScore"); - -``` - | -| [max(value)](./firestore_lite.md#max_7c807cd) | (BETA) Creates an aggregation that finds the maximum value of a field across multiple stage inputs. -```typescript -// Find the highest score in a leaderboard -max("score").as("highestScore"); - -``` - | -| [min(value)](./firestore_lite.md#min_f83680a) | (BETA) Creates an aggregation that finds the minimum value of an expression across multiple stage inputs. -```typescript -// Find the lowest price of all products -min(Field.of("price")).as("lowestPrice"); - -``` - | -| [min(value)](./firestore_lite.md#min_7c807cd) | (BETA) Creates an aggregation that finds the minimum value of a field across multiple stage inputs. -```typescript -// Find the lowest price of all products -min("price").as("lowestPrice"); - -``` - | -| [replaceAll(value, find, replace)](./firestore_lite.md#replaceall_f06d323) | (BETA) Creates an expression that replaces all occurrences of a substring within a string with another substring. -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field. -replaceAll(Field.of("message"), "hello", "hi"); - -``` - | -| [replaceAll(value, find, replace)](./firestore_lite.md#replaceall_26a7926) | (BETA) Creates an expression that replaces all occurrences of a substring within a string with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field. -replaceAll(Field.of("message"), Field.of("findField"), Field.of("replaceField")); - -``` - | -| [replaceFirst(value, find, replace)](./firestore_lite.md#replacefirst_f06d323) | (BETA) Creates an expression that replaces the first occurrence of a substring within a string with another substring. -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field. -replaceFirst(Field.of("message"), "hello", "hi"); - -``` - | -| [replaceFirst(value, find, replace)](./firestore_lite.md#replacefirst_26a7926) | (BETA) Creates an expression that replaces the first occurrence of a substring within a string with another substring, where the substring to find and the replacement substring are specified by expressions. -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field. -replaceFirst(Field.of("message"), Field.of("findField"), Field.of("replaceField")); - -``` - | -| [sumFunction(value)](./firestore_lite.md#sumfunction_f83680a) | (BETA) Creates an aggregation that calculates the sum of values from an expression across multiple stage inputs. -```typescript -// Calculate the total revenue from a set of orders -sum(Field.of("orderAmount")).as("totalRevenue"); - -``` - | -| [sumFunction(value)](./firestore_lite.md#sumfunction_7c807cd) | (BETA) Creates an aggregation that calculates the sum of a field's values across multiple stage inputs. -```typescript -// Calculate the total revenue from a set of orders -sum("orderAmount").as("totalRevenue"); - -``` - | -| function(values, ...) | -| [vector(values)](./firestore_lite.md#vector_0dbdaf2) | Creates a new VectorValue constructed with a copy of the given array of numbers. | - -## Classes - -| Class | Description | -| --- | --- | -| [Add](./firestore_lite.add.md#add_class) | (BETA) | -| [AddFields](./firestore_lite.addfields.md#addfields_class) | (BETA) | -| [Aggregate](./firestore_lite.aggregate.md#aggregate_class) | (BETA) | -| [AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class) | Represents an aggregation that can be performed by Firestore. | -| [AggregateQuerySnapshot](./firestore_lite.aggregatequerysnapshot.md#aggregatequerysnapshot_class) | The results of executing an aggregation query. | -| [And](./firestore_lite.and.md#and_class) | (BETA) | -| [ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) | (BETA) | -| [ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) | (BETA) | -| [ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) | (BETA) | -| [ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) | (BETA) | -| [ArrayElement](./firestore_lite.arrayelement.md#arrayelement_class) | (BETA) | -| [ArrayLength](./firestore_lite.arraylength.md#arraylength_class) | (BETA) | -| [ArrayReverse](./firestore_lite.arrayreverse.md#arrayreverse_class) | (BETA) | -| [Avg](./firestore_lite.avg.md#avg_class) | (BETA) | -| [ByteLength](./firestore_lite.bytelength.md#bytelength_class) | (BETA) | -| [Bytes](./firestore_lite.bytes.md#bytes_class) | An immutable object representing an array of bytes. | -| [CharLength](./firestore_lite.charlength.md#charlength_class) | (BETA) | -| [CollectionGroupSource](./firestore_lite.collectiongroupsource.md#collectiongroupsource_class) | (BETA) | -| [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class) | A CollectionReference object can be used for adding documents, getting document references, and querying for documents (using [query()](./firestore_.md#query_9f7b0f4)). | -| [CollectionSource](./firestore_lite.collectionsource.md#collectionsource_class) | (BETA) | -| [Constant](./firestore_lite.constant.md#constant_class) | (BETA) Represents a constant value that can be used in a Firestore pipeline expression.You can create a Constant instance using the static method: -```typescript -// Create a Constant instance for the number 10 -const ten = Constant.of(10); - -// Create a Constant instance for the string "hello" -const hello = Constant.of("hello"); - -``` - | -| [CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) | (BETA) | -| [Count](./firestore_lite.count.md#count_class) | (BETA) | -| [DatabaseSource](./firestore_lite.databasesource.md#databasesource_class) | (BETA) | -| [Distinct](./firestore_lite.distinct.md#distinct_class) | (BETA) | -| [Divide](./firestore_lite.divide.md#divide_class) | (BETA) | -| [DocumentReference](./firestore_lite.documentreference.md#documentreference_class) | A DocumentReference refers to a document location in a Firestore database and can be used to write, read, or listen to the location. The document at the referenced location may or may not exist. | -| [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class) | A DocumentSnapshot contains data read from a document in your Firestore database. The data can be extracted with .data() or .get(<field>) to get a specific field.For a DocumentSnapshot that points to a non-existing document, any data access will return 'undefined'. You can use the exists() method to explicitly verify a document's existence. | -| [DocumentsSource](./firestore_lite.documentssource.md#documentssource_class) | (BETA) | -| [DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) | (BETA) | -| [EndsWith](./firestore_lite.endswith.md#endswith_class) | (BETA) | -| [Eq](./firestore_lite.eq.md#eq_class) | (BETA) | -| [EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) | (BETA) | -| [Exists](./firestore_lite.exists.md#exists_class) | (BETA) | -| [ExprWithAlias](./firestore_lite.exprwithalias.md#exprwithalias_class) | (BETA) | -| [Field](./firestore_lite.field.md#field_class) | (BETA) Represents a reference to a field in a Firestore document, or outputs of a [Pipeline](./firestore_.pipeline.md#pipeline_class) stage.

Field references are used to access document field values in expressions and to specify fields for sorting, filtering, and projecting data in Firestore pipelines.

You can create a Field instance using the static method: -```typescript -// Create a Field instance for the 'name' field -const nameField = Field.of("name"); - -// Create a Field instance for a nested field 'address.city' -const cityField = Field.of("address.city"); - -``` - | -| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | A FieldPath refers to a field in a document. The path may consist of a single field name (referring to a top-level field in the document), or a list of field names (referring to a nested field in the document).Create a FieldPath by providing field names. If more than one field name is provided, the path will point to a nested field in a document. | -| [Fields](./firestore_lite.fields.md#fields_class) | (BETA) | -| [FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) | Sentinel values that can be used when writing document fields with set() or update(). | -| [FindNearest](./firestore_lite.findnearest.md#findnearest_class) | (BETA) | -| [Firestore](./firestore_lite.firestore.md#firestore_class) | The Cloud Firestore service interface.Do not call this constructor directly. Instead, use [getFirestore()](./firestore_.md#getfirestore). | -| [FirestoreError](./firestore_lite.firestoreerror.md#firestoreerror_class) | An error returned by a Firestore operation. | -| [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) | (BETA) This class defines the base class for Firestore [Pipeline](./firestore_.pipeline.md#pipeline_class) functions, which can be evaluated within pipeline execution.Typically, you would not use this class or its children directly. Use either the functions like , , or the methods on (, , etc) to construct new Function instances. | -| [GenericStage](./firestore_lite.genericstage.md#genericstage_class) | (BETA) | -| [GeoPoint](./firestore_lite.geopoint.md#geopoint_class) | An immutable object representing a geographic location in Firestore. The location is represented as latitude/longitude pair.Latitude values are in the range of \[-90, 90\]. Longitude values are in the range of \[-180, 180\]. | -| [Gt](./firestore_lite.gt.md#gt_class) | (BETA) | -| [Gte](./firestore_lite.gte.md#gte_class) | (BETA) | -| [If](./firestore_lite.if.md#if_class) | (BETA) | -| [In](./firestore_lite.in.md#in_class) | (BETA) | -| [IsNan](./firestore_lite.isnan.md#isnan_class) | (BETA) | -| [Like](./firestore_lite.like.md#like_class) | (BETA) | -| [Limit](./firestore_lite.limit.md#limit_class) | (BETA) | -| [LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) | (BETA) | -| [LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) | (BETA) | -| [Lt](./firestore_lite.lt.md#lt_class) | (BETA) | -| [Lte](./firestore_lite.lte.md#lte_class) | (BETA) | -| [MapGet](./firestore_lite.mapget.md#mapget_class) | (BETA) | -| [Max](./firestore_lite.max.md#max_class) | (BETA) | -| [Min](./firestore_lite.min.md#min_class) | (BETA) | -| [Mod](./firestore_lite.mod.md#mod_class) | (BETA) | -| [Multiply](./firestore_lite.multiply.md#multiply_class) | (BETA) | -| [Neq](./firestore_lite.neq.md#neq_class) | (BETA) | -| [Not](./firestore_lite.not.md#not_class) | (BETA) | -| [Offset](./firestore_lite.offset.md#offset_class) | (BETA) | -| [Or](./firestore_lite.or.md#or_class) | (BETA) | -| [Ordering](./firestore_lite.ordering.md#ordering_class) | (BETA) Represents an ordering criterion for sorting documents in a Firestore pipeline.You create Ordering instances using the ascending and descending helper functions. | -| [Pipeline](./firestore_lite.pipeline.md#pipeline_class) | Base-class implementation | -| [PipelineResult](./firestore_lite.pipelineresult.md#pipelineresult_class) | (BETA) A PipelineResult contains data read from a Firestore Pipeline. The data can be extracted with the or methods.

If the PipelineResult represents a non-document result, ref will return a undefined value. | -| [PipelineSource](./firestore_lite.pipelinesource.md#pipelinesource_class) | (BETA) Represents the source of a Firestore [Pipeline](./firestore_.pipeline.md#pipeline_class). | -| [Query](./firestore_lite.query.md#query_class) | A Query refers to a query which you can read or listen to. You can also construct refined Query objects by adding filters and ordering. | -| [QueryCompositeFilterConstraint](./firestore_lite.querycompositefilterconstraint.md#querycompositefilterconstraint_class) | A QueryCompositeFilterConstraint is used to narrow the set of documents returned by a Firestore query by performing the logical OR or AND of multiple [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class)s or [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class)s. QueryCompositeFilterConstraints are created by invoking or and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the QueryCompositeFilterConstraint. | -| [QueryConstraint](./firestore_lite.queryconstraint.md#queryconstraint_class) | A QueryConstraint is used to narrow the set of documents returned by a Firestore query. QueryConstraints are created by invoking [where()](./firestore_.md#where_0fae4bf), [orderBy()](./firestore_.md#orderby_006d61f), [startAt()](./firestore_.md#startat_9a4477f), [startAfter()](./firestore_.md#startafter_9a4477f), [endBefore()](./firestore_.md#endbefore_9a4477f), [endAt()](./firestore_.md#endat_9a4477f), [limit()](./firestore_.md#limit_ec46c78), [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryConstraint. | -| [QueryDocumentSnapshot](./firestore_lite.querydocumentsnapshot.md#querydocumentsnapshot_class) | A QueryDocumentSnapshot contains data read from a document in your Firestore database as part of a query. The document is guaranteed to exist and its data can be extracted with .data() or .get(<field>) to get a specific field.A QueryDocumentSnapshot offers the same API surface as a DocumentSnapshot. Since query results contain only existing documents, the exists property will always be true and data() will never return 'undefined'. | -| [QueryEndAtConstraint](./firestore_lite.queryendatconstraint.md#queryendatconstraint_class) | A QueryEndAtConstraint is used to exclude documents from the end of a result set returned by a Firestore query. QueryEndAtConstraints are created by invoking [endAt()](./firestore_.md#endat_9a4477f) or [endBefore()](./firestore_.md#endbefore_9a4477f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryEndAtConstraint. | -| [QueryFieldFilterConstraint](./firestore_lite.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) | A QueryFieldFilterConstraint is used to narrow the set of documents returned by a Firestore query by filtering on one or more document fields. QueryFieldFilterConstraints are created by invoking [where()](./firestore_.md#where_0fae4bf) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryFieldFilterConstraint. | -| [QueryLimitConstraint](./firestore_lite.querylimitconstraint.md#querylimitconstraint_class) | A QueryLimitConstraint is used to limit the number of documents returned by a Firestore query. QueryLimitConstraints are created by invoking [limit()](./firestore_.md#limit_ec46c78) or [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryLimitConstraint. | -| [QueryOrderByConstraint](./firestore_lite.queryorderbyconstraint.md#queryorderbyconstraint_class) | A QueryOrderByConstraint is used to sort the set of documents returned by a Firestore query. QueryOrderByConstraints are created by invoking [orderBy()](./firestore_.md#orderby_006d61f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryOrderByConstraint.Note: Documents that do not contain the orderBy field will not be present in the query result. | -| [QuerySnapshot](./firestore_lite.querysnapshot.md#querysnapshot_class) | A QuerySnapshot contains zero or more DocumentSnapshot objects representing the results of a query. The documents can be accessed as an array via the docs property or enumerated using the forEach method. The number of documents can be determined via the empty and size properties. | -| [QueryStartAtConstraint](./firestore_lite.querystartatconstraint.md#querystartatconstraint_class) | A QueryStartAtConstraint is used to exclude documents from the start of a result set returned by a Firestore query. QueryStartAtConstraints are created by invoking [startAt()](./firestore_.md#startat_9a4477f) or [startAfter()](./firestore_.md#startafter_9a4477f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryStartAtConstraint. | -| [RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) | (BETA) | -| [RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) | (BETA) | -| [ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) | (BETA) | -| [ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) | (BETA) | -| [Reverse](./firestore_lite.reverse.md#reverse_class) | (BETA) | -| [Select](./firestore_lite.select.md#select_class) | (BETA) | -| [Sort](./firestore_lite.sort.md#sort_class) | (BETA) | -| [StartsWith](./firestore_lite.startswith.md#startswith_class) | (BETA) | -| [StrConcat](./firestore_lite.strconcat.md#strconcat_class) | (BETA) | -| [StrContains](./firestore_lite.strcontains.md#strcontains_class) | (BETA) | -| [Subtract](./firestore_lite.subtract.md#subtract_class) | (BETA) | -| [Sum](./firestore_lite.sum.md#sum_class) | (BETA) | -| [Timestamp](./firestore_lite.timestamp.md#timestamp_class) | A Timestamp represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time.It is encoded using the Proleptic Gregorian Calendar which extends the Gregorian calendar backwards to year one. It is encoded assuming all minutes are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.For examples and further specifications, refer to the [Timestamp definition](https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto). | -| [TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) | (BETA) | -| [TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) | (BETA) | -| [TimestampToUnixMicros](./firestore_lite.timestamptounixmicros.md#timestamptounixmicros_class) | (BETA) | -| [TimestampToUnixMillis](./firestore_lite.timestamptounixmillis.md#timestamptounixmillis_class) | (BETA) | -| [TimestampToUnixSeconds](./firestore_lite.timestamptounixseconds.md#timestamptounixseconds_class) | (BETA) | -| [ToLower](./firestore_lite.tolower.md#tolower_class) | (BETA) | -| [ToUpper](./firestore_lite.toupper.md#toupper_class) | (BETA) | -| [Transaction](./firestore_lite.transaction.md#transaction_class) | A reference to a transaction.The Transaction object passed to a transaction's updateFunction provides the methods to read and write data within the transaction context. See [runTransaction()](./firestore_.md#runtransaction_6f03ec4). | -| [Trim](./firestore_lite.trim.md#trim_class) | (BETA) | -| [UnixMicrosToTimestamp](./firestore_lite.unixmicrostotimestamp.md#unixmicrostotimestamp_class) | (BETA) | -| [UnixMillisToTimestamp](./firestore_lite.unixmillistotimestamp.md#unixmillistotimestamp_class) | (BETA) | -| [UnixSecondsToTimestamp](./firestore_lite.unixsecondstotimestamp.md#unixsecondstotimestamp_class) | (BETA) | -| [VectorLength](./firestore_lite.vectorlength.md#vectorlength_class) | (BETA) | -| [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | Represents a vector type in Firestore documents. Create an instance with . VectorValue | -| [Where](./firestore_lite.where.md#where_class) | (BETA) | -| [WriteBatch](./firestore_lite.writebatch.md#writebatch_class) | A write batch, used to perform multiple writes as a single atomic unit.A WriteBatch object can be acquired by calling [writeBatch()](./firestore_.md#writebatch_231a8e0). It provides methods for adding writes to the write batch. None of the writes will be committed (or visible locally) until [WriteBatch.commit()](./firestore_.writebatch.md#writebatchcommit) is called. | -| [Xor](./firestore_lite.xor.md#xor_class) | (BETA) | - -## Interfaces - -| Interface | Description | -| --- | --- | -| [Accumulator](./firestore_lite.accumulator.md#accumulator_interface) | (BETA) An interface that represents an accumulator. | -| [AggregateSpec](./firestore_lite.aggregatespec.md#aggregatespec_interface) | Specifies a set of aggregations and their aliases. | -| [DocumentData](./firestore_lite.documentdata.md#documentdata_interface) | Document data (for use with [setDoc()](./firestore_lite.md#setdoc_ee215ad)) consists of fields mapped to values. | -| [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) | (BETA) An interface that represents a filter condition. | -| [FindNearestOptions](./firestore_lite.findnearestoptions.md#findnearestoptions_interface) | (BETA) | -| [FirestoreDataConverter](./firestore_lite.firestoredataconverter.md#firestoredataconverter_interface) | Converter used by withConverter() to transform user objects of type AppModelType into Firestore data of type DbModelType.Using the converter allows you to specify generic type arguments when storing and retrieving objects from Firestore.In this context, an "AppModel" is a class that is used in an application to package together related information and functionality. Such a class could, for example, have properties with complex, nested data types, properties used for memoization, properties of types not supported by Firestore (such as symbol and bigint), and helper functions that perform compound operations. Such classes are not suitable and/or possible to store into a Firestore database. Instead, instances of such classes need to be converted to "plain old JavaScript objects" (POJOs) with exclusively primitive properties, potentially nested inside other POJOs or arrays of POJOs. In this context, this type is referred to as the "DbModel" and would be an object suitable for persisting into Firestore. For convenience, applications can implement FirestoreDataConverter and register the converter with Firestore objects, such as DocumentReference or Query, to automatically convert AppModel to DbModel when storing into Firestore, and convert DbModel to AppModel when retrieving from Firestore. | -| [Selectable](./firestore_lite.selectable.md#selectable_interface) | (BETA) An interface that represents a selectable expression. | -| [Settings](./firestore_lite.settings.md#settings_interface) | Specifies custom configurations for your Cloud Firestore instance. You must set these before invoking any other methods. | -| [Stage](./firestore_lite.stage.md#stage_interface) | (BETA) | -| [TransactionOptions](./firestore_lite.transactionoptions.md#transactionoptions_interface) | Options to customize transaction behavior. | - -## Namespaces - -| Namespace | Description | -| --- | --- | -| [and](./firestore_lite.and.md#and_namespace) | | -| [or](./firestore_lite.or.md#or_namespace) | | - -## Type Aliases - -| Type Alias | Description | -| --- | --- | -| [AccumulatorTarget](./firestore_lite.md#accumulatortarget) | (BETA) An accumulator target, which is an expression with an alias that also implements the Accumulator interface. | -| [AddPrefixToKeys](./firestore_lite.md#addprefixtokeys) | Returns a new map where every key is prefixed with the outer key appended to a dot. | -| [AggregateFieldType](./firestore_lite.md#aggregatefieldtype) | The union of all AggregateField types that are supported by Firestore. | -| [AggregateSpecData](./firestore_lite.md#aggregatespecdata) | A type whose keys are taken from an AggregateSpec, and whose values are the result of the aggregation performed by the corresponding AggregateField from the input AggregateSpec. | -| [AggregateType](./firestore_lite.md#aggregatetype) | Union type representing the aggregate type to be performed. | -| [ChildUpdateFields](./firestore_lite.md#childupdatefields) | Helper for calculating the nested fields for a given type T1. This is needed to distribute union types such as undefined | {...} (happens for optional props) or {a: A} | {b: B}.In this use case, V is used to distribute the union types of T[K] on Record, since T[K] is evaluated as an expression and not distributed.See https://www.typescriptlang.org/docs/handbook/advanced-types.html\#distributive-conditional-types | -| [ExprType](./firestore_lite.md#exprtype) | (BETA) An enumeration of the different types of expressions. | -| [FilterExpr](./firestore_lite.md#filterexpr) | (BETA) A filter expression, which is an expression that also implements the FilterCondition interface. | -| [FirestoreErrorCode](./firestore_lite.md#firestoreerrorcode) | The set of Firestore status codes. The codes are the same at the ones exposed by gRPC here: https://github.com/grpc/grpc/blob/master/doc/statuscodes.mdPossible values: - 'cancelled': The operation was cancelled (typically by the caller). - 'unknown': Unknown error or an error from a different error domain. - 'invalid-argument': Client specified an invalid argument. Note that this differs from 'failed-precondition'. 'invalid-argument' indicates arguments that are problematic regardless of the state of the system (e.g. an invalid field name). - 'deadline-exceeded': Deadline expired before operation could complete. For operations that change the state of the system, this error may be returned even if the operation has completed successfully. For example, a successful response from a server could have been delayed long enough for the deadline to expire. - 'not-found': Some requested document was not found. - 'already-exists': Some document that we attempted to create already exists. - 'permission-denied': The caller does not have permission to execute the specified operation. - 'resource-exhausted': Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space. - 'failed-precondition': Operation was rejected because the system is not in a state required for the operation's execution. - 'aborted': The operation was aborted, typically due to a concurrency issue like transaction aborts, etc. - 'out-of-range': Operation was attempted past the valid range. - 'unimplemented': Operation is not implemented or not supported/enabled. - 'internal': Internal errors. Means some invariants expected by underlying system has been broken. If you see one of these errors, something is very broken. - 'unavailable': The service is currently unavailable. This is most likely a transient condition and may be corrected by retrying with a backoff. - 'data-loss': Unrecoverable data loss or corruption. - 'unauthenticated': The request does not have valid authentication credentials for the operation. | -| [NestedUpdateFields](./firestore_lite.md#nestedupdatefields) | For each field (e.g. 'bar'), find all nested keys (e.g. {'bar.baz': T1, 'bar.qux': T2}). Intersect them together to make a single map containing all possible keys that are all marked as optional | -| [OrderByDirection](./firestore_lite.md#orderbydirection) | The direction of a [orderBy()](./firestore_.md#orderby_006d61f) clause is specified as 'desc' or 'asc' (descending or ascending). | -| [PartialWithFieldValue](./firestore_lite.md#partialwithfieldvalue) | Similar to TypeScript's Partial<T>, but allows nested fields to be omitted and FieldValues to be passed in as property values. | -| [Primitive](./firestore_lite.md#primitive) | Primitive types. | -| [QueryConstraintType](./firestore_lite.md#queryconstrainttype) | Describes the different query constraints available in this SDK. | -| [QueryFilterConstraint](./firestore_lite.md#queryfilterconstraint) | QueryFilterConstraint is a helper union type that represents [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) and [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). | -| [QueryNonFilterConstraint](./firestore_lite.md#querynonfilterconstraint) | QueryNonFilterConstraint is a helper union type that represents QueryConstraints which are used to narrow or order the set of documents, but that do not explicitly filter on a document field. QueryNonFilterConstraints are created by invoking [orderBy()](./firestore_.md#orderby_006d61f), [startAt()](./firestore_.md#startat_9a4477f), [startAfter()](./firestore_.md#startafter_9a4477f), [endBefore()](./firestore_.md#endbefore_9a4477f), [endAt()](./firestore_.md#endat_9a4477f), [limit()](./firestore_.md#limit_ec46c78) or [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the QueryConstraint. | -| [SelectableExpr](./firestore_lite.md#selectableexpr) | (BETA) A selectable expression, which is an expression that also implements the Selectable interface. | -| [SetOptions](./firestore_lite.md#setoptions) | An options object that configures the behavior of [setDoc()](./firestore_lite.md#setdoc_ee215ad), and calls. These calls can be configured to perform granular merges instead of overwriting the target documents in their entirety by providing a SetOptions with merge: true. | -| [UnionToIntersection](./firestore_lite.md#uniontointersection) | Given a union type U = T1 | T2 | ..., returns an intersected type (T1 & T2 & ...).Uses distributive conditional types and inference from conditional types. This works because multiple candidates for the same type variable in contra-variant positions causes an intersection type to be inferred. https://www.typescriptlang.org/docs/handbook/advanced-types.html\#type-inference-in-conditional-types https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type | -| [UpdateData](./firestore_lite.md#updatedata) | Update data (for use with [updateDoc()](./firestore_.md#updatedoc_51a65e3)) that consists of field paths (e.g. 'foo' or 'foo.baz') mapped to values. Fields that contain dots reference nested fields within the document. FieldValues can be passed in as property values. | -| [WhereFilterOp](./firestore_lite.md#wherefilterop) | Filter conditions in a [where()](./firestore_.md#where_0fae4bf) clause are specified using the strings '&lt;', '&lt;=', '==', '!=', '&gt;=', '&gt;', 'array-contains', 'in', 'array-contains-any', and 'not-in'. | -| [WithFieldValue](./firestore_lite.md#withfieldvalue) | Allows FieldValues to be passed in as a property value while maintaining type safety. | - -## function(app, ...) - -### getFirestore(app) {:#getfirestore_cf608e1} - -Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. - -Signature: - -```typescript -export declare function getFirestore(app: FirebaseApp): Firestore; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) instance that the returned [Firestore](./firestore_.firestore.md#firestore_class) instance is associated with. | - -Returns: - -[Firestore](./firestore_lite.firestore.md#firestore_class) - -The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. - -### getFirestore(app, databaseId) {:#getfirestore_48de6cb} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Returns the existing [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. - -Signature: - -```typescript -export declare function getFirestore(app: FirebaseApp, databaseId: string): Firestore; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) instance that the returned [Firestore](./firestore_.firestore.md#firestore_class) instance is associated with. | -| databaseId | string | The name of the database. | - -Returns: - -[Firestore](./firestore_lite.firestore.md#firestore_class) - -The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. - -### initializeFirestore(app, settings) {:#initializefirestore_87c6318} - -Initializes a new instance of Cloud Firestore with the provided settings. Can only be called before any other functions, including [getFirestore()](./firestore_.md#getfirestore). If the custom settings are empty, this function is equivalent to calling [getFirestore()](./firestore_.md#getfirestore). - -Signature: - -```typescript -export declare function initializeFirestore(app: FirebaseApp, settings: Settings): Firestore; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) with which the Firestore instance will be associated. | -| settings | [Settings](./firestore_lite.settings.md#settings_interface) | A settings object to configure the Firestore instance. | - -Returns: - -[Firestore](./firestore_lite.firestore.md#firestore_class) - -A newly initialized `Firestore` instance. - -### initializeFirestore(app, settings, databaseId) {:#initializefirestore_37baaaf} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Initializes a new instance of Cloud Firestore with the provided settings. Can only be called before any other functions, including [getFirestore()](./firestore_.md#getfirestore). If the custom settings are empty, this function is equivalent to calling [getFirestore()](./firestore_.md#getfirestore). - -Signature: - -```typescript -export declare function initializeFirestore(app: FirebaseApp, settings: Settings, databaseId?: string): Firestore; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) with which the Firestore instance will be associated. | -| settings | [Settings](./firestore_lite.settings.md#settings_interface) | A settings object to configure the Firestore instance. | -| databaseId | string | The name of the database. | - -Returns: - -[Firestore](./firestore_lite.firestore.md#firestore_class) - -A newly initialized `Firestore` instance. - -## function(firestore, ...) - -### collection(firestore, path, pathSegments) {:#collection_1eb4c23} - -Gets a `CollectionReference` instance that refers to the collection at the specified absolute path. - -Signature: - -```typescript -export declare function collection(firestore: Firestore, path: string, ...pathSegments: string[]): CollectionReference; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | A reference to the root Firestore instance. | -| path | string | A slash-separated path to a collection. | -| pathSegments | string\[\] | Additional path segments to apply relative to the first argument. | - -Returns: - -[CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> - -The `CollectionReference` instance. - -#### Exceptions - -If the final path has an even number of segments and does not point to a collection. - -### collectionGroup(firestore, collectionId) {:#collectiongroup_1838fc3} - -Creates and returns a new `Query` instance that includes all documents in the database that are contained in a collection or subcollection with the given `collectionId`. - -Signature: - -```typescript -export declare function collectionGroup(firestore: Firestore, collectionId: string): Query; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | A reference to the root Firestore instance. | -| collectionId | string | Identifies the collections to query over. Every collection or subcollection with this ID as the last segment of its path will be included. Cannot contain a slash. | - -Returns: - -[Query](./firestore_lite.query.md#query_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> - -The created `Query`. - -### connectFirestoreEmulator(firestore, host, port, options) {:#connectfirestoreemulator_7c247cd} - -Modify this instance to communicate with the Cloud Firestore emulator. - -Note: This must be called before this instance has been used to do any operations. - -Signature: - -```typescript -export declare function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: { - mockUserToken?: EmulatorMockTokenOptions | string; -}): void; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | The Firestore instance to configure to connect to the emulator. | -| host | string | the emulator host (ex: localhost). | -| port | number | the emulator port (ex: 9000). | -| options | { mockUserToken?: [EmulatorMockTokenOptions](./util.md#emulatormocktokenoptions) \| string; } | | - -Returns: - -void - -### doc(firestore, path, pathSegments) {:#doc_1eb4c23} - -Gets a `DocumentReference` instance that refers to the document at the specified absolute path. - -Signature: - -```typescript -export declare function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | A reference to the root Firestore instance. | -| path | string | A slash-separated path to a document. | -| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | - -Returns: - -[DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> - -The `DocumentReference` instance. - -#### Exceptions - -If the final path has an odd number of segments and does not point to a document. - -### pipeline(firestore) {:#pipeline_231a8e0} - -Experimental Modular API for console testing. - -Signature: - -```typescript -export declare function pipeline(firestore: Firestore): PipelineSource; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | | - -Returns: - -[PipelineSource](./firestore_lite.pipelinesource.md#pipelinesource_class) - -### runTransaction(firestore, updateFunction, options) {:#runtransaction_6f03ec4} - -Executes the given `updateFunction` and then attempts to commit the changes applied within the transaction. If any document read within the transaction has changed, Cloud Firestore retries the `updateFunction`. If it fails to commit after 5 attempts, the transaction fails. - -The maximum number of writes allowed in a single transaction is 500. - -Signature: - -```typescript -export declare function runTransaction(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise, options?: TransactionOptions): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | A reference to the Firestore database to run this transaction against. | -| updateFunction | (transaction: [Transaction](./firestore_lite.transaction.md#transaction_class)) => Promise<T> | The function to execute within the transaction context. | -| options | [TransactionOptions](./firestore_lite.transactionoptions.md#transactionoptions_interface) | An options object to configure maximum number of attempts to commit. | - -Returns: - -Promise<T> - -If the transaction completed successfully or was explicitly aborted (the `updateFunction` returned a failed promise), the promise returned by the `updateFunction `is returned here. Otherwise, if the transaction failed, a rejected promise with the corresponding failure error is returned. - -### terminate(firestore) {:#terminate_231a8e0} - -Terminates the provided `Firestore` instance. - -After calling `terminate()` only the `clearIndexedDbPersistence()` functions may be used. Any other function will throw a `FirestoreError`. Termination does not cancel any pending writes, and any promises that are awaiting a response from the server will not be resolved. - -To restart after termination, create a new instance of `Firestore` with [getFirestore()](./firestore_.md#getfirestore). - -Note: Under normal circumstances, calling `terminate()` is not required. This function is useful only when you want to force this instance to release all of its resources or in combination with [clearIndexedDbPersistence()](./firestore_.md#clearindexeddbpersistence_231a8e0) to ensure that all local state is destroyed between test runs. - -Signature: - -```typescript -export declare function terminate(firestore: Firestore): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | The Firestore instance to terminate. | - -Returns: - -Promise<void> - -A `Promise` that is resolved when the instance has been successfully terminated. - -### writeBatch(firestore) {:#writebatch_231a8e0} - -Creates a write batch, used for performing multiple writes as a single atomic operation. The maximum number of writes allowed in a single WriteBatch is 500. - -The result of these writes will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the write fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. - -Signature: - -```typescript -export declare function writeBatch(firestore: Firestore): WriteBatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | | - -Returns: - -[WriteBatch](./firestore_lite.writebatch.md#writebatch_class) - -A `WriteBatch` that can be used to atomically execute multiple writes. - -## function() - -### count() {:#count} - -Create an AggregateField object that can be used to compute the count of documents in the result set of a query. - -Signature: - -```typescript -export declare function count(): AggregateField; -``` -Returns: - -[AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<number> - -### countAll() {:#countall} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an aggregation that counts the total number of stage inputs. - -```typescript -// Count the total number of users -countAll().as("totalUsers"); - -``` - A new representing the 'countAll' aggregation. - -Signature: - -```typescript -export declare function countAll(): Count; -``` -Returns: - -[Count](./firestore_lite.count.md#count_class) - -### deleteField() {:#deletefield} - -Returns a sentinel for use with [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) or [setDoc()](./firestore_lite.md#setdoc_ee215ad) with `{merge: true}` to mark a field for deletion. - -Signature: - -```typescript -export declare function deleteField(): FieldValue; -``` -Returns: - -[FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) - -### documentId() {:#documentid} - -Returns a special sentinel `FieldPath` to refer to the ID of a document. It can be used in queries to sort or filter by the document ID. - -Signature: - -```typescript -export declare function documentId(): FieldPath; -``` -Returns: - -[FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) - -### getFirestore() {:#getfirestore} - -Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. - -Signature: - -```typescript -export declare function getFirestore(): Firestore; -``` -Returns: - -[Firestore](./firestore_lite.firestore.md#firestore_class) - -The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. - -### serverTimestamp() {:#servertimestamp} - -Returns a sentinel used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) to include a server-generated timestamp in the written data. - -Signature: - -```typescript -export declare function serverTimestamp(): FieldValue; -``` -Returns: - -[FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) - -### useFirestorePipelines() {:#usefirestorepipelines} - - Copyright 2024 Google LLC - -Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - -Signature: - -```typescript -export declare function useFirestorePipelines(): void; -``` -Returns: - -void - -## function(array, ...) - -### arrayConcat(array, elements) {:#arrayconcat_0b3ddb9} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with other arrays. - -```typescript -// Combine the 'items' array with two new item arrays -arrayConcat(Field.of("items"), [Field.of("newItems"), Field.of("otherItems")]); - -``` - -Signature: - -```typescript -export declare function arrayConcat(array: Constant, elements: Constant[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_lite.constant.md#constant_class) | The array expression to concatenate to. | -| elements | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The array expressions to concatenate. A new representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) - -### arrayConcat(array, elements) {:#arrayconcat_21991c1} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates an array expression with other arrays and/or values. - -```typescript -// Combine the 'tags' array with a new array -arrayConcat(Field.of("tags"), ["newTag1", "newTag2"]); - -``` - -Signature: - -```typescript -export declare function arrayConcat(array: Constant, elements: any[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_lite.constant.md#constant_class) | The array expression to concatenate to. | -| elements | any\[\] | The array expressions or single values to concatenate. A new representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) - -### arrayConcat(array, elements) {:#arrayconcat_f8d5d5e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates a field's array value with other arrays. - -```typescript -// Combine the 'items' array with two new item arrays -arrayConcat("items", [Field.of("newItems"), Field.of("otherItems")]); - -``` - -Signature: - -```typescript -export declare function arrayConcat(array: string, elements: Constant[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | string | The field name containing array values. | -| elements | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The array expressions to concatenate. A new representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) - -### arrayConcat(array, elements) {:#arrayconcat_5a66d99} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates a field's array value with other arrays and/or values. - -```typescript -// Combine the 'tags' array with a new array -arrayConcat("tags", ["newTag1", "newTag2"]); - -``` - -Signature: - -```typescript -export declare function arrayConcat(array: string, elements: any[]): ArrayConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | string | The field name containing array values. | -| elements | any\[\] | The array expressions or single values to concatenate. A new representing the concatenated array. | - -Returns: - -[ArrayConcat](./firestore_lite.arrayconcat.md#arrayconcat_class) - -### arrayContains(array, element) {:#arraycontains_01ea7c0} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array expression contains a specific element. - -```typescript -// Check if the 'colors' array contains the value of field 'selectedColor' -arrayContains(Field.of("colors"), Field.of("selectedColor")); - -``` - -Signature: - -```typescript -export declare function arrayContains(array: Constant, element: Constant): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_lite.constant.md#constant_class) | The array expression to check. | -| element | [Constant](./firestore_lite.constant.md#constant_class) | The element to search for in the array. A new representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) - -### arrayContains(array, element) {:#arraycontains_60f8f2f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array expression contains a specific element. - -```typescript -// Check if the 'colors' array contains "red" -arrayContains(Field.of("colors"), "red"); - -``` - -Signature: - -```typescript -export declare function arrayContains(array: Constant, element: any): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_lite.constant.md#constant_class) | The array expression to check. | -| element | any | The element to search for in the array. A new representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) - -### arrayContains(array, element) {:#arraycontains_0ebdbfe} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's array value contains a specific element. - -```typescript -// Check if the 'colors' array contains the value of field 'selectedColor' -arrayContains("colors", Field.of("selectedColor")); - -``` - -Signature: - -```typescript -export declare function arrayContains(array: string, element: Constant): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | string | The field name to check. | -| element | [Constant](./firestore_lite.constant.md#constant_class) | The element to search for in the array. A new representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) - -### arrayContains(array, element) {:#arraycontains_8f718df} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's array value contains a specific value. - -```typescript -// Check if the 'colors' array contains "red" -arrayContains("colors", "red"); - -``` - -Signature: - -```typescript -export declare function arrayContains(array: string, element: any): ArrayContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | string | The field name to check. | -| element | any | The element to search for in the array. A new representing the 'array\_contains' comparison. | - -Returns: - -[ArrayContains](./firestore_lite.arraycontains.md#arraycontains_class) - -### arrayContainsAll(array, values) {:#arraycontainsall_7b7433a} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array expression contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" -arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); - -``` - -Signature: - -```typescript -export declare function arrayContainsAll(array: Constant, values: Constant[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_lite.constant.md#constant_class) | The array expression to check. | -| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) - -### arrayContainsAll(array, values) {:#arraycontainsall_d919466} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array expression contains all the specified elements. - -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" -arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); - -``` - -Signature: - -```typescript -export declare function arrayContainsAll(array: Constant, values: any[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_lite.constant.md#constant_class) | The array expression to check. | -| values | any\[\] | The elements to check for in the array. A new representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) - -### arrayContainsAll(array, values) {:#arraycontainsall_b40e2df} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's array value contains all the specified values or expressions. - -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); - -``` - -Signature: - -```typescript -export declare function arrayContainsAll(array: string, values: Constant[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | string | The field name to check. | -| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) - -### arrayContainsAll(array, values) {:#arraycontainsall_b08efbb} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's array value contains all the specified values or expressions. - -```typescript -// Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" -arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); - -``` - -Signature: - -```typescript -export declare function arrayContainsAll(array: string, values: any[]): ArrayContainsAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | string | The field name to check. | -| values | any\[\] | The elements to check for in the array. A new representing the 'array\_contains\_all' comparison. | - -Returns: - -[ArrayContainsAll](./firestore_lite.arraycontainsall.md#arraycontainsall_class) - -### arrayContainsAny(array, values) {:#arraycontainsany_7b7433a} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array expression contains any of the specified elements. - -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "Science" -arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); - -``` - -Signature: - -```typescript -export declare function arrayContainsAny(array: Constant, values: Constant[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_lite.constant.md#constant_class) | The array expression to check. | -| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) - -### arrayContainsAny(array, values) {:#arraycontainsany_d919466} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an array expression contains any of the specified elements. - -```typescript -// Check if the 'categories' array contains either values from field "cate1" or "Science" -arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); - -``` - -Signature: - -```typescript -export declare function arrayContainsAny(array: Constant, values: any[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_lite.constant.md#constant_class) | The array expression to check. | -| values | any\[\] | The elements to check for in the array. A new representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) - -### arrayContainsAny(array, values) {:#arraycontainsany_b40e2df} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's array value contains any of the specified elements. - -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -arrayContainsAny("categories", [Field.of("cate1"), "Science"]); - -``` - -Signature: - -```typescript -export declare function arrayContainsAny(array: string, values: Constant[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | string | The field name to check. | -| values | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The elements to check for in the array. A new representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) - -### arrayContainsAny(array, values) {:#arraycontainsany_b08efbb} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's array value contains any of the specified elements. - -```typescript -// Check if the 'groups' array contains either the value from the 'userGroup' field -// or the value "guest" -arrayContainsAny("categories", [Field.of("cate1"), "Science"]); - -``` - -Signature: - -```typescript -export declare function arrayContainsAny(array: string, values: any[]): ArrayContainsAny; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | string | The field name to check. | -| values | any\[\] | The elements to check for in the array. A new representing the 'array\_contains\_any' comparison. | - -Returns: - -[ArrayContainsAny](./firestore_lite.arraycontainsany.md#arraycontainsany_class) - -### arrayLength(array) {:#arraylength_0bb5dbb} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of an array expression. - -```typescript -// Get the number of items in the 'cart' array -arrayLength(Field.of("cart")); - -``` - -Signature: - -```typescript -export declare function arrayLength(array: Constant): ArrayLength; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| array | [Constant](./firestore_lite.constant.md#constant_class) | The array expression to calculate the length of. A new representing the length of the array. | - -Returns: - -[ArrayLength](./firestore_lite.arraylength.md#arraylength_class) - -## function(condition, ...) - -### ifFunction(condition, thenExpr, elseExpr) {:#iffunction_f7b2404} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates a conditional expression that evaluates to a 'then' expression if a condition is true and an 'else' expression if the condition is false. - -```typescript -// If 'age' is greater than 18, return "Adult"; otherwise, return "Minor". -ifFunction( - gt("age", 18), Constant.of("Adult"), Constant.of("Minor")); - -``` - -Signature: - -```typescript -export declare function ifFunction(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant): If; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| condition | [FilterExpr](./firestore_lite.md#filterexpr) | The condition to evaluate. | -| thenExpr | [Constant](./firestore_lite.constant.md#constant_class) | The expression to evaluate if the condition is true. | -| elseExpr | [Constant](./firestore_lite.constant.md#constant_class) | The expression to evaluate if the condition is false. A new representing the conditional expression. | - -Returns: - -[If](./firestore_lite.if.md#if_class) - -## function(databaseId, ...) - -### getFirestore(databaseId) {:#getfirestore_53dc891} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Returns the existing [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. - -Signature: - -```typescript -export declare function getFirestore(databaseId: string): Firestore; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| databaseId | string | The name of the database. | - -Returns: - -[Firestore](./firestore_lite.firestore.md#firestore_class) - -The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. - -## function(element, ...) - -### inAny(element, others) {:#inany_a73b259} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an expression is equal to any of the provided values or expressions. - -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -inAny(Field.of("category"), [Constant.of("Electronics"), Field.of("primaryType")]); - -``` - -Signature: - -```typescript -export declare function inAny(element: Constant, others: Constant[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare. | -| others | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The values to check against. A new representing the 'IN' comparison. | - -Returns: - -[In](./firestore_lite.in.md#in_class) - -### inAny(element, others) {:#inany_f5721c6} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an expression is equal to any of the provided values or expressions. - -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -inAny(Field.of("category"), ["Electronics", Field.of("primaryType")]); - -``` - -Signature: - -```typescript -export declare function inAny(element: Constant, others: any[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare. | -| others | any\[\] | The values to check against. A new representing the 'IN' comparison. | - -Returns: - -[In](./firestore_lite.in.md#in_class) - -### inAny(element, others) {:#inany_c6646ea} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is equal to any of the provided values or expressions. - -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -inAny("category", [Constant.of("Electronics"), Field.of("primaryType")]); - -``` - -Signature: - -```typescript -export declare function inAny(element: string, others: Constant[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | string | The field to compare. | -| others | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The values to check against. A new representing the 'IN' comparison. | - -Returns: - -[In](./firestore_lite.in.md#in_class) - -### inAny(element, others) {:#inany_e6877aa} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is equal to any of the provided values or expressions. - -```typescript -// Check if the 'category' field is either "Electronics" or value of field 'primaryType' -inAny("category", ["Electronics", Field.of("primaryType")]); - -``` - -Signature: - -```typescript -export declare function inAny(element: string, others: any[]): In; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | string | The field to compare. | -| others | any\[\] | The values to check against. A new representing the 'IN' comparison. | - -Returns: - -[In](./firestore_lite.in.md#in_class) - -### notInAny(element, others) {:#notinany_a73b259} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an expression is not equal to any of the provided values or expressions. - -```typescript -// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' -notInAny(Field.of("status"), [Constant.of("pending"), Field.of("rejectedStatus")]); - -``` - -Signature: - -```typescript -export declare function notInAny(element: Constant, others: Constant[]): Not; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare. | -| others | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The values to check against. A new representing the 'NOT IN' comparison. | - -Returns: - -[Not](./firestore_lite.not.md#not_class) - -### notInAny(element, others) {:#notinany_f5721c6} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an expression is not equal to any of the provided values or expressions. - -```typescript -// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' -notInAny(Field.of("status"), ["pending", Field.of("rejectedStatus")]); - -``` - -Signature: - -```typescript -export declare function notInAny(element: Constant, others: any[]): Not; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare. | -| others | any\[\] | The values to check against. A new representing the 'NOT IN' comparison. | - -Returns: - -[Not](./firestore_lite.not.md#not_class) - -### notInAny(element, others) {:#notinany_c6646ea} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is not equal to any of the provided values or expressions. - -```typescript -// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' -notInAny("status", [Constant.of("pending"), Field.of("rejectedStatus")]); - -``` - -Signature: - -```typescript -export declare function notInAny(element: string, others: Constant[]): Not; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | string | The field name to compare. | -| others | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The values to check against. A new representing the 'NOT IN' comparison. | - -Returns: - -[Not](./firestore_lite.not.md#not_class) - -### notInAny(element, others) {:#notinany_e6877aa} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is not equal to any of the provided values or expressions. - -```typescript -// Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' -notInAny("status", ["pending", Field.of("rejectedStatus")]); - -``` - -Signature: - -```typescript -export declare function notInAny(element: string, others: any[]): Not; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| element | string | The field name to compare. | -| others | any\[\] | The values to check against. A new representing the 'NOT IN' comparison. | - -Returns: - -[Not](./firestore_lite.not.md#not_class) - -## function(elements, ...) - -### arrayRemove(elements) {:#arrayremove_7d853aa} - -Returns a special value that can be used with [setDoc()](./firestore_.md#setdoc_ee215ad) or that tells the server to remove the given elements from any array value that already exists on the server. All instances of each element specified will be removed from the array. If the field being modified is not already an array it will be overwritten with an empty array. - -Signature: - -```typescript -export declare function arrayRemove(...elements: unknown[]): FieldValue; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| elements | unknown\[\] | The elements to remove from the array. | - -Returns: - -[FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) - -The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()` - -### arrayUnion(elements) {:#arrayunion_7d853aa} - -Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to union the given elements with any array value that already exists on the server. Each specified element that doesn't already exist in the array will be added to the end. If the field being modified is not already an array it will be overwritten with an array containing exactly the specified elements. - -Signature: - -```typescript -export declare function arrayUnion(...elements: unknown[]): FieldValue; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| elements | unknown\[\] | The elements to union into the array. | - -Returns: - -[FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) - -The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()`. - -## function(expr, ...) - -### ascending(expr) {:#ascending_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in ascending order based on this expression. - -```typescript -// Sort documents by the 'name' field in ascending order -firestore.pipeline().collection("users") - .sort(ascending(Field.of("name"))); - -``` - -Signature: - -```typescript -export declare function ascending(expr: Constant): Ordering; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression to create an ascending ordering for. A new Ordering for ascending sorting. | - -Returns: - -[Ordering](./firestore_lite.ordering.md#ordering_class) - -### byteLength(expr) {:#bytelength_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the byte length of a string in UTF-8, or just the length of a Blob. - -```typescript -// Calculate the length of the 'myString' field in bytes. -byteLength(Field.of("myString")); - -``` - -Signature: - -```typescript -export declare function byteLength(expr: Constant): ByteLength; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string. A new representing the length of the string in bytes. | - -Returns: - -[ByteLength](./firestore_lite.bytelength.md#bytelength_class) - -### charLength(expr) {:#charlength_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the character length of a string expression in UTF-8. - -```typescript -// Get the character length of the 'name' field in UTF-8. -strLength(Field.of("name")); - -``` - -Signature: - -```typescript -export declare function charLength(expr: Constant): CharLength; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to calculate the length of. A new representing the length of the string. | - -Returns: - -[CharLength](./firestore_lite.charlength.md#charlength_class) - -### cosineDistance(expr, other) {:#cosinedistance_b4c7dc2} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between a field's vector value and a double array. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -cosineDistance("location", [37.7749, -122.4194]); - -``` - -Signature: - -```typescript -export declare function cosineDistance(expr: string, other: number[]): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the first vector. | -| other | number\[\] | The other vector (as an array of doubles) to compare against. A new representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) - -### cosineDistance(expr, other) {:#cosinedistance_8d2bd9d} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between a field's vector value and a VectorValue. - -```typescript -// Calculate the Cosine distance between the 'location' field and a target location -cosineDistance("location", new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -export declare function cosineDistance(expr: string, other: VectorValue): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the first vector. | -| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new representing the Cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) - -### cosineDistance(expr, other) {:#cosinedistance_c9ae0bc} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between a field's vector value and a vector expression. - -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -cosineDistance("userVector", Field.of("itemVector")); - -``` - -Signature: - -```typescript -export declare function cosineDistance(expr: string, other: Constant): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the first vector. | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new representing the cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) - -### cosineDistance(expr, other) {:#cosinedistance_e701952} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between a vector expression and a double array. - -```typescript -// Calculate the cosine distance between the 'location' field and a target location -cosineDistance(Field.of("location"), [37.7749, -122.4194]); - -``` - -Signature: - -```typescript -export declare function cosineDistance(expr: Constant, other: number[]): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | -| other | number\[\] | The other vector (as an array of doubles) to compare against. A new representing the cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) - -### cosineDistance(expr, other) {:#cosinedistance_cc2e83e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between a vector expression and a VectorValue. - -```typescript -// Calculate the cosine distance between the 'location' field and a target location -cosineDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -export declare function cosineDistance(expr: Constant, other: VectorValue): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | -| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new representing the cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) - -### cosineDistance(expr, other) {:#cosinedistance_0896fbd} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Cosine distance between two vector expressions. - -```typescript -// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field -cosineDistance(Field.of("userVector"), Field.of("itemVector")); - -``` - -Signature: - -```typescript -export declare function cosineDistance(expr: Constant, other: Constant): CosineDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new representing the cosine distance between the two vectors. | - -Returns: - -[CosineDistance](./firestore_lite.cosinedistance.md#cosinedistance_class) - -### descending(expr) {:#descending_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an [Ordering](./firestore_.ordering.md#ordering_class) that sorts documents in descending order based on this expression. - -```typescript -// Sort documents by the 'createdAt' field in descending order -firestore.pipeline().collection("users") - .sort(descending(Field.of("createdAt"))); - -``` - -Signature: - -```typescript -export declare function descending(expr: Constant): Ordering; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression to create a descending ordering for. A new Ordering for descending sorting. | - -Returns: - -[Ordering](./firestore_lite.ordering.md#ordering_class) - -### dotProduct(expr, other) {:#dotproduct_b4c7dc2} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between a field's vector value and a double array. - -```typescript -// Calculate the dot product distance between a feature vector and a target vector -dotProduct("features", [0.5, 0.8, 0.2]); - -``` - -Signature: - -```typescript -export declare function dotProduct(expr: string, other: number[]): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the first vector. | -| other | number\[\] | The other vector (as an array of doubles) to calculate with. A new representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) - -### dotProduct(expr, other) {:#dotproduct_8d2bd9d} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between a field's vector value and a VectorValue. - -```typescript -// Calculate the dot product distance between a feature vector and a target vector -dotProduct("features", new VectorValue([0.5, 0.8, 0.2])); - -``` - -Signature: - -```typescript -export declare function dotProduct(expr: string, other: VectorValue): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the first vector. | -| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to calculate with. A new representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) - -### dotProduct(expr, other) {:#dotproduct_c9ae0bc} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between a field's vector value and a vector expression. - -```typescript -// Calculate the dot product distance between two document vectors: 'docVector1' and 'docVector2' -dotProduct("docVector1", Field.of("docVector2")); - -``` - -Signature: - -```typescript -export declare function dotProduct(expr: string, other: Constant): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the first vector. | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to calculate with. A new representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) - -### dotProduct(expr, other) {:#dotproduct_e701952} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between a vector expression and a double array. - -```typescript -// Calculate the dot product between a feature vector and a target vector -dotProduct(Field.of("features"), [0.5, 0.8, 0.2]); - -``` - -Signature: - -```typescript -export declare function dotProduct(expr: Constant, other: number[]): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The first vector (represented as an Expr) to calculate with. | -| other | number\[\] | The other vector (as an array of doubles) to calculate with. A new representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) - -### dotProduct(expr, other) {:#dotproduct_cc2e83e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between a vector expression and a VectorValue. - -```typescript -// Calculate the dot product between a feature vector and a target vector -dotProduct(Field.of("features"), new VectorValue([0.5, 0.8, 0.2])); - -``` - -Signature: - -```typescript -export declare function dotProduct(expr: Constant, other: VectorValue): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The first vector (represented as an Expr) to calculate with. | -| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to calculate with. A new representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) - -### dotProduct(expr, other) {:#dotproduct_0896fbd} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the dot product between two vector expressions. - -```typescript -// Calculate the dot product between two document vectors: 'docVector1' and 'docVector2' -dotProduct(Field.of("docVector1"), Field.of("docVector2")); - -``` - -Signature: - -```typescript -export declare function dotProduct(expr: Constant, other: Constant): DotProduct; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The first vector (represented as an Expr) to calculate with. | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to calculate with. A new representing the dot product between the two vectors. | - -Returns: - -[DotProduct](./firestore_lite.dotproduct.md#dotproduct_class) - -### endsWith(expr, suffix) {:#endswith_88569cd} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value ends with a given postfix. - -```typescript -// Check if the 'filename' field ends with ".txt" -endsWith("filename", ".txt"); - -``` - -Signature: - -```typescript -export declare function endsWith(expr: string, suffix: string): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The field name to check. | -| suffix | string | The postfix to check for. A new representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_lite.endswith.md#endswith_class) - -### endsWith(expr, suffix) {:#endswith_e2e794e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value ends with a given postfix. - -```typescript -// Check if the 'url' field ends with the value of the 'extension' field -endsWith("url", Field.of("extension")); - -``` - -Signature: - -```typescript -export declare function endsWith(expr: string, suffix: Constant): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The field name to check. | -| suffix | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the postfix. A new representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_lite.endswith.md#endswith_class) - -### endsWith(expr, suffix) {:#endswith_6308b81} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string expression ends with a given postfix. - -```typescript -// Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." -endsWith(Field.of("fullName"), "Jr."); - -``` - -Signature: - -```typescript -export declare function endsWith(expr: Constant, suffix: string): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression to check. | -| suffix | string | The postfix to check for. A new representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_lite.endswith.md#endswith_class) - -### endsWith(expr, suffix) {:#endswith_ab1cc39} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string expression ends with a given postfix. - -```typescript -// Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." -endsWith(Field.of("fullName"), Constant.of("Jr.")); - -``` - -Signature: - -```typescript -export declare function endsWith(expr: Constant, suffix: Constant): EndsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression to check. | -| suffix | [Constant](./firestore_lite.constant.md#constant_class) | The postfix to check for. A new representing the 'ends with' comparison. | - -Returns: - -[EndsWith](./firestore_lite.endswith.md#endswith_class) - -### euclideanDistance(expr, other) {:#euclideandistance_b4c7dc2} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between a field's vector value and a double array. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -euclideanDistance("location", [37.7749, -122.4194]); - -``` - -Signature: - -```typescript -export declare function euclideanDistance(expr: string, other: number[]): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the first vector. | -| other | number\[\] | The other vector (as an array of doubles) to compare against. A new representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) - -### euclideanDistance(expr, other) {:#euclideandistance_8d2bd9d} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between a field's vector value and a VectorValue. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -euclideanDistance("location", new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -export declare function euclideanDistance(expr: string, other: VectorValue): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the first vector. | -| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) - -### euclideanDistance(expr, other) {:#euclideandistance_c9ae0bc} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between a field's vector value and a vector expression. - -```typescript -// Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' -euclideanDistance("pointA", Field.of("pointB")); - -``` - -Signature: - -```typescript -export declare function euclideanDistance(expr: string, other: Constant): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the first vector. | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) - -### euclideanDistance(expr, other) {:#euclideandistance_e701952} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between a vector expression and a double array. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location - -euclideanDistance(Field.of("location"), [37.7749, -122.4194]); - -``` - -Signature: - -```typescript -export declare function euclideanDistance(expr: Constant, other: number[]): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | -| other | number\[\] | The other vector (as an array of doubles) to compare against. A new representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) - -### euclideanDistance(expr, other) {:#euclideandistance_cc2e83e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between a vector expression and a VectorValue. - -```typescript -// Calculate the Euclidean distance between the 'location' field and a target location -euclideanDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); - -``` - -Signature: - -```typescript -export declare function euclideanDistance(expr: Constant, other: VectorValue): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | -| other | [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | The other vector (as a VectorValue) to compare against. A new representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) - -### euclideanDistance(expr, other) {:#euclideandistance_0896fbd} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Calculates the Euclidean distance between two vector expressions. - -```typescript -// Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' -euclideanDistance(Field.of("pointA"), Field.of("pointB")); - -``` - -Signature: - -```typescript -export declare function euclideanDistance(expr: Constant, other: Constant): EuclideanDistance; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The first vector (represented as an Expr) to compare against. | -| other | [Constant](./firestore_lite.constant.md#constant_class) | The other vector (represented as an Expr) to compare against. A new representing the Euclidean distance between the two vectors. | - -Returns: - -[EuclideanDistance](./firestore_lite.euclideandistance.md#euclideandistance_class) - -### reverse(expr) {:#reverse_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that reverses a string. - -```typescript -// Reverse the value of the 'myString' field. -reverse(Field.of("myString")); - -``` - -Signature: - -```typescript -export declare function reverse(expr: Constant): Reverse; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to reverse. A new representing the reversed string. | - -Returns: - -[Reverse](./firestore_lite.reverse.md#reverse_class) - -### startsWith(expr, prefix) {:#startswith_484d9f3} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value starts with a given prefix. - -```typescript -// Check if the 'name' field starts with "Mr." -startsWith("name", "Mr."); - -``` - -Signature: - -```typescript -export declare function startsWith(expr: string, prefix: string): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The field name to check. | -| prefix | string | The prefix to check for. A new representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_lite.startswith.md#startswith_class) - -### startsWith(expr, prefix) {:#startswith_7deb5c7} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value starts with a given prefix. - -```typescript -// Check if the 'fullName' field starts with the value of the 'firstName' field -startsWith("fullName", Field.of("firstName")); - -``` - -Signature: - -```typescript -export declare function startsWith(expr: string, prefix: Constant): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The field name to check. | -| prefix | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the prefix. A new representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_lite.startswith.md#startswith_class) - -### startsWith(expr, prefix) {:#startswith_68300d1} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string expression starts with a given prefix. - -```typescript -// Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." -startsWith(Field.of("fullName"), "Mr."); - -``` - -Signature: - -```typescript -export declare function startsWith(expr: Constant, prefix: string): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression to check. | -| prefix | string | The prefix to check for. A new representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_lite.startswith.md#startswith_class) - -### startsWith(expr, prefix) {:#startswith_5774b68} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string expression starts with a given prefix. - -```typescript -// Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." -startsWith(Field.of("fullName"), Field.of("prefix")); - -``` - -Signature: - -```typescript -export declare function startsWith(expr: Constant, prefix: Constant): StartsWith; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression to check. | -| prefix | [Constant](./firestore_lite.constant.md#constant_class) | The prefix to check for. A new representing the 'starts with' comparison. | - -Returns: - -[StartsWith](./firestore_lite.startswith.md#startswith_class) - -### timestampToUnixMicros(expr) {:#timestamptounixmicros_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -timestampToUnixMicros(Field.of("timestamp")); - -``` - -Signature: - -```typescript -export declare function timestampToUnixMicros(expr: Constant): TimestampToUnixMicros; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the timestamp. A new representing the number of microseconds since epoch. | - -Returns: - -[TimestampToUnixMicros](./firestore_lite.timestamptounixmicros.md#timestamptounixmicros_class) - -### timestampToUnixMillis(expr) {:#timestamptounixmillis_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -timestampToUnixMillis(Field.of("timestamp")); - -``` - -Signature: - -```typescript -export declare function timestampToUnixMillis(expr: Constant): TimestampToUnixMillis; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the timestamp. A new representing the number of milliseconds since epoch. | - -Returns: - -[TimestampToUnixMillis](./firestore_lite.timestamptounixmillis.md#timestamptounixmillis_class) - -### timestampToUnixSeconds(expr) {:#timestamptounixseconds_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to seconds since epoch. -timestampToUnixSeconds(Field.of("timestamp")); - -``` - -Signature: - -```typescript -export declare function timestampToUnixSeconds(expr: Constant): TimestampToUnixSeconds; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the timestamp. A new representing the number of seconds since epoch. | - -Returns: - -[TimestampToUnixSeconds](./firestore_lite.timestamptounixseconds.md#timestamptounixseconds_class) - -### toLower(expr) {:#tolower_1e536ed} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string field to lowercase. - -```typescript -// Convert the 'name' field to lowercase -toLower("name"); - -``` - -Signature: - -```typescript -export declare function toLower(expr: string): ToLower; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the string. A new representing the lowercase string. | - -Returns: - -[ToLower](./firestore_lite.tolower.md#tolower_class) - -### toLower(expr) {:#tolower_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string expression to lowercase. - -```typescript -// Convert the 'name' field to lowercase -toLower(Field.of("name")); - -``` - -Signature: - -```typescript -export declare function toLower(expr: Constant): ToLower; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to convert to lowercase. A new representing the lowercase string. | - -Returns: - -[ToLower](./firestore_lite.tolower.md#tolower_class) - -### toUpper(expr) {:#toupper_1e536ed} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string field to uppercase. - -```typescript -// Convert the 'title' field to uppercase -toUpper("title"); - -``` - -Signature: - -```typescript -export declare function toUpper(expr: string): ToUpper; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the string. A new representing the uppercase string. | - -Returns: - -[ToUpper](./firestore_lite.toupper.md#toupper_class) - -### toUpper(expr) {:#toupper_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a string expression to uppercase. - -```typescript -// Convert the 'title' field to uppercase -toUppercase(Field.of("title")); - -``` - -Signature: - -```typescript -export declare function toUpper(expr: Constant): ToUpper; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to convert to uppercase. A new representing the uppercase string. | - -Returns: - -[ToUpper](./firestore_lite.toupper.md#toupper_class) - -### trim(expr) {:#trim_1e536ed} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that removes leading and trailing whitespace from a string field. - -```typescript -// Trim whitespace from the 'userInput' field -trim("userInput"); - -``` - -Signature: - -```typescript -export declare function trim(expr: string): Trim; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | string | The name of the field containing the string. A new representing the trimmed string. | - -Returns: - -[Trim](./firestore_lite.trim.md#trim_class) - -### trim(expr) {:#trim_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that removes leading and trailing whitespace from a string expression. - -```typescript -// Trim whitespace from the 'userInput' field -trim(Field.of("userInput")); - -``` - -Signature: - -```typescript -export declare function trim(expr: Constant): Trim; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to trim. A new representing the trimmed string. | - -Returns: - -[Trim](./firestore_lite.trim.md#trim_class) - -### unixMicrosToTimestamp(expr) {:#unixmicrostotimestamp_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets an expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -unixMicrosToTimestamp(Field.of("microseconds")); - -``` - -Signature: - -```typescript -export declare function unixMicrosToTimestamp(expr: Constant): UnixMicrosToTimestamp; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the number of microseconds since epoch. A new representing the timestamp. | - -Returns: - -[UnixMicrosToTimestamp](./firestore_lite.unixmicrostotimestamp.md#unixmicrostotimestamp_class) - -### unixMillisToTimestamp(expr) {:#unixmillistotimestamp_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets an expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -unixMillisToTimestamp(Field.of("milliseconds")); - -``` - -Signature: - -```typescript -export declare function unixMillisToTimestamp(expr: Constant): UnixMillisToTimestamp; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the number of milliseconds since epoch. A new representing the timestamp. | - -Returns: - -[UnixMillisToTimestamp](./firestore_lite.unixmillistotimestamp.md#unixmillistotimestamp_class) - -### unixSecondsToTimestamp(expr) {:#unixsecondstotimestamp_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets an expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'seconds' field as seconds since epoch. -unixSecondsToTimestamp(Field.of("seconds")); - -``` - -Signature: - -```typescript -export declare function unixSecondsToTimestamp(expr: Constant): UnixSecondsToTimestamp; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the number of seconds since epoch. A new representing the timestamp. | - -Returns: - -[UnixSecondsToTimestamp](./firestore_lite.unixsecondstotimestamp.md#unixsecondstotimestamp_class) - -### vectorLength(expr) {:#vectorlength_f3fb767} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of a Firestore Vector. - -```typescript -// Get the vector length (dimension) of the field 'embedding'. -vectorLength(Field.of("embedding")); - -``` - -Signature: - -```typescript -export declare function vectorLength(expr: Constant): VectorLength; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the Firestore Vector. A new representing the length of the array. | - -Returns: - -[VectorLength](./firestore_lite.vectorlength.md#vectorlength_class) - -## function(field, ...) - -### average(field) {:#average_aacc3a9} - -Create an AggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query. - -Signature: - -```typescript -export declare function average(field: string | FieldPath): AggregateField; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | Specifies the field to average across the result set. | - -Returns: - -[AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<number \| null> - -### byteLength(field) {:#bytelength_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of a string represented by a field in UTF-8 bytes, or just the length of a Blob. - -```typescript -// Calculate the length of the 'myString' field in bytes. -byteLength("myString"); - -``` - -Signature: - -```typescript -export declare function byteLength(field: string): ByteLength; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the string. A new representing the length of the string in bytes. | - -Returns: - -[ByteLength](./firestore_lite.bytelength.md#bytelength_class) - -### charLength(field) {:#charlength_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the character length of a string field in UTF8. - -```typescript -// Get the character length of the 'name' field in UTF-8. -strLength("name"); - -``` - -Signature: - -```typescript -export declare function charLength(field: string): CharLength; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field containing the string. A new representing the length of the string. | - -Returns: - -[CharLength](./firestore_lite.charlength.md#charlength_class) - -### exists(field) {:#exists_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field exists. - -```typescript -// Check if the document has a field named "phoneNumber" -exists("phoneNumber"); - -``` - -Signature: - -```typescript -export declare function exists(field: string): Exists; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The field name to check. A new representing the 'exists' check. | - -Returns: - -[Exists](./firestore_lite.exists.md#exists_class) - -### replaceAll(field, find, replace) {:#replaceall_b257ab0} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces all occurrences of a substring within a string represented by a field with another substring. - -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field. -replaceAll("message", "hello", "hi"); - -``` - -Signature: - -```typescript -export declare function replaceAll(field: string, find: string, replace: string): ReplaceAll; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the string to perform the replacement on. | -| find | string | The substring to search for. | -| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | - -Returns: - -[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) - -### replaceFirst(field, find, replace) {:#replacefirst_b257ab0} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that replaces the first occurrence of a substring within a string represented by a field with another substring. - -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field. -replaceFirst("message", "hello", "hi"); - -``` - -Signature: - -```typescript -export declare function replaceFirst(field: string, find: string, replace: string): ReplaceFirst; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the string to perform the replacement on. | -| find | string | The substring to search for. | -| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | - -Returns: - -[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) - -### reverse(field) {:#reverse_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that reverses a string represented by a field. - -```typescript -// Reverse the value of the 'myString' field. -reverse("myString"); - -``` - -Signature: - -```typescript -export declare function reverse(field: string): Reverse; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the string to reverse. A new representing the reversed string. | - -Returns: - -[Reverse](./firestore_lite.reverse.md#reverse_class) - -### sum(field) {:#sum_aacc3a9} - -Create an AggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query. - -Signature: - -```typescript -export declare function sum(field: string | FieldPath): AggregateField; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | Specifies the field to sum across the result set. | - -Returns: - -[AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<number> - -### timestampAdd(field, unit, amount) {:#timestampadd_565792c} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a specified amount of time to a timestamp represented by a field. - -```typescript -// Add 1 day to the 'timestamp' field. -timestampAdd("timestamp", "day", 1); - -``` - -Signature: - -```typescript -export declare function timestampAdd(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the timestamp. | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | -| amount | number | The amount of time to add. A new representing the resulting timestamp. | - -Returns: - -[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) - -### timestampSub(field, unit, amount) {:#timestampsub_565792c} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that subtracts a specified amount of time from a timestamp represented by a field. - -```typescript -// Subtract 1 day from the 'timestamp' field. -timestampSub("timestamp", "day", 1); - -``` - -Signature: - -```typescript -export declare function timestampSub(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the timestamp. | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | -| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | - -Returns: - -[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) - -### timestampToUnixMicros(field) {:#timestamptounixmicros_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a timestamp field to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to microseconds since epoch. -timestampToUnixMicros("timestamp"); - -``` - -Signature: - -```typescript -export declare function timestampToUnixMicros(field: string): TimestampToUnixMicros; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the timestamp. A new representing the number of microseconds since epoch. | - -Returns: - -[TimestampToUnixMicros](./firestore_lite.timestamptounixmicros.md#timestamptounixmicros_class) - -### timestampToUnixMillis(field) {:#timestamptounixmillis_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a timestamp field to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to milliseconds since epoch. -timestampToUnixMillis("timestamp"); - -``` - -Signature: - -```typescript -export declare function timestampToUnixMillis(field: string): TimestampToUnixMillis; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the timestamp. A new representing the number of milliseconds since epoch. | - -Returns: - -[TimestampToUnixMillis](./firestore_lite.timestamptounixmillis.md#timestamptounixmillis_class) - -### timestampToUnixSeconds(field) {:#timestamptounixseconds_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that converts a timestamp field to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). - -```typescript -// Convert the 'timestamp' field to seconds since epoch. -timestampToUnixSeconds("timestamp"); - -``` - -Signature: - -```typescript -export declare function timestampToUnixSeconds(field: string): TimestampToUnixSeconds; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the timestamp. A new representing the number of seconds since epoch. | - -Returns: - -[TimestampToUnixSeconds](./firestore_lite.timestamptounixseconds.md#timestamptounixseconds_class) - -### unixMicrosToTimestamp(field) {:#unixmicrostotimestamp_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets a field's value as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'microseconds' field as microseconds since epoch. -unixMicrosToTimestamp("microseconds"); - -``` - -Signature: - -```typescript -export declare function unixMicrosToTimestamp(field: string): UnixMicrosToTimestamp; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the number of microseconds since epoch. A new representing the timestamp. | - -Returns: - -[UnixMicrosToTimestamp](./firestore_lite.unixmicrostotimestamp.md#unixmicrostotimestamp_class) - -### unixMillisToTimestamp(field) {:#unixmillistotimestamp_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets a field's value as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'milliseconds' field as milliseconds since epoch. -unixMillisToTimestamp("milliseconds"); - -``` - -Signature: - -```typescript -export declare function unixMillisToTimestamp(field: string): UnixMillisToTimestamp; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the number of milliseconds since epoch. A new representing the timestamp. | - -Returns: - -[UnixMillisToTimestamp](./firestore_lite.unixmillistotimestamp.md#unixmillistotimestamp_class) - -### unixSecondsToTimestamp(field) {:#unixsecondstotimestamp_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that interprets a field's value as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. - -```typescript -// Interpret the 'seconds' field as seconds since epoch. -unixSecondsToTimestamp("seconds"); - -``` - -Signature: - -```typescript -export declare function unixSecondsToTimestamp(field: string): UnixSecondsToTimestamp; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the number of seconds since epoch. A new representing the timestamp. | - -Returns: - -[UnixSecondsToTimestamp](./firestore_lite.unixsecondstotimestamp.md#unixsecondstotimestamp_class) - -### vectorLength(field) {:#vectorlength_0fb8cd4} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the length of a Firestore Vector represented by a field. - -```typescript -// Get the vector length (dimension) of the field 'embedding'. -vectorLength("embedding"); - -``` - -Signature: - -```typescript -export declare function vectorLength(field: string): VectorLength; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| field | string | The name of the field representing the Firestore Vector. A new representing the length of the array. | - -Returns: - -[VectorLength](./firestore_lite.vectorlength.md#vectorlength_class) - -## function(fieldPath, ...) - -### orderBy(fieldPath, directionStr) {:#orderby_006d61f} - -Creates a [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) that sorts the query result by the specified field, optionally in descending order instead of ascending. - -Note: Documents that do not contain the specified field will not be present in the query result. - -Signature: - -```typescript -export declare function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryOrderByConstraint; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| fieldPath | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | The field to sort by. | -| directionStr | [OrderByDirection](./firestore_lite.md#orderbydirection) | Optional direction to sort by ('asc' or 'desc'). If not specified, order will be ascending. | - -Returns: - -[QueryOrderByConstraint](./firestore_lite.queryorderbyconstraint.md#queryorderbyconstraint_class) - -The created [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class). - -### where(fieldPath, opStr, value) {:#where_0fae4bf} - -Creates a [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) that enforces that documents must contain the specified field and that the value should satisfy the relation constraint provided. - -Signature: - -```typescript -export declare function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryFieldFilterConstraint; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| fieldPath | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | The path to compare | -| opStr | [WhereFilterOp](./firestore_lite.md#wherefilterop) | The operation string (e.g "&lt;", "&lt;=", "==", "&lt;", "&lt;=", "!="). | -| value | unknown | The value for comparison | - -Returns: - -[QueryFieldFilterConstraint](./firestore_lite.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) - -The created [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class). - -## function(fieldValues, ...) - -### endAt(fieldValues) {:#endat_8b2f2c8} - -Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. - -Signature: - -```typescript -export declare function endAt(...fieldValues: unknown[]): QueryEndAtConstraint; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| fieldValues | unknown\[\] | The field values to end this query at, in order of the query's order by. | - -Returns: - -[QueryEndAtConstraint](./firestore_lite.queryendatconstraint.md#queryendatconstraint_class) - -A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` - -### endBefore(fieldValues) {:#endbefore_8b2f2c8} - -Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. - -Signature: - -```typescript -export declare function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| fieldValues | unknown\[\] | The field values to end this query before, in order of the query's order by. | - -Returns: - -[QueryEndAtConstraint](./firestore_lite.queryendatconstraint.md#queryendatconstraint_class) - -A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` - -### startAfter(fieldValues) {:#startafter_8b2f2c8} - -Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. - -Signature: - -```typescript -export declare function startAfter(...fieldValues: unknown[]): QueryStartAtConstraint; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| fieldValues | unknown\[\] | The field values to start this query after, in order of the query's order by. | - -Returns: - -[QueryStartAtConstraint](./firestore_lite.querystartatconstraint.md#querystartatconstraint_class) - -A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()` - -### startAt(fieldValues) {:#startat_8b2f2c8} - -Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. - -Signature: - -```typescript -export declare function startAt(...fieldValues: unknown[]): QueryStartAtConstraint; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| fieldValues | unknown\[\] | The field values to start this query at, in order of the query's order by. | - -Returns: - -[QueryStartAtConstraint](./firestore_lite.querystartatconstraint.md#querystartatconstraint_class) - -A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()`. - -## function(filter, ...) - -### not(filter) {:#not_5520849} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that negates a filter condition. - -```typescript -// Find documents where the 'completed' field is NOT true -not(eq("completed", true)); - -``` - -Signature: - -```typescript -export declare function not(filter: FilterExpr): Not; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| filter | [FilterExpr](./firestore_lite.md#filterexpr) | The filter condition to negate. A new representing the negated filter condition. | - -Returns: - -[Not](./firestore_lite.not.md#not_class) - -## function(first, ...) - -### strConcat(first, elements) {:#strconcat_0f1bdbf} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates string functions, fields or constants together. - -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -strConcat("firstName", " ", Field.of("lastName")); - -``` - -Signature: - -```typescript -export declare function strConcat(first: string, ...elements: Array): StrConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| first | string | The field name containing the initial string value. | -| elements | Array<[Constant](./firestore_lite.constant.md#constant_class) \| string> | The expressions (typically strings) to concatenate. A new representing the concatenated string. | - -Returns: - -[StrConcat](./firestore_lite.strconcat.md#strconcat_class) - -### strConcat(first, elements) {:#strconcat_1eb0ac1} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that concatenates string expressions together. - -```typescript -// Combine the 'firstName', " ", and 'lastName' fields into a single string -strConcat(Field.of("firstName"), " ", Field.of("lastName")); - -``` - -Signature: - -```typescript -export declare function strConcat(first: Constant, ...elements: Array): StrConcat; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| first | [Constant](./firestore_lite.constant.md#constant_class) | The initial string expression to concatenate to. | -| elements | Array<[Constant](./firestore_lite.constant.md#constant_class) \| string> | The expressions (typically strings) to concatenate. A new representing the concatenated string. | - -Returns: - -[StrConcat](./firestore_lite.strconcat.md#strconcat_class) - -## function(left, ...) - -### add(left, right) {:#add_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds two expressions together. - -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -add(Field.of("quantity"), Field.of("reserve")); - -``` - -Signature: - -```typescript -export declare function add(left: Constant, right: Constant): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The first expression to add. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The second expression to add. A new representing the addition operation. | - -Returns: - -[Add](./firestore_lite.add.md#add_class) - -### add(left, right) {:#add_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds an expression to a constant value. - -```typescript -// Add 5 to the value of the 'age' field -add(Field.of("age"), 5); - -``` - -Signature: - -```typescript -export declare function add(left: Constant, right: any): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to add to. | -| right | any | The constant value to add. A new representing the addition operation. | - -Returns: - -[Add](./firestore_lite.add.md#add_class) - -### add(left, right) {:#add_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a field's value to an expression. - -```typescript -// Add the value of the 'quantity' field and the 'reserve' field. -add("quantity", Field.of("reserve")); - -``` - -Signature: - -```typescript -export declare function add(left: string, right: Constant): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to add to. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to add. A new representing the addition operation. | - -Returns: - -[Add](./firestore_lite.add.md#add_class) - -### add(left, right) {:#add_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that adds a field's value to a constant value. - -```typescript -// Add 5 to the value of the 'age' field -add("age", 5); - -``` - -Signature: - -```typescript -export declare function add(left: string, right: any): Add; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to add to. | -| right | any | The constant value to add. A new representing the addition operation. | - -Returns: - -[Add](./firestore_lite.add.md#add_class) - -### aggregateFieldEqual(left, right) {:#aggregatefieldequal_e80a2b2} - -Compares two 'AggregateField\` instances for equality. - -Signature: - -```typescript -export declare function aggregateFieldEqual(left: AggregateField, right: AggregateField): boolean; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<unknown> | Compare this AggregateField to the right. | -| right | [AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<unknown> | Compare this AggregateField to the left. | - -Returns: - -boolean - -### aggregateQuerySnapshotEqual(left, right) {:#aggregatequerysnapshotequal_1529a20} - -Compares two `AggregateQuerySnapshot` instances for equality. - -Two `AggregateQuerySnapshot` instances are considered "equal" if they have underlying queries that compare equal, and the same data. - -Signature: - -```typescript -export declare function aggregateQuerySnapshotEqual(left: AggregateQuerySnapshot, right: AggregateQuerySnapshot): boolean; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [AggregateQuerySnapshot](./firestore_lite.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType> | The first AggregateQuerySnapshot to compare. | -| right | [AggregateQuerySnapshot](./firestore_lite.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType> | The second AggregateQuerySnapshot to compare. | - -Returns: - -boolean - -`true` if the objects are "equal", as defined above, or `false` otherwise. - -### and(left, right) {:#and_eba7e36} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that performs a logical 'AND' operation on multiple filter conditions. - -```typescript -// Check if the 'age' field is greater than 18 AND the 'city' field is "London" AND -// the 'status' field is "active" -const condition = and(gt("age", 18), eq("city", "London"), eq("status", "active")); - -``` - -Signature: - -```typescript -export declare function and(left: FilterExpr, ...right: FilterExpr[]): And; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [FilterExpr](./firestore_lite.md#filterexpr) | The first filter condition. | -| right | [FilterExpr](./firestore_lite.md#filterexpr)\[\] | Additional filter conditions to 'AND' together. A new representing the logical 'AND' operation. | - -Returns: - -[And](./firestore_lite.and.md#and_class) - -### divide(left, right) {:#divide_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides two expressions. - -```typescript -// Divide the 'total' field by the 'count' field -divide(Field.of("total"), Field.of("count")); - -``` - -Signature: - -```typescript -export declare function divide(left: Constant, right: Constant): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to be divided. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new representing the division operation. | - -Returns: - -[Divide](./firestore_lite.divide.md#divide_class) - -### divide(left, right) {:#divide_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides an expression by a constant value. - -```typescript -// Divide the 'value' field by 10 -divide(Field.of("value"), 10); - -``` - -Signature: - -```typescript -export declare function divide(left: Constant, right: any): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to be divided. | -| right | any | The constant value to divide by. A new representing the division operation. | - -Returns: - -[Divide](./firestore_lite.divide.md#divide_class) - -### divide(left, right) {:#divide_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides a field's value by an expression. - -```typescript -// Divide the 'total' field by the 'count' field -divide("total", Field.of("count")); - -``` - -Signature: - -```typescript -export declare function divide(left: string, right: Constant): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to be divided. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to divide by. A new representing the division operation. | - -Returns: - -[Divide](./firestore_lite.divide.md#divide_class) - -### divide(left, right) {:#divide_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that divides a field's value by a constant value. - -```typescript -// Divide the 'value' field by 10 -divide("value", 10); - -``` - -Signature: - -```typescript -export declare function divide(left: string, right: any): Divide; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to be divided. | -| right | any | The constant value to divide by. A new representing the division operation. | - -Returns: - -[Divide](./firestore_lite.divide.md#divide_class) - -### eq(left, right) {:#eq_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if two expressions are equal. - -```typescript -// Check if the 'age' field is equal to an expression -eq(Field.of("age"), Field.of("minAge").add(10)); - -``` - -Signature: - -```typescript -export declare function eq(left: Constant, right: Constant): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The first expression to compare. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The second expression to compare. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_lite.eq.md#eq_class) - -### eq(left, right) {:#eq_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an expression is equal to a constant value. - -```typescript -// Check if the 'age' field is equal to 21 -eq(Field.of("age"), 21); - -``` - -Signature: - -```typescript -export declare function eq(left: Constant, right: any): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare. | -| right | any | The constant value to compare to. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_lite.eq.md#eq_class) - -### eq(left, right) {:#eq_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is equal to an expression. - -```typescript -// Check if the 'age' field is equal to the 'limit' field -eq("age", Field.of("limit")); - -``` - -Signature: - -```typescript -export declare function eq(left: string, right: Constant): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare to. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_lite.eq.md#eq_class) - -### eq(left, right) {:#eq_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is equal to a constant value. - -```typescript -// Check if the 'city' field is equal to string constant "London" -eq("city", "London"); - -``` - -Signature: - -```typescript -export declare function eq(left: string, right: any): Eq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | any | The constant value to compare to. A new Expr representing the equality comparison. | - -Returns: - -[Eq](./firestore_lite.eq.md#eq_class) - -### gt(left, right) {:#gt_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if the first expression is greater than the second expression. - -```typescript -// Check if the 'age' field is greater than 18 -gt(Field.of("age"), Constant(9).add(9)); - -``` - -Signature: - -```typescript -export declare function gt(left: Constant, right: Constant): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The first expression to compare. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The second expression to compare. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_lite.gt.md#gt_class) - -### gt(left, right) {:#gt_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an expression is greater than a constant value. - -```typescript -// Check if the 'age' field is greater than 18 -gt(Field.of("age"), 18); - -``` - -Signature: - -```typescript -export declare function gt(left: Constant, right: any): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare. | -| right | any | The constant value to compare to. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_lite.gt.md#gt_class) - -### gt(left, right) {:#gt_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is greater than an expression. - -```typescript -// Check if the value of field 'age' is greater than the value of field 'limit' -gt("age", Field.of("limit")); - -``` - -Signature: - -```typescript -export declare function gt(left: string, right: Constant): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare to. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_lite.gt.md#gt_class) - -### gt(left, right) {:#gt_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is greater than a constant value. - -```typescript -// Check if the 'price' field is greater than 100 -gt("price", 100); - -``` - -Signature: - -```typescript -export declare function gt(left: string, right: any): Gt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | any | The constant value to compare to. A new Expr representing the greater than comparison. | - -Returns: - -[Gt](./firestore_lite.gt.md#gt_class) - -### gte(left, right) {:#gte_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if the first expression is greater than or equal to the second expression. - -```typescript -// Check if the 'quantity' field is greater than or equal to the field "threshold" -gte(Field.of("quantity"), Field.of("threshold")); - -``` - -Signature: - -```typescript -export declare function gte(left: Constant, right: Constant): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The first expression to compare. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The second expression to compare. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_lite.gte.md#gte_class) - -### gte(left, right) {:#gte_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an expression is greater than or equal to a constant value. - -```typescript -// Check if the 'quantity' field is greater than or equal to 10 -gte(Field.of("quantity"), 10); - -``` - -Signature: - -```typescript -export declare function gte(left: Constant, right: any): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare. | -| right | any | The constant value to compare to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_lite.gte.md#gte_class) - -### gte(left, right) {:#gte_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is greater than or equal to an expression. - -```typescript -// Check if the value of field 'age' is greater than or equal to the value of field 'limit' -gte("age", Field.of("limit")); - -``` - -Signature: - -```typescript -export declare function gte(left: string, right: Constant): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_lite.gte.md#gte_class) - -### gte(left, right) {:#gte_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is greater than or equal to a constant value. - -```typescript -// Check if the 'score' field is greater than or equal to 80 -gte("score", 80); - -``` - -Signature: - -```typescript -export declare function gte(left: string, right: any): Gte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | any | The constant value to compare to. A new Expr representing the greater than or equal to comparison. | - -Returns: - -[Gte](./firestore_lite.gte.md#gte_class) - -### like(left, pattern) {:#like_33ec01b} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that performs a case-sensitive wildcard string comparison against a field. - -```typescript -// Check if the 'title' field contains the string "guide" -like("title", "%guide%"); - -``` - -Signature: - -```typescript -export declare function like(left: string, pattern: string): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The name of the field containing the string. | -| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new representing the 'like' comparison. | - -Returns: - -[Like](./firestore_lite.like.md#like_class) - -### like(left, pattern) {:#like_dd84184} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that performs a case-sensitive wildcard string comparison against a field. - -```typescript -// Check if the 'title' field contains the string "guide" -like("title", Field.of("pattern")); - -``` - -Signature: - -```typescript -export declare function like(left: string, pattern: Constant): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The name of the field containing the string. | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The pattern to search for. You can use "%" as a wildcard character. A new representing the 'like' comparison. | - -Returns: - -[Like](./firestore_lite.like.md#like_class) - -### like(left, pattern) {:#like_3aaffe0} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that performs a case-sensitive wildcard string comparison. - -```typescript -// Check if the 'title' field contains the string "guide" -like(Field.of("title"), "%guide%"); - -``` - -Signature: - -```typescript -export declare function like(left: Constant, pattern: string): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to perform the comparison on. | -| pattern | string | The pattern to search for. You can use "%" as a wildcard character. A new representing the 'like' comparison. | - -Returns: - -[Like](./firestore_lite.like.md#like_class) - -### like(left, pattern) {:#like_a2c3e8b} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that performs a case-sensitive wildcard string comparison. - -```typescript -// Check if the 'title' field contains the string "guide" -like(Field.of("title"), Field.of("pattern")); - -``` - -Signature: - -```typescript -export declare function like(left: Constant, pattern: Constant): Like; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to perform the comparison on. | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The pattern to search for. You can use "%" as a wildcard character. A new representing the 'like' comparison. | - -Returns: - -[Like](./firestore_lite.like.md#like_class) - -### logicalMax(left, right) {:#logicalmax_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between two expressions, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'field1' field and the 'field2' field. -logicalMax(Field.of("field1"), Field.of("field2")); - -``` - -Signature: - -```typescript -export declare function logicalMax(left: Constant, right: Constant): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The left operand expression. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The right operand expression. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) - -### logicalMax(left, right) {:#logicalmax_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between an expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'value' field and 10. -logicalMax(Field.of("value"), 10); - -``` - -Signature: - -```typescript -export declare function logicalMax(left: Constant, right: any): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The left operand expression. | -| right | any | The right operand constant. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) - -### logicalMax(left, right) {:#logicalmax_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between a field and an expression, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'field1' field and the 'field2' field. -logicalMax("field1", Field.of('field2')); - -``` - -Signature: - -```typescript -export declare function logicalMax(left: string, right: Constant): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The left operand field name. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The right operand expression. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) - -### logicalMax(left, right) {:#logicalmax_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the larger value between a field and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the larger value between the 'value' field and 10. -logicalMax("value", 10); - -``` - -Signature: - -```typescript -export declare function logicalMax(left: string, right: any): LogicalMax; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The left operand field name. | -| right | any | The right operand constant. A new representing the logical max operation. | - -Returns: - -[LogicalMax](./firestore_lite.logicalmax.md#logicalmax_class) - -### logicalMin(left, right) {:#logicalmin_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between two expressions, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'field1' field and the 'field2' field. -logicalMin(Field.of("field1"), Field.of("field2")); - -``` - -Signature: - -```typescript -export declare function logicalMin(left: Constant, right: Constant): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The left operand expression. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The right operand expression. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) - -### logicalMin(left, right) {:#logicalmin_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between an expression and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'value' field and 10. -logicalMin(Field.of("value"), 10); - -``` - -Signature: - -```typescript -export declare function logicalMin(left: Constant, right: any): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The left operand expression. | -| right | any | The right operand constant. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) - -### logicalMin(left, right) {:#logicalmin_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between a field and an expression, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'field1' field and the 'field2' field. -logicalMin("field1", Field.of("field2")); - -``` - -Signature: - -```typescript -export declare function logicalMin(left: string, right: Constant): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The left operand field name. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The right operand expression. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) - -### logicalMin(left, right) {:#logicalmin_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that returns the smaller value between a field and a constant value, based on Firestore's value type ordering. - -```typescript -// Returns the smaller value between the 'value' field and 10. -logicalMin("value", 10); - -``` - -Signature: - -```typescript -export declare function logicalMin(left: string, right: any): LogicalMin; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The left operand field name. | -| right | any | The right operand constant. A new representing the logical min operation. | - -Returns: - -[LogicalMin](./firestore_lite.logicalmin.md#logicalmin_class) - -### lt(left, right) {:#lt_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if the first expression is less than the second expression. - -```typescript -// Check if the 'age' field is less than 30 -lt(Field.of("age"), Field.of("limit")); - -``` - -Signature: - -```typescript -export declare function lt(left: Constant, right: Constant): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The first expression to compare. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The second expression to compare. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_lite.lt.md#lt_class) - -### lt(left, right) {:#lt_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an expression is less than a constant value. - -```typescript -// Check if the 'age' field is less than 30 -lt(Field.of("age"), 30); - -``` - -Signature: - -```typescript -export declare function lt(left: Constant, right: any): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare. | -| right | any | The constant value to compare to. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_lite.lt.md#lt_class) - -### lt(left, right) {:#lt_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is less than an expression. - -```typescript -// Check if the 'age' field is less than the 'limit' field -lt("age", Field.of("limit")); - -``` - -Signature: - -```typescript -export declare function lt(left: string, right: Constant): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare to. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_lite.lt.md#lt_class) - -### lt(left, right) {:#lt_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is less than a constant value. - -```typescript -// Check if the 'price' field is less than 50 -lt("price", 50); - -``` - -Signature: - -```typescript -export declare function lt(left: string, right: any): Lt; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | any | The constant value to compare to. A new Expr representing the less than comparison. | - -Returns: - -[Lt](./firestore_lite.lt.md#lt_class) - -### lte(left, right) {:#lte_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if the first expression is less than or equal to the second expression. - -```typescript -// Check if the 'quantity' field is less than or equal to 20 -lte(Field.of("quantity"), Field.of("limit")); - -``` - -Signature: - -```typescript -export declare function lte(left: Constant, right: Constant): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The first expression to compare. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The second expression to compare. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_lite.lte.md#lte_class) - -### lte(left, right) {:#lte_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an expression is less than or equal to a constant value. - -```typescript -// Check if the 'quantity' field is less than or equal to 20 -lte(Field.of("quantity"), 20); - -``` - -Signature: - -```typescript -export declare function lte(left: Constant, right: any): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare. | -| right | any | The constant value to compare to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_lite.lte.md#lte_class) - -### lte(left, right) {:#lte_674c63f} - -Creates an expression that checks if a field's value is less than or equal to an expression. - -```typescript -// Check if the 'quantity' field is less than or equal to the 'limit' field -lte("quantity", Field.of("limit")); - -``` - -Signature: - -```typescript -export declare function lte(left: string, right: Constant): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_lite.lte.md#lte_class) - -### lte(left, right) {:#lte_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is less than or equal to a constant value. - -```typescript -// Check if the 'score' field is less than or equal to 70 -lte("score", 70); - -``` - -Signature: - -```typescript -export declare function lte(left: string, right: any): Lte; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | any | The constant value to compare to. A new Expr representing the less than or equal to comparison. | - -Returns: - -[Lte](./firestore_lite.lte.md#lte_class) - -### mod(left, right) {:#mod_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing two expressions. - -```typescript -// Calculate the remainder of dividing 'field1' by 'field2'. -mod(Field.of("field1"), Field.of("field2")); - -``` - -Signature: - -```typescript -export declare function mod(left: Constant, right: Constant): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The dividend expression. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The divisor expression. A new representing the modulo operation. | - -Returns: - -[Mod](./firestore_lite.mod.md#mod_class) - -### mod(left, right) {:#mod_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing an expression by a constant. - -```typescript -// Calculate the remainder of dividing 'field1' by 5. -mod(Field.of("field1"), 5); - -``` - -Signature: - -```typescript -export declare function mod(left: Constant, right: any): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The dividend expression. | -| right | any | The divisor constant. A new representing the modulo operation. | - -Returns: - -[Mod](./firestore_lite.mod.md#mod_class) - -### mod(left, right) {:#mod_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing a field's value by an expression. - -```typescript -// Calculate the remainder of dividing 'field1' by 'field2'. -mod("field1", Field.of("field2")); - -``` - -Signature: - -```typescript -export declare function mod(left: string, right: Constant): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The dividend field name. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The divisor expression. A new representing the modulo operation. | - -Returns: - -[Mod](./firestore_lite.mod.md#mod_class) - -### mod(left, right) {:#mod_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that calculates the modulo (remainder) of dividing a field's value by a constant. - -```typescript -// Calculate the remainder of dividing 'field1' by 5. -mod("field1", 5); - -``` - -Signature: - -```typescript -export declare function mod(left: string, right: any): Mod; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The dividend field name. | -| right | any | The divisor constant. A new representing the modulo operation. | - -Returns: - -[Mod](./firestore_lite.mod.md#mod_class) - -### multiply(left, right) {:#multiply_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies two expressions together. - -```typescript -// Multiply the 'quantity' field by the 'price' field -multiply(Field.of("quantity"), Field.of("price")); - -``` - -Signature: - -```typescript -export declare function multiply(left: Constant, right: Constant): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The first expression to multiply. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The second expression to multiply. A new representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_lite.multiply.md#multiply_class) - -### multiply(left, right) {:#multiply_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies an expression by a constant value. - -```typescript -// Multiply the value of the 'price' field by 2 -multiply(Field.of("price"), 2); - -``` - -Signature: - -```typescript -export declare function multiply(left: Constant, right: any): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to multiply. | -| right | any | The constant value to multiply by. A new representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_lite.multiply.md#multiply_class) - -### multiply(left, right) {:#multiply_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies a field's value by an expression. - -```typescript -// Multiply the 'quantity' field by the 'price' field -multiply("quantity", Field.of("price")); - -``` - -Signature: - -```typescript -export declare function multiply(left: string, right: Constant): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to multiply. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to multiply by. A new representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_lite.multiply.md#multiply_class) - -### multiply(left, right) {:#multiply_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that multiplies a field's value by a constant value. - -```typescript -// Multiply the 'value' field by 2 -multiply("value", 2); - -``` - -Signature: - -```typescript -export declare function multiply(left: string, right: any): Multiply; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to multiply. | -| right | any | The constant value to multiply by. A new representing the multiplication operation. | - -Returns: - -[Multiply](./firestore_lite.multiply.md#multiply_class) - -### neq(left, right) {:#neq_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if two expressions are not equal. - -```typescript -// Check if the 'status' field is not equal to field 'finalState' -neq(Field.of("status"), Field.of("finalState")); - -``` - -Signature: - -```typescript -export declare function neq(left: Constant, right: Constant): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The first expression to compare. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The second expression to compare. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_lite.neq.md#neq_class) - -### neq(left, right) {:#neq_010ba9e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if an expression is not equal to a constant value. - -```typescript -// Check if the 'status' field is not equal to "completed" -neq(Field.of("status"), "completed"); - -``` - -Signature: - -```typescript -export declare function neq(left: Constant, right: any): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare. | -| right | any | The constant value to compare to. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_lite.neq.md#neq_class) - -### neq(left, right) {:#neq_674c63f} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is not equal to an expression. - -```typescript -// Check if the 'status' field is not equal to the value of 'expectedStatus' -neq("status", Field.of("expectedStatus")); - -``` - -Signature: - -```typescript -export declare function neq(left: string, right: Constant): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to compare to. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_lite.neq.md#neq_class) - -### neq(left, right) {:#neq_1f46a76} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a field's value is not equal to a constant value. - -```typescript -// Check if the 'country' field is not equal to "USA" -neq("country", "USA"); - -``` - -Signature: - -```typescript -export declare function neq(left: string, right: any): Neq; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The field name to compare. | -| right | any | The constant value to compare to. A new Expr representing the inequality comparison. | - -Returns: - -[Neq](./firestore_lite.neq.md#neq_class) - -### or(left, right) {:#or_eba7e36} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that performs a logical 'OR' operation on multiple filter conditions. - -```typescript -// Check if the 'age' field is greater than 18 OR the 'city' field is "London" OR -// the 'status' field is "active" -const condition = or(gt("age", 18), eq("city", "London"), eq("status", "active")); - -``` - -Signature: - -```typescript -export declare function or(left: FilterExpr, ...right: FilterExpr[]): Or; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [FilterExpr](./firestore_lite.md#filterexpr) | The first filter condition. | -| right | [FilterExpr](./firestore_lite.md#filterexpr)\[\] | Additional filter conditions to 'OR' together. A new representing the logical 'OR' operation. | - -Returns: - -[Or](./firestore_lite.or.md#or_class) - -### queryEqual(left, right) {:#queryequal_7a1f045} - -Returns true if the provided queries point to the same collection and apply the same constraints. - -Signature: - -```typescript -export declare function queryEqual(left: Query, right: Query): boolean; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | A Query to compare. | -| right | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | A Query to compare. | - -Returns: - -boolean - -true if the references point to the same location in the same Firestore database. - -### refEqual(left, right) {:#refequal_598b780} - -Returns true if the provided references are equal. - -Signature: - -```typescript -export declare function refEqual(left: DocumentReference | CollectionReference, right: DocumentReference | CollectionReference): boolean; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> \| [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to compare. | -| right | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> \| [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to compare. | - -Returns: - -boolean - -true if the references point to the same location in the same Firestore database. - -### regexContains(left, pattern) {:#regexcontains_33ec01b} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string field contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -regexContains("description", "(?i)example"); - -``` - -Signature: - -```typescript -export declare function regexContains(left: string, pattern: string): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The name of the field containing the string. | -| pattern | string | The regular expression to use for the search. A new representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) - -### regexContains(left, pattern) {:#regexcontains_dd84184} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string field contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -regexContains("description", Field.of("pattern")); - -``` - -Signature: - -```typescript -export declare function regexContains(left: string, pattern: Constant): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The name of the field containing the string. | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the search. A new representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) - -### regexContains(left, pattern) {:#regexcontains_3aaffe0} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string expression contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -regexContains(Field.of("description"), "(?i)example"); - -``` - -Signature: - -```typescript -export declare function regexContains(left: Constant, pattern: string): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to perform the comparison on. | -| pattern | string | The regular expression to use for the search. A new representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) - -### regexContains(left, pattern) {:#regexcontains_a2c3e8b} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string expression contains a specified regular expression as a substring. - -```typescript -// Check if the 'description' field contains "example" (case-insensitive) -regexContains(Field.of("description"), Field.of("pattern")); - -``` - -Signature: - -```typescript -export declare function regexContains(left: Constant, pattern: Constant): RegexContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to perform the comparison on. | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the search. A new representing the 'contains' comparison. | - -Returns: - -[RegexContains](./firestore_lite.regexcontains.md#regexcontains_class) - -### regexMatch(left, pattern) {:#regexmatch_33ec01b} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string field matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a valid email pattern -regexMatch("email", "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - -Signature: - -```typescript -export declare function regexMatch(left: string, pattern: string): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The name of the field containing the string. | -| pattern | string | The regular expression to use for the match. A new representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) - -### regexMatch(left, pattern) {:#regexmatch_dd84184} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string field matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a valid email pattern -regexMatch("email", Field.of("pattern")); - -``` - -Signature: - -```typescript -export declare function regexMatch(left: string, pattern: Constant): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The name of the field containing the string. | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the match. A new representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) - -### regexMatch(left, pattern) {:#regexmatch_3aaffe0} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string expression matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a valid email pattern -regexMatch(Field.of("email"), "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); - -``` - -Signature: - -```typescript -export declare function regexMatch(left: Constant, pattern: string): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to match against. | -| pattern | string | The regular expression to use for the match. A new representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) - -### regexMatch(left, pattern) {:#regexmatch_a2c3e8b} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string expression matches a specified regular expression. - -```typescript -// Check if the 'email' field matches a valid email pattern -regexMatch(Field.of("email"), Field.of("pattern")); - -``` - -Signature: - -```typescript -export declare function regexMatch(left: Constant, pattern: Constant): RegexMatch; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to match against. | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | The regular expression to use for the match. A new representing the regular expression match. | - -Returns: - -[RegexMatch](./firestore_lite.regexmatch.md#regexmatch_class) - -### snapshotEqual(left, right) {:#snapshotequal_5109204} - -Returns true if the provided snapshots are equal. - -Signature: - -```typescript -export declare function snapshotEqual(left: DocumentSnapshot | QuerySnapshot, right: DocumentSnapshot | QuerySnapshot): boolean; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> \| [QuerySnapshot](./firestore_lite.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType> | A snapshot to compare. | -| right | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> \| [QuerySnapshot](./firestore_lite.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType> | A snapshot to compare. | - -Returns: - -boolean - -true if the snapshots are equal. - -### strContains(left, substring) {:#strcontains_18eaf5d} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string field contains a specified substring. - -```typescript -// Check if the 'description' field contains "example". -strContains("description", "example"); - -``` - -Signature: - -```typescript -export declare function strContains(left: string, substring: string): StrContains; -``` +| [startAt(snapshot)](./firestore_lite.md#startat_9a4477f) | Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided document (inclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of this query. | +| function(values, ...) | +| [vector(values)](./firestore_lite.md#vector_0dbdaf2) | Creates a new VectorValue constructed with a copy of the given array of numbers. | -#### Parameters +## Classes -| Parameter | Type | Description | -| --- | --- | --- | -| left | string | The name of the field containing the string. | -| substring | string | The substring to search for. A new representing the 'contains' comparison. | +| Class | Description | +| --- | --- | +| [AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class) | Represents an aggregation that can be performed by Firestore. | +| [AggregateQuerySnapshot](./firestore_lite.aggregatequerysnapshot.md#aggregatequerysnapshot_class) | The results of executing an aggregation query. | +| [Bytes](./firestore_lite.bytes.md#bytes_class) | An immutable object representing an array of bytes. | +| [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class) | A CollectionReference object can be used for adding documents, getting document references, and querying for documents (using [query()](./firestore_.md#query_9f7b0f4)). | +| [DocumentReference](./firestore_lite.documentreference.md#documentreference_class) | A DocumentReference refers to a document location in a Firestore database and can be used to write, read, or listen to the location. The document at the referenced location may or may not exist. | +| [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class) | A DocumentSnapshot contains data read from a document in your Firestore database. The data can be extracted with .data() or .get(<field>) to get a specific field.For a DocumentSnapshot that points to a non-existing document, any data access will return 'undefined'. You can use the exists() method to explicitly verify a document's existence. | +| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | A FieldPath refers to a field in a document. The path may consist of a single field name (referring to a top-level field in the document), or a list of field names (referring to a nested field in the document).Create a FieldPath by providing field names. If more than one field name is provided, the path will point to a nested field in a document. | +| [FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) | Sentinel values that can be used when writing document fields with set() or update(). | +| [Firestore](./firestore_lite.firestore.md#firestore_class) | The Cloud Firestore service interface.Do not call this constructor directly. Instead, use [getFirestore()](./firestore_.md#getfirestore). | +| [FirestoreError](./firestore_lite.firestoreerror.md#firestoreerror_class) | An error returned by a Firestore operation. | +| [GeoPoint](./firestore_lite.geopoint.md#geopoint_class) | An immutable object representing a geographic location in Firestore. The location is represented as latitude/longitude pair.Latitude values are in the range of \[-90, 90\]. Longitude values are in the range of \[-180, 180\]. | +| [Query](./firestore_lite.query.md#query_class) | A Query refers to a query which you can read or listen to. You can also construct refined Query objects by adding filters and ordering. | +| [QueryCompositeFilterConstraint](./firestore_lite.querycompositefilterconstraint.md#querycompositefilterconstraint_class) | A QueryCompositeFilterConstraint is used to narrow the set of documents returned by a Firestore query by performing the logical OR or AND of multiple [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class)s or [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class)s. QueryCompositeFilterConstraints are created by invoking [or()](./firestore_.md#or_e72c712) or [and()](./firestore_.md#and_e72c712) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the QueryCompositeFilterConstraint. | +| [QueryConstraint](./firestore_lite.queryconstraint.md#queryconstraint_class) | A QueryConstraint is used to narrow the set of documents returned by a Firestore query. QueryConstraints are created by invoking [where()](./firestore_.md#where_0fae4bf), [orderBy()](./firestore_.md#orderby_006d61f), [startAt()](./firestore_.md#startat_9a4477f), [startAfter()](./firestore_.md#startafter_9a4477f), [endBefore()](./firestore_.md#endbefore_9a4477f), [endAt()](./firestore_.md#endat_9a4477f), [limit()](./firestore_.md#limit_ec46c78), [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryConstraint. | +| [QueryDocumentSnapshot](./firestore_lite.querydocumentsnapshot.md#querydocumentsnapshot_class) | A QueryDocumentSnapshot contains data read from a document in your Firestore database as part of a query. The document is guaranteed to exist and its data can be extracted with .data() or .get(<field>) to get a specific field.A QueryDocumentSnapshot offers the same API surface as a DocumentSnapshot. Since query results contain only existing documents, the exists property will always be true and data() will never return 'undefined'. | +| [QueryEndAtConstraint](./firestore_lite.queryendatconstraint.md#queryendatconstraint_class) | A QueryEndAtConstraint is used to exclude documents from the end of a result set returned by a Firestore query. QueryEndAtConstraints are created by invoking [endAt()](./firestore_.md#endat_9a4477f) or [endBefore()](./firestore_.md#endbefore_9a4477f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryEndAtConstraint. | +| [QueryFieldFilterConstraint](./firestore_lite.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) | A QueryFieldFilterConstraint is used to narrow the set of documents returned by a Firestore query by filtering on one or more document fields. QueryFieldFilterConstraints are created by invoking [where()](./firestore_.md#where_0fae4bf) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryFieldFilterConstraint. | +| [QueryLimitConstraint](./firestore_lite.querylimitconstraint.md#querylimitconstraint_class) | A QueryLimitConstraint is used to limit the number of documents returned by a Firestore query. QueryLimitConstraints are created by invoking [limit()](./firestore_.md#limit_ec46c78) or [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryLimitConstraint. | +| [QueryOrderByConstraint](./firestore_lite.queryorderbyconstraint.md#queryorderbyconstraint_class) | A QueryOrderByConstraint is used to sort the set of documents returned by a Firestore query. QueryOrderByConstraints are created by invoking [orderBy()](./firestore_.md#orderby_006d61f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryOrderByConstraint.Note: Documents that do not contain the orderBy field will not be present in the query result. | +| [QuerySnapshot](./firestore_lite.querysnapshot.md#querysnapshot_class) | A QuerySnapshot contains zero or more DocumentSnapshot objects representing the results of a query. The documents can be accessed as an array via the docs property or enumerated using the forEach method. The number of documents can be determined via the empty and size properties. | +| [QueryStartAtConstraint](./firestore_lite.querystartatconstraint.md#querystartatconstraint_class) | A QueryStartAtConstraint is used to exclude documents from the start of a result set returned by a Firestore query. QueryStartAtConstraints are created by invoking [startAt()](./firestore_.md#startat_9a4477f) or [startAfter()](./firestore_.md#startafter_9a4477f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this QueryStartAtConstraint. | +| [Timestamp](./firestore_lite.timestamp.md#timestamp_class) | A Timestamp represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time.It is encoded using the Proleptic Gregorian Calendar which extends the Gregorian calendar backwards to year one. It is encoded assuming all minutes are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.For examples and further specifications, refer to the [Timestamp definition](https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto). | +| [Transaction](./firestore_lite.transaction.md#transaction_class) | A reference to a transaction.The Transaction object passed to a transaction's updateFunction provides the methods to read and write data within the transaction context. See [runTransaction()](./firestore_.md#runtransaction_6f03ec4). | +| [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | Represents a vector type in Firestore documents. Create an instance with . VectorValue | +| [WriteBatch](./firestore_lite.writebatch.md#writebatch_class) | A write batch, used to perform multiple writes as a single atomic unit.A WriteBatch object can be acquired by calling [writeBatch()](./firestore_.md#writebatch_231a8e0). It provides methods for adding writes to the write batch. None of the writes will be committed (or visible locally) until [WriteBatch.commit()](./firestore_.writebatch.md#writebatchcommit) is called. | -Returns: +## Interfaces -[StrContains](./firestore_lite.strcontains.md#strcontains_class) +| Interface | Description | +| --- | --- | +| [AggregateSpec](./firestore_lite.aggregatespec.md#aggregatespec_interface) | Specifies a set of aggregations and their aliases. | +| [DocumentData](./firestore_lite.documentdata.md#documentdata_interface) | Document data (for use with [setDoc()](./firestore_lite.md#setdoc_ee215ad)) consists of fields mapped to values. | +| [FirestoreDataConverter](./firestore_lite.firestoredataconverter.md#firestoredataconverter_interface) | Converter used by withConverter() to transform user objects of type AppModelType into Firestore data of type DbModelType.Using the converter allows you to specify generic type arguments when storing and retrieving objects from Firestore.In this context, an "AppModel" is a class that is used in an application to package together related information and functionality. Such a class could, for example, have properties with complex, nested data types, properties used for memoization, properties of types not supported by Firestore (such as symbol and bigint), and helper functions that perform compound operations. Such classes are not suitable and/or possible to store into a Firestore database. Instead, instances of such classes need to be converted to "plain old JavaScript objects" (POJOs) with exclusively primitive properties, potentially nested inside other POJOs or arrays of POJOs. In this context, this type is referred to as the "DbModel" and would be an object suitable for persisting into Firestore. For convenience, applications can implement FirestoreDataConverter and register the converter with Firestore objects, such as DocumentReference or Query, to automatically convert AppModel to DbModel when storing into Firestore, and convert DbModel to AppModel when retrieving from Firestore. | +| [Settings](./firestore_lite.settings.md#settings_interface) | Specifies custom configurations for your Cloud Firestore instance. You must set these before invoking any other methods. | +| [TransactionOptions](./firestore_lite.transactionoptions.md#transactionoptions_interface) | Options to customize transaction behavior. | -### strContains(left, substring) {:#strcontains_f0f1f2f} +## Type Aliases -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +| Type Alias | Description | +| --- | --- | +| [AddPrefixToKeys](./firestore_lite.md#addprefixtokeys) | Returns a new map where every key is prefixed with the outer key appended to a dot. | +| [AggregateFieldType](./firestore_lite.md#aggregatefieldtype) | The union of all AggregateField types that are supported by Firestore. | +| [AggregateSpecData](./firestore_lite.md#aggregatespecdata) | A type whose keys are taken from an AggregateSpec, and whose values are the result of the aggregation performed by the corresponding AggregateField from the input AggregateSpec. | +| [AggregateType](./firestore_lite.md#aggregatetype) | Union type representing the aggregate type to be performed. | +| [ChildUpdateFields](./firestore_lite.md#childupdatefields) | Helper for calculating the nested fields for a given type T1. This is needed to distribute union types such as undefined | {...} (happens for optional props) or {a: A} | {b: B}.In this use case, V is used to distribute the union types of T[K] on Record, since T[K] is evaluated as an expression and not distributed.See https://www.typescriptlang.org/docs/handbook/advanced-types.html\#distributive-conditional-types | +| [FirestoreErrorCode](./firestore_lite.md#firestoreerrorcode) | The set of Firestore status codes. The codes are the same at the ones exposed by gRPC here: https://github.com/grpc/grpc/blob/master/doc/statuscodes.mdPossible values: - 'cancelled': The operation was cancelled (typically by the caller). - 'unknown': Unknown error or an error from a different error domain. - 'invalid-argument': Client specified an invalid argument. Note that this differs from 'failed-precondition'. 'invalid-argument' indicates arguments that are problematic regardless of the state of the system (e.g. an invalid field name). - 'deadline-exceeded': Deadline expired before operation could complete. For operations that change the state of the system, this error may be returned even if the operation has completed successfully. For example, a successful response from a server could have been delayed long enough for the deadline to expire. - 'not-found': Some requested document was not found. - 'already-exists': Some document that we attempted to create already exists. - 'permission-denied': The caller does not have permission to execute the specified operation. - 'resource-exhausted': Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space. - 'failed-precondition': Operation was rejected because the system is not in a state required for the operation's execution. - 'aborted': The operation was aborted, typically due to a concurrency issue like transaction aborts, etc. - 'out-of-range': Operation was attempted past the valid range. - 'unimplemented': Operation is not implemented or not supported/enabled. - 'internal': Internal errors. Means some invariants expected by underlying system has been broken. If you see one of these errors, something is very broken. - 'unavailable': The service is currently unavailable. This is most likely a transient condition and may be corrected by retrying with a backoff. - 'data-loss': Unrecoverable data loss or corruption. - 'unauthenticated': The request does not have valid authentication credentials for the operation. | +| [NestedUpdateFields](./firestore_lite.md#nestedupdatefields) | For each field (e.g. 'bar'), find all nested keys (e.g. {'bar.baz': T1, 'bar.qux': T2}). Intersect them together to make a single map containing all possible keys that are all marked as optional | +| [OrderByDirection](./firestore_lite.md#orderbydirection) | The direction of a [orderBy()](./firestore_.md#orderby_006d61f) clause is specified as 'desc' or 'asc' (descending or ascending). | +| [PartialWithFieldValue](./firestore_lite.md#partialwithfieldvalue) | Similar to TypeScript's Partial<T>, but allows nested fields to be omitted and FieldValues to be passed in as property values. | +| [Primitive](./firestore_lite.md#primitive) | Primitive types. | +| [QueryConstraintType](./firestore_lite.md#queryconstrainttype) | Describes the different query constraints available in this SDK. | +| [QueryFilterConstraint](./firestore_lite.md#queryfilterconstraint) | QueryFilterConstraint is a helper union type that represents [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) and [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). | +| [QueryNonFilterConstraint](./firestore_lite.md#querynonfilterconstraint) | QueryNonFilterConstraint is a helper union type that represents QueryConstraints which are used to narrow or order the set of documents, but that do not explicitly filter on a document field. QueryNonFilterConstraints are created by invoking [orderBy()](./firestore_.md#orderby_006d61f), [startAt()](./firestore_.md#startat_9a4477f), [startAfter()](./firestore_.md#startafter_9a4477f), [endBefore()](./firestore_.md#endbefore_9a4477f), [endAt()](./firestore_.md#endat_9a4477f), [limit()](./firestore_.md#limit_ec46c78) or [limitToLast()](./firestore_.md#limittolast_ec46c78) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the QueryConstraint. | +| [SetOptions](./firestore_lite.md#setoptions) | An options object that configures the behavior of [setDoc()](./firestore_lite.md#setdoc_ee215ad), and calls. These calls can be configured to perform granular merges instead of overwriting the target documents in their entirety by providing a SetOptions with merge: true. | +| [UnionToIntersection](./firestore_lite.md#uniontointersection) | Given a union type U = T1 | T2 | ..., returns an intersected type (T1 & T2 & ...).Uses distributive conditional types and inference from conditional types. This works because multiple candidates for the same type variable in contra-variant positions causes an intersection type to be inferred. https://www.typescriptlang.org/docs/handbook/advanced-types.html\#type-inference-in-conditional-types https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type | +| [UpdateData](./firestore_lite.md#updatedata) | Update data (for use with [updateDoc()](./firestore_.md#updatedoc_51a65e3)) that consists of field paths (e.g. 'foo' or 'foo.baz') mapped to values. Fields that contain dots reference nested fields within the document. FieldValues can be passed in as property values. | +| [WhereFilterOp](./firestore_lite.md#wherefilterop) | Filter conditions in a [where()](./firestore_.md#where_0fae4bf) clause are specified using the strings '&lt;', '&lt;=', '==', '!=', '&gt;=', '&gt;', 'array-contains', 'in', 'array-contains-any', and 'not-in'. | +| [WithFieldValue](./firestore_lite.md#withfieldvalue) | Allows FieldValues to be passed in as a property value while maintaining type safety. | -Creates an expression that checks if a string field contains a substring specified by an expression. +## function(app, ...) -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -strContains("description", Field.of("keyword")); +### getFirestore(app) {:#getfirestore_cf608e1} -``` +Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. Signature: ```typescript -export declare function strContains(left: string, substring: Constant): StrContains; +export declare function getFirestore(app: FirebaseApp): Firestore; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | string | The name of the field containing the string. | -| substring | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. A new representing the 'contains' comparison. | +| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) instance that the returned [Firestore](./firestore_.firestore.md#firestore_class) instance is associated with. | Returns: -[StrContains](./firestore_lite.strcontains.md#strcontains_class) - -### strContains(left, substring) {:#strcontains_5fdbd29} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Creates an expression that checks if a string expression contains a specified substring. - -```typescript -// Check if the 'description' field contains "example". -strContains(Field.of("description"), "example"); - -``` - -Signature: - -```typescript -export declare function strContains(left: Constant, substring: string): StrContains; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to perform the comparison on. | -| substring | string | The substring to search for. A new representing the 'contains' comparison. | - -Returns: +[Firestore](./firestore_lite.firestore.md#firestore_class) -[StrContains](./firestore_lite.strcontains.md#strcontains_class) +The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. -### strContains(left, substring) {:#strcontains_d9d749f} +### getFirestore(app, databaseId) {:#getfirestore_48de6cb} > This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. > -Creates an expression that checks if a string expression contains a substring specified by another expression. - -```typescript -// Check if the 'description' field contains the value of the 'keyword' field. -strContains(Field.of("description"), Field.of("keyword")); - -``` +Returns the existing [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. Signature: ```typescript -export declare function strContains(left: Constant, substring: Constant): StrContains; +export declare function getFirestore(app: FirebaseApp, databaseId: string): Firestore; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to perform the comparison on. | -| substring | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. A new representing the 'contains' comparison. | +| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) instance that the returned [Firestore](./firestore_.firestore.md#firestore_class) instance is associated with. | +| databaseId | string | The name of the database. | Returns: -[StrContains](./firestore_lite.strcontains.md#strcontains_class) - -### subtract(left, right) {:#subtract_be96f75} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +[Firestore](./firestore_lite.firestore.md#firestore_class) -Creates an expression that subtracts two expressions. +The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. -```typescript -// Subtract the 'discount' field from the 'price' field -subtract(Field.of("price"), Field.of("discount")); +### initializeFirestore(app, settings) {:#initializefirestore_87c6318} -``` +Initializes a new instance of Cloud Firestore with the provided settings. Can only be called before any other functions, including [getFirestore()](./firestore_.md#getfirestore). If the custom settings are empty, this function is equivalent to calling [getFirestore()](./firestore_.md#getfirestore). Signature: ```typescript -export declare function subtract(left: Constant, right: Constant): Subtract; +export declare function initializeFirestore(app: FirebaseApp, settings: Settings): Firestore; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to subtract from. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to subtract. A new representing the subtraction operation. | +| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) with which the Firestore instance will be associated. | +| settings | [Settings](./firestore_lite.settings.md#settings_interface) | A settings object to configure the Firestore instance. | Returns: -[Subtract](./firestore_lite.subtract.md#subtract_class) +[Firestore](./firestore_lite.firestore.md#firestore_class) + +A newly initialized `Firestore` instance. -### subtract(left, right) {:#subtract_010ba9e} +### initializeFirestore(app, settings, databaseId) {:#initializefirestore_37baaaf} > This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. > -Creates an expression that subtracts a constant value from an expression. - -```typescript -// Subtract the constant value 2 from the 'value' field -subtract(Field.of("value"), 2); - -``` +Initializes a new instance of Cloud Firestore with the provided settings. Can only be called before any other functions, including [getFirestore()](./firestore_.md#getfirestore). If the custom settings are empty, this function is equivalent to calling [getFirestore()](./firestore_.md#getfirestore). Signature: ```typescript -export declare function subtract(left: Constant, right: any): Subtract; +export declare function initializeFirestore(app: FirebaseApp, settings: Settings, databaseId?: string): Firestore; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | The expression to subtract from. | -| right | any | The constant value to subtract. A new representing the subtraction operation. | +| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) with which the Firestore instance will be associated. | +| settings | [Settings](./firestore_lite.settings.md#settings_interface) | A settings object to configure the Firestore instance. | +| databaseId | string | The name of the database. | Returns: -[Subtract](./firestore_lite.subtract.md#subtract_class) - -### subtract(left, right) {:#subtract_674c63f} +[Firestore](./firestore_lite.firestore.md#firestore_class) -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +A newly initialized `Firestore` instance. -Creates an expression that subtracts an expression from a field's value. +## function(firestore, ...) -```typescript -// Subtract the 'discount' field from the 'price' field -subtract("price", Field.of("discount")); +### collection(firestore, path, pathSegments) {:#collection_1eb4c23} -``` +Gets a `CollectionReference` instance that refers to the collection at the specified absolute path. Signature: ```typescript -export declare function subtract(left: string, right: Constant): Subtract; +export declare function collection(firestore: Firestore, path: string, ...pathSegments: string[]): CollectionReference; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | string | The field name to subtract from. | -| right | [Constant](./firestore_lite.constant.md#constant_class) | The expression to subtract. A new representing the subtraction operation. | +| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | A reference to the root Firestore instance. | +| path | string | A slash-separated path to a collection. | +| pathSegments | string\[\] | Additional path segments to apply relative to the first argument. | Returns: -[Subtract](./firestore_lite.subtract.md#subtract_class) +[CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> -### subtract(left, right) {:#subtract_1f46a76} +The `CollectionReference` instance. -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +#### Exceptions -Creates an expression that subtracts a constant value from a field's value. +If the final path has an even number of segments and does not point to a collection. -```typescript -// Subtract 20 from the value of the 'total' field -subtract("total", 20); +### collectionGroup(firestore, collectionId) {:#collectiongroup_1838fc3} -``` +Creates and returns a new `Query` instance that includes all documents in the database that are contained in a collection or subcollection with the given `collectionId`. Signature: ```typescript -export declare function subtract(left: string, right: any): Subtract; +export declare function collectionGroup(firestore: Firestore, collectionId: string): Query; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | string | The field name to subtract from. | -| right | any | The constant value to subtract. A new representing the subtraction operation. | +| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | A reference to the root Firestore instance. | +| collectionId | string | Identifies the collections to query over. Every collection or subcollection with this ID as the last segment of its path will be included. Cannot contain a slash. | Returns: -[Subtract](./firestore_lite.subtract.md#subtract_class) - -### xor(left, right) {:#xor_eba7e36} +[Query](./firestore_lite.query.md#query_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +The created `Query`. -Creates an expression that performs a logical 'XOR' (exclusive OR) operation on multiple filter conditions. +### connectFirestoreEmulator(firestore, host, port, options) {:#connectfirestoreemulator_7c247cd} -```typescript -// Check if only one of the conditions is true: 'age' greater than 18, 'city' is "London", -// or 'status' is "active". -const condition = xor( - gt("age", 18), - eq("city", "London"), - eq("status", "active")); +Modify this instance to communicate with the Cloud Firestore emulator. -``` +Note: This must be called before this instance has been used to do any operations. Signature: ```typescript -export declare function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; +export declare function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: { + mockUserToken?: EmulatorMockTokenOptions | string; +}): void; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| left | [FilterExpr](./firestore_lite.md#filterexpr) | The first filter condition. | -| right | [FilterExpr](./firestore_lite.md#filterexpr)\[\] | Additional filter conditions to 'XOR' together. A new representing the logical 'XOR' operation. | +| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | The Firestore instance to configure to connect to the emulator. | +| host | string | the emulator host (ex: localhost). | +| port | number | the emulator port (ex: 9000). | +| options | { mockUserToken?: [EmulatorMockTokenOptions](./util.md#emulatormocktokenoptions) \| string; } | | Returns: -[Xor](./firestore_lite.xor.md#xor_class) - -## function(limit, ...) +void -### limit(limit) {:#limit_ec46c78} +### doc(firestore, path, pathSegments) {:#doc_1eb4c23} -Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the first matching documents. +Gets a `DocumentReference` instance that refers to the document at the specified absolute path. Signature: ```typescript -export declare function limit(limit: number): QueryLimitConstraint; +export declare function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| limit | number | The maximum number of items to return. | +| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | A reference to the root Firestore instance. | +| path | string | A slash-separated path to a document. | +| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | Returns: -[QueryLimitConstraint](./firestore_lite.querylimitconstraint.md#querylimitconstraint_class) - -The created [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class). - -### limitToLast(limit) {:#limittolast_ec46c78} - -Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the last matching documents. - -You must specify at least one `orderBy` clause for `limitToLast` queries, otherwise an exception will be thrown during execution. - -Signature: - -```typescript -export declare function limitToLast(limit: number): QueryLimitConstraint; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| limit | number | The maximum number of items to return. | +[DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> -Returns: +The `DocumentReference` instance. -[QueryLimitConstraint](./firestore_lite.querylimitconstraint.md#querylimitconstraint_class) +#### Exceptions -The created [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class). +If the final path has an odd number of segments and does not point to a document. -## function(logLevel, ...) +### runTransaction(firestore, updateFunction, options) {:#runtransaction_6f03ec4} -### setLogLevel(logLevel) {:#setloglevel_d02fda2} +Executes the given `updateFunction` and then attempts to commit the changes applied within the transaction. If any document read within the transaction has changed, Cloud Firestore retries the `updateFunction`. If it fails to commit after 5 attempts, the transaction fails. -Sets the verbosity of Cloud Firestore logs (debug, error, or silent). +The maximum number of writes allowed in a single transaction is 500. Signature: ```typescript -export declare function setLogLevel(logLevel: LogLevel): void; +export declare function runTransaction(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise, options?: TransactionOptions): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| logLevel | LogLevel | The verbosity you set for activity and error logging. Can be any of the following values:

  • debug for the most verbose logging level, primarily for debugging.
  • error to log errors only.
  • silent to turn off logging.
| +| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | A reference to the Firestore database to run this transaction against. | +| updateFunction | (transaction: [Transaction](./firestore_lite.transaction.md#transaction_class)) => Promise<T> | The function to execute within the transaction context. | +| options | [TransactionOptions](./firestore_lite.transactionoptions.md#transactionoptions_interface) | An options object to configure maximum number of attempts to commit. | Returns: -void +Promise<T> -## function(mapExpr, ...) +If the transaction completed successfully or was explicitly aborted (the `updateFunction` returned a failed promise), the promise returned by the `updateFunction `is returned here. Otherwise, if the transaction failed, a rejected promise with the corresponding failure error is returned. -### mapGet(mapExpr, subField) {:#mapget_9715f90} +### terminate(firestore) {:#terminate_231a8e0} -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +Terminates the provided `Firestore` instance. -Accesses a value from a map (object) expression using the provided key. +After calling `terminate()` only the `clearIndexedDbPersistence()` functions may be used. Any other function will throw a `FirestoreError`. Termination does not cancel any pending writes, and any promises that are awaiting a response from the server will not be resolved. -```typescript -// Get the 'city' value from the 'address' map field -mapGet(Field.of("address"), "city"); +To restart after termination, create a new instance of `Firestore` with [getFirestore()](./firestore_.md#getfirestore). -``` +Note: Under normal circumstances, calling `terminate()` is not required. This function is useful only when you want to force this instance to release all of its resources or in combination with [clearIndexedDbPersistence()](./firestore_.md#clearindexeddbpersistence_231a8e0) to ensure that all local state is destroyed between test runs. Signature: ```typescript -export declare function mapGet(mapExpr: Constant, subField: string): MapGet; +export declare function terminate(firestore: Firestore): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| mapExpr | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the map. | -| subField | string | The key to access in the map. A new representing the value associated with the given key in the map. | +| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | The Firestore instance to terminate. | Returns: -[MapGet](./firestore_lite.mapget.md#mapget_class) - -## function(mapField, ...) - -### mapGet(mapField, subField) {:#mapget_b37bbb6} +Promise<void> -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +A `Promise` that is resolved when the instance has been successfully terminated. -Accesses a value from a map (object) field using the provided key. +### writeBatch(firestore) {:#writebatch_231a8e0} -```typescript -// Get the 'city' value from the 'address' map field -mapGet("address", "city"); +Creates a write batch, used for performing multiple writes as a single atomic operation. The maximum number of writes allowed in a single WriteBatch is 500. -``` +The result of these writes will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the write fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. Signature: ```typescript -export declare function mapGet(mapField: string, subField: string): MapGet; +export declare function writeBatch(firestore: Firestore): WriteBatch; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| mapField | string | The field name of the map field. | -| subField | string | The key to access in the map. A new representing the value associated with the given key in the map. | +| firestore | [Firestore](./firestore_lite.firestore.md#firestore_class) | | Returns: -[MapGet](./firestore_lite.mapget.md#mapget_class) - -## function(n, ...) +[WriteBatch](./firestore_lite.writebatch.md#writebatch_class) -### increment(n) {:#increment_5685735} +A `WriteBatch` that can be used to atomically execute multiple writes. -Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to increment the field's current value by the given value. +## function() -If either the operand or the current field value uses floating point precision, all arithmetic follows IEEE 754 semantics. If both values are integers, values outside of JavaScript's safe number range (`Number.MIN_SAFE_INTEGER` to `Number.MAX_SAFE_INTEGER`) are also subject to precision loss. Furthermore, once processed by the Firestore backend, all integer operations are capped between -2^63 and 2^63-1. +### count() {:#count} -If the current field value is not of type `number`, or if the field does not yet exist, the transformation sets the field to the given value. +Create an AggregateField object that can be used to compute the count of documents in the result set of a query. Signature: ```typescript -export declare function increment(n: number): FieldValue; +export declare function count(): AggregateField; ``` +Returns: -#### Parameters +[AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<number> -| Parameter | Type | Description | -| --- | --- | --- | -| n | number | The value to increment by. | +### deleteField() {:#deletefield} + +Returns a sentinel for use with [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) or [setDoc()](./firestore_lite.md#setdoc_ee215ad) with `{merge: true}` to mark a field for deletion. +Signature: + +```typescript +export declare function deleteField(): FieldValue; +``` Returns: [FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) -The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()` +### documentId() {:#documentid} -## function(name, ...) +Returns a special sentinel `FieldPath` to refer to the ID of a document. It can be used in queries to sort or filter by the document ID. -### genericFunction(name, params) {:#genericfunction_b886545} +Signature: -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +```typescript +export declare function documentId(): FieldPath; +``` +Returns: -Creates functions that work on the backend but do not exist in the SDK yet. +[FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) -```typescript -// Call a user defined function named "myFunc" with the arguments 10 and 20 -// This is the same of the 'sum(Field.of("price"))', if it did not exist -genericFunction("sum", [Field.of("price")]); +### getFirestore() {:#getfirestore} -``` +Returns the existing default [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. Signature: ```typescript -export declare function genericFunction(name: string, params: Constant[]): FirestoreFunction; +export declare function getFirestore(): Firestore; ``` +Returns: -#### Parameters +[Firestore](./firestore_lite.firestore.md#firestore_class) -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | The name of the user defined function. | -| params | [Constant](./firestore_lite.constant.md#constant_class)\[\] | The arguments to pass to the function. A new representing the function call. | +The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. + +### serverTimestamp() {:#servertimestamp} + +Returns a sentinel used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) to include a server-generated timestamp in the written data. + +Signature: +```typescript +export declare function serverTimestamp(): FieldValue; +``` Returns: -[FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) +[FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) -## function(pipeline, ...) +## function(databaseId, ...) -### execute(pipeline) {:#execute_86486e6} +### getFirestore(databaseId) {:#getfirestore_53dc891} > This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. > -Modular API for console experimentation. +Returns the existing [Firestore](./firestore_.firestore.md#firestore_class) instance that is associated with the default [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes a new instance with default settings. Signature: ```typescript -export declare function execute(pipeline: Pipeline): Promise>>; +export declare function getFirestore(databaseId: string): Firestore; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| pipeline | [Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> | Execute this pipeline. | +| databaseId | string | The name of the database. | Returns: -Promise<Array<[PipelineResult](./firestore_lite.pipelineresult.md#pipelineresult_class)<AppModelType>>> +[Firestore](./firestore_lite.firestore.md#firestore_class) -## function(query, ...) +The [Firestore](./firestore_.firestore.md#firestore_class) instance of the provided app. -### getAggregate(query, aggregateSpec) {:#getaggregate_2073a74} +## function(elements, ...) -Calculates the specified aggregations over the documents in the result set of the given query without actually downloading the documents. +### arrayRemove(elements) {:#arrayremove_7d853aa} -Using this function to perform aggregations is efficient because only the final aggregation values, not the documents' data, are downloaded. This function can perform aggregations of the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). +Returns a special value that can be used with [setDoc()](./firestore_.md#setdoc_ee215ad) or that tells the server to remove the given elements from any array value that already exists on the server. All instances of each element specified will be removed from the array. If the field being modified is not already an array it will be overwritten with an empty array. Signature: ```typescript -export declare function getAggregate(query: Query, aggregateSpec: AggregateSpecType): Promise>; +export declare function arrayRemove(...elements: unknown[]): FieldValue; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | The query whose result set is aggregated over. | -| aggregateSpec | AggregateSpecType | An AggregateSpec object that specifies the aggregates to perform over the result set. The AggregateSpec specifies aliases for each aggregate, which can be used to retrieve the aggregate result. | +| elements | unknown\[\] | The elements to remove from the array. | Returns: -Promise<[AggregateQuerySnapshot](./firestore_lite.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType>> - -### Example - - -```typescript -const aggregateSnapshot = await getAggregate(query, { - countOfDocs: count(), - totalHours: sum('hours'), - averageScore: average('score') -}); - -const countOfDocs: number = aggregateSnapshot.data().countOfDocs; -const totalHours: number = aggregateSnapshot.data().totalHours; -const averageScore: number | null = aggregateSnapshot.data().averageScore; - -``` +[FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) -### getCount(query) {:#getcount_4e56953} +The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()` -Calculates the number of documents in the result set of the given query without actually downloading the documents. +### arrayUnion(elements) {:#arrayunion_7d853aa} -Using this function to count the documents is efficient because only the final count, not the documents' data, is downloaded. This function can count the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). +Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to union the given elements with any array value that already exists on the server. Each specified element that doesn't already exist in the array will be added to the end. If the field being modified is not already an array it will be overwritten with an array containing exactly the specified elements. Signature: ```typescript -export declare function getCount(query: Query): Promise; -}, AppModelType, DbModelType>>; +export declare function arrayUnion(...elements: unknown[]): FieldValue; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | The query whose result set size is calculated. | +| elements | unknown\[\] | The elements to union into the array. | Returns: -Promise<[AggregateQuerySnapshot](./firestore_lite.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<{ count: [AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<number>; }, AppModelType, DbModelType>> +[FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) -A Promise that will be resolved with the count; the count can be retrieved from `snapshot.data().count`, where `snapshot` is the `AggregateQuerySnapshot` to which the returned Promise resolves. +The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()`. -### getDocs(query) {:#getdocs_4e56953} +## function(field, ...) -Executes the query and returns the results as a [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class). +### average(field) {:#average_aacc3a9} -All queries are executed directly by the server, even if the query was previously executed. Recent modifications are only reflected in the retrieved results if they have already been applied by the backend. If the client is offline, the operation fails. To see previously cached result and local modifications, use the full Firestore SDK. +Create an AggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query. Signature: ```typescript -export declare function getDocs(query: Query): Promise>; +export declare function average(field: string | FieldPath): AggregateField; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | The Query to execute. | +| field | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | Specifies the field to average across the result set. | Returns: -Promise<[QuerySnapshot](./firestore_lite.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>> - -A Promise that will be resolved with the results of the query. +[AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<number \| null> -### pipeline(query) {:#pipeline_20b2416} +### sum(field) {:#sum_aacc3a9} -Experimental Modular API for console testing. +Create an AggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query. Signature: ```typescript -export declare function pipeline(query: Query): Pipeline; +export declare function sum(field: string | FieldPath): AggregateField; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_lite.query.md#query_class) | | +| field | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | Specifies the field to sum across the result set. | Returns: -[Pipeline](./firestore_lite.pipeline.md#pipeline_class) +[AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<number> -### query(query, compositeFilter, queryConstraints) {:#query_9f7b0f4} +## function(fieldPath, ...) -Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. +### orderBy(fieldPath, directionStr) {:#orderby_006d61f} + +Creates a [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class) that sorts the query result by the specified field, optionally in descending order instead of ascending. + +Note: Documents that do not contain the specified field will not be present in the query result. Signature: ```typescript -export declare function query(query: Query, compositeFilter: QueryCompositeFilterConstraint, ...queryConstraints: QueryNonFilterConstraint[]): Query; +export declare function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryOrderByConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | The [Query](./firestore_.query.md#query_class) instance to use as a base for the new constraints. | -| compositeFilter | [QueryCompositeFilterConstraint](./firestore_lite.querycompositefilterconstraint.md#querycompositefilterconstraint_class) | The [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) to apply. Create [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) using or . | -| queryConstraints | [QueryNonFilterConstraint](./firestore_lite.md#querynonfilterconstraint)\[\] | Additional [QueryNonFilterConstraint](./firestore_.md#querynonfilterconstraint)s to apply (e.g. [orderBy()](./firestore_.md#orderby_006d61f), [limit()](./firestore_.md#limit_ec46c78)). | +| fieldPath | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | The field to sort by. | +| directionStr | [OrderByDirection](./firestore_lite.md#orderbydirection) | Optional direction to sort by ('asc' or 'desc'). If not specified, order will be ascending. | Returns: -[Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> - -#### Exceptions +[QueryOrderByConstraint](./firestore_lite.queryorderbyconstraint.md#queryorderbyconstraint_class) -if any of the provided query constraints cannot be combined with the existing or new constraints. +The created [QueryOrderByConstraint](./firestore_.queryorderbyconstraint.md#queryorderbyconstraint_class). -### query(query, queryConstraints) {:#query_0f46da1} +### where(fieldPath, opStr, value) {:#where_0fae4bf} -Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. +Creates a [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) that enforces that documents must contain the specified field and that the value should satisfy the relation constraint provided. Signature: ```typescript -export declare function query(query: Query, ...queryConstraints: QueryConstraint[]): Query; +export declare function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryFieldFilterConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| query | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | The [Query](./firestore_.query.md#query_class) instance to use as a base for the new constraints. | -| queryConstraints | [QueryConstraint](./firestore_lite.queryconstraint.md#queryconstraint_class)\[\] | The list of [QueryConstraint](./firestore_.queryconstraint.md#queryconstraint_class)s to apply. | +| fieldPath | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | The path to compare | +| opStr | [WhereFilterOp](./firestore_lite.md#wherefilterop) | The operation string (e.g "&lt;", "&lt;=", "==", "&lt;", "&lt;=", "!="). | +| value | unknown | The value for comparison | Returns: -[Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> - -#### Exceptions +[QueryFieldFilterConstraint](./firestore_lite.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class) -if any of the provided query constraints cannot be combined with the existing or new constraints. +The created [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class). -## function(queryConstraints, ...) +## function(fieldValues, ...) -### and(queryConstraints) {:#and_e72c712} +### endAt(fieldValues) {:#endat_8b2f2c8} -Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a conjunction of the given filter constraints. A conjunction filter includes a document if it satisfies all of the given filters. +Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. Signature: ```typescript -export declare function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; +export declare function endAt(...fieldValues: unknown[]): QueryEndAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| queryConstraints | [QueryFilterConstraint](./firestore_lite.md#queryfilterconstraint)\[\] | Optional. The list of [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)s to perform a conjunction for. These must be created with calls to [where()](./firestore_.md#where_0fae4bf), , or . | +| fieldValues | unknown\[\] | The field values to end this query at, in order of the query's order by. | Returns: -[QueryCompositeFilterConstraint](./firestore_lite.querycompositefilterconstraint.md#querycompositefilterconstraint_class) +[QueryEndAtConstraint](./firestore_lite.queryendatconstraint.md#queryendatconstraint_class) -The newly created [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). +A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` -### or(queryConstraints) {:#or_e72c712} +### endBefore(fieldValues) {:#endbefore_8b2f2c8} -Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a disjunction of the given filter constraints. A disjunction filter includes a document if it satisfies any of the given filters. +Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. Signature: ```typescript -export declare function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; +export declare function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| queryConstraints | [QueryFilterConstraint](./firestore_lite.md#queryfilterconstraint)\[\] | Optional. The list of [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)s to perform a disjunction for. These must be created with calls to [where()](./firestore_.md#where_0fae4bf), , or . | +| fieldValues | unknown\[\] | The field values to end this query before, in order of the query's order by. | Returns: -[QueryCompositeFilterConstraint](./firestore_lite.querycompositefilterconstraint.md#querycompositefilterconstraint_class) - -The newly created [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). - -## function(reference, ...) +[QueryEndAtConstraint](./firestore_lite.queryendatconstraint.md#queryendatconstraint_class) -### addDoc(reference, data) {:#adddoc_6e783ff} +A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` -Add a new document to specified `CollectionReference` with the given data, assigning it a document ID automatically. +### startAfter(fieldValues) {:#startafter_8b2f2c8} -The result of this write will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the write fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. +Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. Signature: ```typescript -export declare function addDoc(reference: CollectionReference, data: WithFieldValue): Promise>; +export declare function startAfter(...fieldValues: unknown[]): QueryStartAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to the collection to add this document to. | -| data | [WithFieldValue](./firestore_lite.md#withfieldvalue)<AppModelType> | An Object containing the data for the new document. | +| fieldValues | unknown\[\] | The field values to start this query after, in order of the query's order by. | Returns: -Promise<[DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType>> - -A `Promise` resolved with a `DocumentReference` pointing to the newly created document after it has been written to the backend. - -#### Exceptions +[QueryStartAtConstraint](./firestore_lite.querystartatconstraint.md#querystartatconstraint_class) -Error - If the provided input is not a valid Firestore document. +A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()` -### collection(reference, path, pathSegments) {:#collection_568f98d} +### startAt(fieldValues) {:#startat_8b2f2c8} -Gets a `CollectionReference` instance that refers to a subcollection of `reference` at the specified relative path. +Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query. Signature: ```typescript -export declare function collection(reference: CollectionReference, path: string, ...pathSegments: string[]): CollectionReference; +export declare function startAt(...fieldValues: unknown[]): QueryStartAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to a collection. | -| path | string | A slash-separated path to a collection. | -| pathSegments | string\[\] | Additional path segments to apply relative to the first argument. | +| fieldValues | unknown\[\] | The field values to start this query at, in order of the query's order by. | Returns: -[CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> - -The `CollectionReference` instance. +[QueryStartAtConstraint](./firestore_lite.querystartatconstraint.md#querystartatconstraint_class) -#### Exceptions +A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()`. -If the final path has an even number of segments and does not point to a collection. +## function(left, ...) -### collection(reference, path, pathSegments) {:#collection_70b4396} +### aggregateFieldEqual(left, right) {:#aggregatefieldequal_e80a2b2} -Gets a `CollectionReference` instance that refers to a subcollection of `reference` at the specified relative path. +Compares two 'AggregateField\` instances for equality. Signature: ```typescript -export declare function collection(reference: DocumentReference, path: string, ...pathSegments: string[]): CollectionReference; +export declare function aggregateFieldEqual(left: AggregateField, right: AggregateField): boolean; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to a Firestore document. | -| path | string | A slash-separated path to a collection. | -| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | +| left | [AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<unknown> | Compare this AggregateField to the right. | +| right | [AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<unknown> | Compare this AggregateField to the left. | Returns: -[CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> - -The `CollectionReference` instance. - -#### Exceptions - -If the final path has an even number of segments and does not point to a collection. +boolean -### deleteDoc(reference) {:#deletedoc_4569087} +### aggregateQuerySnapshotEqual(left, right) {:#aggregatequerysnapshotequal_1529a20} -Deletes the document referred to by the specified `DocumentReference`. +Compares two `AggregateQuerySnapshot` instances for equality. -The deletion will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the delete fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. +Two `AggregateQuerySnapshot` instances are considered "equal" if they have underlying queries that compare equal, and the same data. Signature: ```typescript -export declare function deleteDoc(reference: DocumentReference): Promise; +export declare function aggregateQuerySnapshotEqual(left: AggregateQuerySnapshot, right: AggregateQuerySnapshot): boolean; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to delete. | +| left | [AggregateQuerySnapshot](./firestore_lite.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType> | The first AggregateQuerySnapshot to compare. | +| right | [AggregateQuerySnapshot](./firestore_lite.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType> | The second AggregateQuerySnapshot to compare. | Returns: -Promise<void> +boolean -A `Promise` resolved once the document has been successfully deleted from the backend. +`true` if the objects are "equal", as defined above, or `false` otherwise. -### doc(reference, path, pathSegments) {:#doc_568f98d} +### queryEqual(left, right) {:#queryequal_7a1f045} -Gets a `DocumentReference` instance that refers to a document within `reference` at the specified relative path. If no path is specified, an automatically-generated unique ID will be used for the returned `DocumentReference`. +Returns true if the provided queries point to the same collection and apply the same constraints. Signature: ```typescript -export declare function doc(reference: CollectionReference, path?: string, ...pathSegments: string[]): DocumentReference; +export declare function queryEqual(left: Query, right: Query): boolean; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to a collection. | -| path | string | A slash-separated path to a document. Has to be omitted to use auto-generated IDs. | -| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | +| left | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | A Query to compare. | +| right | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | A Query to compare. | Returns: -[DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> - -The `DocumentReference` instance. - -#### Exceptions +boolean -If the final path has an odd number of segments and does not point to a document. +true if the references point to the same location in the same Firestore database. -### doc(reference, path, pathSegments) {:#doc_70b4396} +### refEqual(left, right) {:#refequal_598b780} -Gets a `DocumentReference` instance that refers to a document within `reference` at the specified relative path. +Returns true if the provided references are equal. Signature: ```typescript -export declare function doc(reference: DocumentReference, path: string, ...pathSegments: string[]): DocumentReference; +export declare function refEqual(left: DocumentReference | CollectionReference, right: DocumentReference | CollectionReference): boolean; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to a Firestore document. | -| path | string | A slash-separated path to a document. | -| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | +| left | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> \| [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to compare. | +| right | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> \| [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to compare. | Returns: -[DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> - -The `DocumentReference` instance. - -#### Exceptions - -If the final path has an odd number of segments and does not point to a document. +boolean -### getDoc(reference) {:#getdoc_4569087} +true if the references point to the same location in the same Firestore database. -Reads the document referred to by the specified document reference. +### snapshotEqual(left, right) {:#snapshotequal_5109204} -All documents are directly fetched from the server, even if the document was previously read or modified. Recent modifications are only reflected in the retrieved `DocumentSnapshot` if they have already been applied by the backend. If the client is offline, the read fails. If you like to use caching or see local modifications, please use the full Firestore SDK. +Returns true if the provided snapshots are equal. Signature: ```typescript -export declare function getDoc(reference: DocumentReference): Promise>; +export declare function snapshotEqual(left: DocumentSnapshot | QuerySnapshot, right: DocumentSnapshot | QuerySnapshot): boolean; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | The reference of the document to fetch. | +| left | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> \| [QuerySnapshot](./firestore_lite.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType> | A snapshot to compare. | +| right | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> \| [QuerySnapshot](./firestore_lite.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType> | A snapshot to compare. | Returns: -Promise<[DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>> +boolean -A Promise resolved with a `DocumentSnapshot` containing the current document contents. +true if the snapshots are equal. -### setDoc(reference, data) {:#setdoc_ee215ad} +## function(limit, ...) -Writes to the document referred to by the specified `DocumentReference`. If the document does not yet exist, it will be created. +### limit(limit) {:#limit_ec46c78} -The result of this write will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the write fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. +Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the first matching documents. Signature: ```typescript -export declare function setDoc(reference: DocumentReference, data: WithFieldValue): Promise; +export declare function limit(limit: number): QueryLimitConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to write. | -| data | [WithFieldValue](./firestore_lite.md#withfieldvalue)<AppModelType> | A map of the fields and values for the document. | +| limit | number | The maximum number of items to return. | Returns: -Promise<void> - -A `Promise` resolved once the data has been successfully written to the backend. - -#### Exceptions +[QueryLimitConstraint](./firestore_lite.querylimitconstraint.md#querylimitconstraint_class) -Error - If the provided input is not a valid Firestore document. +The created [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class). -### setDoc(reference, data, options) {:#setdoc_ff80739} +### limitToLast(limit) {:#limittolast_ec46c78} -Writes to the document referred to by the specified `DocumentReference`. If the document does not yet exist, it will be created. If you provide `merge` or `mergeFields`, the provided data can be merged into an existing document. +Creates a [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class) that only returns the last matching documents. -The result of this write will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the write fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. +You must specify at least one `orderBy` clause for `limitToLast` queries, otherwise an exception will be thrown during execution. Signature: ```typescript -export declare function setDoc(reference: DocumentReference, data: PartialWithFieldValue, options: SetOptions): Promise; +export declare function limitToLast(limit: number): QueryLimitConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to write. | -| data | [PartialWithFieldValue](./firestore_lite.md#partialwithfieldvalue)<AppModelType> | A map of the fields and values for the document. | -| options | [SetOptions](./firestore_lite.md#setoptions) | An object to configure the set behavior. | +| limit | number | The maximum number of items to return. | Returns: -Promise<void> - -A `Promise` resolved once the data has been successfully written to the backend. - -#### Exceptions +[QueryLimitConstraint](./firestore_lite.querylimitconstraint.md#querylimitconstraint_class) -Error - If the provided input is not a valid Firestore document. +The created [QueryLimitConstraint](./firestore_.querylimitconstraint.md#querylimitconstraint_class). -### updateDoc(reference, data) {:#updatedoc_51a65e3} +## function(logLevel, ...) -Updates fields in the document referred to by the specified `DocumentReference`. The update will fail if applied to a document that does not exist. +### setLogLevel(logLevel) {:#setloglevel_d02fda2} -The result of this update will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the update fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. +Sets the verbosity of Cloud Firestore logs (debug, error, or silent). Signature: ```typescript -export declare function updateDoc(reference: DocumentReference, data: UpdateData): Promise; +export declare function setLogLevel(logLevel: LogLevel): void; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to update. | -| data | [UpdateData](./firestore_lite.md#updatedata)<DbModelType> | An object containing the fields and values with which to update the document. Fields can contain dots to reference nested fields within the document. | +| logLevel | LogLevel | The verbosity you set for activity and error logging. Can be any of the following values:
  • debug for the most verbose logging level, primarily for debugging.
  • error to log errors only.
  • silent to turn off logging.
| Returns: -Promise<void> - -A `Promise` resolved once the data has been successfully written to the backend. - -#### Exceptions +void -Error - If the provided input is not valid Firestore data. +## function(n, ...) -### updateDoc(reference, field, value, moreFieldsAndValues) {:#updatedoc_7c28659} +### increment(n) {:#increment_5685735} -Updates fields in the document referred to by the specified `DocumentReference` The update will fail if applied to a document that does not exist. +Returns a special value that can be used with [setDoc()](./firestore_lite.md#setdoc_ee215ad) or [updateDoc()](./firestore_lite.md#updatedoc_51a65e3) that tells the server to increment the field's current value by the given value. -Nested fields can be updated by providing dot-separated field path strings or by providing `FieldPath` objects. +If either the operand or the current field value uses floating point precision, all arithmetic follows IEEE 754 semantics. If both values are integers, values outside of JavaScript's safe number range (`Number.MIN_SAFE_INTEGER` to `Number.MAX_SAFE_INTEGER`) are also subject to precision loss. Furthermore, once processed by the Firestore backend, all integer operations are capped between -2^63 and 2^63-1. -The result of this update will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the update fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. +If the current field value is not of type `number`, or if the field does not yet exist, the transformation sets the field to the given value. Signature: ```typescript -export declare function updateDoc(reference: DocumentReference, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise; +export declare function increment(n: number): FieldValue; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to update. | -| field | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | The first field to update. | -| value | unknown | The first value. | -| moreFieldsAndValues | unknown\[\] | Additional key value pairs. | +| n | number | The value to increment by. | Returns: -Promise<void> - -A `Promise` resolved once the data has been successfully written to the backend. +[FieldValue](./firestore_lite.fieldvalue.md#fieldvalue_class) -#### Exceptions +The `FieldValue` sentinel for use in a call to `setDoc()` or `updateDoc()` -Error - If the provided input is not valid Firestore data. +## function(query, ...) -## function(snapshot, ...) +### getAggregate(query, aggregateSpec) {:#getaggregate_2073a74} -### endAt(snapshot) {:#endat_9a4477f} +Calculates the specified aggregations over the documents in the result set of the given query without actually downloading the documents. -Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided document (inclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. +Using this function to perform aggregations is efficient because only the final aggregation values, not the documents' data, are downloaded. This function can perform aggregations of the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). Signature: ```typescript -export declare function endAt(snapshot: DocumentSnapshot): QueryEndAtConstraint; +export declare function getAggregate(query: Query, aggregateSpec: AggregateSpecType): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| snapshot | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to end at. | +| query | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | The query whose result set is aggregated over. | +| aggregateSpec | AggregateSpecType | An AggregateSpec object that specifies the aggregates to perform over the result set. The AggregateSpec specifies aliases for each aggregate, which can be used to retrieve the aggregate result. | Returns: -[QueryEndAtConstraint](./firestore_lite.queryendatconstraint.md#queryendatconstraint_class) - -A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` - -### endBefore(snapshot) {:#endbefore_9a4477f} +Promise<[AggregateQuerySnapshot](./firestore_lite.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<AggregateSpecType, AppModelType, DbModelType>> -Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided document (exclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. +### Example -Signature: ```typescript -export declare function endBefore(snapshot: DocumentSnapshot): QueryEndAtConstraint; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| snapshot | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to end before. | +const aggregateSnapshot = await getAggregate(query, { + countOfDocs: count(), + totalHours: sum('hours'), + averageScore: average('score') +}); -Returns: +const countOfDocs: number = aggregateSnapshot.data().countOfDocs; +const totalHours: number = aggregateSnapshot.data().totalHours; +const averageScore: number | null = aggregateSnapshot.data().averageScore; -[QueryEndAtConstraint](./firestore_lite.queryendatconstraint.md#queryendatconstraint_class) +``` -A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` +### getCount(query) {:#getcount_4e56953} -### startAfter(snapshot) {:#startafter_9a4477f} +Calculates the number of documents in the result set of the given query without actually downloading the documents. -Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided document (exclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. +Using this function to count the documents is efficient because only the final count, not the documents' data, is downloaded. This function can count the documents in cases where the result set is prohibitively large to download entirely (thousands of documents). Signature: ```typescript -export declare function startAfter(snapshot: DocumentSnapshot): QueryStartAtConstraint; +export declare function getCount(query: Query): Promise; +}, AppModelType, DbModelType>>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| snapshot | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to start after. | +| query | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | The query whose result set size is calculated. | Returns: -[QueryStartAtConstraint](./firestore_lite.querystartatconstraint.md#querystartatconstraint_class) +Promise<[AggregateQuerySnapshot](./firestore_lite.aggregatequerysnapshot.md#aggregatequerysnapshot_class)<{ count: [AggregateField](./firestore_lite.aggregatefield.md#aggregatefield_class)<number>; }, AppModelType, DbModelType>> -A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()` +A Promise that will be resolved with the count; the count can be retrieved from `snapshot.data().count`, where `snapshot` is the `AggregateQuerySnapshot` to which the returned Promise resolves. -### startAt(snapshot) {:#startat_9a4477f} +### getDocs(query) {:#getdocs_4e56953} -Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided document (inclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the `orderBy` of this query. +Executes the query and returns the results as a [QuerySnapshot](./firestore_.querysnapshot.md#querysnapshot_class). + +All queries are executed directly by the server, even if the query was previously executed. Recent modifications are only reflected in the retrieved results if they have already been applied by the backend. If the client is offline, the operation fails. To see previously cached result and local modifications, use the full Firestore SDK. Signature: ```typescript -export declare function startAt(snapshot: DocumentSnapshot): QueryStartAtConstraint; +export declare function getDocs(query: Query): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| snapshot | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to start at. | +| query | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | The Query to execute. | Returns: -[QueryStartAtConstraint](./firestore_lite.querystartatconstraint.md#querystartatconstraint_class) - -A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()`. - -## function(timestamp, ...) - -### timestampAdd(timestamp, unit, amount) {:#timestampadd_87db576} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +Promise<[QuerySnapshot](./firestore_lite.querysnapshot.md#querysnapshot_class)<AppModelType, DbModelType>> -Creates an expression that adds a specified amount of time to a timestamp. +A Promise that will be resolved with the results of the query. -```typescript -// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. -timestampAdd(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); +### query(query, compositeFilter, queryConstraints) {:#query_9f7b0f4} -``` +Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. Signature: ```typescript -export declare function timestampAdd(timestamp: Constant, unit: Constant, amount: Constant): TimestampAdd; +export declare function query(query: Query, compositeFilter: QueryCompositeFilterConstraint, ...queryConstraints: QueryNonFilterConstraint[]): Query; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| timestamp | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the timestamp. | -| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | +| query | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | The [Query](./firestore_.query.md#query_class) instance to use as a base for the new constraints. | +| compositeFilter | [QueryCompositeFilterConstraint](./firestore_lite.querycompositefilterconstraint.md#querycompositefilterconstraint_class) | The [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) to apply. Create [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) using [and()](./firestore_.md#and_e72c712) or [or()](./firestore_.md#or_e72c712). | +| queryConstraints | [QueryNonFilterConstraint](./firestore_lite.md#querynonfilterconstraint)\[\] | Additional [QueryNonFilterConstraint](./firestore_.md#querynonfilterconstraint)s to apply (e.g. [orderBy()](./firestore_.md#orderby_006d61f), [limit()](./firestore_.md#limit_ec46c78)). | Returns: -[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) - -### timestampAdd(timestamp, unit, amount) {:#timestampadd_46a2d7e} +[Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +#### Exceptions -Creates an expression that adds a specified amount of time to a timestamp. +if any of the provided query constraints cannot be combined with the existing or new constraints. -```typescript -// Add 1 day to the 'timestamp' field. -timestampAdd(Field.of("timestamp"), "day", 1); +### query(query, queryConstraints) {:#query_0f46da1} -``` +Creates a new immutable instance of [Query](./firestore_.query.md#query_class) that is extended to also include additional query constraints. Signature: ```typescript -export declare function timestampAdd(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; +export declare function query(query: Query, ...queryConstraints: QueryConstraint[]): Query; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| timestamp | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the timestamp. | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to add (e.g., "day", "hour"). | -| amount | number | The amount of time to add. A new representing the resulting timestamp. | +| query | [Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> | The [Query](./firestore_.query.md#query_class) instance to use as a base for the new constraints. | +| queryConstraints | [QueryConstraint](./firestore_lite.queryconstraint.md#queryconstraint_class)\[\] | The list of [QueryConstraint](./firestore_.queryconstraint.md#queryconstraint_class)s to apply. | Returns: -[TimestampAdd](./firestore_lite.timestampadd.md#timestampadd_class) +[Query](./firestore_lite.query.md#query_class)<AppModelType, DbModelType> -### timestampSub(timestamp, unit, amount) {:#timestampsub_87db576} +#### Exceptions -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +if any of the provided query constraints cannot be combined with the existing or new constraints. -Creates an expression that subtracts a specified amount of time from a timestamp. +## function(queryConstraints, ...) -```typescript -// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. -timestampSub(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); +### and(queryConstraints) {:#and_e72c712} -``` +Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a conjunction of the given filter constraints. A conjunction filter includes a document if it satisfies all of the given filters. Signature: ```typescript -export declare function timestampSub(timestamp: Constant, unit: Constant, amount: Constant): TimestampSub; +export declare function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| timestamp | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the timestamp. | -| unit | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. | -| amount | [Constant](./firestore_lite.constant.md#constant_class) | The expression evaluates to amount of the unit. A new representing the resulting timestamp. | +| queryConstraints | [QueryFilterConstraint](./firestore_lite.md#queryfilterconstraint)\[\] | Optional. The list of [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)s to perform a conjunction for. These must be created with calls to [where()](./firestore_.md#where_0fae4bf), [or()](./firestore_.md#or_e72c712), or [and()](./firestore_.md#and_e72c712). | Returns: -[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) - -### timestampSub(timestamp, unit, amount) {:#timestampsub_46a2d7e} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +[QueryCompositeFilterConstraint](./firestore_lite.querycompositefilterconstraint.md#querycompositefilterconstraint_class) -Creates an expression that subtracts a specified amount of time from a timestamp. +The newly created [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). -```typescript -// Subtract 1 day from the 'timestamp' field. -timestampSub(Field.of("timestamp"), "day", 1); +### or(queryConstraints) {:#or_e72c712} -``` +Creates a new [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class) that is a disjunction of the given filter constraints. A disjunction filter includes a document if it satisfies any of the given filters. Signature: ```typescript -export declare function timestampSub(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; +export declare function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| timestamp | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the timestamp. | -| unit | 'microsecond' \| 'millisecond' \| 'second' \| 'minute' \| 'hour' \| 'day' | The unit of time to subtract (e.g., "day", "hour"). | -| amount | number | The amount of time to subtract. A new representing the resulting timestamp. | +| queryConstraints | [QueryFilterConstraint](./firestore_lite.md#queryfilterconstraint)\[\] | Optional. The list of [QueryFilterConstraint](./firestore_.md#queryfilterconstraint)s to perform a disjunction for. These must be created with calls to [where()](./firestore_.md#where_0fae4bf), [or()](./firestore_.md#or_e72c712), or [and()](./firestore_.md#and_e72c712). | Returns: -[TimestampSub](./firestore_lite.timestampsub.md#timestampsub_class) - -## function(value, ...) +[QueryCompositeFilterConstraint](./firestore_lite.querycompositefilterconstraint.md#querycompositefilterconstraint_class) -### avgFunction(value) {:#avgfunction_f83680a} +The newly created [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class). -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +## function(reference, ...) -Creates an aggregation that calculates the average (mean) of values from an expression across multiple stage inputs. +### addDoc(reference, data) {:#adddoc_6e783ff} -```typescript -// Calculate the average age of users -avg(Field.of("age")).as("averageAge"); +Add a new document to specified `CollectionReference` with the given data, assigning it a document ID automatically. -``` +The result of this write will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the write fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. Signature: ```typescript -export declare function avgFunction(value: Constant): Avg; +export declare function addDoc(reference: CollectionReference, data: WithFieldValue): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the values to average. A new representing the 'avg' aggregation. | +| reference | [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to the collection to add this document to. | +| data | [WithFieldValue](./firestore_lite.md#withfieldvalue)<AppModelType> | An Object containing the data for the new document. | Returns: -[Avg](./firestore_lite.avg.md#avg_class) +Promise<[DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType>> -### avgFunction(value) {:#avgfunction_7c807cd} +A `Promise` resolved with a `DocumentReference` pointing to the newly created document after it has been written to the backend. -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +#### Exceptions -Creates an aggregation that calculates the average (mean) of a field's values across multiple stage inputs. +Error - If the provided input is not a valid Firestore document. -```typescript -// Calculate the average age of users -avg("age").as("averageAge"); +### collection(reference, path, pathSegments) {:#collection_568f98d} -``` +Gets a `CollectionReference` instance that refers to a subcollection of `reference` at the specified relative path. Signature: ```typescript -export declare function avgFunction(value: string): Avg; +export declare function collection(reference: CollectionReference, path: string, ...pathSegments: string[]): CollectionReference; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | string | The name of the field containing numeric values to average. A new representing the 'avg' aggregation. | +| reference | [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to a collection. | +| path | string | A slash-separated path to a collection. | +| pathSegments | string\[\] | Additional path segments to apply relative to the first argument. | Returns: -[Avg](./firestore_lite.avg.md#avg_class) +[CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> -### exists(value) {:#exists_f83680a} +The `CollectionReference` instance. -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +#### Exceptions -Creates an expression that checks if a field exists. +If the final path has an even number of segments and does not point to a collection. -```typescript -// Check if the document has a field named "phoneNumber" -exists(Field.of("phoneNumber")); +### collection(reference, path, pathSegments) {:#collection_70b4396} -``` +Gets a `CollectionReference` instance that refers to a subcollection of `reference` at the specified relative path. Signature: ```typescript -export declare function exists(value: Constant): Exists; +export declare function collection(reference: DocumentReference, path: string, ...pathSegments: string[]): CollectionReference; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | [Constant](./firestore_lite.constant.md#constant_class) | An expression evaluates to the name of the field to check. A new representing the 'exists' check. | +| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to a Firestore document. | +| path | string | A slash-separated path to a collection. | +| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | Returns: -[Exists](./firestore_lite.exists.md#exists_class) +[CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> -### isNan(value) {:#isnan_f83680a} +The `CollectionReference` instance. -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +#### Exceptions -Creates an expression that checks if an expression evaluates to 'NaN' (Not a Number). +If the final path has an even number of segments and does not point to a collection. -```typescript -// Check if the result of a calculation is NaN -isNaN(Field.of("value").divide(0)); +### deleteDoc(reference) {:#deletedoc_4569087} -``` +Deletes the document referred to by the specified `DocumentReference`. + +The deletion will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the delete fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. Signature: ```typescript -export declare function isNan(value: Constant): IsNan; +export declare function deleteDoc(reference: DocumentReference): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | [Constant](./firestore_lite.constant.md#constant_class) | The expression to check. A new representing the 'isNaN' check. | +| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to delete. | Returns: -[IsNan](./firestore_lite.isnan.md#isnan_class) - -### isNan(value) {:#isnan_7c807cd} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +Promise<void> -Creates an expression that checks if a field's value evaluates to 'NaN' (Not a Number). +A `Promise` resolved once the document has been successfully deleted from the backend. -```typescript -// Check if the result of a calculation is NaN -isNaN("value"); +### doc(reference, path, pathSegments) {:#doc_568f98d} -``` +Gets a `DocumentReference` instance that refers to a document within `reference` at the specified relative path. If no path is specified, an automatically-generated unique ID will be used for the returned `DocumentReference`. Signature: ```typescript -export declare function isNan(value: string): IsNan; +export declare function doc(reference: CollectionReference, path?: string, ...pathSegments: string[]): DocumentReference; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | string | The name of the field to check. A new representing the 'isNaN' check. | +| reference | [CollectionReference](./firestore_lite.collectionreference.md#collectionreference_class)<AppModelType, DbModelType> | A reference to a collection. | +| path | string | A slash-separated path to a document. Has to be omitted to use auto-generated IDs. | +| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | Returns: -[IsNan](./firestore_lite.isnan.md#isnan_class) +[DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> -### max(value) {:#max_f83680a} +The `DocumentReference` instance. -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +#### Exceptions -Creates an aggregation that finds the maximum value of an expression across multiple stage inputs. +If the final path has an odd number of segments and does not point to a document. -```typescript -// Find the highest score in a leaderboard -max(Field.of("score")).as("highestScore"); +### doc(reference, path, pathSegments) {:#doc_70b4396} -``` +Gets a `DocumentReference` instance that refers to a document within `reference` at the specified relative path. Signature: ```typescript -export declare function max(value: Constant): Max; +export declare function doc(reference: DocumentReference, path: string, ...pathSegments: string[]): DocumentReference; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | [Constant](./firestore_lite.constant.md#constant_class) | The expression to find the maximum value of. A new representing the 'max' aggregation. | +| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to a Firestore document. | +| path | string | A slash-separated path to a document. | +| pathSegments | string\[\] | Additional path segments that will be applied relative to the first argument. | Returns: -[Max](./firestore_lite.max.md#max_class) +[DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<[DocumentData](./firestore_lite.documentdata.md#documentdata_interface), [DocumentData](./firestore_lite.documentdata.md#documentdata_interface)> -### max(value) {:#max_7c807cd} +The `DocumentReference` instance. -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +#### Exceptions -Creates an aggregation that finds the maximum value of a field across multiple stage inputs. +If the final path has an odd number of segments and does not point to a document. -```typescript -// Find the highest score in a leaderboard -max("score").as("highestScore"); +### getDoc(reference) {:#getdoc_4569087} -``` +Reads the document referred to by the specified document reference. + +All documents are directly fetched from the server, even if the document was previously read or modified. Recent modifications are only reflected in the retrieved `DocumentSnapshot` if they have already been applied by the backend. If the client is offline, the read fails. If you like to use caching or see local modifications, please use the full Firestore SDK. Signature: ```typescript -export declare function max(value: string): Max; +export declare function getDoc(reference: DocumentReference): Promise>; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | string | The name of the field to find the maximum value of. A new representing the 'max' aggregation. | +| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | The reference of the document to fetch. | Returns: -[Max](./firestore_lite.max.md#max_class) - -### min(value) {:#min_f83680a} +Promise<[DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType>> -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +A Promise resolved with a `DocumentSnapshot` containing the current document contents. -Creates an aggregation that finds the minimum value of an expression across multiple stage inputs. +### setDoc(reference, data) {:#setdoc_ee215ad} -```typescript -// Find the lowest price of all products -min(Field.of("price")).as("lowestPrice"); +Writes to the document referred to by the specified `DocumentReference`. If the document does not yet exist, it will be created. -``` +The result of this write will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the write fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. Signature: ```typescript -export declare function min(value: Constant): Min; +export declare function setDoc(reference: DocumentReference, data: WithFieldValue): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | [Constant](./firestore_lite.constant.md#constant_class) | The expression to find the minimum value of. A new representing the 'min' aggregation. | +| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to write. | +| data | [WithFieldValue](./firestore_lite.md#withfieldvalue)<AppModelType> | A map of the fields and values for the document. | Returns: -[Min](./firestore_lite.min.md#min_class) +Promise<void> -### min(value) {:#min_7c807cd} +A `Promise` resolved once the data has been successfully written to the backend. -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +#### Exceptions -Creates an aggregation that finds the minimum value of a field across multiple stage inputs. +Error - If the provided input is not a valid Firestore document. -```typescript -// Find the lowest price of all products -min("price").as("lowestPrice"); +### setDoc(reference, data, options) {:#setdoc_ff80739} -``` +Writes to the document referred to by the specified `DocumentReference`. If the document does not yet exist, it will be created. If you provide `merge` or `mergeFields`, the provided data can be merged into an existing document. + +The result of this write will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the write fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. Signature: ```typescript -export declare function min(value: string): Min; +export declare function setDoc(reference: DocumentReference, data: PartialWithFieldValue, options: SetOptions): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | string | The name of the field to find the minimum value of. A new representing the 'min' aggregation. | +| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to write. | +| data | [PartialWithFieldValue](./firestore_lite.md#partialwithfieldvalue)<AppModelType> | A map of the fields and values for the document. | +| options | [SetOptions](./firestore_lite.md#setoptions) | An object to configure the set behavior. | Returns: -[Min](./firestore_lite.min.md#min_class) +Promise<void> -### replaceAll(value, find, replace) {:#replaceall_f06d323} +A `Promise` resolved once the data has been successfully written to the backend. -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +#### Exceptions -Creates an expression that replaces all occurrences of a substring within a string with another substring. +Error - If the provided input is not a valid Firestore document. -```typescript -// Replace all occurrences of "hello" with "hi" in the 'message' field. -replaceAll(Field.of("message"), "hello", "hi"); +### updateDoc(reference, data) {:#updatedoc_51a65e3} -``` +Updates fields in the document referred to by the specified `DocumentReference`. The update will fail if applied to a document that does not exist. + +The result of this update will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the update fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. Signature: ```typescript -export declare function replaceAll(value: Constant, find: string, replace: string): ReplaceAll; +export declare function updateDoc(reference: DocumentReference, data: UpdateData): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to perform the replacement on. | -| find | string | The substring to search for. | -| replace | string | The substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | +| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to update. | +| data | [UpdateData](./firestore_lite.md#updatedata)<DbModelType> | An object containing the fields and values with which to update the document. Fields can contain dots to reference nested fields within the document. | Returns: -[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) +Promise<void> -### replaceAll(value, find, replace) {:#replaceall_26a7926} +A `Promise` resolved once the data has been successfully written to the backend. -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +#### Exceptions -Creates an expression that replaces all occurrences of a substring within a string with another substring, where the substring to find and the replacement substring are specified by expressions. +Error - If the provided input is not valid Firestore data. -```typescript -// Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field. -replaceAll(Field.of("message"), Field.of("findField"), Field.of("replaceField")); +### updateDoc(reference, field, value, moreFieldsAndValues) {:#updatedoc_7c28659} -``` +Updates fields in the document referred to by the specified `DocumentReference` The update will fail if applied to a document that does not exist. + +Nested fields can be updated by providing dot-separated field path strings or by providing `FieldPath` objects. + +The result of this update will only be reflected in document reads that occur after the returned promise resolves. If the client is offline, the update fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK. Signature: ```typescript -export declare function replaceAll(value: Constant, find: Constant, replace: Constant): ReplaceAll; +export declare function updateDoc(reference: DocumentReference, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to perform the replacement on. | -| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace all occurrences of 'find' with. A new representing the string with all occurrences replaced. | +| reference | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)<AppModelType, DbModelType> | A reference to the document to update. | +| field | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | The first field to update. | +| value | unknown | The first value. | +| moreFieldsAndValues | unknown\[\] | Additional key value pairs. | Returns: -[ReplaceAll](./firestore_lite.replaceall.md#replaceall_class) +Promise<void> -### replaceFirst(value, find, replace) {:#replacefirst_f06d323} +A `Promise` resolved once the data has been successfully written to the backend. -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +#### Exceptions -Creates an expression that replaces the first occurrence of a substring within a string with another substring. +Error - If the provided input is not valid Firestore data. -```typescript -// Replace the first occurrence of "hello" with "hi" in the 'message' field. -replaceFirst(Field.of("message"), "hello", "hi"); +## function(snapshot, ...) -``` +### endAt(snapshot) {:#endat_9a4477f} + +Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end at the provided document (inclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. Signature: ```typescript -export declare function replaceFirst(value: Constant, find: string, replace: string): ReplaceFirst; +export declare function endAt(snapshot: DocumentSnapshot): QueryEndAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to perform the replacement on. | -| find | string | The substring to search for. | -| replace | string | The substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | +| snapshot | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to end at. | Returns: -[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) - -### replaceFirst(value, find, replace) {:#replacefirst_26a7926} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +[QueryEndAtConstraint](./firestore_lite.queryendatconstraint.md#queryendatconstraint_class) -Creates an expression that replaces the first occurrence of a substring within a string with another substring, where the substring to find and the replacement substring are specified by expressions. +A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` -```typescript -// Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field. -replaceFirst(Field.of("message"), Field.of("findField"), Field.of("replaceField")); +### endBefore(snapshot) {:#endbefore_9a4477f} -``` +Creates a [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) that modifies the result set to end before the provided document (exclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. Signature: ```typescript -export declare function replaceFirst(value: Constant, find: Constant, replace: Constant): ReplaceFirst; +export declare function endBefore(snapshot: DocumentSnapshot): QueryEndAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the string to perform the replacement on. | -| find | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to search for. | -| replace | [Constant](./firestore_lite.constant.md#constant_class) | The expression representing the substring to replace the first occurrence of 'find' with. A new representing the string with the first occurrence replaced. | +| snapshot | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to end before. | Returns: -[ReplaceFirst](./firestore_lite.replacefirst.md#replacefirst_class) - -### sumFunction(value) {:#sumfunction_f83680a} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +[QueryEndAtConstraint](./firestore_lite.queryendatconstraint.md#queryendatconstraint_class) -Creates an aggregation that calculates the sum of values from an expression across multiple stage inputs. +A [QueryEndAtConstraint](./firestore_.queryendatconstraint.md#queryendatconstraint_class) to pass to `query()` -```typescript -// Calculate the total revenue from a set of orders -sum(Field.of("orderAmount")).as("totalRevenue"); +### startAfter(snapshot) {:#startafter_9a4477f} -``` +Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start after the provided document (exclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. Signature: ```typescript -export declare function sumFunction(value: Constant): Sum; +export declare function startAfter(snapshot: DocumentSnapshot): QueryStartAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | [Constant](./firestore_lite.constant.md#constant_class) | The expression to sum up. A new representing the 'sum' aggregation. | +| snapshot | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to start after. | Returns: -[Sum](./firestore_lite.sum.md#sum_class) - -### sumFunction(value) {:#sumfunction_7c807cd} - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> +[QueryStartAtConstraint](./firestore_lite.querystartatconstraint.md#querystartatconstraint_class) -Creates an aggregation that calculates the sum of a field's values across multiple stage inputs. +A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()` -```typescript -// Calculate the total revenue from a set of orders -sum("orderAmount").as("totalRevenue"); +### startAt(snapshot) {:#startat_9a4477f} -``` +Creates a [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) that modifies the result set to start at the provided document (inclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the `orderBy` of this query. Signature: ```typescript -export declare function sumFunction(value: string): Sum; +export declare function startAt(snapshot: DocumentSnapshot): QueryStartAtConstraint; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | -| value | string | The name of the field containing numeric values to sum up. A new representing the 'sum' aggregation. | +| snapshot | [DocumentSnapshot](./firestore_lite.documentsnapshot.md#documentsnapshot_class)<AppModelType, DbModelType> | The snapshot of the document to start at. | Returns: -[Sum](./firestore_lite.sum.md#sum_class) +[QueryStartAtConstraint](./firestore_lite.querystartatconstraint.md#querystartatconstraint_class) + +A [QueryStartAtConstraint](./firestore_.querystartatconstraint.md#querystartatconstraint_class) to pass to `query()`. ## function(values, ...) @@ -8556,19 +1595,6 @@ export declare function vector(values?: number[]): VectorValue; A new `VectorValue` constructed with a copy of the given array of numbers. -## AccumulatorTarget - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -An accumulator target, which is an expression with an alias that also implements the Accumulator interface. - -Signature: - -```typescript -export declare type AccumulatorTarget = ExprWithAlias; -``` - ## AddPrefixToKeys Returns a new map where every key is prefixed with the outer key appended to a dot. @@ -8627,32 +1653,6 @@ See https://www.typescriptlang.org/docs/handbook/advanced-types.html\#distributi export declare type ChildUpdateFields = V extends Record ? AddPrefixToKeys> : never; ``` -## ExprType - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -An enumeration of the different types of expressions. - -Signature: - -```typescript -export declare type ExprType = 'Field' | 'Constant' | 'Function' | 'ListOfExprs' | 'ExprWithAlias'; -``` - -## FilterExpr - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -A filter expression, which is an expression that also implements the FilterCondition interface. - -Signature: - -```typescript -export declare type FilterExpr = Constant & FilterCondition; -``` - ## FirestoreErrorCode The set of Firestore status codes. The codes are the same at the ones exposed by gRPC here: https://github.com/grpc/grpc/blob/master/doc/statuscodes.md @@ -8739,19 +1739,6 @@ export declare type QueryFilterConstraint = QueryFieldFilterConstraint | QueryCo export declare type QueryNonFilterConstraint = QueryOrderByConstraint | QueryLimitConstraint | QueryStartAtConstraint | QueryEndAtConstraint; ``` -## SelectableExpr - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -A selectable expression, which is an expression that also implements the Selectable interface. - -Signature: - -```typescript -export declare type SelectableExpr = Constant & Selectable; -``` - ## SetOptions An options object that configures the behavior of [setDoc()](./firestore_lite.md#setdoc_ee215ad), and calls. These calls can be configured to perform granular merges instead of overwriting the target documents in their entirety by providing a `SetOptions` with `merge: true`. diff --git a/docs-devsite/firestore_lite.min.md b/docs-devsite/firestore_lite.min.md deleted file mode 100644 index 684db43d806..00000000000 --- a/docs-devsite/firestore_lite.min.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Min class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Min extends FirestoreFunction implements Accumulator -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [Accumulator](./firestore_lite.accumulator.md#accumulator_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value, distinct)](./firestore_lite.min.md#minconstructor) | | (BETA) Constructs a new instance of the Min class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [accumulator](./firestore_lite.min.md#minaccumulator) | | true | (BETA) | - -## Min.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Min` class - -Signature: - -```typescript -constructor(value: Constant, distinct: boolean); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_lite.constant.md#constant_class) | | -| distinct | boolean | | - -## Min.accumulator - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -accumulator: true; -``` diff --git a/docs-devsite/firestore_lite.mod.md b/docs-devsite/firestore_lite.mod.md deleted file mode 100644 index f007f09a87e..00000000000 --- a/docs-devsite/firestore_lite.mod.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Mod class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Mod extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_lite.mod.md#modconstructor) | | (BETA) Constructs a new instance of the Mod class | - -## Mod.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Mod` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | | -| right | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.multiply.md b/docs-devsite/firestore_lite.multiply.md deleted file mode 100644 index 38ca6014b2c..00000000000 --- a/docs-devsite/firestore_lite.multiply.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Multiply class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Multiply extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_lite.multiply.md#multiplyconstructor) | | (BETA) Constructs a new instance of the Multiply class | - -## Multiply.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Multiply` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | | -| right | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.neq.md b/docs-devsite/firestore_lite.neq.md deleted file mode 100644 index 132e5721b8f..00000000000 --- a/docs-devsite/firestore_lite.neq.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Neq class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Neq extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_lite.neq.md#neqconstructor) | | (BETA) Constructs a new instance of the Neq class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_lite.neq.md#neqfilterable) | | true | (BETA) | - -## Neq.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Neq` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | | -| right | [Constant](./firestore_lite.constant.md#constant_class) | | - -## Neq.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.not.md b/docs-devsite/firestore_lite.not.md deleted file mode 100644 index 362ccd8a789..00000000000 --- a/docs-devsite/firestore_lite.not.md +++ /dev/null @@ -1,66 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Not class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Not extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr)](./firestore_lite.not.md#notconstructor) | | (BETA) Constructs a new instance of the Not class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_lite.not.md#notfilterable) | | true | (BETA) | - -## Not.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Not` class - -Signature: - -```typescript -constructor(expr: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | | - -## Not.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.offset.md b/docs-devsite/firestore_lite.offset.md deleted file mode 100644 index dc09ac97be6..00000000000 --- a/docs-devsite/firestore_lite.offset.md +++ /dev/null @@ -1,64 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Offset class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Offset implements Stage -``` -Implements: [Stage](./firestore_lite.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(offset)](./firestore_lite.offset.md#offsetconstructor) | | (BETA) Constructs a new instance of the Offset class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_lite.offset.md#offsetname) | | string | (BETA) | - -## Offset.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Offset` class - -Signature: - -```typescript -constructor(offset: number); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| offset | number | | - -## Offset.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_lite.or.md b/docs-devsite/firestore_lite.or.md deleted file mode 100644 index d2c506893a0..00000000000 --- a/docs-devsite/firestore_lite.or.md +++ /dev/null @@ -1,17 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# or namespace -Signature: - -```typescript -export declare namespace or -``` diff --git a/docs-devsite/firestore_lite.ordering.md b/docs-devsite/firestore_lite.ordering.md deleted file mode 100644 index c8dc1249d73..00000000000 --- a/docs-devsite/firestore_lite.ordering.md +++ /dev/null @@ -1,51 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Ordering class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Represents an ordering criterion for sorting documents in a Firestore pipeline. - -You create `Ordering` instances using the `ascending` and `descending` helper functions. - -Signature: - -```typescript -export declare class Ordering -``` - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr, direction)](./firestore_lite.ordering.md#orderingconstructor) | | (BETA) Constructs a new instance of the Ordering class | - -## Ordering.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Ordering` class - -Signature: - -```typescript -constructor(expr: Constant, direction: 'ascending' | 'descending'); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | | -| direction | 'ascending' \| 'descending' | | - diff --git a/docs-devsite/firestore_lite.pipeline.md b/docs-devsite/firestore_lite.pipeline.md deleted file mode 100644 index c34aa32109e..00000000000 --- a/docs-devsite/firestore_lite.pipeline.md +++ /dev/null @@ -1,564 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Pipeline class -Base-class implementation - -Signature: - -```typescript -export declare class Pipeline -``` - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [addFields(fields)](./firestore_lite.pipeline.md#pipelineaddfields) | | Adds new fields to outputs from previous stages.This stage allows you to compute values on-the-fly based on existing data from previous stages or constants. You can use this to create new fields or overwrite existing ones (if there is name overlaps).The added fields are defined using [Selectable](./firestore_.selectable.md#selectable_interface)s, which can be:- [Field](./firestore_.field.md#field_class): References an existing document field. - : Performs a calculation using functions like add, multiply with assigned aliases using .Example: -```typescript -firestore.pipeline().collection("books") - .addFields( - Field.of("rating").as("bookRating"), // Rename 'rating' to 'bookRating' - add(5, Field.of("quantity")).as("totalCost") // Calculate 'totalCost' - ); - -``` - | -| [aggregate(accumulators)](./firestore_lite.pipeline.md#pipelineaggregate) | | Performs aggregation operations on the documents from previous stages.

This stage allows you to calculate aggregate values over a set of documents. You define the aggregations to perform using [AccumulatorTarget](./firestore_.md#accumulatortarget) expressions which are typically results of calling on [Accumulator](./firestore_.accumulator.md#accumulator_interface) instances.

Example: -```typescript -// Calculate the average rating and the total number of books -firestore.pipeline().collection("books") - .aggregate( - Field.of("rating").avg().as("averageRating"), - countAll().as("totalBooks") - ); - -``` - | -| [aggregate(options)](./firestore_lite.pipeline.md#pipelineaggregate) | | Performs optionally grouped aggregation operations on the documents from previous stages.

This stage allows you to calculate aggregate values over a set of documents, optionally grouped by one or more fields or functions. You can specify:

  • \*\*Grouping Fields or Functions:\*\* One or more fields or functions to group the documents by. For each distinct combination of values in these fields, a separate group is created. If no grouping fields are provided, a single group containing all documents is used. Not specifying groups is the same as putting the entire inputs into one group.
  • \*\*Accumulators:\*\* One or more accumulation operations to perform within each group. These are defined using [AccumulatorTarget](./firestore_.md#accumulatortarget) expressions, which are typically created by calling on [Accumulator](./firestore_.accumulator.md#accumulator_interface) instances. Each aggregation calculates a value (e.g., sum, average, count) based on the documents within its group.

Example: -```typescript -// Calculate the average rating for each genre. -firestore.pipeline().collection("books") - .aggregate({ - accumulators: [avg(Field.of("rating")).as("avg_rating")] - groups: ["genre"] - }); - -``` - | -| [distinct(groups)](./firestore_lite.pipeline.md#pipelinedistinct) | | Returns a set of distinct values from the inputs to this stage.

This stage run through the results from previous stages to include only results with unique combinations of values ([Field](./firestore_.field.md#field_class), , etc).

The parameters to this stage are defined using [Selectable](./firestore_.selectable.md#selectable_interface) expressions or s:

  • : Name of an existing field
  • [Field](./firestore_.field.md#field_class): References an existing document field.
  • : Represents the result of a function with an assigned alias name using

Example: -```typescript -// Get a list of unique author names in uppercase and genre combinations. -firestore.pipeline().collection("books") - .distinct(toUppercase(Field.of("author")).as("authorName"), Field.of("genre"), "publishedAt") - .select("authorName"); - -``` - | -| [execute()](./firestore_lite.pipeline.md#pipelineexecute) | | Executes this pipeline and returns a Promise to represent the asynchronous operation.

The returned Promise can be used to track the progress of the pipeline execution and retrieve the results (or handle any errors) asynchronously.

The pipeline results are returned as a list of [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) objects. Each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) typically represents a single key/value map that has passed through all the stages of the pipeline, however this might differ depending on the stages involved in the pipeline. For example:

  • If there are no stages or only transformation stages, each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) represents a single document.
  • If there is an aggregation, only a single [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) is returned, representing the aggregated results over the entire dataset .
  • If there is an aggregation stage with grouping, each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) represents a distinct group and its associated aggregated values.

Example: -```typescript -const futureResults = await firestore.pipeline().collection("books") - .where(gt(Field.of("rating"), 4.5)) - .select("title", "author", "rating") - .execute(); - -``` - A Promise representing the asynchronous pipeline execution. | -| [findNearest(options)](./firestore_lite.pipeline.md#pipelinefindnearest) | | | -| [genericStage(name, params)](./firestore_lite.pipeline.md#pipelinegenericstage) | | Adds a generic stage to the pipeline.

This method provides a flexible way to extend the pipeline's functionality by adding custom stages. Each generic stage is defined by a unique name and a set of params that control its behavior.

Example (Assuming there is no "where" stage available in SDK): -```typescript -// Assume we don't have a built-in "where" stage -firestore.pipeline().collection("books") - .genericStage("where", [Field.of("published").lt(1900)]) // Custom "where" stage - .select("title", "author"); - -``` - | -| [limit(limit)](./firestore_lite.pipeline.md#pipelinelimit) | | Limits the maximum number of documents returned by previous stages to limit.

This stage is particularly useful when you want to retrieve a controlled subset of data from a potentially large result set. It's often used for:

  • \*\*Pagination:\*\* In combination with to retrieve specific pages of results.
  • \*\*Limiting Data Retrieval:\*\* To prevent excessive data transfer and improve performance, especially when dealing with large collections.

Example: -```typescript -// Limit the results to the top 10 highest-rated books -firestore.pipeline().collection("books") - .sort(Field.of("rating").descending()) - .limit(10); - -``` - | -| [offset(offset)](./firestore_lite.pipeline.md#pipelineoffset) | | Skips the first offset number of documents from the results of previous stages.

This stage is useful for implementing pagination in your pipelines, allowing you to retrieve results in chunks. It is typically used in conjunction with to control the size of each page.

Example: -```typescript -// Retrieve the second page of 20 results -firestore.pipeline().collection("books") - .sort(Field.of("published").descending()) - .offset(20) // Skip the first 20 results - .limit(20); // Take the next 20 results - -``` - | -| [select(selections)](./firestore_lite.pipeline.md#pipelineselect) | | Selects or creates a set of fields from the outputs of previous stages.

The selected fields are defined using [Selectable](./firestore_.selectable.md#selectable_interface) expressions, which can be:

  • : Name of an existing field
  • [Field](./firestore_.field.md#field_class): References an existing field.
  • : Represents the result of a function with an assigned alias name using

If no selections are provided, the output of this stage is empty. Use instead if only additions are desired.

Example: -```typescript -firestore.pipeline().collection("books") - .select( - "firstName", - Field.of("lastName"), - Field.of("address").toUppercase().as("upperAddress"), - ); - -``` - | -| [sort(orderings)](./firestore_lite.pipeline.md#pipelinesort) | | Sorts the documents from previous stages based on one or more [Ordering](./firestore_.ordering.md#ordering_class) criteria.

This stage allows you to order the results of your pipeline. You can specify multiple [Ordering](./firestore_.ordering.md#ordering_class) instances to sort by multiple fields in ascending or descending order. If documents have the same value for a field used for sorting, the next specified ordering will be used. If all orderings result in equal comparison, the documents are considered equal and the order is unspecified.

Example: -```typescript -// Sort books by rating in descending order, and then by title in ascending order for books -// with the same rating -firestore.pipeline().collection("books") - .sort( - Ordering.of(Field.of("rating")).descending(), - Ordering.of(Field.of("title")) // Ascending order is the default - ); - -``` - | -| [sort(options)](./firestore_lite.pipeline.md#pipelinesort) | | | -| [where(condition)](./firestore_lite.pipeline.md#pipelinewhere) | | Filters the documents from previous stages to only include those matching the specified [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface).

This stage allows you to apply conditions to the data, similar to a "WHERE" clause in SQL. You can filter documents based on their field values, using implementations of [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface), typically including but not limited to:

  • field comparators: , (less than), (greater than), etc.
  • logical operators: , , , etc.
  • advanced functions: , , etc.

Example: -```typescript -firestore.pipeline().collection("books") - .where( - and( - gt(Field.of("rating"), 4.0), // Filter for ratings greater than 4.0 - Field.of("genre").eq("Science Fiction") // Equivalent to gt("genre", "Science Fiction") - ) - ); - -``` - | - -## Pipeline.addFields() - -Adds new fields to outputs from previous stages. - -This stage allows you to compute values on-the-fly based on existing data from previous stages or constants. You can use this to create new fields or overwrite existing ones (if there is name overlaps). - -The added fields are defined using [Selectable](./firestore_.selectable.md#selectable_interface)s, which can be: - -- [Field](./firestore_.field.md#field_class): References an existing document field. - : Performs a calculation using functions like `add`, `multiply` with assigned aliases using . - -Example: - -```typescript -firestore.pipeline().collection("books") - .addFields( - Field.of("rating").as("bookRating"), // Rename 'rating' to 'bookRating' - add(5, Field.of("quantity")).as("totalCost") // Calculate 'totalCost' - ); - -``` - -Signature: - -```typescript -addFields(...fields: Selectable[]): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| fields | [Selectable](./firestore_lite.selectable.md#selectable_interface)\[\] | The fields to add to the documents, specified as [Selectable](./firestore_.selectable.md#selectable_interface)s. A new Pipeline object with this stage appended to the stage list. | - -Returns: - -[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.aggregate() - -Performs aggregation operations on the documents from previous stages. - -

This stage allows you to calculate aggregate values over a set of documents. You define the aggregations to perform using [AccumulatorTarget](./firestore_.md#accumulatortarget) expressions which are typically results of calling on [Accumulator](./firestore_.accumulator.md#accumulator_interface) instances. - -

Example: - -```typescript -// Calculate the average rating and the total number of books -firestore.pipeline().collection("books") - .aggregate( - Field.of("rating").avg().as("averageRating"), - countAll().as("totalBooks") - ); - -``` - -Signature: - -```typescript -aggregate(...accumulators: AccumulatorTarget[]): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| accumulators | [AccumulatorTarget](./firestore_lite.md#accumulatortarget)\[\] | The [AccumulatorTarget](./firestore_.md#accumulatortarget) expressions, each wrapping an [Accumulator](./firestore_.accumulator.md#accumulator_interface) and provide a name for the accumulated results. A new Pipeline object with this stage appended to the stage list. | - -Returns: - -[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.aggregate() - -Performs optionally grouped aggregation operations on the documents from previous stages. - -

This stage allows you to calculate aggregate values over a set of documents, optionally grouped by one or more fields or functions. You can specify: - -

  • \*\*Grouping Fields or Functions:\*\* One or more fields or functions to group the documents by. For each distinct combination of values in these fields, a separate group is created. If no grouping fields are provided, a single group containing all documents is used. Not specifying groups is the same as putting the entire inputs into one group.
  • \*\*Accumulators:\*\* One or more accumulation operations to perform within each group. These are defined using [AccumulatorTarget](./firestore_.md#accumulatortarget) expressions, which are typically created by calling on [Accumulator](./firestore_.accumulator.md#accumulator_interface) instances. Each aggregation calculates a value (e.g., sum, average, count) based on the documents within its group.
- -

Example: - -```typescript -// Calculate the average rating for each genre. -firestore.pipeline().collection("books") - .aggregate({ - accumulators: [avg(Field.of("rating")).as("avg_rating")] - groups: ["genre"] - }); - -``` - -Signature: - -```typescript -aggregate(options: { - accumulators: AccumulatorTarget[]; - groups?: Array; - }): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| options | { accumulators: [AccumulatorTarget](./firestore_lite.md#accumulatortarget)\[\]; groups?: Array<string \| [Selectable](./firestore_lite.selectable.md#selectable_interface)>; } | | - -Returns: - -[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.distinct() - -Returns a set of distinct values from the inputs to this stage. - -

This stage run through the results from previous stages to include only results with unique combinations of values ([Field](./firestore_.field.md#field_class), , etc). - -

The parameters to this stage are defined using [Selectable](./firestore_.selectable.md#selectable_interface) expressions or s: - -

  • : Name of an existing field
  • [Field](./firestore_.field.md#field_class): References an existing document field.
  • : Represents the result of a function with an assigned alias name using
- -

Example: - -```typescript -// Get a list of unique author names in uppercase and genre combinations. -firestore.pipeline().collection("books") - .distinct(toUppercase(Field.of("author")).as("authorName"), Field.of("genre"), "publishedAt") - .select("authorName"); - -``` - -Signature: - -```typescript -distinct(...groups: Array): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| groups | Array<string \| [Selectable](./firestore_lite.selectable.md#selectable_interface)> | | - -Returns: - -[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.execute() - -Executes this pipeline and returns a Promise to represent the asynchronous operation. - -

The returned Promise can be used to track the progress of the pipeline execution and retrieve the results (or handle any errors) asynchronously. - -

The pipeline results are returned as a list of [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) objects. Each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) typically represents a single key/value map that has passed through all the stages of the pipeline, however this might differ depending on the stages involved in the pipeline. For example: - -

  • If there are no stages or only transformation stages, each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) represents a single document.
  • If there is an aggregation, only a single [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) is returned, representing the aggregated results over the entire dataset .
  • If there is an aggregation stage with grouping, each [PipelineResult](./firestore_.pipelineresult.md#pipelineresult_class) represents a distinct group and its associated aggregated values.
- -

Example: - -```typescript -const futureResults = await firestore.pipeline().collection("books") - .where(gt(Field.of("rating"), 4.5)) - .select("title", "author", "rating") - .execute(); - -``` - A Promise representing the asynchronous pipeline execution. - -Signature: - -```typescript -execute(): Promise>>; -``` -Returns: - -Promise<Array<[PipelineResult](./firestore_lite.pipelineresult.md#pipelineresult_class)<AppModelType>>> - -## Pipeline.findNearest() - -Signature: - -```typescript -findNearest(options: FindNearestOptions): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| options | [FindNearestOptions](./firestore_lite.findnearestoptions.md#findnearestoptions_interface) | | - -Returns: - -[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.genericStage() - -Adds a generic stage to the pipeline. - -

This method provides a flexible way to extend the pipeline's functionality by adding custom stages. Each generic stage is defined by a unique `name` and a set of `params` that control its behavior. - -

Example (Assuming there is no "where" stage available in SDK): - -```typescript -// Assume we don't have a built-in "where" stage -firestore.pipeline().collection("books") - .genericStage("where", [Field.of("published").lt(1900)]) // Custom "where" stage - .select("title", "author"); - -``` - -Signature: - -```typescript -genericStage(name: string, params: any[]): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| name | string | The unique name of the generic stage to add. | -| params | any\[\] | A list of parameters to configure the generic stage's behavior. A new object with this stage appended to the stage list. | - -Returns: - -[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.limit() - -Limits the maximum number of documents returned by previous stages to `limit`. - -

This stage is particularly useful when you want to retrieve a controlled subset of data from a potentially large result set. It's often used for: - -

  • \*\*Pagination:\*\* In combination with to retrieve specific pages of results.
  • \*\*Limiting Data Retrieval:\*\* To prevent excessive data transfer and improve performance, especially when dealing with large collections.
- -

Example: - -```typescript -// Limit the results to the top 10 highest-rated books -firestore.pipeline().collection("books") - .sort(Field.of("rating").descending()) - .limit(10); - -``` - -Signature: - -```typescript -limit(limit: number): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| limit | number | The maximum number of documents to return. A new Pipeline object with this stage appended to the stage list. | - -Returns: - -[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.offset() - -Skips the first `offset` number of documents from the results of previous stages. - -

This stage is useful for implementing pagination in your pipelines, allowing you to retrieve results in chunks. It is typically used in conjunction with to control the size of each page. - -

Example: - -```typescript -// Retrieve the second page of 20 results -firestore.pipeline().collection("books") - .sort(Field.of("published").descending()) - .offset(20) // Skip the first 20 results - .limit(20); // Take the next 20 results - -``` - -Signature: - -```typescript -offset(offset: number): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| offset | number | The number of documents to skip. A new Pipeline object with this stage appended to the stage list. | - -Returns: - -[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.select() - -Selects or creates a set of fields from the outputs of previous stages. - -

The selected fields are defined using [Selectable](./firestore_.selectable.md#selectable_interface) expressions, which can be: - -

  • : Name of an existing field
  • [Field](./firestore_.field.md#field_class): References an existing field.
  • : Represents the result of a function with an assigned alias name using
- -

If no selections are provided, the output of this stage is empty. Use instead if only additions are desired. - -

Example: - -```typescript -firestore.pipeline().collection("books") - .select( - "firstName", - Field.of("lastName"), - Field.of("address").toUppercase().as("upperAddress"), - ); - -``` - -Signature: - -```typescript -select(...selections: Array): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| selections | Array<[Selectable](./firestore_lite.selectable.md#selectable_interface) \| string> | The fields to include in the output documents, specified as [Selectable](./firestore_.selectable.md#selectable_interface) expressions or values representing field names. A new Pipeline object with this stage appended to the stage list. | - -Returns: - -[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.sort() - -Sorts the documents from previous stages based on one or more [Ordering](./firestore_.ordering.md#ordering_class) criteria. - -

This stage allows you to order the results of your pipeline. You can specify multiple [Ordering](./firestore_.ordering.md#ordering_class) instances to sort by multiple fields in ascending or descending order. If documents have the same value for a field used for sorting, the next specified ordering will be used. If all orderings result in equal comparison, the documents are considered equal and the order is unspecified. - -

Example: - -```typescript -// Sort books by rating in descending order, and then by title in ascending order for books -// with the same rating -firestore.pipeline().collection("books") - .sort( - Ordering.of(Field.of("rating")).descending(), - Ordering.of(Field.of("title")) // Ascending order is the default - ); - -``` - -Signature: - -```typescript -sort(...orderings: Ordering[]): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| orderings | [Ordering](./firestore_lite.ordering.md#ordering_class)\[\] | | - -Returns: - -[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.sort() - -Signature: - -```typescript -sort(options: { - orderings: Ordering[]; - }): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| options | { orderings: [Ordering](./firestore_lite.ordering.md#ordering_class)\[\]; } | | - -Returns: - -[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> - -## Pipeline.where() - -Filters the documents from previous stages to only include those matching the specified [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface). - -

This stage allows you to apply conditions to the data, similar to a "WHERE" clause in SQL. You can filter documents based on their field values, using implementations of [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface), typically including but not limited to: - -

  • field comparators: , (less than), (greater than), etc.
  • logical operators: , , , etc.
  • advanced functions: , , etc.
- -

Example: - -```typescript -firestore.pipeline().collection("books") - .where( - and( - gt(Field.of("rating"), 4.0), // Filter for ratings greater than 4.0 - Field.of("genre").eq("Science Fiction") // Equivalent to gt("genre", "Science Fiction") - ) - ); - -``` - -Signature: - -```typescript -where(condition: FilterCondition & Constant): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| condition | [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) & [Constant](./firestore_lite.constant.md#constant_class) | The [FilterCondition](./firestore_.filtercondition.md#filtercondition_interface) to apply. A new Pipeline object with this stage appended to the stage list. | - -Returns: - -[Pipeline](./firestore_lite.pipeline.md#pipeline_class)<AppModelType> - diff --git a/docs-devsite/firestore_lite.pipelineresult.md b/docs-devsite/firestore_lite.pipelineresult.md deleted file mode 100644 index 16a64fd9b7c..00000000000 --- a/docs-devsite/firestore_lite.pipelineresult.md +++ /dev/null @@ -1,184 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# PipelineResult class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -A PipelineResult contains data read from a Firestore Pipeline. The data can be extracted with the or methods. - -

If the PipelineResult represents a non-document result, `ref` will return a undefined value. - -Signature: - -```typescript -export declare class PipelineResult -``` - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [createTime](./firestore_lite.pipelineresult.md#pipelineresultcreatetime) | | [Timestamp](./firestore_lite.timestamp.md#timestamp_class) \| undefined | (BETA) The time the document was created. Undefined if this result is not a document. {Timestamp\|undefined} | -| [executionTime](./firestore_lite.pipelineresult.md#pipelineresultexecutiontime) | | [Timestamp](./firestore_lite.timestamp.md#timestamp_class) | (BETA) The time at which the pipeline producing this result is executed. {Timestamp} | -| [id](./firestore_lite.pipelineresult.md#pipelineresultid) | | string \| undefined | (BETA) The ID of the document for which this PipelineResult contains data, if it is a document; otherwise undefined. {string} | -| [ref](./firestore_lite.pipelineresult.md#pipelineresultref) | | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class) \| undefined | (BETA) The reference of the document, if it is a document; otherwise undefined. | -| [updateTime](./firestore_lite.pipelineresult.md#pipelineresultupdatetime) | | [Timestamp](./firestore_lite.timestamp.md#timestamp_class) \| undefined | (BETA) The time the document was last updated (at the time the snapshot was generated). Undefined if this result is not a document. {Timestamp\|undefined} | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [data()](./firestore_lite.pipelineresult.md#pipelineresultdata) | | (BETA) Retrieves all fields in the result as an object. Returns 'undefined' if the document doesn't exist. | -| [get(fieldPath)](./firestore_lite.pipelineresult.md#pipelineresultget) | | (BETA) Retrieves the field specified by field. | - -## PipelineResult.createTime - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -The time the document was created. Undefined if this result is not a document. - - {Timestamp\|undefined} - -Signature: - -```typescript -get createTime(): Timestamp | undefined; -``` - -## PipelineResult.executionTime - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -The time at which the pipeline producing this result is executed. - - {Timestamp} - -Signature: - -```typescript -get executionTime(): Timestamp; -``` - -## PipelineResult.id - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -The ID of the document for which this PipelineResult contains data, if it is a document; otherwise `undefined`. - - {string} - -Signature: - -```typescript -get id(): string | undefined; -``` - -## PipelineResult.ref - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -The reference of the document, if it is a document; otherwise `undefined`. - -Signature: - -```typescript -get ref(): DocumentReference | undefined; -``` - -## PipelineResult.updateTime - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -The time the document was last updated (at the time the snapshot was generated). Undefined if this result is not a document. - - {Timestamp\|undefined} - -Signature: - -```typescript -get updateTime(): Timestamp | undefined; -``` - -## PipelineResult.data() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Retrieves all fields in the result as an object. Returns 'undefined' if the document doesn't exist. - -Signature: - -```typescript -data(): AppModelType | undefined; -``` -Returns: - -AppModelType \| undefined - -{T\|undefined} An object containing all fields in the document or 'undefined' if the document doesn't exist. - -### Example - - -``` -let p = firestore.pipeline().collection('col'); - -p.execute().then(results => { - let data = results[0].data(); - console.log(`Retrieved data: ${JSON.stringify(data)}`); -}); - -``` - -## PipelineResult.get() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Retrieves the field specified by `field`. - -Signature: - -```typescript -get(fieldPath: string | FieldPath): any; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| fieldPath | string \| [FieldPath](./firestore_lite.fieldpath.md#fieldpath_class) | | - -Returns: - -any - -{\*} The data at the specified field location or undefined if no such field exists. - -### Example - - -``` -let p = firestore.pipeline().collection('col'); - -p.execute().then(results => { - let field = results[0].get('a.b'); - console.log(`Retrieved field value: ${field}`); -}); - -``` - diff --git a/docs-devsite/firestore_lite.pipelinesource.md b/docs-devsite/firestore_lite.pipelinesource.md deleted file mode 100644 index 9a5f0362c93..00000000000 --- a/docs-devsite/firestore_lite.pipelinesource.md +++ /dev/null @@ -1,109 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# PipelineSource class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Represents the source of a Firestore [Pipeline](./firestore_.pipeline.md#pipeline_class). - -Signature: - -```typescript -export declare class PipelineSource -``` - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [collection(collectionPath)](./firestore_lite.pipelinesource.md#pipelinesourcecollection) | | (BETA) | -| [collectionGroup(collectionId)](./firestore_lite.pipelinesource.md#pipelinesourcecollectiongroup) | | (BETA) | -| [database()](./firestore_lite.pipelinesource.md#pipelinesourcedatabase) | | (BETA) | -| [documents(docs)](./firestore_lite.pipelinesource.md#pipelinesourcedocuments) | | (BETA) | - -## PipelineSource.collection() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -collection(collectionPath: string): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| collectionPath | string | | - -Returns: - -[Pipeline](./firestore_lite.pipeline.md#pipeline_class) - -## PipelineSource.collectionGroup() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -collectionGroup(collectionId: string): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| collectionId | string | | - -Returns: - -[Pipeline](./firestore_lite.pipeline.md#pipeline_class) - -## PipelineSource.database() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -database(): Pipeline; -``` -Returns: - -[Pipeline](./firestore_lite.pipeline.md#pipeline_class) - -## PipelineSource.documents() - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -documents(docs: DocumentReference[]): Pipeline; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| docs | [DocumentReference](./firestore_lite.documentreference.md#documentreference_class)\[\] | | - -Returns: - -[Pipeline](./firestore_lite.pipeline.md#pipeline_class) - diff --git a/docs-devsite/firestore_lite.query.md b/docs-devsite/firestore_lite.query.md index 210d2b0895e..48beee0e10c 100644 --- a/docs-devsite/firestore_lite.query.md +++ b/docs-devsite/firestore_lite.query.md @@ -36,7 +36,6 @@ export declare class QueryNewDbModelType and your custom type NewAppModelType. | @@ -80,19 +79,6 @@ The type of this Firestore reference. readonly type: 'query' | 'collection'; ``` -## Query.pipeline() - -Pipeline query. - -Signature: - -```typescript -pipeline(): Pipeline; -``` -Returns: - -[Pipeline](./firestore_lite.pipeline.md#pipeline_class) - ## Query.withConverter() Removes the current converter. diff --git a/docs-devsite/firestore_lite.querycompositefilterconstraint.md b/docs-devsite/firestore_lite.querycompositefilterconstraint.md index c32cfa1b5a0..1db79b79522 100644 --- a/docs-devsite/firestore_lite.querycompositefilterconstraint.md +++ b/docs-devsite/firestore_lite.querycompositefilterconstraint.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # QueryCompositeFilterConstraint class -A `QueryCompositeFilterConstraint` is used to narrow the set of documents returned by a Firestore query by performing the logical OR or AND of multiple [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class)s or [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class)s. `QueryCompositeFilterConstraint`s are created by invoking or and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the `QueryCompositeFilterConstraint`. +A `QueryCompositeFilterConstraint` is used to narrow the set of documents returned by a Firestore query by performing the logical OR or AND of multiple [QueryFieldFilterConstraint](./firestore_.queryfieldfilterconstraint.md#queryfieldfilterconstraint_class)s or [QueryCompositeFilterConstraint](./firestore_.querycompositefilterconstraint.md#querycompositefilterconstraint_class)s. `QueryCompositeFilterConstraint`s are created by invoking [or()](./firestore_.md#or_e72c712) or [and()](./firestore_.md#and_e72c712) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains the `QueryCompositeFilterConstraint`. Signature: diff --git a/docs-devsite/firestore_lite.regexcontains.md b/docs-devsite/firestore_lite.regexcontains.md deleted file mode 100644 index aaf069cde7f..00000000000 --- a/docs-devsite/firestore_lite.regexcontains.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# RegexContains class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class RegexContains extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr, pattern)](./firestore_lite.regexcontains.md#regexcontainsconstructor) | | (BETA) Constructs a new instance of the RegexContains class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_lite.regexcontains.md#regexcontainsfilterable) | | true | (BETA) | - -## RegexContains.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `RegexContains` class - -Signature: - -```typescript -constructor(expr: Constant, pattern: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | | - -## RegexContains.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.regexmatch.md b/docs-devsite/firestore_lite.regexmatch.md deleted file mode 100644 index 78d9029e3a9..00000000000 --- a/docs-devsite/firestore_lite.regexmatch.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# RegexMatch class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class RegexMatch extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr, pattern)](./firestore_lite.regexmatch.md#regexmatchconstructor) | | (BETA) Constructs a new instance of the RegexMatch class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_lite.regexmatch.md#regexmatchfilterable) | | true | (BETA) | - -## RegexMatch.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `RegexMatch` class - -Signature: - -```typescript -constructor(expr: Constant, pattern: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | | -| pattern | [Constant](./firestore_lite.constant.md#constant_class) | | - -## RegexMatch.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.replaceall.md b/docs-devsite/firestore_lite.replaceall.md deleted file mode 100644 index d318d936b96..00000000000 --- a/docs-devsite/firestore_lite.replaceall.md +++ /dev/null @@ -1,50 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ReplaceAll class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ReplaceAll extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value, find, replace)](./firestore_lite.replaceall.md#replaceallconstructor) | | (BETA) Constructs a new instance of the ReplaceAll class | - -## ReplaceAll.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ReplaceAll` class - -Signature: - -```typescript -constructor(value: Constant, find: Constant, replace: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_lite.constant.md#constant_class) | | -| find | [Constant](./firestore_lite.constant.md#constant_class) | | -| replace | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.replacefirst.md b/docs-devsite/firestore_lite.replacefirst.md deleted file mode 100644 index d8e83dd2140..00000000000 --- a/docs-devsite/firestore_lite.replacefirst.md +++ /dev/null @@ -1,50 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ReplaceFirst class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ReplaceFirst extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value, find, replace)](./firestore_lite.replacefirst.md#replacefirstconstructor) | | (BETA) Constructs a new instance of the ReplaceFirst class | - -## ReplaceFirst.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ReplaceFirst` class - -Signature: - -```typescript -constructor(value: Constant, find: Constant, replace: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_lite.constant.md#constant_class) | | -| find | [Constant](./firestore_lite.constant.md#constant_class) | | -| replace | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.reverse.md b/docs-devsite/firestore_lite.reverse.md deleted file mode 100644 index 65b4d256a5c..00000000000 --- a/docs-devsite/firestore_lite.reverse.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Reverse class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Reverse extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value)](./firestore_lite.reverse.md#reverseconstructor) | | (BETA) Constructs a new instance of the Reverse class | - -## Reverse.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Reverse` class - -Signature: - -```typescript -constructor(value: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.select.md b/docs-devsite/firestore_lite.select.md deleted file mode 100644 index 6221a7c41a7..00000000000 --- a/docs-devsite/firestore_lite.select.md +++ /dev/null @@ -1,64 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Select class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Select implements Stage -``` -Implements: [Stage](./firestore_lite.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(projections)](./firestore_lite.select.md#selectconstructor) | | (BETA) Constructs a new instance of the Select class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_lite.select.md#selectname) | | string | (BETA) | - -## Select.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Select` class - -Signature: - -```typescript -constructor(projections: Map); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| projections | Map<string, [Constant](./firestore_lite.constant.md#constant_class)> | | - -## Select.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_lite.selectable.md b/docs-devsite/firestore_lite.selectable.md deleted file mode 100644 index aeb75036db3..00000000000 --- a/docs-devsite/firestore_lite.selectable.md +++ /dev/null @@ -1,39 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Selectable interface -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -An interface that represents a selectable expression. - -Signature: - -```typescript -export declare interface Selectable -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [selectable](./firestore_lite.selectable.md#selectableselectable) | true | (BETA) | - -## Selectable.selectable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -selectable: true; -``` diff --git a/docs-devsite/firestore_lite.sort.md b/docs-devsite/firestore_lite.sort.md deleted file mode 100644 index f387044b540..00000000000 --- a/docs-devsite/firestore_lite.sort.md +++ /dev/null @@ -1,64 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Sort class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Sort implements Stage -``` -Implements: [Stage](./firestore_lite.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(orders)](./firestore_lite.sort.md#sortconstructor) | | (BETA) Constructs a new instance of the Sort class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_lite.sort.md#sortname) | | string | (BETA) | - -## Sort.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Sort` class - -Signature: - -```typescript -constructor(orders: Ordering[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| orders | [Ordering](./firestore_lite.ordering.md#ordering_class)\[\] | | - -## Sort.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_lite.stage.md b/docs-devsite/firestore_lite.stage.md deleted file mode 100644 index 9aa24210656..00000000000 --- a/docs-devsite/firestore_lite.stage.md +++ /dev/null @@ -1,38 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Stage interface -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare interface Stage -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [name](./firestore_lite.stage.md#stagename) | string | (BETA) | - -## Stage.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_lite.startswith.md b/docs-devsite/firestore_lite.startswith.md deleted file mode 100644 index a30cdae497a..00000000000 --- a/docs-devsite/firestore_lite.startswith.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# StartsWith class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class StartsWith extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr, prefix)](./firestore_lite.startswith.md#startswithconstructor) | | (BETA) Constructs a new instance of the StartsWith class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_lite.startswith.md#startswithfilterable) | | true | (BETA) | - -## StartsWith.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `StartsWith` class - -Signature: - -```typescript -constructor(expr: Constant, prefix: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | | -| prefix | [Constant](./firestore_lite.constant.md#constant_class) | | - -## StartsWith.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.strconcat.md b/docs-devsite/firestore_lite.strconcat.md deleted file mode 100644 index f3e1ad2bcde..00000000000 --- a/docs-devsite/firestore_lite.strconcat.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# StrConcat class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class StrConcat extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(first, rest)](./firestore_lite.strconcat.md#strconcatconstructor) | | (BETA) Constructs a new instance of the StrConcat class | - -## StrConcat.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `StrConcat` class - -Signature: - -```typescript -constructor(first: Constant, rest: Constant[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| first | [Constant](./firestore_lite.constant.md#constant_class) | | -| rest | [Constant](./firestore_lite.constant.md#constant_class)\[\] | | - diff --git a/docs-devsite/firestore_lite.strcontains.md b/docs-devsite/firestore_lite.strcontains.md deleted file mode 100644 index 36fed4dd005..00000000000 --- a/docs-devsite/firestore_lite.strcontains.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# StrContains class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class StrContains extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr, substring)](./firestore_lite.strcontains.md#strcontainsconstructor) | | (BETA) Constructs a new instance of the StrContains class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_lite.strcontains.md#strcontainsfilterable) | | true | (BETA) | - -## StrContains.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `StrContains` class - -Signature: - -```typescript -constructor(expr: Constant, substring: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | | -| substring | [Constant](./firestore_lite.constant.md#constant_class) | | - -## StrContains.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` diff --git a/docs-devsite/firestore_lite.subtract.md b/docs-devsite/firestore_lite.subtract.md deleted file mode 100644 index 7d692f3c779..00000000000 --- a/docs-devsite/firestore_lite.subtract.md +++ /dev/null @@ -1,49 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Subtract class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Subtract extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(left, right)](./firestore_lite.subtract.md#subtractconstructor) | | (BETA) Constructs a new instance of the Subtract class | - -## Subtract.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Subtract` class - -Signature: - -```typescript -constructor(left: Constant, right: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| left | [Constant](./firestore_lite.constant.md#constant_class) | | -| right | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.sum.md b/docs-devsite/firestore_lite.sum.md deleted file mode 100644 index 0f65e6aa601..00000000000 --- a/docs-devsite/firestore_lite.sum.md +++ /dev/null @@ -1,67 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Sum class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Sum extends FirestoreFunction implements Accumulator -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [Accumulator](./firestore_lite.accumulator.md#accumulator_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value, distinct)](./firestore_lite.sum.md#sumconstructor) | | (BETA) Constructs a new instance of the Sum class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [accumulator](./firestore_lite.sum.md#sumaccumulator) | | true | (BETA) | - -## Sum.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Sum` class - -Signature: - -```typescript -constructor(value: Constant, distinct: boolean); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_lite.constant.md#constant_class) | | -| distinct | boolean | | - -## Sum.accumulator - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -accumulator: true; -``` diff --git a/docs-devsite/firestore_lite.timestampadd.md b/docs-devsite/firestore_lite.timestampadd.md deleted file mode 100644 index 10f90f438e0..00000000000 --- a/docs-devsite/firestore_lite.timestampadd.md +++ /dev/null @@ -1,50 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# TimestampAdd class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class TimestampAdd extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(timestamp, unit, amount)](./firestore_lite.timestampadd.md#timestampaddconstructor) | | (BETA) Constructs a new instance of the TimestampAdd class | - -## TimestampAdd.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `TimestampAdd` class - -Signature: - -```typescript -constructor(timestamp: Constant, unit: Constant, amount: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| timestamp | [Constant](./firestore_lite.constant.md#constant_class) | | -| unit | [Constant](./firestore_lite.constant.md#constant_class) | | -| amount | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.timestampsub.md b/docs-devsite/firestore_lite.timestampsub.md deleted file mode 100644 index 076e525cf10..00000000000 --- a/docs-devsite/firestore_lite.timestampsub.md +++ /dev/null @@ -1,50 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# TimestampSub class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class TimestampSub extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(timestamp, unit, amount)](./firestore_lite.timestampsub.md#timestampsubconstructor) | | (BETA) Constructs a new instance of the TimestampSub class | - -## TimestampSub.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `TimestampSub` class - -Signature: - -```typescript -constructor(timestamp: Constant, unit: Constant, amount: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| timestamp | [Constant](./firestore_lite.constant.md#constant_class) | | -| unit | [Constant](./firestore_lite.constant.md#constant_class) | | -| amount | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.timestamptounixmicros.md b/docs-devsite/firestore_lite.timestamptounixmicros.md deleted file mode 100644 index e9f398659a7..00000000000 --- a/docs-devsite/firestore_lite.timestamptounixmicros.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# TimestampToUnixMicros class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class TimestampToUnixMicros extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(input)](./firestore_lite.timestamptounixmicros.md#timestamptounixmicrosconstructor) | | (BETA) Constructs a new instance of the TimestampToUnixMicros class | - -## TimestampToUnixMicros.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `TimestampToUnixMicros` class - -Signature: - -```typescript -constructor(input: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| input | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.timestamptounixmillis.md b/docs-devsite/firestore_lite.timestamptounixmillis.md deleted file mode 100644 index b354dcc5585..00000000000 --- a/docs-devsite/firestore_lite.timestamptounixmillis.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# TimestampToUnixMillis class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class TimestampToUnixMillis extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(input)](./firestore_lite.timestamptounixmillis.md#timestamptounixmillisconstructor) | | (BETA) Constructs a new instance of the TimestampToUnixMillis class | - -## TimestampToUnixMillis.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `TimestampToUnixMillis` class - -Signature: - -```typescript -constructor(input: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| input | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.timestamptounixseconds.md b/docs-devsite/firestore_lite.timestamptounixseconds.md deleted file mode 100644 index 2275fe6ebac..00000000000 --- a/docs-devsite/firestore_lite.timestamptounixseconds.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# TimestampToUnixSeconds class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class TimestampToUnixSeconds extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(input)](./firestore_lite.timestamptounixseconds.md#timestamptounixsecondsconstructor) | | (BETA) Constructs a new instance of the TimestampToUnixSeconds class | - -## TimestampToUnixSeconds.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `TimestampToUnixSeconds` class - -Signature: - -```typescript -constructor(input: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| input | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.tolower.md b/docs-devsite/firestore_lite.tolower.md deleted file mode 100644 index 49128adf612..00000000000 --- a/docs-devsite/firestore_lite.tolower.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ToLower class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ToLower extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr)](./firestore_lite.tolower.md#tolowerconstructor) | | (BETA) Constructs a new instance of the ToLower class | - -## ToLower.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ToLower` class - -Signature: - -```typescript -constructor(expr: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.toupper.md b/docs-devsite/firestore_lite.toupper.md deleted file mode 100644 index 120c81d05bd..00000000000 --- a/docs-devsite/firestore_lite.toupper.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ToUpper class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class ToUpper extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr)](./firestore_lite.toupper.md#toupperconstructor) | | (BETA) Constructs a new instance of the ToUpper class | - -## ToUpper.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `ToUpper` class - -Signature: - -```typescript -constructor(expr: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.trim.md b/docs-devsite/firestore_lite.trim.md deleted file mode 100644 index 8de73fd1667..00000000000 --- a/docs-devsite/firestore_lite.trim.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Trim class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Trim extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(expr)](./firestore_lite.trim.md#trimconstructor) | | (BETA) Constructs a new instance of the Trim class | - -## Trim.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Trim` class - -Signature: - -```typescript -constructor(expr: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| expr | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.unixmicrostotimestamp.md b/docs-devsite/firestore_lite.unixmicrostotimestamp.md deleted file mode 100644 index a2e03a5dedf..00000000000 --- a/docs-devsite/firestore_lite.unixmicrostotimestamp.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# UnixMicrosToTimestamp class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class UnixMicrosToTimestamp extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(input)](./firestore_lite.unixmicrostotimestamp.md#unixmicrostotimestampconstructor) | | (BETA) Constructs a new instance of the UnixMicrosToTimestamp class | - -## UnixMicrosToTimestamp.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `UnixMicrosToTimestamp` class - -Signature: - -```typescript -constructor(input: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| input | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.unixmillistotimestamp.md b/docs-devsite/firestore_lite.unixmillistotimestamp.md deleted file mode 100644 index a48df96c0e9..00000000000 --- a/docs-devsite/firestore_lite.unixmillistotimestamp.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# UnixMillisToTimestamp class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class UnixMillisToTimestamp extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(input)](./firestore_lite.unixmillistotimestamp.md#unixmillistotimestampconstructor) | | (BETA) Constructs a new instance of the UnixMillisToTimestamp class | - -## UnixMillisToTimestamp.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `UnixMillisToTimestamp` class - -Signature: - -```typescript -constructor(input: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| input | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.unixsecondstotimestamp.md b/docs-devsite/firestore_lite.unixsecondstotimestamp.md deleted file mode 100644 index 99ad2f71285..00000000000 --- a/docs-devsite/firestore_lite.unixsecondstotimestamp.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# UnixSecondsToTimestamp class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class UnixSecondsToTimestamp extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(input)](./firestore_lite.unixsecondstotimestamp.md#unixsecondstotimestampconstructor) | | (BETA) Constructs a new instance of the UnixSecondsToTimestamp class | - -## UnixSecondsToTimestamp.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `UnixSecondsToTimestamp` class - -Signature: - -```typescript -constructor(input: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| input | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.vectorlength.md b/docs-devsite/firestore_lite.vectorlength.md deleted file mode 100644 index 58636d6f95a..00000000000 --- a/docs-devsite/firestore_lite.vectorlength.md +++ /dev/null @@ -1,48 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# VectorLength class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class VectorLength extends FirestoreFunction -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(value)](./firestore_lite.vectorlength.md#vectorlengthconstructor) | | (BETA) Constructs a new instance of the VectorLength class | - -## VectorLength.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `VectorLength` class - -Signature: - -```typescript -constructor(value: Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| value | [Constant](./firestore_lite.constant.md#constant_class) | | - diff --git a/docs-devsite/firestore_lite.where.md b/docs-devsite/firestore_lite.where.md deleted file mode 100644 index 1d3674f2659..00000000000 --- a/docs-devsite/firestore_lite.where.md +++ /dev/null @@ -1,64 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Where class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Where implements Stage -``` -Implements: [Stage](./firestore_lite.stage.md#stage_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(condition)](./firestore_lite.where.md#whereconstructor) | | (BETA) Constructs a new instance of the Where class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [name](./firestore_lite.where.md#wherename) | | string | (BETA) | - -## Where.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Where` class - -Signature: - -```typescript -constructor(condition: FilterCondition & Constant); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| condition | [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) & [Constant](./firestore_lite.constant.md#constant_class) | | - -## Where.name - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -name: string; -``` diff --git a/docs-devsite/firestore_lite.xor.md b/docs-devsite/firestore_lite.xor.md deleted file mode 100644 index 2a94acbe570..00000000000 --- a/docs-devsite/firestore_lite.xor.md +++ /dev/null @@ -1,66 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# Xor class -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - - -Signature: - -```typescript -export declare class Xor extends FirestoreFunction implements FilterCondition -``` -Extends: [FirestoreFunction](./firestore_lite.firestorefunction.md#firestorefunction_class) - -Implements: [FilterCondition](./firestore_lite.filtercondition.md#filtercondition_interface) - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(conditions)](./firestore_lite.xor.md#xorconstructor) | | (BETA) Constructs a new instance of the Xor class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [filterable](./firestore_lite.xor.md#xorfilterable) | | true | (BETA) | - -## Xor.(constructor) - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Constructs a new instance of the `Xor` class - -Signature: - -```typescript -constructor(conditions: FilterExpr[]); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| conditions | [FilterExpr](./firestore_lite.md#filterexpr)\[\] | | - -## Xor.filterable - -> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - -Signature: - -```typescript -filterable: true; -``` From 703b18f9138d6ab34c0b2402bc4f3962f014d84f Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 13 Nov 2024 16:19:43 -0700 Subject: [PATCH 38/59] revert and/or overloads --- common/api-review/firestore-lite.api.md | 32 +--- common/api-review/firestore.api.md | 38 ++-- packages/firestore/lite/index.ts | 8 +- packages/firestore/src/api.ts | 12 +- .../src/api/database_augmentation.ts | 10 - packages/firestore/src/api/filter.ts | 2 + packages/firestore/src/core/pipeline-util.ts | 37 ++-- .../src/lite-api/database_augmentation.ts | 10 - .../firestore/src/lite-api/expressions.ts | 56 +++++- packages/firestore/src/lite-api/overloads.ts | 172 ------------------ packages/firestore/src/lite-api/query.ts | 48 +++++ .../test/integration/api/pipeline.test.ts | 24 +-- 12 files changed, 156 insertions(+), 293 deletions(-) delete mode 100644 packages/firestore/src/lite-api/overloads.ts diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 165385bf890..ee77620fc7e 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -100,16 +100,9 @@ export class And extends FirestoreFunction implements FilterCondition { filterable: true; } -// @beta -export function and(left: FilterExpr, ...right: FilterExpr[]): And; - // @public export function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; -// @public (undocumented) -export namespace and { -} - // @beta (undocumented) export class ArrayConcat extends FirestoreFunction { constructor(array: Constant, elements: Constant[]); @@ -221,12 +214,6 @@ export class Avg extends FirestoreFunction implements Accumulator { accumulator: true; } -// @beta -export function avgFunction(value: Constant): Avg; - -// @beta -export function avgFunction(value: string): Avg; - // @beta (undocumented) export class ByteLength extends FirestoreFunction { constructor(value: Constant); @@ -1530,16 +1517,9 @@ export class Or extends FirestoreFunction implements FilterCondition { filterable: true; } -// @beta -export function or(left: FilterExpr, ...right: FilterExpr[]): Or; - // @public export function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; -// @public (undocumented) -export namespace or { -} - // @public export function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryOrderByConstraint; @@ -1960,12 +1940,6 @@ export class Sum extends FirestoreFunction implements Accumulator { // @public export function sum(field: string | FieldPath): AggregateField; -// @beta -export function sumFunction(value: Constant): Sum; - -// @beta -export function sumFunction(value: string): Sum; - // @public export function terminate(firestore: Firestore): Promise; @@ -2214,8 +2188,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9243:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9244:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9273:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9177:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9178:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9207:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index d8beb999ddd..025073704e4 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -100,15 +100,11 @@ export class And extends FirestoreFunction implements FilterCondition { filterable: true; } -// @beta -export function and(left: FilterExpr, ...right: FilterExpr[]): And; - // @public export function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; -// @public (undocumented) -export namespace and { -} +// @beta +export function andFunction(left: FilterExpr, ...right: FilterExpr[]): And; // @beta (undocumented) export class ArrayConcat extends FirestoreFunction { @@ -222,10 +218,10 @@ export class Avg extends FirestoreFunction implements Accumulator { } // @beta -export function avg(value: Constant): Avg; +export function avgFunction(value: Constant): Avg; // @beta -export function avg(value: string): Avg; +export function avgFunction(value: string): Avg; // @beta (undocumented) export class ByteLength extends FirestoreFunction { @@ -461,12 +457,12 @@ export function count(): AggregateField; export function countAll(): Count; // @beta -export function countExpression(value: Constant): Count; +export function countFunction(value: Constant): Count; -// Warning: (ae-incompatible-release-tags) The symbol "countExpression" is marked as @public, but its signature references "Count" which is marked as @beta +// Warning: (ae-incompatible-release-tags) The symbol "countFunction" is marked as @public, but its signature references "Count" which is marked as @beta // // @public -export function countExpression(value: string): Count; +export function countFunction(value: string): Count; // @beta (undocumented) export class DatabaseSource implements Stage { @@ -1745,16 +1741,9 @@ export class Or extends FirestoreFunction implements FilterCondition { filterable: true; } -// @beta -export function or(left: FilterExpr, ...right: FilterExpr[]): Or; - // @public export function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; -// @public (undocumented) -export namespace or { -} - // @public export function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryOrderByConstraint; @@ -1766,6 +1755,9 @@ export class Ordering { constructor(expr: Constant, direction: 'ascending' | 'descending'); } +// @beta +export function orFunction(left: FilterExpr, ...right: FilterExpr[]): Or; + // @public export type PartialWithFieldValue = Partial | (T extends Primitive ? T : T extends {} ? { [K in keyof T]?: PartialWithFieldValue | FieldValue; @@ -2226,10 +2218,10 @@ export class Sum extends FirestoreFunction implements Accumulator { export function sum(field: string | FieldPath): AggregateField; // @beta -export function sumExpression(value: Constant): Sum; +export function sumFunction(value: Constant): Sum; // @beta -export function sumExpression(value: string): Sum; +export function sumFunction(value: string): Sum; // @public export type TaskState = 'Error' | 'Running' | 'Success'; @@ -2490,8 +2482,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10106:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10106:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10133:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10102:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10102:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10129:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/packages/firestore/lite/index.ts b/packages/firestore/lite/index.ts index 7bd1b2ce3db..636eb4c6709 100644 --- a/packages/firestore/lite/index.ts +++ b/packages/firestore/lite/index.ts @@ -189,9 +189,7 @@ export { SelectableExpr, Selectable, FilterCondition, - Accumulator, - sum as sumFunction, - avg as avgFunction + Accumulator } from '../src/lite-api/expressions'; export { @@ -240,9 +238,8 @@ export { queryEqual } from '../src/lite-api/reference'; -export { and, or } from '../src/lite-api/overloads'; - export { + and, endAt, endBefore, startAt, @@ -250,6 +247,7 @@ export { limit, limitToLast, where, + or, orderBy, query, QueryConstraint, diff --git a/packages/firestore/src/api.ts b/packages/firestore/src/api.ts index 9b77311666b..4d33b925706 100644 --- a/packages/firestore/src/api.ts +++ b/packages/firestore/src/api.ts @@ -87,9 +87,11 @@ export { strConcat, mapGet, countAll, - count as countExpression, - sum as sumExpression, - avg, + countFunction, + sumFunction, + avgFunction, + andFunction, + orFunction, min, max, cosineDistance, @@ -183,8 +185,6 @@ export { Accumulator } from './lite-api/expressions'; -export { and, or } from './lite-api/overloads'; - export { aggregateFieldEqual, aggregateQuerySnapshotEqual, @@ -284,10 +284,12 @@ export { } from './api/reference'; export { + and, endAt, endBefore, limit, limitToLast, + or, orderBy, OrderByDirection, query, diff --git a/packages/firestore/src/api/database_augmentation.ts b/packages/firestore/src/api/database_augmentation.ts index b59f160c1ba..0eb8c91a034 100644 --- a/packages/firestore/src/api/database_augmentation.ts +++ b/packages/firestore/src/api/database_augmentation.ts @@ -15,8 +15,6 @@ * limitations under the License. */ -import { And, FilterExpr, Or } from '../lite-api/expressions'; -import { and, or } from '../lite-api/overloads'; import { Pipeline } from '../lite-api/pipeline'; import { PipelineSource } from '../lite-api/pipeline-source'; import { newUserDataReader } from '../lite-api/user_data_reader'; @@ -56,12 +54,4 @@ export function useFirestorePipelines(): void { return pipeline; }; - - and._andFunction = function (left: FilterExpr, ...right: FilterExpr[]): And { - return new And([left, ...right]); - }; - - or._orFunction = function (left: FilterExpr, ...right: FilterExpr[]): Or { - return new Or([left, ...right]); - }; } diff --git a/packages/firestore/src/api/filter.ts b/packages/firestore/src/api/filter.ts index 99906e31db8..035aca66aba 100644 --- a/packages/firestore/src/api/filter.ts +++ b/packages/firestore/src/api/filter.ts @@ -16,12 +16,14 @@ */ export { + and, endAt, endBefore, startAfter, startAt, limitToLast, limit, + or, orderBy, OrderByDirection, where, diff --git a/packages/firestore/src/core/pipeline-util.ts b/packages/firestore/src/core/pipeline-util.ts index 5f0f418d2e4..732d2963fcf 100644 --- a/packages/firestore/src/core/pipeline-util.ts +++ b/packages/firestore/src/core/pipeline-util.ts @@ -20,9 +20,10 @@ import { Expr, Field, FilterCondition, - not + not, + andFunction, + orFunction } from '../lite-api/expressions'; -import { and, or } from '../lite-api/overloads'; import { isNanValue, isNullValue } from '../model/values'; import { ArrayValue as ProtoArrayValue, @@ -178,51 +179,51 @@ export function toPipelineFilterCondition( const field = Field.of(f.field.toString()); if (isNanValue(f.value)) { if (f.op === Operator.EQUAL) { - return and(field.exists(), field.isNaN()); + return andFunction(field.exists(), field.isNaN()); } else { - return and(field.exists(), not(field.isNaN())); + return andFunction(field.exists(), not(field.isNaN())); } } else if (isNullValue(f.value)) { if (f.op === Operator.EQUAL) { - return and(field.exists(), field.eq(null)); + return andFunction(field.exists(), field.eq(null)); } else { - return and(field.exists(), not(field.eq(null))); + return andFunction(field.exists(), not(field.eq(null))); } } else { // Comparison filters const value = f.value; switch (f.op) { case Operator.LESS_THAN: - return and(field.exists(), field.lt(value)); + return andFunction(field.exists(), field.lt(value)); case Operator.LESS_THAN_OR_EQUAL: - return and(field.exists(), field.lte(value)); + return andFunction(field.exists(), field.lte(value)); case Operator.GREATER_THAN: - return and(field.exists(), field.gt(value)); + return andFunction(field.exists(), field.gt(value)); case Operator.GREATER_THAN_OR_EQUAL: - return and(field.exists(), field.gte(value)); + return andFunction(field.exists(), field.gte(value)); case Operator.EQUAL: - return and(field.exists(), field.eq(value)); + return andFunction(field.exists(), field.eq(value)); case Operator.NOT_EQUAL: - return and(field.exists(), field.neq(value)); + return andFunction(field.exists(), field.neq(value)); case Operator.ARRAY_CONTAINS: - return and(field.exists(), field.arrayContains(value)); + return andFunction(field.exists(), field.arrayContains(value)); case Operator.IN: { const values = value?.arrayValue?.values?.map((val: any) => Constant.of(val) ); - return and(field.exists(), field.in(...values!)); + return andFunction(field.exists(), field.in(...values!)); } case Operator.ARRAY_CONTAINS_ANY: { const values = value?.arrayValue?.values?.map((val: any) => Constant.of(val) ); - return and(field.exists(), field.arrayContainsAny(values!)); + return andFunction(field.exists(), field.arrayContainsAny(values!)); } case Operator.NOT_IN: { const values = value?.arrayValue?.values?.map((val: any) => Constant.of(val) ); - return and(field.exists(), not(field.in(...values!))); + return andFunction(field.exists(), not(field.in(...values!))); } default: fail('Unexpected operator'); @@ -234,13 +235,13 @@ export function toPipelineFilterCondition( const conditions = f .getFilters() .map(f => toPipelineFilterCondition(f)); - return and(conditions[0], ...conditions.slice(1)); + return andFunction(conditions[0], ...conditions.slice(1)); } case CompositeOperator.OR: { const conditions = f .getFilters() .map(f => toPipelineFilterCondition(f)); - return or(conditions[0], ...conditions.slice(1)); + return orFunction(conditions[0], ...conditions.slice(1)); } default: fail('Unexpected operator'); diff --git a/packages/firestore/src/lite-api/database_augmentation.ts b/packages/firestore/src/lite-api/database_augmentation.ts index a2c3652bd71..14b9cf101c5 100644 --- a/packages/firestore/src/lite-api/database_augmentation.ts +++ b/packages/firestore/src/lite-api/database_augmentation.ts @@ -18,8 +18,6 @@ import { DocumentKey } from '../model/document_key'; import { Firestore } from './database'; -import { And, FilterExpr, Or } from './expressions'; -import { or, and } from './overloads'; import { Pipeline } from './pipeline'; import { PipelineSource } from './pipeline-source'; import { DocumentReference, Query } from './reference'; @@ -57,12 +55,4 @@ export function useFirestorePipelines(): void { return pipeline; }; - - and._andFunction = function (left: FilterExpr, ...right: FilterExpr[]): And { - return new And([left, ...right]); - }; - - or._orFunction = function (left: FilterExpr, ...right: FilterExpr[]): Or { - return new Or([left, ...right]); - }; } diff --git a/packages/firestore/src/lite-api/expressions.ts b/packages/firestore/src/lite-api/expressions.ts index 336a7b7d2b1..26a2f7c617c 100644 --- a/packages/firestore/src/lite-api/expressions.ts +++ b/packages/firestore/src/lite-api/expressions.ts @@ -5686,7 +5686,7 @@ export function countAll(): Count { * @param value The expression to count. * @return A new {@code Accumulator} representing the 'count' aggregation. */ -export function count(value: Expr): Count; +export function countFunction(value: Expr): Count; /** * Creates an aggregation that counts the number of stage inputs with valid evaluations of the @@ -5700,8 +5700,8 @@ export function count(value: Expr): Count; * @param value The name of the field to count. * @return A new {@code Accumulator} representing the 'count' aggregation. */ -export function count(value: string): Count; -export function count(value: Expr | string): Count { +export function countFunction(value: string): Count; +export function countFunction(value: Expr | string): Count { const exprValue = value instanceof Expr ? value : Field.of(value); return new Count(exprValue, false); } @@ -5720,7 +5720,7 @@ export function count(value: Expr | string): Count { * @param value The expression to sum up. * @return A new {@code Accumulator} representing the 'sum' aggregation. */ -export function sum(value: Expr): Sum; +export function sumFunction(value: Expr): Sum; /** * @beta @@ -5736,8 +5736,8 @@ export function sum(value: Expr): Sum; * @param value The name of the field containing numeric values to sum up. * @return A new {@code Accumulator} representing the 'sum' aggregation. */ -export function sum(value: string): Sum; -export function sum(value: Expr | string): Sum { +export function sumFunction(value: string): Sum; +export function sumFunction(value: Expr | string): Sum { const exprValue = value instanceof Expr ? value : Field.of(value); return new Sum(exprValue, false); } @@ -5756,7 +5756,7 @@ export function sum(value: Expr | string): Sum { * @param value The expression representing the values to average. * @return A new {@code Accumulator} representing the 'avg' aggregation. */ -export function avg(value: Expr): Avg; +export function avgFunction(value: Expr): Avg; /** * @beta @@ -5772,8 +5772,8 @@ export function avg(value: Expr): Avg; * @param value The name of the field containing numeric values to average. * @return A new {@code Accumulator} representing the 'avg' aggregation. */ -export function avg(value: string): Avg; -export function avg(value: Expr | string): Avg { +export function avgFunction(value: string): Avg; +export function avgFunction(value: Expr | string): Avg { const exprValue = value instanceof Expr ? value : Field.of(value); return new Avg(exprValue, false); } @@ -6626,6 +6626,44 @@ export function genericFunction( return new FirestoreFunction(name, params); } +/** + * @beta + * + * Creates an expression that performs a logical 'AND' operation on multiple filter conditions. + * + * ```typescript + * // Check if the 'age' field is greater than 18 AND the 'city' field is "London" AND + * // the 'status' field is "active" + * const condition = and(gt("age", 18), eq("city", "London"), eq("status", "active")); + * ``` + * + * @param left The first filter condition. + * @param right Additional filter conditions to 'AND' together. + * @return A new {@code Expr} representing the logical 'AND' operation. + */ +export function andFunction(left: FilterExpr, ...right: FilterExpr[]): And { + return new And([left, ...right]); +} + +/** + * @beta + * + * Creates an expression that performs a logical 'OR' operation on multiple filter conditions. + * + * ```typescript + * // Check if the 'age' field is greater than 18 OR the 'city' field is "London" OR + * // the 'status' field is "active" + * const condition = or(gt("age", 18), eq("city", "London"), eq("status", "active")); + * ``` + * + * @param left The first filter condition. + * @param right Additional filter conditions to 'OR' together. + * @return A new {@code Expr} representing the logical 'OR' operation. + */ +export function orFunction(left: FilterExpr, ...right: FilterExpr[]): Or { + return new Or([left, ...right]); +} + /** * @beta * diff --git a/packages/firestore/src/lite-api/overloads.ts b/packages/firestore/src/lite-api/overloads.ts deleted file mode 100644 index 6a4b87e96c5..00000000000 --- a/packages/firestore/src/lite-api/overloads.ts +++ /dev/null @@ -1,172 +0,0 @@ -/** - * @license - * Copyright 2024 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { CompositeOperator } from '../core/filter'; - -import { And, FilterExpr, Or } from './expressions'; -import { - QueryCompositeFilterConstraint, - QueryConstraint, - QueryFilterConstraint, - validateQueryFilterConstraint -} from './query'; - -/** - * @beta - * - * Creates an expression that performs a logical 'OR' operation on multiple filter conditions. - * - * ```typescript - * // Check if the 'age' field is greater than 18 OR the 'city' field is "London" OR - * // the 'status' field is "active" - * const condition = or(gt("age", 18), eq("city", "London"), eq("status", "active")); - * ``` - * - * @param left The first filter condition. - * @param right Additional filter conditions to 'OR' together. - * @return A new {@code Expr} representing the logical 'OR' operation. - */ -export function or(left: FilterExpr, ...right: FilterExpr[]): Or; - -/** - * Creates a new {@link QueryCompositeFilterConstraint} that is a disjunction of - * the given filter constraints. A disjunction filter includes a document if it - * satisfies any of the given filters. - * - * @param queryConstraints - Optional. The list of - * {@link QueryFilterConstraint}s to perform a disjunction for. These must be - * created with calls to {@link where}, {@link or}, or {@link and}. - * @returns The newly created {@link QueryCompositeFilterConstraint}. - */ -export function or( - ...queryConstraints: QueryFilterConstraint[] -): QueryCompositeFilterConstraint; - -export function or( - leftFilterExprOrQueryConstraint?: FilterExpr | QueryFilterConstraint, - ...right: FilterExpr[] | QueryFilterConstraint[] -): Or | QueryCompositeFilterConstraint { - if (leftFilterExprOrQueryConstraint === undefined) { - return or._orFilters(); - } else if ( - leftFilterExprOrQueryConstraint instanceof QueryConstraint || - leftFilterExprOrQueryConstraint instanceof QueryCompositeFilterConstraint || - leftFilterExprOrQueryConstraint === undefined - ) { - return or._orFilters( - leftFilterExprOrQueryConstraint, - ...(right as QueryFilterConstraint[]) - ); - } else { - // @ts-ignore - return or._orFunction(leftFilterExprOrQueryConstraint, ...right); - } -} - -or._orFilters = function ( - ...queryConstraints: QueryFilterConstraint[] -): QueryCompositeFilterConstraint { - // Only support QueryFilterConstraints - queryConstraints.forEach(queryConstraint => - validateQueryFilterConstraint('or', queryConstraint) - ); - - return QueryCompositeFilterConstraint._create( - CompositeOperator.OR, - queryConstraints as QueryFilterConstraint[] - ); -}; - -or._orFunction = function (left: FilterExpr, ...right: FilterExpr[]): Or { - throw new Error( - 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' - ); -}; - -/** - * @beta - * - * Creates an expression that performs a logical 'AND' operation on multiple filter conditions. - * - * ```typescript - * // Check if the 'age' field is greater than 18 AND the 'city' field is "London" AND - * // the 'status' field is "active" - * const condition = and(gt("age", 18), eq("city", "London"), eq("status", "active")); - * ``` - * - * @param left The first filter condition. - * @param right Additional filter conditions to 'AND' together. - * @return A new {@code Expr} representing the logical 'AND' operation. - */ -export function and(left: FilterExpr, ...right: FilterExpr[]): And; - -/** - * Creates a new {@link QueryCompositeFilterConstraint} that is a conjunction of - * the given filter constraints. A conjunction filter includes a document if it - * satisfies all of the given filters. - * - * @param queryConstraints - Optional. The list of - * {@link QueryFilterConstraint}s to perform a conjunction for. These must be - * created with calls to {@link where}, {@link or}, or {@link and}. - * @returns The newly created {@link QueryCompositeFilterConstraint}. - */ -export function and( - ...queryConstraints: QueryFilterConstraint[] -): QueryCompositeFilterConstraint; - -export function and( - leftFilterExprOrQueryConstraint?: FilterExpr | QueryFilterConstraint, - ...right: FilterExpr[] | QueryFilterConstraint[] -): And | QueryCompositeFilterConstraint { - if (leftFilterExprOrQueryConstraint === undefined) { - return and._andFilters(); - } - if ( - leftFilterExprOrQueryConstraint instanceof QueryConstraint || - leftFilterExprOrQueryConstraint === undefined - ) { - return and._andFilters( - leftFilterExprOrQueryConstraint, - ...(right as QueryFilterConstraint[]) - ); - } else { - return and._andFunction( - leftFilterExprOrQueryConstraint as FilterExpr, - ...(right as FilterExpr[]) - ); - } -} - -and._andFilters = function ( - ...queryConstraints: QueryFilterConstraint[] -): QueryCompositeFilterConstraint { - // Only support QueryFilterConstraints - queryConstraints.forEach(queryConstraint => - validateQueryFilterConstraint('and', queryConstraint) - ); - - return QueryCompositeFilterConstraint._create( - CompositeOperator.AND, - queryConstraints as QueryFilterConstraint[] - ); -}; - -and._andFunction = function (left: FilterExpr, ...right: FilterExpr[]): And { - throw new Error( - 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' - ); -}; diff --git a/packages/firestore/src/lite-api/query.ts b/packages/firestore/src/lite-api/query.ts index 16ed4f69a31..f0a357b828c 100644 --- a/packages/firestore/src/lite-api/query.ts +++ b/packages/firestore/src/lite-api/query.ts @@ -367,6 +367,54 @@ export type QueryFilterConstraint = | QueryFieldFilterConstraint | QueryCompositeFilterConstraint; +/** + * Creates a new {@link QueryCompositeFilterConstraint} that is a disjunction of + * the given filter constraints. A disjunction filter includes a document if it + * satisfies any of the given filters. + * + * @param queryConstraints - Optional. The list of + * {@link QueryFilterConstraint}s to perform a disjunction for. These must be + * created with calls to {@link where}, {@link or}, or {@link and}. + * @returns The newly created {@link QueryCompositeFilterConstraint}. + */ +export function or( + ...queryConstraints: QueryFilterConstraint[] +): QueryCompositeFilterConstraint { + // Only support QueryFilterConstraints + queryConstraints.forEach(queryConstraint => + validateQueryFilterConstraint('or', queryConstraint) + ); + + return QueryCompositeFilterConstraint._create( + CompositeOperator.OR, + queryConstraints as QueryFilterConstraint[] + ); +} + +/** + * Creates a new {@link QueryCompositeFilterConstraint} that is a conjunction of + * the given filter constraints. A conjunction filter includes a document if it + * satisfies all of the given filters. + * + * @param queryConstraints - Optional. The list of + * {@link QueryFilterConstraint}s to perform a conjunction for. These must be + * created with calls to {@link where}, {@link or}, or {@link and}. + * @returns The newly created {@link QueryCompositeFilterConstraint}. + */ +export function and( + ...queryConstraints: QueryFilterConstraint[] +): QueryCompositeFilterConstraint { + // Only support QueryFilterConstraints + queryConstraints.forEach(queryConstraint => + validateQueryFilterConstraint('and', queryConstraint) + ); + + return QueryCompositeFilterConstraint._create( + CompositeOperator.AND, + queryConstraints as QueryFilterConstraint[] + ); +} + /** * A `QueryOrderByConstraint` is used to sort the set of documents returned by a * Firestore query. `QueryOrderByConstraint`s are created by invoking diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index 9bdb35251d0..3c4e5a1fa48 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -25,10 +25,10 @@ import { Deferred } from '../../util/promise'; import { _internalPipelineToExecutePipelineRequestProto, add, - and, + andFunction, arrayContains, arrayContainsAny, - avg, + avgFunction, CollectionReference, Constant, cosineDistance, @@ -48,7 +48,7 @@ import { mapGet, neq, not, - or, + orFunction, PipelineResult, regexContains, regexMatch, @@ -290,7 +290,7 @@ apiDescribe.skip('Pipelines', persistence => { .where(eq('genre', 'Science Fiction')) .aggregate( countAll().as('count'), - avg('rating').as('avgRating'), + avgFunction('rating').as('avgRating'), Field.of('rating').max().as('maxRating') ) .execute(); @@ -329,7 +329,7 @@ apiDescribe.skip('Pipelines', persistence => { .pipeline() .where(lt(Field.of('published'), 1984)) .aggregate({ - accumulators: [avg('rating').as('avgRating')], + accumulators: [avgFunction('rating').as('avgRating')], groups: ['genre'] }) .where(gt('avgRating', 4.3)) @@ -390,7 +390,7 @@ apiDescribe.skip('Pipelines', persistence => { it('where with and', async () => { const results = await randomCol .pipeline() - .where(and(gt('rating', 4.5), eq('genre', 'Science Fiction'))) + .where(andFunction(gt('rating', 4.5), eq('genre', 'Science Fiction'))) .execute(); expectResults(results, 'book10'); }); @@ -398,7 +398,7 @@ apiDescribe.skip('Pipelines', persistence => { it('where with or', async () => { const results = await randomCol .pipeline() - .where(or(eq('genre', 'Romance'), eq('genre', 'Dystopian'))) + .where(orFunction(eq('genre', 'Romance'), eq('genre', 'Dystopian'))) .select('title') .execute(); expectResults( @@ -643,7 +643,7 @@ apiDescribe.skip('Pipelines', persistence => { const results = await randomCol .pipeline() .where( - and( + andFunction( gt('rating', 4.2), lte(Field.of('rating'), 4.5), neq('genre', 'Science Fiction') @@ -667,8 +667,8 @@ apiDescribe.skip('Pipelines', persistence => { const results = await randomCol .pipeline() .where( - or( - and(gt('rating', 4.5), eq('genre', 'Science Fiction')), + orFunction( + andFunction(gt('rating', 4.5), eq('genre', 'Science Fiction')), lt('published', 1900) ) ) @@ -853,7 +853,7 @@ apiDescribe.skip('Pipelines', persistence => { .collection(randomCol.path) .where(lt(Field.of('published'), 1984)) .aggregate({ - accumulators: [avg('rating').as('avgRating')], + accumulators: [avgFunction('rating').as('avgRating')], groups: ['genre'] }) .where(gt('avgRating', 4.3)) @@ -873,7 +873,7 @@ apiDescribe.skip('Pipelines', persistence => { const myPipeline = pipeline(randomCol) .where(lt(Field.of('published'), 1984)) .aggregate({ - accumulators: [avg('rating').as('avgRating')], + accumulators: [avgFunction('rating').as('avgRating')], groups: ['genre'] }) .where(gt('avgRating', 4.3)) From 75e35c8d6d11698b4aaab2999ad93723489af243 Mon Sep 17 00:00:00 2001 From: MarkDuckworth Date: Wed, 13 Nov 2024 23:31:39 +0000 Subject: [PATCH 39/59] Update API reports --- common/api-review/firestore-lite.api.md | 6 +++--- common/api-review/firestore.api.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index ee77620fc7e..d3edaf71247 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -2188,8 +2188,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9177:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9178:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9207:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9177:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9178:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9207:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index 025073704e4..212d93972b2 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -2482,8 +2482,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10102:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10102:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10129:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10102:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10102:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10129:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` From 4bb953a7f2823ff65cb686ea50a571541147d91d Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Fri, 15 Nov 2024 08:20:42 -0700 Subject: [PATCH 40/59] Fix bundle definition --- repo-scripts/size-analysis/bundle-definitions/firestore.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repo-scripts/size-analysis/bundle-definitions/firestore.json b/repo-scripts/size-analysis/bundle-definitions/firestore.json index f7e13a8f401..6c1adcad52c 100644 --- a/repo-scripts/size-analysis/bundle-definitions/firestore.json +++ b/repo-scripts/size-analysis/bundle-definitions/firestore.json @@ -186,7 +186,7 @@ "lt", "Field", "useFirestorePipelines", - "andExpression" + "andFunction" ] } ] From 92c651fda2b355ac91a92eaabc6c5e614bf0391b Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Fri, 15 Nov 2024 08:44:13 -0700 Subject: [PATCH 41/59] Fix imports --- packages/firestore/test/integration/api/pipeline.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index 3c4e5a1fa48..a954d9b53e1 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -18,11 +18,11 @@ import { expect, use } from 'chai'; import chaiAsPromised from 'chai-as-promised'; -import { pipeline } from '../../../src/api/pipeline'; -import { execute } from '../../../src/lite-api/pipeline_impl'; import { addEqualityMatcher } from '../../util/equality_matcher'; import { Deferred } from '../../util/promise'; import { + pipeline, + execute, _internalPipelineToExecutePipelineRequestProto, add, andFunction, From cc3146c8435f2d22b6728c5ec69446f66a2b6292 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:04:44 -0700 Subject: [PATCH 42/59] Re-adding circular dependency check. --- packages/firestore/rollup.shared.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/firestore/rollup.shared.js b/packages/firestore/rollup.shared.js index 9cc31e3dc72..1b33ddf0b1b 100644 --- a/packages/firestore/rollup.shared.js +++ b/packages/firestore/rollup.shared.js @@ -96,11 +96,9 @@ exports.resolveNodeExterns = function (id) { /** Breaks the build if there is a circular dependency. */ exports.onwarn = function (warning, defaultWarn) { - // TODO(pipeline) re-enable and fix circular dependencies after the pipeline exploration phase - // if (warning.code === 'CIRCULAR_DEPENDENCY') { - // console.log(JSON.stringify(warning)); - // throw new Error(warning); - // } + if (warning.code === 'CIRCULAR_DEPENDENCY') { + throw new Error(warning); + } defaultWarn(warning); }; From d2e8d60afbeb5586d399a6c9abbefa8806ac0089 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:27:03 -0700 Subject: [PATCH 43/59] Addressing review comments. --- packages/firestore/src/lite-api/database.ts | 4 +- .../src/lite-api/user_data_reader.ts | 62 ------------------- .../src/remote/internal_serializer.ts | 1 - 3 files changed, 2 insertions(+), 65 deletions(-) diff --git a/packages/firestore/src/lite-api/database.ts b/packages/firestore/src/lite-api/database.ts index f67c5c32767..6ef01bb5172 100644 --- a/packages/firestore/src/lite-api/database.ts +++ b/packages/firestore/src/lite-api/database.ts @@ -41,6 +41,8 @@ import { cast } from '../util/input_validation'; import { logWarn } from '../util/log'; import { FirestoreService, removeComponents } from './components'; +// `import type` to avoid bundling the source for +// pipelines if `useFirestorePipelines()` is not called import type { PipelineSource } from './pipeline-source'; import { DEFAULT_HOST, @@ -48,8 +50,6 @@ import { PrivateSettings, FirestoreSettings } from './settings'; -// `import type` to avoid bundling the source for -// pipelines if `useFirestorePipelines()` is not called export { EmulatorMockTokenOptions } from '@firebase/util'; diff --git a/packages/firestore/src/lite-api/user_data_reader.ts b/packages/firestore/src/lite-api/user_data_reader.ts index 8412c388faf..42f905d5cab 100644 --- a/packages/firestore/src/lite-api/user_data_reader.ts +++ b/packages/firestore/src/lite-api/user_data_reader.ts @@ -437,68 +437,6 @@ export function parseSetData( ); } -export function parse( - userDataReader: UserDataReader, - methodName: string, - targetDoc: DocumentKey, - input: unknown, - hasConverter: boolean, - options: SetOptions = {} -): ParsedSetData { - const context = userDataReader.createContext( - options.merge || options.mergeFields - ? UserDataSource.MergeSet - : UserDataSource.Set, - methodName, - targetDoc, - hasConverter - ); - validatePlainObject('Data must be an object, but it was:', context, input); - const updateData = parseObject(input, context)!; - - let fieldMask: FieldMask | null; - let fieldTransforms: FieldTransform[]; - - if (options.merge) { - fieldMask = new FieldMask(context.fieldMask); - fieldTransforms = context.fieldTransforms; - } else if (options.mergeFields) { - const validatedFieldPaths: InternalFieldPath[] = []; - - for (const stringOrFieldPath of options.mergeFields) { - const fieldPath = fieldPathFromArgument( - methodName, - stringOrFieldPath, - targetDoc - ); - if (!context.contains(fieldPath)) { - throw new FirestoreError( - Code.INVALID_ARGUMENT, - `Field '${fieldPath}' is specified in your field mask but missing from your input data.` - ); - } - - if (!fieldMaskContains(validatedFieldPaths, fieldPath)) { - validatedFieldPaths.push(fieldPath); - } - } - - fieldMask = new FieldMask(validatedFieldPaths); - fieldTransforms = context.fieldTransforms.filter(transform => - fieldMask!.covers(transform.field) - ); - } else { - fieldMask = null; - fieldTransforms = context.fieldTransforms; - } - - return new ParsedSetData( - new ObjectValue(updateData), - fieldMask, - fieldTransforms - ); -} - export class DeleteFieldValueImpl extends FieldValue { _toFieldTransform(context: ParseContextImpl): null { if (context.dataSource === UserDataSource.MergeSet) { diff --git a/packages/firestore/src/remote/internal_serializer.ts b/packages/firestore/src/remote/internal_serializer.ts index dafdea85efc..29a68620efc 100644 --- a/packages/firestore/src/remote/internal_serializer.ts +++ b/packages/firestore/src/remote/internal_serializer.ts @@ -102,7 +102,6 @@ export function _internalAggregationQueryToProtoRunAggregationQueryRequest< * * @param pipeline - The Pipeline to convert to proto representation. */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any export function _internalPipelineToExecutePipelineRequestProto( pipeline: Pipeline // eslint-disable-next-line @typescript-eslint/no-explicit-any From fafadbc9679133cc3b18fd7b63f8306d3f9ee770 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 20 Nov 2024 11:18:23 -0700 Subject: [PATCH 44/59] PPL to Console (#8638) * Pipelines for Console Evaluation --- common/api-review/firestore-lite.api.md | 1776 ++++- common/api-review/firestore.api.md | 1705 ++++- package.json | 1 + packages/firestore/lite/index.ts | 165 + packages/firestore/src/api.ts | 173 +- packages/firestore/src/api/aggregate.ts | 10 +- packages/firestore/src/api/database.ts | 10 + .../src/api/database_augmentation.ts | 57 + packages/firestore/src/api/pipeline.ts | 135 + packages/firestore/src/api/reference_impl.ts | 19 +- packages/firestore/src/api/transaction.ts | 2 +- .../firestore/src/api/user_data_writer.ts | 38 + .../firestore/src/core/firestore_client.ts | 25 +- packages/firestore/src/core/pipeline-util.ts | 252 + packages/firestore/src/lite-api/database.ts | 12 + .../src/lite-api/database_augmentation.ts | 58 + .../firestore/src/lite-api/expressions.ts | 6738 +++++++++++++++++ .../firestore/src/lite-api/pipeline-result.ts | 232 + .../firestore/src/lite-api/pipeline-source.ts | 91 + packages/firestore/src/lite-api/pipeline.ts | 853 +++ .../firestore/src/lite-api/pipeline_impl.ts | 30 + packages/firestore/src/lite-api/reference.ts | 10 + packages/firestore/src/lite-api/stage.ts | 380 + .../src/lite-api/user_data_reader.ts | 9 +- .../src/model/aggregate_result_value.ts | 42 + .../src/model/pipeline_stream_element.ts | 30 + packages/firestore/src/protos/compile.sh | 15 +- .../src/protos/firestore_proto_api.ts | 92 +- .../src/protos/google/api/launch_stage.proto | 72 + .../protos/google/firestore/v1/document.proto | 112 + .../google/firestore/v1/firestore.proto | 88 +- .../protos/google/firestore/v1/pipeline.proto | 41 + .../google/firestore/v1/query_profile.proto | 92 + packages/firestore/src/protos/protos.json | 854 ++- packages/firestore/src/remote/datastore.ts | 37 +- .../src/remote/internal_serializer.ts | 27 + .../firestore/src/remote/rest_connection.ts | 1 + packages/firestore/src/remote/serializer.ts | 123 +- packages/firestore/src/util/misc.ts | 20 + packages/firestore/src/util/obj.ts | 2 +- .../test/integration/api/pipeline.test.ts | 892 +++ .../test/unit/api/document_change.test.ts | 2 +- .../test/unit/remote/serializer.helper.ts | 2 +- .../firestore/test/unit/specs/spec_builder.ts | 2 +- packages/firestore/test/util/api_helpers.ts | 2 +- .../bundle-definitions/firestore.json | 65 + yarn.lock | 196 +- 47 files changed, 15241 insertions(+), 349 deletions(-) create mode 100644 packages/firestore/src/api/database_augmentation.ts create mode 100644 packages/firestore/src/api/pipeline.ts create mode 100644 packages/firestore/src/api/user_data_writer.ts create mode 100644 packages/firestore/src/core/pipeline-util.ts create mode 100644 packages/firestore/src/lite-api/database_augmentation.ts create mode 100644 packages/firestore/src/lite-api/expressions.ts create mode 100644 packages/firestore/src/lite-api/pipeline-result.ts create mode 100644 packages/firestore/src/lite-api/pipeline-source.ts create mode 100644 packages/firestore/src/lite-api/pipeline.ts create mode 100644 packages/firestore/src/lite-api/pipeline_impl.ts create mode 100644 packages/firestore/src/lite-api/stage.ts create mode 100644 packages/firestore/src/model/aggregate_result_value.ts create mode 100644 packages/firestore/src/model/pipeline_stream_element.ts create mode 100644 packages/firestore/src/protos/google/api/launch_stage.proto create mode 100644 packages/firestore/src/protos/google/firestore/v1/pipeline.proto create mode 100644 packages/firestore/src/protos/google/firestore/v1/query_profile.proto create mode 100644 packages/firestore/test/integration/api/pipeline.test.ts diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 603e2349505..d3edaf71247 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -9,14 +9,54 @@ import { FirebaseApp } from '@firebase/app'; import { FirebaseError } from '@firebase/util'; import { LogLevelString as LogLevel } from '@firebase/logger'; +// @beta +export interface Accumulator { + // (undocumented) + accumulator: true; +} + +// @beta +export type AccumulatorTarget = ExprWithAlias; + +// @beta (undocumented) +export class Add extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function add(left: Constant, right: Constant): Add; + +// @beta +export function add(left: Constant, right: any): Add; + +// @beta +export function add(left: string, right: Constant): Add; + +// @beta +export function add(left: string, right: any): Add; + // @public export function addDoc(reference: CollectionReference, data: WithFieldValue): Promise>; +// @beta (undocumented) +export class AddFields implements Stage { + constructor(fields: Map); + // (undocumented) + name: string; +} + // @public export type AddPrefixToKeys> = { [K in keyof T & string as `${Prefix}.${K}`]+?: string extends K ? any : T[K]; }; +// @beta (undocumented) +export class Aggregate implements Stage { + constructor(accumulators: Map, groups: Map); + // (undocumented) + name: string; +} + // @public export class AggregateField { readonly aggregateType: AggregateType; @@ -53,18 +93,138 @@ export type AggregateSpecData = { // @public export type AggregateType = 'count' | 'avg' | 'sum'; +// @beta (undocumented) +export class And extends FirestoreFunction implements FilterCondition { + constructor(conditions: FilterExpr[]); + // (undocumented) + filterable: true; +} + // @public export function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; +// @beta (undocumented) +export class ArrayConcat extends FirestoreFunction { + constructor(array: Constant, elements: Constant[]); + } + +// @beta +export function arrayConcat(array: Constant, elements: Constant[]): ArrayConcat; + +// @beta +export function arrayConcat(array: Constant, elements: any[]): ArrayConcat; + +// @beta +export function arrayConcat(array: string, elements: Constant[]): ArrayConcat; + +// @beta +export function arrayConcat(array: string, elements: any[]): ArrayConcat; + +// @beta (undocumented) +export class ArrayContains extends FirestoreFunction implements FilterCondition { + constructor(array: Constant, element: Constant); + // (undocumented) + filterable: true; +} + +// @beta +export function arrayContains(array: Constant, element: Constant): ArrayContains; + +// @beta +export function arrayContains(array: Constant, element: any): ArrayContains; + +// @beta +export function arrayContains(array: string, element: Constant): ArrayContains; + +// @beta +export function arrayContains(array: string, element: any): ArrayContains; + +// @beta (undocumented) +export class ArrayContainsAll extends FirestoreFunction implements FilterCondition { + constructor(array: Constant, values: Constant[]); + // (undocumented) + filterable: true; + } + +// @beta +export function arrayContainsAll(array: Constant, values: Constant[]): ArrayContainsAll; + +// @beta +export function arrayContainsAll(array: Constant, values: any[]): ArrayContainsAll; + +// @beta +export function arrayContainsAll(array: string, values: Constant[]): ArrayContainsAll; + +// @beta +export function arrayContainsAll(array: string, values: any[]): ArrayContainsAll; + +// @beta (undocumented) +export class ArrayContainsAny extends FirestoreFunction implements FilterCondition { + constructor(array: Constant, values: Constant[]); + // (undocumented) + filterable: true; + } + +// @beta +export function arrayContainsAny(array: Constant, values: Constant[]): ArrayContainsAny; + +// @beta +export function arrayContainsAny(array: Constant, values: any[]): ArrayContainsAny; + +// @beta +export function arrayContainsAny(array: string, values: Constant[]): ArrayContainsAny; + +// @beta +export function arrayContainsAny(array: string, values: any[]): ArrayContainsAny; + +// @beta (undocumented) +export class ArrayElement extends FirestoreFunction { + constructor(); +} + +// @beta (undocumented) +export class ArrayLength extends FirestoreFunction { + constructor(array: Constant); + } + +// @beta +export function arrayLength(array: Constant): ArrayLength; + // @public export function arrayRemove(...elements: unknown[]): FieldValue; +// @beta (undocumented) +export class ArrayReverse extends FirestoreFunction { + constructor(array: Constant); + } + // @public export function arrayUnion(...elements: unknown[]): FieldValue; +// @beta +export function ascending(expr: Constant): Ordering; + // @public export function average(field: string | FieldPath): AggregateField; +// @beta (undocumented) +export class Avg extends FirestoreFunction implements Accumulator { + constructor(value: Constant, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta (undocumented) +export class ByteLength extends FirestoreFunction { + constructor(value: Constant); + } + +// @beta +export function byteLength(expr: Constant): ByteLength; + +// @beta +export function byteLength(field: string): ByteLength; + // @public export class Bytes { static fromBase64String(base64: string): Bytes; @@ -75,6 +235,17 @@ export class Bytes { toUint8Array(): Uint8Array; } +// @beta (undocumented) +export class CharLength extends FirestoreFunction { + constructor(value: Constant); + } + +// @beta +export function charLength(field: string): CharLength; + +// @beta +export function charLength(expr: Constant): CharLength; + // @public export type ChildUpdateFields = V extends Record ? AddPrefixToKeys> : never; @@ -90,6 +261,13 @@ export function collection(refer // @public export function collectionGroup(firestore: Firestore, collectionId: string): Query; +// @beta (undocumented) +export class CollectionGroupSource implements Stage { + constructor(collectionId: string); + // (undocumented) + name: string; +} + // @public export class CollectionReference extends Query { get id(): string; @@ -100,20 +278,208 @@ export class CollectionReference; } +// @beta (undocumented) +export class CollectionSource implements Stage { + constructor(collectionPath: string); + // (undocumented) + name: string; +} + // @public export function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: { mockUserToken?: EmulatorMockTokenOptions | string; }): void; +// @beta +export class Constant { + add(other: Constant): Add; + add(other: any): Add; + arrayConcat(arrays: Constant[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat; + arrayContains(element: Constant): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Constant[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Constant[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Constant): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Constant): Divide; + divide(other: any): Divide; + dotProduct(other: Constant): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Constant): EndsWith; + eq(other: Constant): Eq; + eq(other: any): Eq; + euclideanDistance(other: Constant): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + gt(other: Constant): Gt; + gt(other: any): Gt; + gte(other: Constant): Gte; + gte(other: any): Gte; + in(...others: Constant[]): In; + // (undocumented) + in(...others: any[]): In; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Constant): Like; + logicalMax(other: Constant): LogicalMax; + logicalMax(other: any): LogicalMax; + logicalMin(other: Constant): LogicalMin; + logicalMin(other: any): LogicalMin; + lt(other: Constant): Lt; + lt(other: any): Lt; + lte(other: Constant): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + max(): Max; + min(): Min; + mod(other: Constant): Mod; + mod(other: any): Mod; + multiply(other: Constant): Multiply; + multiply(other: any): Multiply; + neq(other: Constant): Neq; + neq(other: any): Neq; + static of(value: number): Constant; + static of(value: string): Constant; + static of(value: boolean): Constant; + static of(value: null): Constant; + static of(value: undefined): Constant; + static of(value: GeoPoint): Constant; + static of(value: Timestamp): Constant; + static of(value: Date): Constant; + static of(value: Uint8Array): Constant; + static of(value: DocumentReference): Constant; + static of(value: any[]): Constant; + static of(value: Map): Constant; + static of(value: VectorValue): Constant; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Constant): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Constant): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Constant, replace: Constant): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Constant, replace: Constant): ReplaceFirst; + reverse(): Reverse; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Constant): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Constant): StrContains; + subtract(other: Constant): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Constant, amount: Constant): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Constant, amount: Constant): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + static vector(value: number[] | VectorValue): Constant; + vectorLength(): VectorLength; +} + +// @beta (undocumented) +export class CosineDistance extends FirestoreFunction { + constructor(vector1: Constant, vector2: Constant); + } + +// @beta +export function cosineDistance(expr: string, other: number[]): CosineDistance; + +// @beta +export function cosineDistance(expr: string, other: VectorValue): CosineDistance; + +// @beta +export function cosineDistance(expr: string, other: Constant): CosineDistance; + +// @beta +export function cosineDistance(expr: Constant, other: number[]): CosineDistance; + +// @beta +export function cosineDistance(expr: Constant, other: VectorValue): CosineDistance; + +// @beta +export function cosineDistance(expr: Constant, other: Constant): CosineDistance; + +// @beta (undocumented) +export class Count extends FirestoreFunction implements Accumulator { + constructor(value: Constant | undefined, distinct: boolean); + // (undocumented) + accumulator: true; + } + // @public export function count(): AggregateField; +// @beta +export function countAll(): Count; + +// @beta (undocumented) +export class DatabaseSource implements Stage { + // (undocumented) + name: string; +} + // @public export function deleteDoc(reference: DocumentReference): Promise; // @public export function deleteField(): FieldValue; +// @beta +export function descending(expr: Constant): Ordering; + +// @beta (undocumented) +export class Distinct implements Stage { + constructor(groups: Map); + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class Divide extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function divide(left: Constant, right: Constant): Divide; + +// @beta +export function divide(left: Constant, right: any): Divide; + +// @beta +export function divide(left: string, right: Constant): Divide; + +// @beta +export function divide(left: string, right: any): Divide; + // @public export function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference; @@ -153,6 +519,38 @@ export class DocumentSnapshot; } +// @beta (undocumented) +export class DocumentsSource implements Stage { + constructor(docPaths: string[]); + // (undocumented) + name: string; + // (undocumented) + static of(refs: DocumentReference[]): DocumentsSource; +} + +// @beta (undocumented) +export class DotProduct extends FirestoreFunction { + constructor(vector1: Constant, vector2: Constant); + } + +// @beta +export function dotProduct(expr: string, other: number[]): DotProduct; + +// @beta +export function dotProduct(expr: string, other: VectorValue): DotProduct; + +// @beta +export function dotProduct(expr: string, other: Constant): DotProduct; + +// @beta +export function dotProduct(expr: Constant, other: number[]): DotProduct; + +// @beta +export function dotProduct(expr: Constant, other: VectorValue): DotProduct; + +// @beta +export function dotProduct(expr: Constant, other: Constant): DotProduct; + export { EmulatorMockTokenOptions } // @public @@ -167,20 +565,458 @@ export function endBefore(snapsh // @public export function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint; +// @beta (undocumented) +export class EndsWith extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, suffix: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function endsWith(expr: string, suffix: string): EndsWith; + +// @beta +export function endsWith(expr: string, suffix: Constant): EndsWith; + +// @beta +export function endsWith(expr: Constant, suffix: string): EndsWith; + +// @beta +export function endsWith(expr: Constant, suffix: Constant): EndsWith; + +// @beta (undocumented) +export class Eq extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function eq(left: Constant, right: Constant): Eq; + +// @beta +export function eq(left: Constant, right: any): Eq; + +// @beta +export function eq(left: string, right: Constant): Eq; + +// @beta +export function eq(left: string, right: any): Eq; + +// @beta (undocumented) +export class EuclideanDistance extends FirestoreFunction { + constructor(vector1: Constant, vector2: Constant); + } + +// @beta +export function euclideanDistance(expr: string, other: number[]): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: string, other: VectorValue): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: string, other: Constant): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: Constant, other: number[]): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: Constant, other: VectorValue): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: Constant, other: Constant): EuclideanDistance; + +// @beta +export function execute(pipeline: Pipeline): Promise>>; + +// @beta (undocumented) +export class Exists extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant); + // (undocumented) + filterable: true; +} + +// @beta +export function exists(value: Constant): Exists; + +// @beta +export function exists(field: string): Exists; + +// @beta +export type ExprType = 'Field' | 'Constant' | 'Function' | 'ListOfExprs' | 'ExprWithAlias'; + +// @beta (undocumented) +export class ExprWithAlias implements Selectable { + constructor(expr: T, alias: string); + add(other: Constant): Add; + add(other: any): Add; + // (undocumented) + alias: string; + arrayConcat(arrays: Constant[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat; + arrayContains(element: Constant): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Constant[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Constant[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Constant): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Constant): Divide; + divide(other: any): Divide; + dotProduct(other: Constant): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Constant): EndsWith; + eq(other: Constant): Eq; + eq(other: any): Eq; + euclideanDistance(other: Constant): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + expr: T; + // (undocumented) + exprType: ExprType; + gt(other: Constant): Gt; + gt(other: any): Gt; + gte(other: Constant): Gte; + gte(other: any): Gte; + in(...others: Constant[]): In; + // (undocumented) + in(...others: any[]): In; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Constant): Like; + logicalMax(other: Constant): LogicalMax; + logicalMax(other: any): LogicalMax; + logicalMin(other: Constant): LogicalMin; + logicalMin(other: any): LogicalMin; + lt(other: Constant): Lt; + lt(other: any): Lt; + lte(other: Constant): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + max(): Max; + min(): Min; + mod(other: Constant): Mod; + mod(other: any): Mod; + multiply(other: Constant): Multiply; + multiply(other: any): Multiply; + neq(other: Constant): Neq; + neq(other: any): Neq; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Constant): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Constant): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Constant, replace: Constant): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Constant, replace: Constant): ReplaceFirst; + reverse(): Reverse; + // (undocumented) + selectable: true; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Constant): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Constant): StrContains; + subtract(other: Constant): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Constant, amount: Constant): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Constant, amount: Constant): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + +// @beta +export class Field implements Selectable { + add(other: Constant): Add; + add(other: any): Add; + arrayConcat(arrays: Constant[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat; + arrayContains(element: Constant): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Constant[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Constant[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Constant): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Constant): Divide; + divide(other: any): Divide; + dotProduct(other: Constant): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Constant): EndsWith; + eq(other: Constant): Eq; + eq(other: any): Eq; + euclideanDistance(other: Constant): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + // (undocumented) + fieldName(): string; + gt(other: Constant): Gt; + gt(other: any): Gt; + gte(other: Constant): Gte; + gte(other: any): Gte; + in(...others: Constant[]): In; + // (undocumented) + in(...others: any[]): In; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Constant): Like; + logicalMax(other: Constant): LogicalMax; + logicalMax(other: any): LogicalMax; + logicalMin(other: Constant): LogicalMin; + logicalMin(other: any): LogicalMin; + lt(other: Constant): Lt; + lt(other: any): Lt; + lte(other: Constant): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + max(): Max; + min(): Min; + mod(other: Constant): Mod; + mod(other: any): Mod; + multiply(other: Constant): Multiply; + multiply(other: any): Multiply; + neq(other: Constant): Neq; + neq(other: any): Neq; + static of(name: string): Field; + // (undocumented) + static of(path: FieldPath): Field; + // (undocumented) + static of(pipeline: Pipeline, name: string): Field; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Constant): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Constant): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Constant, replace: Constant): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Constant, replace: Constant): ReplaceFirst; + reverse(): Reverse; + // (undocumented) + selectable: true; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Constant): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Constant): StrContains; + subtract(other: Constant): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Constant, amount: Constant): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Constant, amount: Constant): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + // @public export class FieldPath { constructor(...fieldNames: string[]); isEqual(other: FieldPath): boolean; } +// @beta (undocumented) +export class Fields implements Selectable { + add(other: Constant): Add; + add(other: any): Add; + arrayConcat(arrays: Constant[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat; + arrayContains(element: Constant): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Constant[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Constant[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Constant): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Constant): Divide; + divide(other: any): Divide; + dotProduct(other: Constant): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Constant): EndsWith; + eq(other: Constant): Eq; + eq(other: any): Eq; + euclideanDistance(other: Constant): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + // (undocumented) + fieldList(): Field[]; + gt(other: Constant): Gt; + gt(other: any): Gt; + gte(other: Constant): Gte; + gte(other: any): Gte; + in(...others: Constant[]): In; + // (undocumented) + in(...others: any[]): In; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Constant): Like; + logicalMax(other: Constant): LogicalMax; + logicalMax(other: any): LogicalMax; + logicalMin(other: Constant): LogicalMin; + logicalMin(other: any): LogicalMin; + lt(other: Constant): Lt; + lt(other: any): Lt; + lte(other: Constant): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + max(): Max; + min(): Min; + mod(other: Constant): Mod; + mod(other: any): Mod; + multiply(other: Constant): Multiply; + multiply(other: any): Multiply; + neq(other: Constant): Neq; + neq(other: any): Neq; + // (undocumented) + static of(name: string, ...others: string[]): Fields; + // (undocumented) + static ofAll(): Fields; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Constant): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Constant): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Constant, replace: Constant): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Constant, replace: Constant): ReplaceFirst; + reverse(): Reverse; + // (undocumented) + selectable: true; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Constant): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Constant): StrContains; + subtract(other: Constant): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Constant, amount: Constant): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Constant, amount: Constant): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + // @public export abstract class FieldValue { abstract isEqual(other: FieldValue): boolean; } +// @beta +export interface FilterCondition { + // (undocumented) + filterable: true; +} + +// @beta +export type FilterExpr = Constant & FilterCondition; + +// @beta (undocumented) +export class FindNearest implements Stage { + // (undocumented) + name: string; +} + +// @beta (undocumented) +export interface FindNearestOptions { + // (undocumented) + distanceField?: string; + // (undocumented) + distanceMeasure: 'euclidean' | 'cosine' | 'dot_product'; + // (undocumented) + field: Field; + // (undocumented) + limit?: number; + // (undocumented) + vectorValue: VectorValue | number[]; +} + // @public export class Firestore { get app(): FirebaseApp; + // Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta + pipeline(): PipelineSource; toJSON(): object; type: 'firestore-lite' | 'firestore'; } @@ -199,69 +1035,488 @@ export class FirestoreError extends FirebaseError { readonly stack?: string; } -// @public -export type FirestoreErrorCode = 'cancelled' | 'unknown' | 'invalid-argument' | 'deadline-exceeded' | 'not-found' | 'already-exists' | 'permission-denied' | 'resource-exhausted' | 'failed-precondition' | 'aborted' | 'out-of-range' | 'unimplemented' | 'internal' | 'unavailable' | 'data-loss' | 'unauthenticated'; +// @public +export type FirestoreErrorCode = 'cancelled' | 'unknown' | 'invalid-argument' | 'deadline-exceeded' | 'not-found' | 'already-exists' | 'permission-denied' | 'resource-exhausted' | 'failed-precondition' | 'aborted' | 'out-of-range' | 'unimplemented' | 'internal' | 'unavailable' | 'data-loss' | 'unauthenticated'; + +// @beta +export class FirestoreFunction { + constructor(name: string, params: Constant[]); + add(other: Constant): Add; + add(other: any): Add; + arrayConcat(arrays: Constant[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat; + arrayContains(element: Constant): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Constant[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Constant[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Constant): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Constant): Divide; + divide(other: any): Divide; + dotProduct(other: Constant): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Constant): EndsWith; + eq(other: Constant): Eq; + eq(other: any): Eq; + euclideanDistance(other: Constant): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + gt(other: Constant): Gt; + gt(other: any): Gt; + gte(other: Constant): Gte; + gte(other: any): Gte; + in(...others: Constant[]): In; + // (undocumented) + in(...others: any[]): In; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Constant): Like; + logicalMax(other: Constant): LogicalMax; + logicalMax(other: any): LogicalMax; + logicalMin(other: Constant): LogicalMin; + logicalMin(other: any): LogicalMin; + lt(other: Constant): Lt; + lt(other: any): Lt; + lte(other: Constant): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + max(): Max; + min(): Min; + mod(other: Constant): Mod; + mod(other: any): Mod; + multiply(other: Constant): Multiply; + multiply(other: any): Multiply; + neq(other: Constant): Neq; + neq(other: any): Neq; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Constant): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Constant): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Constant, replace: Constant): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Constant, replace: Constant): ReplaceFirst; + reverse(): Reverse; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Constant): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Constant): StrContains; + subtract(other: Constant): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Constant, amount: Constant): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Constant, amount: Constant): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + +// @beta +export function genericFunction(name: string, params: Constant[]): FirestoreFunction; + +// @beta (undocumented) +export class GenericStage implements Stage { + constructor(name: string, params: unknown[]); + // (undocumented) + name: string; +} + +// @public +export class GeoPoint { + constructor(latitude: number, longitude: number); + isEqual(other: GeoPoint): boolean; + get latitude(): number; + get longitude(): number; + toJSON(): { + latitude: number; + longitude: number; + }; +} + +// @public +export function getAggregate(query: Query, aggregateSpec: AggregateSpecType): Promise>; + +// @public +export function getCount(query: Query): Promise; +}, AppModelType, DbModelType>>; + +// @public +export function getDoc(reference: DocumentReference): Promise>; + +// @public +export function getDocs(query: Query): Promise>; + +// @public +export function getFirestore(): Firestore; + +// @public +export function getFirestore(app: FirebaseApp): Firestore; + +// @beta +export function getFirestore(databaseId: string): Firestore; + +// @beta +export function getFirestore(app: FirebaseApp, databaseId: string): Firestore; + +// @beta (undocumented) +export class Gt extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function gt(left: Constant, right: Constant): Gt; + +// @beta +export function gt(left: Constant, right: any): Gt; + +// @beta +export function gt(left: string, right: Constant): Gt; + +// @beta +export function gt(left: string, right: any): Gt; + +// @beta (undocumented) +export class Gte extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function gte(left: Constant, right: Constant): Gte; + +// @beta +export function gte(left: Constant, right: any): Gte; + +// @beta +export function gte(left: string, right: Constant): Gte; + +// @beta +export function gte(left: string, right: any): Gte; + +// @beta (undocumented) +export class If extends FirestoreFunction implements FilterCondition { + constructor(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function ifFunction(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant): If; + +// @beta (undocumented) +export class In extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, others: Constant[]); + // (undocumented) + filterable: true; + } + +// @beta +export function inAny(element: Constant, others: Constant[]): In; + +// @beta +export function inAny(element: Constant, others: any[]): In; + +// @beta +export function inAny(element: string, others: Constant[]): In; + +// @beta +export function inAny(element: string, others: any[]): In; + +// @public +export function increment(n: number): FieldValue; + +// @public +export function initializeFirestore(app: FirebaseApp, settings: Settings): Firestore; + +// @beta +export function initializeFirestore(app: FirebaseApp, settings: Settings, databaseId?: string): Firestore; + +// @beta (undocumented) +export class IsNan extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant); + // (undocumented) + filterable: true; +} + +// @beta +export function isNan(value: Constant): IsNan; + +// @beta +export function isNan(value: string): IsNan; + +// @beta (undocumented) +export class Like extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, pattern: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function like(left: string, pattern: string): Like; + +// @beta +export function like(left: string, pattern: Constant): Like; + +// @beta +export function like(left: Constant, pattern: string): Like; + +// @beta +export function like(left: Constant, pattern: Constant): Like; + +// @beta (undocumented) +export class Limit implements Stage { + constructor(limit: number); + // (undocumented) + name: string; +} + +// @public +export function limit(limit: number): QueryLimitConstraint; + +// @public +export function limitToLast(limit: number): QueryLimitConstraint; + +// @beta (undocumented) +export class LogicalMax extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function logicalMax(left: Constant, right: Constant): LogicalMax; + +// @beta +export function logicalMax(left: Constant, right: any): LogicalMax; + +// @beta +export function logicalMax(left: string, right: Constant): LogicalMax; + +// @beta +export function logicalMax(left: string, right: any): LogicalMax; + +// @beta (undocumented) +export class LogicalMin extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function logicalMin(left: Constant, right: Constant): LogicalMin; + +// @beta +export function logicalMin(left: Constant, right: any): LogicalMin; + +// @beta +export function logicalMin(left: string, right: Constant): LogicalMin; + +// @beta +export function logicalMin(left: string, right: any): LogicalMin; + +export { LogLevel } + +// @beta (undocumented) +export class Lt extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function lt(left: Constant, right: Constant): Lt; + +// @beta +export function lt(left: Constant, right: any): Lt; + +// @beta +export function lt(left: string, right: Constant): Lt; + +// @beta +export function lt(left: string, right: any): Lt; + +// @beta (undocumented) +export class Lte extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function lte(left: Constant, right: Constant): Lte; + +// @beta +export function lte(left: Constant, right: any): Lte; + +// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Constant" which is marked as @beta +// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Lte" which is marked as @beta +// +// @public +export function lte(left: string, right: Constant): Lte; + +// @beta +export function lte(left: string, right: any): Lte; + +// @beta (undocumented) +export class MapGet extends FirestoreFunction { + constructor(map: Constant, name: string); +} + +// @beta +export function mapGet(mapField: string, subField: string): MapGet; + +// @beta +export function mapGet(mapExpr: Constant, subField: string): MapGet; + +// @beta (undocumented) +export class Max extends FirestoreFunction implements Accumulator { + constructor(value: Constant, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta +export function max(value: Constant): Max; + +// @beta +export function max(value: string): Max; + +// @beta (undocumented) +export class Min extends FirestoreFunction implements Accumulator { + constructor(value: Constant, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta +export function min(value: Constant): Min; + +// @beta +export function min(value: string): Min; -// @public -export class GeoPoint { - constructor(latitude: number, longitude: number); - isEqual(other: GeoPoint): boolean; - get latitude(): number; - get longitude(): number; - toJSON(): { - latitude: number; - longitude: number; - }; -} +// @beta (undocumented) +export class Mod extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } -// @public -export function getAggregate(query: Query, aggregateSpec: AggregateSpecType): Promise>; +// @beta +export function mod(left: Constant, right: Constant): Mod; -// @public -export function getCount(query: Query): Promise; -}, AppModelType, DbModelType>>; +// @beta +export function mod(left: Constant, right: any): Mod; -// @public -export function getDoc(reference: DocumentReference): Promise>; +// @beta +export function mod(left: string, right: Constant): Mod; -// @public -export function getDocs(query: Query): Promise>; +// @beta +export function mod(left: string, right: any): Mod; -// @public -export function getFirestore(): Firestore; +// @beta (undocumented) +export class Multiply extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } -// @public -export function getFirestore(app: FirebaseApp): Firestore; +// @beta +export function multiply(left: Constant, right: Constant): Multiply; // @beta -export function getFirestore(databaseId: string): Firestore; +export function multiply(left: Constant, right: any): Multiply; // @beta -export function getFirestore(app: FirebaseApp, databaseId: string): Firestore; +export function multiply(left: string, right: Constant): Multiply; -// @public -export function increment(n: number): FieldValue; +// @beta +export function multiply(left: string, right: any): Multiply; -// @public -export function initializeFirestore(app: FirebaseApp, settings: Settings): Firestore; +// @beta (undocumented) +export class Neq extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } // @beta -export function initializeFirestore(app: FirebaseApp, settings: Settings, databaseId?: string): Firestore; +export function neq(left: Constant, right: Constant): Neq; -// @public -export function limit(limit: number): QueryLimitConstraint; +// @beta +export function neq(left: Constant, right: any): Neq; -// @public -export function limitToLast(limit: number): QueryLimitConstraint; +// @beta +export function neq(left: string, right: Constant): Neq; -export { LogLevel } +// @beta +export function neq(left: string, right: any): Neq; // @public export type NestedUpdateFields> = UnionToIntersection<{ [K in keyof T & string]: ChildUpdateFields; }[keyof T & string]>; +// @beta (undocumented) +export class Not extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant); + // (undocumented) + filterable: true; +} + +// @beta +export function not(filter: FilterExpr): Not; + +// @beta +export function notInAny(element: Constant, others: Constant[]): Not; + +// @beta +export function notInAny(element: Constant, others: any[]): Not; + +// @beta +export function notInAny(element: string, others: Constant[]): Not; + +// @beta +export function notInAny(element: string, others: any[]): Not; + +// @beta (undocumented) +export class Offset implements Stage { + constructor(offset: number); + // (undocumented) + name: string; + } + +// @beta (undocumented) +export class Or extends FirestoreFunction implements FilterCondition { + constructor(conditions: FilterExpr[]); + // (undocumented) + filterable: true; +} + // @public export function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; @@ -271,11 +1526,109 @@ export function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDir // @public export type OrderByDirection = 'desc' | 'asc'; +// @beta +export class Ordering { + constructor(expr: Constant, direction: 'ascending' | 'descending'); + } + // @public export type PartialWithFieldValue = Partial | (T extends Primitive ? T : T extends {} ? { [K in keyof T]?: PartialWithFieldValue | FieldValue; } : never); +// @public +export class Pipeline { + /* Excluded from this release type: _db */ + // Warning: (ae-incompatible-release-tags) The symbol "addFields" is marked as @public, but its signature references "Selectable" which is marked as @beta + addFields(...fields: Selectable[]): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ + // Warning: (ae-incompatible-release-tags) The symbol "aggregate" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta + aggregate(...accumulators: AccumulatorTarget[]): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ + aggregate(options: { + accumulators: AccumulatorTarget[]; + groups?: Array; + }): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ + // Warning: (ae-incompatible-release-tags) The symbol "distinct" is marked as @public, but its signature references "Selectable" which is marked as @beta + distinct(...groups: Array): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ + // Warning: (ae-incompatible-release-tags) The symbol "execute" is marked as @public, but its signature references "PipelineResult" which is marked as @beta + execute(): Promise>>; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ + // Warning: (ae-incompatible-release-tags) The symbol "findNearest" is marked as @public, but its signature references "FindNearestOptions" which is marked as @beta + // + // (undocumented) + findNearest(options: FindNearestOptions): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ + genericStage(name: string, params: any[]): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ + limit(limit: number): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ + offset(offset: number): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ + // Warning: (ae-incompatible-release-tags) The symbol "select" is marked as @public, but its signature references "Selectable" which is marked as @beta + select(...selections: Array): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ + // Warning: (ae-incompatible-release-tags) The symbol "sort" is marked as @public, but its signature references "Ordering" which is marked as @beta + sort(...orderings: Ordering[]): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ + // (undocumented) + sort(options: { + orderings: Ordering[]; + }): Pipeline; + /* Excluded from this release type: userDataWriter */ + /* Excluded from this release type: documentReferenceFactory */ + // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "FilterCondition" which is marked as @beta + // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "Constant" which is marked as @beta + where(condition: FilterCondition & Constant): Pipeline; +} + +// Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta +// +// @public +export function pipeline(firestore: Firestore): PipelineSource; + +// @public +export function pipeline(query: Query): Pipeline; + +// @beta +export class PipelineResult { + /* Excluded from this release type: _ref */ + /* Excluded from this release type: _fields */ + /* Excluded from this release type: __constructor */ + get createTime(): Timestamp | undefined; + data(): AppModelType | undefined; + get executionTime(): Timestamp; + get(fieldPath: string | FieldPath): any; + get id(): string | undefined; + get ref(): DocumentReference | undefined; + get updateTime(): Timestamp | undefined; +} + +// @beta +export class PipelineSource { + // (undocumented) + collection(collectionPath: string): Pipeline; + // (undocumented) + collectionGroup(collectionId: string): Pipeline; + // (undocumented) + database(): Pipeline; + // (undocumented) + documents(docs: DocumentReference[]): Pipeline; + } + // @public export type Primitive = string | number | boolean | undefined | null; @@ -284,6 +1637,7 @@ export class Query | null; readonly firestore: Firestore; + pipeline(): Pipeline; readonly type: 'query' | 'collection'; withConverter(converter: null): Query; withConverter(converter: FirestoreDataConverter): Query; @@ -360,9 +1714,102 @@ export class QueryStartAtConstraint extends QueryConstraint { // @public export function refEqual(left: DocumentReference | CollectionReference, right: DocumentReference | CollectionReference): boolean; +// @beta (undocumented) +export class RegexContains extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, pattern: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function regexContains(left: string, pattern: string): RegexContains; + +// @beta +export function regexContains(left: string, pattern: Constant): RegexContains; + +// @beta +export function regexContains(left: Constant, pattern: string): RegexContains; + +// @beta +export function regexContains(left: Constant, pattern: Constant): RegexContains; + +// @beta (undocumented) +export class RegexMatch extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, pattern: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function regexMatch(left: string, pattern: string): RegexMatch; + +// @beta +export function regexMatch(left: string, pattern: Constant): RegexMatch; + +// @beta +export function regexMatch(left: Constant, pattern: string): RegexMatch; + +// @beta +export function regexMatch(left: Constant, pattern: Constant): RegexMatch; + +// @beta (undocumented) +export class ReplaceAll extends FirestoreFunction { + constructor(value: Constant, find: Constant, replace: Constant); + } + +// @beta +export function replaceAll(value: Constant, find: string, replace: string): ReplaceAll; + +// @beta +export function replaceAll(value: Constant, find: Constant, replace: Constant): ReplaceAll; + +// @beta +export function replaceAll(field: string, find: string, replace: string): ReplaceAll; + +// @beta (undocumented) +export class ReplaceFirst extends FirestoreFunction { + constructor(value: Constant, find: Constant, replace: Constant); + } + +// @beta +export function replaceFirst(value: Constant, find: string, replace: string): ReplaceFirst; + +// @beta +export function replaceFirst(value: Constant, find: Constant, replace: Constant): ReplaceFirst; + +// @beta +export function replaceFirst(field: string, find: string, replace: string): ReplaceFirst; + +// @beta (undocumented) +export class Reverse extends FirestoreFunction { + constructor(value: Constant); + } + +// @beta +export function reverse(expr: Constant): Reverse; + +// @beta +export function reverse(field: string): Reverse; + // @public export function runTransaction(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise, options?: TransactionOptions): Promise; +// @beta (undocumented) +export class Select implements Stage { + constructor(projections: Map); + // (undocumented) + name: string; + } + +// @beta +export interface Selectable { + // (undocumented) + selectable: true; +} + +// @beta +export type SelectableExpr = Constant & Selectable; + // @public export function serverTimestamp(): FieldValue; @@ -392,6 +1839,19 @@ export interface Settings { // @public export function snapshotEqual(left: DocumentSnapshot | QuerySnapshot, right: DocumentSnapshot | QuerySnapshot): boolean; +// @beta (undocumented) +export class Sort implements Stage { + constructor(orders: Ordering[]); + // (undocumented) + name: string; + } + +// @beta (undocumented) +export interface Stage { + // (undocumented) + name: string; +} + // @public export function startAfter(snapshot: DocumentSnapshot): QueryStartAtConstraint; @@ -404,6 +1864,79 @@ export function startAt(snapshot // @public export function startAt(...fieldValues: unknown[]): QueryStartAtConstraint; +// @beta (undocumented) +export class StartsWith extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, prefix: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function startsWith(expr: string, prefix: string): StartsWith; + +// @beta +export function startsWith(expr: string, prefix: Constant): StartsWith; + +// @beta +export function startsWith(expr: Constant, prefix: string): StartsWith; + +// @beta +export function startsWith(expr: Constant, prefix: Constant): StartsWith; + +// @beta (undocumented) +export class StrConcat extends FirestoreFunction { + constructor(first: Constant, rest: Constant[]); + } + +// @beta +export function strConcat(first: string, ...elements: Array): StrConcat; + +// @beta +export function strConcat(first: Constant, ...elements: Array): StrConcat; + +// @beta (undocumented) +export class StrContains extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, substring: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function strContains(left: string, substring: string): StrContains; + +// @beta +export function strContains(left: string, substring: Constant): StrContains; + +// @beta +export function strContains(left: Constant, substring: string): StrContains; + +// @beta +export function strContains(left: Constant, substring: Constant): StrContains; + +// @beta (undocumented) +export class Subtract extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function subtract(left: Constant, right: Constant): Subtract; + +// @beta +export function subtract(left: Constant, right: any): Subtract; + +// @beta +export function subtract(left: string, right: Constant): Subtract; + +// @beta +export function subtract(left: string, right: any): Subtract; + +// @beta (undocumented) +export class Sum extends FirestoreFunction implements Accumulator { + constructor(value: Constant, distinct: boolean); + // (undocumented) + accumulator: true; + } + // @public export function sum(field: string | FieldPath): AggregateField; @@ -431,6 +1964,89 @@ export class Timestamp { valueOf(): string; } +// @beta (undocumented) +export class TimestampAdd extends FirestoreFunction { + constructor(timestamp: Constant, unit: Constant, amount: Constant); + } + +// @beta +export function timestampAdd(timestamp: Constant, unit: Constant, amount: Constant): TimestampAdd; + +// @beta +export function timestampAdd(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + +// @beta +export function timestampAdd(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + +// @beta (undocumented) +export class TimestampSub extends FirestoreFunction { + constructor(timestamp: Constant, unit: Constant, amount: Constant); + } + +// @beta +export function timestampSub(timestamp: Constant, unit: Constant, amount: Constant): TimestampSub; + +// @beta +export function timestampSub(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + +// @beta +export function timestampSub(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + +// @beta (undocumented) +export class TimestampToUnixMicros extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function timestampToUnixMicros(expr: Constant): TimestampToUnixMicros; + +// @beta +export function timestampToUnixMicros(field: string): TimestampToUnixMicros; + +// @beta (undocumented) +export class TimestampToUnixMillis extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function timestampToUnixMillis(expr: Constant): TimestampToUnixMillis; + +// @beta +export function timestampToUnixMillis(field: string): TimestampToUnixMillis; + +// @beta (undocumented) +export class TimestampToUnixSeconds extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function timestampToUnixSeconds(expr: Constant): TimestampToUnixSeconds; + +// @beta +export function timestampToUnixSeconds(field: string): TimestampToUnixSeconds; + +// @beta (undocumented) +export class ToLower extends FirestoreFunction { + constructor(expr: Constant); + } + +// @beta +export function toLower(expr: string): ToLower; + +// @beta +export function toLower(expr: Constant): ToLower; + +// @beta (undocumented) +export class ToUpper extends FirestoreFunction { + constructor(expr: Constant); + } + +// @beta +export function toUpper(expr: string): ToUpper; + +// @beta +export function toUpper(expr: Constant): ToUpper; + // @public export class Transaction { delete(documentRef: DocumentReference): this; @@ -446,9 +2062,53 @@ export interface TransactionOptions { readonly maxAttempts?: number; } +// @beta (undocumented) +export class Trim extends FirestoreFunction { + constructor(expr: Constant); + } + +// @beta +export function trim(expr: string): Trim; + +// @beta +export function trim(expr: Constant): Trim; + // @public export type UnionToIntersection = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never; +// @beta (undocumented) +export class UnixMicrosToTimestamp extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function unixMicrosToTimestamp(expr: Constant): UnixMicrosToTimestamp; + +// @beta +export function unixMicrosToTimestamp(field: string): UnixMicrosToTimestamp; + +// @beta (undocumented) +export class UnixMillisToTimestamp extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function unixMillisToTimestamp(expr: Constant): UnixMillisToTimestamp; + +// @beta +export function unixMillisToTimestamp(field: string): UnixMillisToTimestamp; + +// @beta (undocumented) +export class UnixSecondsToTimestamp extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function unixSecondsToTimestamp(expr: Constant): UnixSecondsToTimestamp; + +// @beta +export function unixSecondsToTimestamp(field: string): UnixSecondsToTimestamp; + // @public export type UpdateData = T extends Primitive ? T : T extends {} ? { [K in keyof T]?: UpdateData | FieldValue; @@ -460,9 +2120,23 @@ export function updateDoc(refere // @public export function updateDoc(reference: DocumentReference, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise; +// @public +export function useFirestorePipelines(): void; + // @public export function vector(values?: number[]): VectorValue; +// @beta (undocumented) +export class VectorLength extends FirestoreFunction { + constructor(value: Constant); + } + +// @beta +export function vectorLength(expr: Constant): VectorLength; + +// @beta +export function vectorLength(field: string): VectorLength; + // @public export class VectorValue { /* Excluded from this release type: __constructor */ @@ -470,6 +2144,13 @@ export class VectorValue { toArray(): number[]; } +// @beta (undocumented) +export class Where implements Stage { + constructor(condition: FilterCondition & Constant); + // (undocumented) + name: string; +} + // @public export function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryFieldFilterConstraint; @@ -494,4 +2175,21 @@ export class WriteBatch { // @public export function writeBatch(firestore: Firestore): WriteBatch; +// @beta (undocumented) +export class Xor extends FirestoreFunction implements FilterCondition { + constructor(conditions: FilterExpr[]); + // (undocumented) + filterable: true; +} + +// @beta +export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; + + +// Warnings were encountered during analysis: +// +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9177:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9178:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9207:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta + ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index 34b56b97f21..212d93972b2 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -9,14 +9,54 @@ import { FirebaseApp } from '@firebase/app'; import { FirebaseError } from '@firebase/util'; import { LogLevelString as LogLevel } from '@firebase/logger'; +// @beta +export interface Accumulator { + // (undocumented) + accumulator: true; +} + +// @beta +export type AccumulatorTarget = ExprWithAlias; + +// @beta (undocumented) +export class Add extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function add(left: Constant, right: Constant): Add; + +// @beta +export function add(left: Constant, right: any): Add; + +// @beta +export function add(left: string, right: Constant): Add; + +// @beta +export function add(left: string, right: any): Add; + // @public export function addDoc(reference: CollectionReference, data: WithFieldValue): Promise>; +// @beta (undocumented) +export class AddFields implements Stage { + constructor(fields: Map); + // (undocumented) + name: string; +} + // @public export type AddPrefixToKeys> = { [K in keyof T & string as `${Prefix}.${K}`]+?: string extends K ? any : T[K]; }; +// @beta (undocumented) +export class Aggregate implements Stage { + constructor(accumulators: Map, groups: Map); + // (undocumented) + name: string; +} + // @public export class AggregateField { readonly aggregateType: AggregateType; @@ -53,18 +93,147 @@ export type AggregateSpecData = { // @public export type AggregateType = 'count' | 'avg' | 'sum'; +// @beta (undocumented) +export class And extends FirestoreFunction implements FilterCondition { + constructor(conditions: FilterExpr[]); + // (undocumented) + filterable: true; +} + // @public export function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; +// @beta +export function andFunction(left: FilterExpr, ...right: FilterExpr[]): And; + +// @beta (undocumented) +export class ArrayConcat extends FirestoreFunction { + constructor(array: Constant, elements: Constant[]); + } + +// @beta +export function arrayConcat(array: Constant, elements: Constant[]): ArrayConcat; + +// @beta +export function arrayConcat(array: Constant, elements: any[]): ArrayConcat; + +// @beta +export function arrayConcat(array: string, elements: Constant[]): ArrayConcat; + +// @beta +export function arrayConcat(array: string, elements: any[]): ArrayConcat; + +// @beta (undocumented) +export class ArrayContains extends FirestoreFunction implements FilterCondition { + constructor(array: Constant, element: Constant); + // (undocumented) + filterable: true; +} + +// @beta +export function arrayContains(array: Constant, element: Constant): ArrayContains; + +// @beta +export function arrayContains(array: Constant, element: any): ArrayContains; + +// @beta +export function arrayContains(array: string, element: Constant): ArrayContains; + +// @beta +export function arrayContains(array: string, element: any): ArrayContains; + +// @beta (undocumented) +export class ArrayContainsAll extends FirestoreFunction implements FilterCondition { + constructor(array: Constant, values: Constant[]); + // (undocumented) + filterable: true; + } + +// @beta +export function arrayContainsAll(array: Constant, values: Constant[]): ArrayContainsAll; + +// @beta +export function arrayContainsAll(array: Constant, values: any[]): ArrayContainsAll; + +// @beta +export function arrayContainsAll(array: string, values: Constant[]): ArrayContainsAll; + +// @beta +export function arrayContainsAll(array: string, values: any[]): ArrayContainsAll; + +// @beta (undocumented) +export class ArrayContainsAny extends FirestoreFunction implements FilterCondition { + constructor(array: Constant, values: Constant[]); + // (undocumented) + filterable: true; + } + +// @beta +export function arrayContainsAny(array: Constant, values: Constant[]): ArrayContainsAny; + +// @beta +export function arrayContainsAny(array: Constant, values: any[]): ArrayContainsAny; + +// @beta +export function arrayContainsAny(array: string, values: Constant[]): ArrayContainsAny; + +// @beta +export function arrayContainsAny(array: string, values: any[]): ArrayContainsAny; + +// @beta (undocumented) +export class ArrayElement extends FirestoreFunction { + constructor(); +} + +// @beta (undocumented) +export class ArrayLength extends FirestoreFunction { + constructor(array: Constant); + } + +// @beta +export function arrayLength(array: Constant): ArrayLength; + // @public export function arrayRemove(...elements: unknown[]): FieldValue; +// @beta (undocumented) +export class ArrayReverse extends FirestoreFunction { + constructor(array: Constant); + } + // @public export function arrayUnion(...elements: unknown[]): FieldValue; +// @beta +export function ascending(expr: Constant): Ordering; + // @public export function average(field: string | FieldPath): AggregateField; +// @beta (undocumented) +export class Avg extends FirestoreFunction implements Accumulator { + constructor(value: Constant, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta +export function avgFunction(value: Constant): Avg; + +// @beta +export function avgFunction(value: string): Avg; + +// @beta (undocumented) +export class ByteLength extends FirestoreFunction { + constructor(value: Constant); + } + +// @beta +export function byteLength(expr: Constant): ByteLength; + +// @beta +export function byteLength(field: string): ByteLength; + // @public export class Bytes { static fromBase64String(base64: string): Bytes; @@ -78,6 +247,17 @@ export class Bytes { // @public export const CACHE_SIZE_UNLIMITED = -1; +// @beta (undocumented) +export class CharLength extends FirestoreFunction { + constructor(value: Constant); + } + +// @beta +export function charLength(field: string): CharLength; + +// @beta +export function charLength(expr: Constant): CharLength; + // @public export type ChildUpdateFields = V extends Record ? AddPrefixToKeys> : never; @@ -96,6 +276,13 @@ export function collection(refer // @public export function collectionGroup(firestore: Firestore, collectionId: string): Query; +// @beta (undocumented) +export class CollectionGroupSource implements Stage { + constructor(collectionId: string); + // (undocumented) + name: string; +} + // @public export class CollectionReference extends Query { get id(): string; @@ -106,14 +293,183 @@ export class CollectionReference; } +// @beta (undocumented) +export class CollectionSource implements Stage { + constructor(collectionPath: string); + // (undocumented) + name: string; +} + // @public export function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: { mockUserToken?: EmulatorMockTokenOptions | string; }): void; +// @beta +export class Constant { + add(other: Constant): Add; + add(other: any): Add; + arrayConcat(arrays: Constant[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat; + arrayContains(element: Constant): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Constant[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Constant[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Constant): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Constant): Divide; + divide(other: any): Divide; + dotProduct(other: Constant): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Constant): EndsWith; + eq(other: Constant): Eq; + eq(other: any): Eq; + euclideanDistance(other: Constant): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + gt(other: Constant): Gt; + gt(other: any): Gt; + gte(other: Constant): Gte; + gte(other: any): Gte; + in(...others: Constant[]): In; + // (undocumented) + in(...others: any[]): In; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Constant): Like; + logicalMax(other: Constant): LogicalMax; + logicalMax(other: any): LogicalMax; + logicalMin(other: Constant): LogicalMin; + logicalMin(other: any): LogicalMin; + lt(other: Constant): Lt; + lt(other: any): Lt; + lte(other: Constant): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + max(): Max; + min(): Min; + mod(other: Constant): Mod; + mod(other: any): Mod; + multiply(other: Constant): Multiply; + multiply(other: any): Multiply; + neq(other: Constant): Neq; + neq(other: any): Neq; + static of(value: number): Constant; + static of(value: string): Constant; + static of(value: boolean): Constant; + static of(value: null): Constant; + static of(value: undefined): Constant; + static of(value: GeoPoint): Constant; + static of(value: Timestamp): Constant; + static of(value: Date): Constant; + static of(value: Uint8Array): Constant; + static of(value: DocumentReference): Constant; + static of(value: any[]): Constant; + static of(value: Map): Constant; + static of(value: VectorValue): Constant; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Constant): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Constant): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Constant, replace: Constant): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Constant, replace: Constant): ReplaceFirst; + reverse(): Reverse; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Constant): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Constant): StrContains; + subtract(other: Constant): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Constant, amount: Constant): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Constant, amount: Constant): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + static vector(value: number[] | VectorValue): Constant; + vectorLength(): VectorLength; +} + +// @beta (undocumented) +export class CosineDistance extends FirestoreFunction { + constructor(vector1: Constant, vector2: Constant); + } + +// @beta +export function cosineDistance(expr: string, other: number[]): CosineDistance; + +// @beta +export function cosineDistance(expr: string, other: VectorValue): CosineDistance; + +// @beta +export function cosineDistance(expr: string, other: Constant): CosineDistance; + +// @beta +export function cosineDistance(expr: Constant, other: number[]): CosineDistance; + +// @beta +export function cosineDistance(expr: Constant, other: VectorValue): CosineDistance; + +// @beta +export function cosineDistance(expr: Constant, other: Constant): CosineDistance; + +// @beta (undocumented) +export class Count extends FirestoreFunction implements Accumulator { + constructor(value: Constant | undefined, distinct: boolean); + // (undocumented) + accumulator: true; + } + // @public export function count(): AggregateField; +// @beta +export function countAll(): Count; + +// @beta +export function countFunction(value: Constant): Count; + +// Warning: (ae-incompatible-release-tags) The symbol "countFunction" is marked as @public, but its signature references "Count" which is marked as @beta +// +// @public +export function countFunction(value: string): Count; + +// @beta (undocumented) +export class DatabaseSource implements Stage { + // (undocumented) + name: string; +} + // @public export function deleteAllPersistentCacheIndexes(indexManager: PersistentCacheIndexManager): void; @@ -123,12 +479,39 @@ export function deleteDoc(refere // @public export function deleteField(): FieldValue; +// @beta +export function descending(expr: Constant): Ordering; + // @public export function disableNetwork(firestore: Firestore): Promise; // @public export function disablePersistentCacheIndexAutoCreation(indexManager: PersistentCacheIndexManager): void; +// @beta (undocumented) +export class Distinct implements Stage { + constructor(groups: Map); + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class Divide extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function divide(left: Constant, right: Constant): Divide; + +// @beta +export function divide(left: Constant, right: any): Divide; + +// @beta +export function divide(left: string, right: Constant): Divide; + +// @beta +export function divide(left: string, right: any): Divide; + // @public export function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference; @@ -180,6 +563,38 @@ export class DocumentSnapshot; } +// @beta (undocumented) +export class DocumentsSource implements Stage { + constructor(docPaths: string[]); + // (undocumented) + name: string; + // (undocumented) + static of(refs: DocumentReference[]): DocumentsSource; +} + +// @beta (undocumented) +export class DotProduct extends FirestoreFunction { + constructor(vector1: Constant, vector2: Constant); + } + +// @beta +export function dotProduct(expr: string, other: number[]): DotProduct; + +// @beta +export function dotProduct(expr: string, other: VectorValue): DotProduct; + +// @beta +export function dotProduct(expr: string, other: Constant): DotProduct; + +// @beta +export function dotProduct(expr: Constant, other: number[]): DotProduct; + +// @beta +export function dotProduct(expr: Constant, other: VectorValue): DotProduct; + +// @beta +export function dotProduct(expr: Constant, other: Constant): DotProduct; + export { EmulatorMockTokenOptions } // @public @deprecated @@ -206,25 +621,463 @@ export function endBefore(snapsh // @public export function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint; +// @beta (undocumented) +export class EndsWith extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, suffix: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function endsWith(expr: string, suffix: string): EndsWith; + +// @beta +export function endsWith(expr: string, suffix: Constant): EndsWith; + +// @beta +export function endsWith(expr: Constant, suffix: string): EndsWith; + +// @beta +export function endsWith(expr: Constant, suffix: Constant): EndsWith; + +// @beta (undocumented) +export class Eq extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function eq(left: Constant, right: Constant): Eq; + +// @beta +export function eq(left: Constant, right: any): Eq; + +// @beta +export function eq(left: string, right: Constant): Eq; + +// @beta +export function eq(left: string, right: any): Eq; + +// @beta (undocumented) +export class EuclideanDistance extends FirestoreFunction { + constructor(vector1: Constant, vector2: Constant); + } + +// @beta +export function euclideanDistance(expr: string, other: number[]): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: string, other: VectorValue): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: string, other: Constant): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: Constant, other: number[]): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: Constant, other: VectorValue): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: Constant, other: Constant): EuclideanDistance; + +// @beta +export function execute(pipeline: Pipeline): Promise>>; + +// @beta (undocumented) +export class Exists extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant); + // (undocumented) + filterable: true; +} + +// @beta +export function exists(value: Constant): Exists; + +// @beta +export function exists(field: string): Exists; + // @public export interface ExperimentalLongPollingOptions { timeoutSeconds?: number; } +// @beta +export type ExprType = 'Field' | 'Constant' | 'Function' | 'ListOfExprs' | 'ExprWithAlias'; + +// @beta (undocumented) +export class ExprWithAlias implements Selectable { + constructor(expr: T, alias: string); + add(other: Constant): Add; + add(other: any): Add; + // (undocumented) + alias: string; + arrayConcat(arrays: Constant[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat; + arrayContains(element: Constant): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Constant[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Constant[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Constant): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Constant): Divide; + divide(other: any): Divide; + dotProduct(other: Constant): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Constant): EndsWith; + eq(other: Constant): Eq; + eq(other: any): Eq; + euclideanDistance(other: Constant): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + expr: T; + // (undocumented) + exprType: ExprType; + gt(other: Constant): Gt; + gt(other: any): Gt; + gte(other: Constant): Gte; + gte(other: any): Gte; + in(...others: Constant[]): In; + // (undocumented) + in(...others: any[]): In; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Constant): Like; + logicalMax(other: Constant): LogicalMax; + logicalMax(other: any): LogicalMax; + logicalMin(other: Constant): LogicalMin; + logicalMin(other: any): LogicalMin; + lt(other: Constant): Lt; + lt(other: any): Lt; + lte(other: Constant): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + max(): Max; + min(): Min; + mod(other: Constant): Mod; + mod(other: any): Mod; + multiply(other: Constant): Multiply; + multiply(other: any): Multiply; + neq(other: Constant): Neq; + neq(other: any): Neq; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Constant): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Constant): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Constant, replace: Constant): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Constant, replace: Constant): ReplaceFirst; + reverse(): Reverse; + // (undocumented) + selectable: true; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Constant): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Constant): StrContains; + subtract(other: Constant): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Constant, amount: Constant): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Constant, amount: Constant): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + +// @beta +export class Field implements Selectable { + add(other: Constant): Add; + add(other: any): Add; + arrayConcat(arrays: Constant[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat; + arrayContains(element: Constant): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Constant[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Constant[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Constant): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Constant): Divide; + divide(other: any): Divide; + dotProduct(other: Constant): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Constant): EndsWith; + eq(other: Constant): Eq; + eq(other: any): Eq; + euclideanDistance(other: Constant): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + // (undocumented) + fieldName(): string; + gt(other: Constant): Gt; + gt(other: any): Gt; + gte(other: Constant): Gte; + gte(other: any): Gte; + in(...others: Constant[]): In; + // (undocumented) + in(...others: any[]): In; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Constant): Like; + logicalMax(other: Constant): LogicalMax; + logicalMax(other: any): LogicalMax; + logicalMin(other: Constant): LogicalMin; + logicalMin(other: any): LogicalMin; + lt(other: Constant): Lt; + lt(other: any): Lt; + lte(other: Constant): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + max(): Max; + min(): Min; + mod(other: Constant): Mod; + mod(other: any): Mod; + multiply(other: Constant): Multiply; + multiply(other: any): Multiply; + neq(other: Constant): Neq; + neq(other: any): Neq; + static of(name: string): Field; + // (undocumented) + static of(path: FieldPath): Field; + // (undocumented) + static of(pipeline: Pipeline, name: string): Field; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Constant): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Constant): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Constant, replace: Constant): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Constant, replace: Constant): ReplaceFirst; + reverse(): Reverse; + // (undocumented) + selectable: true; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Constant): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Constant): StrContains; + subtract(other: Constant): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Constant, amount: Constant): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Constant, amount: Constant): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + // @public export class FieldPath { constructor(...fieldNames: string[]); isEqual(other: FieldPath): boolean; } +// @beta (undocumented) +export class Fields implements Selectable { + add(other: Constant): Add; + add(other: any): Add; + arrayConcat(arrays: Constant[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat; + arrayContains(element: Constant): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Constant[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Constant[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Constant): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Constant): Divide; + divide(other: any): Divide; + dotProduct(other: Constant): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Constant): EndsWith; + eq(other: Constant): Eq; + eq(other: any): Eq; + euclideanDistance(other: Constant): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + // (undocumented) + fieldList(): Field[]; + gt(other: Constant): Gt; + gt(other: any): Gt; + gte(other: Constant): Gte; + gte(other: any): Gte; + in(...others: Constant[]): In; + // (undocumented) + in(...others: any[]): In; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Constant): Like; + logicalMax(other: Constant): LogicalMax; + logicalMax(other: any): LogicalMax; + logicalMin(other: Constant): LogicalMin; + logicalMin(other: any): LogicalMin; + lt(other: Constant): Lt; + lt(other: any): Lt; + lte(other: Constant): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + max(): Max; + min(): Min; + mod(other: Constant): Mod; + mod(other: any): Mod; + multiply(other: Constant): Multiply; + multiply(other: any): Multiply; + neq(other: Constant): Neq; + neq(other: any): Neq; + // (undocumented) + static of(name: string, ...others: string[]): Fields; + // (undocumented) + static ofAll(): Fields; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Constant): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Constant): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Constant, replace: Constant): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Constant, replace: Constant): ReplaceFirst; + reverse(): Reverse; + // (undocumented) + selectable: true; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Constant): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Constant): StrContains; + subtract(other: Constant): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Constant, amount: Constant): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Constant, amount: Constant): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + // @public export abstract class FieldValue { abstract isEqual(other: FieldValue): boolean; } +// @beta +export interface FilterCondition { + // (undocumented) + filterable: true; +} + +// @beta +export type FilterExpr = Constant & FilterCondition; + +// @beta (undocumented) +export class FindNearest implements Stage { + // (undocumented) + name: string; +} + +// @beta (undocumented) +export interface FindNearestOptions { + // (undocumented) + distanceField?: string; + // (undocumented) + distanceMeasure: 'euclidean' | 'cosine' | 'dot_product'; + // (undocumented) + field: Field; + // (undocumented) + limit?: number; + // (undocumented) + vectorValue: VectorValue | number[]; +} + // @public export class Firestore { get app(): FirebaseApp; + // Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta + pipeline(): PipelineSource; toJSON(): object; type: 'firestore-lite' | 'firestore'; } @@ -246,6 +1099,108 @@ export class FirestoreError extends FirebaseError { // @public export type FirestoreErrorCode = 'cancelled' | 'unknown' | 'invalid-argument' | 'deadline-exceeded' | 'not-found' | 'already-exists' | 'permission-denied' | 'resource-exhausted' | 'failed-precondition' | 'aborted' | 'out-of-range' | 'unimplemented' | 'internal' | 'unavailable' | 'data-loss' | 'unauthenticated'; +// @beta +export class FirestoreFunction { + constructor(name: string, params: Constant[]); + add(other: Constant): Add; + add(other: any): Add; + arrayConcat(arrays: Constant[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat; + arrayContains(element: Constant): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Constant[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Constant[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Constant): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Constant): Divide; + divide(other: any): Divide; + dotProduct(other: Constant): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Constant): EndsWith; + eq(other: Constant): Eq; + eq(other: any): Eq; + euclideanDistance(other: Constant): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + gt(other: Constant): Gt; + gt(other: any): Gt; + gte(other: Constant): Gte; + gte(other: any): Gte; + in(...others: Constant[]): In; + // (undocumented) + in(...others: any[]): In; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Constant): Like; + logicalMax(other: Constant): LogicalMax; + logicalMax(other: any): LogicalMax; + logicalMin(other: Constant): LogicalMin; + logicalMin(other: any): LogicalMin; + lt(other: Constant): Lt; + lt(other: any): Lt; + lte(other: Constant): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + max(): Max; + min(): Min; + mod(other: Constant): Mod; + mod(other: any): Mod; + multiply(other: Constant): Multiply; + multiply(other: any): Multiply; + neq(other: Constant): Neq; + neq(other: any): Neq; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Constant): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Constant): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Constant, replace: Constant): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Constant, replace: Constant): ReplaceFirst; + reverse(): Reverse; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Constant): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Constant): StrContains; + subtract(other: Constant): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Constant, amount: Constant): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Constant, amount: Constant): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + // @public export type FirestoreLocalCache = MemoryLocalCache | PersistentLocalCache; @@ -261,6 +1216,16 @@ export interface FirestoreSettings { ssl?: boolean; } +// @beta +export function genericFunction(name: string, params: Constant[]): FirestoreFunction; + +// @beta (undocumented) +export class GenericStage implements Stage { + constructor(name: string, params: unknown[]); + // (undocumented) + name: string; +} + // @public export class GeoPoint { constructor(latitude: number, longitude: number); @@ -314,6 +1279,73 @@ export function getFirestore(app: FirebaseApp, databaseId: string): Firestore; // @public export function getPersistentCacheIndexManager(firestore: Firestore): PersistentCacheIndexManager | null; +// @beta (undocumented) +export class Gt extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function gt(left: Constant, right: Constant): Gt; + +// @beta +export function gt(left: Constant, right: any): Gt; + +// @beta +export function gt(left: string, right: Constant): Gt; + +// @beta +export function gt(left: string, right: any): Gt; + +// @beta (undocumented) +export class Gte extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function gte(left: Constant, right: Constant): Gte; + +// @beta +export function gte(left: Constant, right: any): Gte; + +// @beta +export function gte(left: string, right: Constant): Gte; + +// @beta +export function gte(left: string, right: any): Gte; + +// @beta (undocumented) +export class If extends FirestoreFunction implements FilterCondition { + constructor(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function ifFunction(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant): If; + +// @beta (undocumented) +export class In extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, others: Constant[]); + // (undocumented) + filterable: true; + } + +// @beta +export function inAny(element: Constant, others: Constant[]): In; + +// @beta +export function inAny(element: Constant, others: any[]): In; + +// @beta +export function inAny(element: string, others: Constant[]): In; + +// @beta +export function inAny(element: string, others: any[]): In; + // @public export function increment(n: number): FieldValue; @@ -344,6 +1376,45 @@ export interface IndexField { // @public export function initializeFirestore(app: FirebaseApp, settings: FirestoreSettings, databaseId?: string): Firestore; +// @beta (undocumented) +export class IsNan extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant); + // (undocumented) + filterable: true; +} + +// @beta +export function isNan(value: Constant): IsNan; + +// @beta +export function isNan(value: string): IsNan; + +// @beta (undocumented) +export class Like extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, pattern: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function like(left: string, pattern: string): Like; + +// @beta +export function like(left: string, pattern: Constant): Like; + +// @beta +export function like(left: Constant, pattern: string): Like; + +// @beta +export function like(left: Constant, pattern: Constant): Like; + +// @beta (undocumented) +export class Limit implements Stage { + constructor(limit: number); + // (undocumented) + name: string; +} + // @public export function limit(limit: number): QueryLimitConstraint; @@ -372,7 +1443,106 @@ export interface LoadBundleTaskProgress { totalDocuments: number; } -export { LogLevel } +// @beta (undocumented) +export class LogicalMax extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function logicalMax(left: Constant, right: Constant): LogicalMax; + +// @beta +export function logicalMax(left: Constant, right: any): LogicalMax; + +// @beta +export function logicalMax(left: string, right: Constant): LogicalMax; + +// @beta +export function logicalMax(left: string, right: any): LogicalMax; + +// @beta (undocumented) +export class LogicalMin extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function logicalMin(left: Constant, right: Constant): LogicalMin; + +// @beta +export function logicalMin(left: Constant, right: any): LogicalMin; + +// @beta +export function logicalMin(left: string, right: Constant): LogicalMin; + +// @beta +export function logicalMin(left: string, right: any): LogicalMin; + +export { LogLevel } + +// @beta (undocumented) +export class Lt extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function lt(left: Constant, right: Constant): Lt; + +// @beta +export function lt(left: Constant, right: any): Lt; + +// @beta +export function lt(left: string, right: Constant): Lt; + +// @beta +export function lt(left: string, right: any): Lt; + +// @beta (undocumented) +export class Lte extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function lte(left: Constant, right: Constant): Lte; + +// @beta +export function lte(left: Constant, right: any): Lte; + +// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Constant" which is marked as @beta +// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Lte" which is marked as @beta +// +// @public +export function lte(left: string, right: Constant): Lte; + +// @beta +export function lte(left: string, right: any): Lte; + +// @beta (undocumented) +export class MapGet extends FirestoreFunction { + constructor(map: Constant, name: string); +} + +// @beta +export function mapGet(mapField: string, subField: string): MapGet; + +// @beta +export function mapGet(mapExpr: Constant, subField: string): MapGet; + +// @beta (undocumented) +export class Max extends FirestoreFunction implements Accumulator { + constructor(value: Constant, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta +export function max(value: Constant): Max; + +// @beta +export function max(value: string): Max; // @public export interface MemoryCacheSettings { @@ -411,14 +1581,109 @@ export function memoryLruGarbageCollector(settings?: { cacheSizeBytes?: number; }): MemoryLruGarbageCollector; +// @beta (undocumented) +export class Min extends FirestoreFunction implements Accumulator { + constructor(value: Constant, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta +export function min(value: Constant): Min; + +// @beta +export function min(value: string): Min; + +// @beta (undocumented) +export class Mod extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function mod(left: Constant, right: Constant): Mod; + +// @beta +export function mod(left: Constant, right: any): Mod; + +// @beta +export function mod(left: string, right: Constant): Mod; + +// @beta +export function mod(left: string, right: any): Mod; + +// @beta (undocumented) +export class Multiply extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function multiply(left: Constant, right: Constant): Multiply; + +// @beta +export function multiply(left: Constant, right: any): Multiply; + +// @beta +export function multiply(left: string, right: Constant): Multiply; + +// @beta +export function multiply(left: string, right: any): Multiply; + // @public export function namedQuery(firestore: Firestore, name: string): Promise; +// @beta (undocumented) +export class Neq extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, right: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function neq(left: Constant, right: Constant): Neq; + +// @beta +export function neq(left: Constant, right: any): Neq; + +// @beta +export function neq(left: string, right: Constant): Neq; + +// @beta +export function neq(left: string, right: any): Neq; + // @public export type NestedUpdateFields> = UnionToIntersection<{ [K in keyof T & string]: ChildUpdateFields; }[keyof T & string]>; +// @beta (undocumented) +export class Not extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant); + // (undocumented) + filterable: true; +} + +// @beta +export function not(filter: FilterExpr): Not; + +// @beta +export function notInAny(element: Constant, others: Constant[]): Not; + +// @beta +export function notInAny(element: Constant, others: any[]): Not; + +// @beta +export function notInAny(element: string, others: Constant[]): Not; + +// @beta +export function notInAny(element: string, others: any[]): Not; + +// @beta (undocumented) +export class Offset implements Stage { + constructor(offset: number); + // (undocumented) + name: string; + } + // @public export function onSnapshot(reference: DocumentReference, observer: { next?: (snapshot: DocumentSnapshot) => void; @@ -469,6 +1734,13 @@ export function onSnapshotsInSync(firestore: Firestore, observer: { // @public export function onSnapshotsInSync(firestore: Firestore, onSync: () => void): Unsubscribe; +// @beta (undocumented) +export class Or extends FirestoreFunction implements FilterCondition { + constructor(conditions: FilterExpr[]); + // (undocumented) + filterable: true; +} + // @public export function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; @@ -478,6 +1750,14 @@ export function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDir // @public export type OrderByDirection = 'desc' | 'asc'; +// @beta +export class Ordering { + constructor(expr: Constant, direction: 'ascending' | 'descending'); + } + +// @beta +export function orFunction(left: FilterExpr, ...right: FilterExpr[]): Or; + // @public export type PartialWithFieldValue = Partial | (T extends Primitive ? T : T extends {} ? { [K in keyof T]?: PartialWithFieldValue | FieldValue; @@ -534,6 +1814,79 @@ export interface PersistentSingleTabManagerSettings { // @public export type PersistentTabManager = PersistentSingleTabManager | PersistentMultipleTabManager; +// @public (undocumented) +export class Pipeline { + /* Excluded from this release type: __constructor */ + // Warning: (ae-incompatible-release-tags) The symbol "addFields" is marked as @public, but its signature references "Selectable" which is marked as @beta + addFields(...fields: Selectable[]): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "aggregate" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta + aggregate(...accumulators: AccumulatorTarget[]): Pipeline; + aggregate(options: { accumulators: AccumulatorTarget[]; groups?: Array; }): Pipeline; + // (undocumented) + converter: any; + // Warning: (ae-incompatible-release-tags) The symbol "distinct" is marked as @public, but its signature references "Selectable" which is marked as @beta + distinct(...groups: Array): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "execute" is marked as @public, but its signature references "PipelineResult" which is marked as @beta + execute(): Promise>>; + // Warning: (ae-incompatible-release-tags) The symbol "findNearest" is marked as @public, but its signature references "FindNearestOptions" which is marked as @beta + // + // (undocumented) + findNearest(options: FindNearestOptions): Pipeline; + genericStage(name: string, params: any[]): Pipeline; + limit(limit: number): Pipeline; + offset(offset: number): Pipeline; + readUserData: any; + // Warning: (ae-incompatible-release-tags) The symbol "select" is marked as @public, but its signature references "Selectable" which is marked as @beta + select(...selections: Array): Pipeline; + // (undocumented) + selectablesToMap: any; + // Warning: (ae-incompatible-release-tags) The symbol "sort" is marked as @public, but its signature references "Ordering" which is marked as @beta + sort(...orderings: Ordering[]): Pipeline; + // (undocumented) + sort(options: { orderings: Ordering[]; }): Pipeline; + // (undocumented) + stages: any; + // (undocumented) + userDataReader: any; + // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "FilterCondition" which is marked as @beta + // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "Constant" which is marked as @beta + where(condition: FilterCondition & Constant): Pipeline; +} + +// Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta +// +// @public +export function pipeline(firestore: Firestore): PipelineSource; + +// @public +export function pipeline(query: Query): Pipeline; + +// @beta +export class PipelineResult { + /* Excluded from this release type: _ref */ + /* Excluded from this release type: _fields */ + /* Excluded from this release type: __constructor */ + get createTime(): Timestamp | undefined; + data(): AppModelType | undefined; + get executionTime(): Timestamp; + get(fieldPath: string | FieldPath): any; + get id(): string | undefined; + get ref(): DocumentReference | undefined; + get updateTime(): Timestamp | undefined; +} + +// @beta +export class PipelineSource { + // (undocumented) + collection(collectionPath: string): Pipeline; + // (undocumented) + collectionGroup(collectionId: string): Pipeline; + // (undocumented) + database(): Pipeline; + // (undocumented) + documents(docs: DocumentReference[]): Pipeline; + } + // @public export type Primitive = string | number | boolean | undefined | null; @@ -542,6 +1895,7 @@ export class Query | null; readonly firestore: Firestore; + pipeline(): Pipeline; readonly type: 'query' | 'collection'; withConverter(converter: null): Query; withConverter(converter: FirestoreDataConverter): Query; @@ -620,9 +1974,102 @@ export class QueryStartAtConstraint extends QueryConstraint { // @public export function refEqual(left: DocumentReference | CollectionReference, right: DocumentReference | CollectionReference): boolean; +// @beta (undocumented) +export class RegexContains extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, pattern: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function regexContains(left: string, pattern: string): RegexContains; + +// @beta +export function regexContains(left: string, pattern: Constant): RegexContains; + +// @beta +export function regexContains(left: Constant, pattern: string): RegexContains; + +// @beta +export function regexContains(left: Constant, pattern: Constant): RegexContains; + +// @beta (undocumented) +export class RegexMatch extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, pattern: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function regexMatch(left: string, pattern: string): RegexMatch; + +// @beta +export function regexMatch(left: string, pattern: Constant): RegexMatch; + +// @beta +export function regexMatch(left: Constant, pattern: string): RegexMatch; + +// @beta +export function regexMatch(left: Constant, pattern: Constant): RegexMatch; + +// @beta (undocumented) +export class ReplaceAll extends FirestoreFunction { + constructor(value: Constant, find: Constant, replace: Constant); + } + +// @beta +export function replaceAll(value: Constant, find: string, replace: string): ReplaceAll; + +// @beta +export function replaceAll(value: Constant, find: Constant, replace: Constant): ReplaceAll; + +// @beta +export function replaceAll(field: string, find: string, replace: string): ReplaceAll; + +// @beta (undocumented) +export class ReplaceFirst extends FirestoreFunction { + constructor(value: Constant, find: Constant, replace: Constant); + } + +// @beta +export function replaceFirst(value: Constant, find: string, replace: string): ReplaceFirst; + +// @beta +export function replaceFirst(value: Constant, find: Constant, replace: Constant): ReplaceFirst; + +// @beta +export function replaceFirst(field: string, find: string, replace: string): ReplaceFirst; + +// @beta (undocumented) +export class Reverse extends FirestoreFunction { + constructor(value: Constant); + } + +// @beta +export function reverse(expr: Constant): Reverse; + +// @beta +export function reverse(field: string): Reverse; + // @public export function runTransaction(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise, options?: TransactionOptions): Promise; +// @beta (undocumented) +export class Select implements Stage { + constructor(projections: Map); + // (undocumented) + name: string; + } + +// @beta +export interface Selectable { + // (undocumented) + selectable: true; +} + +// @beta +export type SelectableExpr = Constant & Selectable; + // @public export function serverTimestamp(): FieldValue; @@ -669,6 +2116,19 @@ export interface SnapshotOptions { readonly serverTimestamps?: 'estimate' | 'previous' | 'none'; } +// @beta (undocumented) +export class Sort implements Stage { + constructor(orders: Ordering[]); + // (undocumented) + name: string; + } + +// @beta (undocumented) +export interface Stage { + // (undocumented) + name: string; +} + // @public export function startAfter(snapshot: DocumentSnapshot): QueryStartAtConstraint; @@ -681,9 +2141,88 @@ export function startAt(snapshot // @public export function startAt(...fieldValues: unknown[]): QueryStartAtConstraint; +// @beta (undocumented) +export class StartsWith extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, prefix: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function startsWith(expr: string, prefix: string): StartsWith; + +// @beta +export function startsWith(expr: string, prefix: Constant): StartsWith; + +// @beta +export function startsWith(expr: Constant, prefix: string): StartsWith; + +// @beta +export function startsWith(expr: Constant, prefix: Constant): StartsWith; + +// @beta (undocumented) +export class StrConcat extends FirestoreFunction { + constructor(first: Constant, rest: Constant[]); + } + +// @beta +export function strConcat(first: string, ...elements: Array): StrConcat; + +// @beta +export function strConcat(first: Constant, ...elements: Array): StrConcat; + +// @beta (undocumented) +export class StrContains extends FirestoreFunction implements FilterCondition { + constructor(expr: Constant, substring: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function strContains(left: string, substring: string): StrContains; + +// @beta +export function strContains(left: string, substring: Constant): StrContains; + +// @beta +export function strContains(left: Constant, substring: string): StrContains; + +// @beta +export function strContains(left: Constant, substring: Constant): StrContains; + +// @beta (undocumented) +export class Subtract extends FirestoreFunction { + constructor(left: Constant, right: Constant); + } + +// @beta +export function subtract(left: Constant, right: Constant): Subtract; + +// @beta +export function subtract(left: Constant, right: any): Subtract; + +// @beta +export function subtract(left: string, right: Constant): Subtract; + +// @beta +export function subtract(left: string, right: any): Subtract; + +// @beta (undocumented) +export class Sum extends FirestoreFunction implements Accumulator { + constructor(value: Constant, distinct: boolean); + // (undocumented) + accumulator: true; + } + // @public export function sum(field: string | FieldPath): AggregateField; +// @beta +export function sumFunction(value: Constant): Sum; + +// @beta +export function sumFunction(value: string): Sum; + // @public export type TaskState = 'Error' | 'Running' | 'Success'; @@ -711,6 +2250,89 @@ export class Timestamp { valueOf(): string; } +// @beta (undocumented) +export class TimestampAdd extends FirestoreFunction { + constructor(timestamp: Constant, unit: Constant, amount: Constant); + } + +// @beta +export function timestampAdd(timestamp: Constant, unit: Constant, amount: Constant): TimestampAdd; + +// @beta +export function timestampAdd(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + +// @beta +export function timestampAdd(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + +// @beta (undocumented) +export class TimestampSub extends FirestoreFunction { + constructor(timestamp: Constant, unit: Constant, amount: Constant); + } + +// @beta +export function timestampSub(timestamp: Constant, unit: Constant, amount: Constant): TimestampSub; + +// @beta +export function timestampSub(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + +// @beta +export function timestampSub(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + +// @beta (undocumented) +export class TimestampToUnixMicros extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function timestampToUnixMicros(expr: Constant): TimestampToUnixMicros; + +// @beta +export function timestampToUnixMicros(field: string): TimestampToUnixMicros; + +// @beta (undocumented) +export class TimestampToUnixMillis extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function timestampToUnixMillis(expr: Constant): TimestampToUnixMillis; + +// @beta +export function timestampToUnixMillis(field: string): TimestampToUnixMillis; + +// @beta (undocumented) +export class TimestampToUnixSeconds extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function timestampToUnixSeconds(expr: Constant): TimestampToUnixSeconds; + +// @beta +export function timestampToUnixSeconds(field: string): TimestampToUnixSeconds; + +// @beta (undocumented) +export class ToLower extends FirestoreFunction { + constructor(expr: Constant); + } + +// @beta +export function toLower(expr: string): ToLower; + +// @beta +export function toLower(expr: Constant): ToLower; + +// @beta (undocumented) +export class ToUpper extends FirestoreFunction { + constructor(expr: Constant); + } + +// @beta +export function toUpper(expr: string): ToUpper; + +// @beta +export function toUpper(expr: Constant): ToUpper; + // @public export class Transaction { delete(documentRef: DocumentReference): this; @@ -726,9 +2348,53 @@ export interface TransactionOptions { readonly maxAttempts?: number; } +// @beta (undocumented) +export class Trim extends FirestoreFunction { + constructor(expr: Constant); + } + +// @beta +export function trim(expr: string): Trim; + +// @beta +export function trim(expr: Constant): Trim; + // @public export type UnionToIntersection = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never; +// @beta (undocumented) +export class UnixMicrosToTimestamp extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function unixMicrosToTimestamp(expr: Constant): UnixMicrosToTimestamp; + +// @beta +export function unixMicrosToTimestamp(field: string): UnixMicrosToTimestamp; + +// @beta (undocumented) +export class UnixMillisToTimestamp extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function unixMillisToTimestamp(expr: Constant): UnixMillisToTimestamp; + +// @beta +export function unixMillisToTimestamp(field: string): UnixMillisToTimestamp; + +// @beta (undocumented) +export class UnixSecondsToTimestamp extends FirestoreFunction { + constructor(input: Constant); + } + +// @beta +export function unixSecondsToTimestamp(expr: Constant): UnixSecondsToTimestamp; + +// @beta +export function unixSecondsToTimestamp(field: string): UnixSecondsToTimestamp; + // @public export interface Unsubscribe { (): void; @@ -745,9 +2411,23 @@ export function updateDoc(refere // @public export function updateDoc(reference: DocumentReference, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise; +// @public +export function useFirestorePipelines(): void; + // @public export function vector(values?: number[]): VectorValue; +// @beta (undocumented) +export class VectorLength extends FirestoreFunction { + constructor(value: Constant); + } + +// @beta +export function vectorLength(expr: Constant): VectorLength; + +// @beta +export function vectorLength(field: string): VectorLength; + // @public export class VectorValue { /* Excluded from this release type: __constructor */ @@ -758,6 +2438,13 @@ export class VectorValue { // @public export function waitForPendingWrites(firestore: Firestore): Promise; +// @beta (undocumented) +export class Where implements Stage { + constructor(condition: FilterCondition & Constant); + // (undocumented) + name: string; +} + // @public export function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryFieldFilterConstraint; @@ -782,5 +2469,21 @@ export class WriteBatch { // @public export function writeBatch(firestore: Firestore): WriteBatch; +// @beta (undocumented) +export class Xor extends FirestoreFunction implements FilterCondition { + constructor(conditions: FilterExpr[]); + // (undocumented) + filterable: true; +} + +// @beta +export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; + + +// Warnings were encountered during analysis: +// +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10102:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10102:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10129:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/package.json b/package.json index 62fe45a3256..d6fbc47e019 100644 --- a/package.json +++ b/package.json @@ -143,6 +143,7 @@ "postinstall-postinstall": "2.1.0", "prettier": "2.8.7", "protractor": "5.4.2", + "protobufjs-cli": "^1.1.3", "request": "2.88.2", "semver": "7.5.3", "simple-git": "3.24.0", diff --git a/packages/firestore/lite/index.ts b/packages/firestore/lite/index.ts index b751f0a8254..636eb4c6709 100644 --- a/packages/firestore/lite/index.ts +++ b/packages/firestore/lite/index.ts @@ -27,6 +27,171 @@ import { registerFirestore } from './register'; registerFirestore(); +export { PipelineSource } from '../src/lite-api/pipeline-source'; + +export { PipelineResult } from '../src/lite-api/pipeline-result'; + +export { Pipeline, pipeline } from '../src/lite-api/pipeline'; + +export { useFirestorePipelines } from '../src/lite-api/database_augmentation'; + +export { execute } from '../src/lite-api/pipeline_impl'; + +export { + Stage, + FindNearestOptions, + AddFields, + Aggregate, + Distinct, + CollectionSource, + CollectionGroupSource, + DatabaseSource, + DocumentsSource, + Where, + FindNearest, + Limit, + Offset, + Select, + Sort, + GenericStage +} from '../src/lite-api/stage'; + +export { + add, + subtract, + multiply, + divide, + mod, + eq, + neq, + lt, + lte, + gt, + gte, + arrayConcat, + arrayContains, + arrayContainsAny, + arrayContainsAll, + arrayLength, + inAny, + notInAny, + xor, + ifFunction, + not, + logicalMax, + logicalMin, + exists, + isNan, + reverse, + replaceFirst, + replaceAll, + byteLength, + charLength, + like, + regexContains, + regexMatch, + strContains, + startsWith, + endsWith, + toLower, + toUpper, + trim, + strConcat, + mapGet, + countAll, + min, + max, + cosineDistance, + dotProduct, + euclideanDistance, + vectorLength, + unixMicrosToTimestamp, + timestampToUnixMicros, + unixMillisToTimestamp, + timestampToUnixMillis, + unixSecondsToTimestamp, + timestampToUnixSeconds, + timestampAdd, + timestampSub, + genericFunction, + ascending, + descending, + ExprWithAlias, + Field, + Fields, + Constant, + FirestoreFunction, + Add, + Subtract, + Multiply, + Divide, + Mod, + Eq, + Neq, + Lt, + Lte, + Gt, + Gte, + ArrayConcat, + ArrayReverse, + ArrayContains, + ArrayContainsAll, + ArrayContainsAny, + ArrayLength, + ArrayElement, + In, + IsNan, + Exists, + Not, + And, + Or, + Xor, + If, + LogicalMax, + LogicalMin, + Reverse, + ReplaceFirst, + ReplaceAll, + CharLength, + ByteLength, + Like, + RegexContains, + RegexMatch, + StrContains, + StartsWith, + EndsWith, + ToLower, + ToUpper, + Trim, + StrConcat, + MapGet, + Count, + Sum, + Avg, + Min, + Max, + CosineDistance, + DotProduct, + EuclideanDistance, + VectorLength, + UnixMicrosToTimestamp, + TimestampToUnixMicros, + UnixMillisToTimestamp, + TimestampToUnixMillis, + UnixSecondsToTimestamp, + TimestampToUnixSeconds, + TimestampAdd, + TimestampSub, + Ordering, + ExprType, + AccumulatorTarget, + FilterExpr, + SelectableExpr, + Selectable, + FilterCondition, + Accumulator +} from '../src/lite-api/expressions'; + export { aggregateQuerySnapshotEqual, getCount, diff --git a/packages/firestore/src/api.ts b/packages/firestore/src/api.ts index ea969c6b94c..4d33b925706 100644 --- a/packages/firestore/src/api.ts +++ b/packages/firestore/src/api.ts @@ -15,6 +15,176 @@ * limitations under the License. */ +export { PipelineSource } from './lite-api/pipeline-source'; + +export { PipelineResult } from './lite-api/pipeline-result'; + +export { Pipeline, pipeline } from './api/pipeline'; + +export { useFirestorePipelines } from './api/database_augmentation'; + +export { execute } from './lite-api/pipeline_impl'; + +export { + Stage, + FindNearestOptions, + AddFields, + Aggregate, + Distinct, + CollectionSource, + CollectionGroupSource, + DatabaseSource, + DocumentsSource, + Where, + FindNearest, + Limit, + Offset, + Select, + Sort, + GenericStage +} from './lite-api/stage'; + +export { + add, + subtract, + multiply, + divide, + mod, + eq, + neq, + lt, + lte, + gt, + gte, + arrayConcat, + arrayContains, + arrayContainsAny, + arrayContainsAll, + arrayLength, + inAny, + notInAny, + xor, + ifFunction, + not, + logicalMax, + logicalMin, + exists, + isNan, + reverse, + replaceFirst, + replaceAll, + byteLength, + charLength, + like, + regexContains, + regexMatch, + strContains, + startsWith, + endsWith, + toLower, + toUpper, + trim, + strConcat, + mapGet, + countAll, + countFunction, + sumFunction, + avgFunction, + andFunction, + orFunction, + min, + max, + cosineDistance, + dotProduct, + euclideanDistance, + vectorLength, + unixMicrosToTimestamp, + timestampToUnixMicros, + unixMillisToTimestamp, + timestampToUnixMillis, + unixSecondsToTimestamp, + timestampToUnixSeconds, + timestampAdd, + timestampSub, + genericFunction, + ascending, + descending, + ExprWithAlias, + Field, + Fields, + Constant, + FirestoreFunction, + Add, + Subtract, + Multiply, + Divide, + Mod, + Eq, + Neq, + Lt, + Lte, + Gt, + Gte, + ArrayConcat, + ArrayReverse, + ArrayContains, + ArrayContainsAll, + ArrayContainsAny, + ArrayLength, + ArrayElement, + In, + IsNan, + Exists, + Not, + And, + Or, + Xor, + If, + LogicalMax, + LogicalMin, + Reverse, + ReplaceFirst, + ReplaceAll, + CharLength, + ByteLength, + Like, + RegexContains, + RegexMatch, + StrContains, + StartsWith, + EndsWith, + ToLower, + ToUpper, + Trim, + StrConcat, + MapGet, + Count, + Sum, + Avg, + Min, + Max, + CosineDistance, + DotProduct, + EuclideanDistance, + VectorLength, + UnixMicrosToTimestamp, + TimestampToUnixMicros, + UnixMillisToTimestamp, + TimestampToUnixMillis, + UnixSecondsToTimestamp, + TimestampToUnixSeconds, + TimestampAdd, + TimestampSub, + Ordering, + ExprType, + AccumulatorTarget, + FilterExpr, + SelectableExpr, + Selectable, + FilterCondition, + Accumulator +} from './lite-api/expressions'; + export { aggregateFieldEqual, aggregateQuerySnapshotEqual, @@ -224,7 +394,8 @@ export { isBase64Available as _isBase64Available } from './platform/base64'; export { DatabaseId as _DatabaseId } from './core/database_info'; export { _internalQueryToProtoQueryTarget, - _internalAggregationQueryToProtoRunAggregationQueryRequest + _internalAggregationQueryToProtoRunAggregationQueryRequest, + _internalPipelineToExecutePipelineRequestProto } from './remote/internal_serializer'; export { cast as _cast, diff --git a/packages/firestore/src/api/aggregate.ts b/packages/firestore/src/api/aggregate.ts index f0e2c1e1dc0..453f9e0a841 100644 --- a/packages/firestore/src/api/aggregate.ts +++ b/packages/firestore/src/api/aggregate.ts @@ -15,17 +15,21 @@ * limitations under the License. */ -import { AggregateField, AggregateSpec, DocumentData, Query } from '../api'; import { AggregateImpl } from '../core/aggregate'; import { firestoreClientRunAggregateQuery } from '../core/firestore_client'; import { count } from '../lite-api/aggregate'; -import { AggregateQuerySnapshot } from '../lite-api/aggregate_types'; +import { + AggregateField, + AggregateQuerySnapshot, + AggregateSpec +} from '../lite-api/aggregate_types'; +import { DocumentData, Query } from '../lite-api/reference'; import { ApiClientObjectMap, Value } from '../protos/firestore_proto_api'; import { cast } from '../util/input_validation'; import { mapToArray } from '../util/obj'; import { ensureFirestoreConfigured, Firestore } from './database'; -import { ExpUserDataWriter } from './reference_impl'; +import { ExpUserDataWriter } from './user_data_writer'; export { aggregateQuerySnapshotEqual, diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index 0757378a74c..cc1fab0c86a 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -46,6 +46,7 @@ import { connectFirestoreEmulator, Firestore as LiteFirestore } from '../lite-api/database'; +import type { PipelineSource } from '../lite-api/pipeline-source'; import { Query } from '../lite-api/reference'; import { indexedDbClearPersistence, @@ -128,6 +129,15 @@ export class Firestore extends LiteFirestore { await terminate; } } + + /** + * Pipeline query. + */ + pipeline(): PipelineSource { + throw new Error( + 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' + ); + } } /** diff --git a/packages/firestore/src/api/database_augmentation.ts b/packages/firestore/src/api/database_augmentation.ts new file mode 100644 index 00000000000..0eb8c91a034 --- /dev/null +++ b/packages/firestore/src/api/database_augmentation.ts @@ -0,0 +1,57 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Pipeline } from '../lite-api/pipeline'; +import { PipelineSource } from '../lite-api/pipeline-source'; +import { newUserDataReader } from '../lite-api/user_data_reader'; +import { DocumentKey } from '../model/document_key'; + +import { Firestore } from './database'; +import { DocumentReference, Query } from './reference'; +import { ExpUserDataWriter } from './user_data_writer'; + +export function useFirestorePipelines(): void { + Firestore.prototype.pipeline = function (): PipelineSource { + const firestore = this; + return new PipelineSource( + this, + newUserDataReader(firestore), + new ExpUserDataWriter(firestore), + (key: DocumentKey) => { + return new DocumentReference(firestore, null, key); + } + ); + }; + + Query.prototype.pipeline = function (): Pipeline { + let pipeline; + if (this._query.collectionGroup) { + pipeline = this.firestore + .pipeline() + .collectionGroup(this._query.collectionGroup); + } else { + pipeline = this.firestore + .pipeline() + .collection(this._query.path.canonicalString()); + } + + // TODO(pipeline) convert existing query filters, limits, etc into + // pipeline stages + + return pipeline; + }; +} diff --git a/packages/firestore/src/api/pipeline.ts b/packages/firestore/src/api/pipeline.ts new file mode 100644 index 00000000000..14532ba85c0 --- /dev/null +++ b/packages/firestore/src/api/pipeline.ts @@ -0,0 +1,135 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { firestoreClientExecutePipeline } from '../core/firestore_client'; +import { Pipeline as LitePipeline } from '../lite-api/pipeline'; +import { PipelineResult } from '../lite-api/pipeline-result'; +import { PipelineSource } from '../lite-api/pipeline-source'; +import { DocumentData, DocumentReference, Query } from '../lite-api/reference'; +import { Stage } from '../lite-api/stage'; +import { UserDataReader } from '../lite-api/user_data_reader'; +import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; +import { DocumentKey } from '../model/document_key'; +import { cast } from '../util/input_validation'; + +import { ensureFirestoreConfigured, Firestore } from './database'; + +export class Pipeline< + AppModelType = DocumentData +> extends LitePipeline { + /** + * @internal + * @private + * @param db + * @param userDataReader + * @param userDataWriter + * @param documentReferenceFactory + * @param stages + * @param converter + */ + constructor( + db: Firestore, + userDataReader: UserDataReader, + userDataWriter: AbstractUserDataWriter, + documentReferenceFactory: (id: DocumentKey) => DocumentReference, + stages: Stage[], + // TODO(pipeline) support converter + //private converter: FirestorePipelineConverter = defaultPipelineConverter() + converter: unknown = {} + ) { + super( + db, + userDataReader, + userDataWriter, + documentReferenceFactory, + stages, + converter + ); + } + + /** + * Executes this pipeline and returns a Promise to represent the asynchronous operation. + * + *

The returned Promise can be used to track the progress of the pipeline execution + * and retrieve the results (or handle any errors) asynchronously. + * + *

The pipeline results are returned as a list of {@link PipelineResult} objects. Each {@link + * PipelineResult} typically represents a single key/value map that has passed through all the + * stages of the pipeline, however this might differ depending on the stages involved in the + * pipeline. For example: + * + *

    + *
  • If there are no stages or only transformation stages, each {@link PipelineResult} + * represents a single document.
  • + *
  • If there is an aggregation, only a single {@link PipelineResult} is returned, + * representing the aggregated results over the entire dataset .
  • + *
  • If there is an aggregation stage with grouping, each {@link PipelineResult} represents a + * distinct group and its associated aggregated values.
  • + *
+ * + *

Example: + * + * ```typescript + * const futureResults = await firestore.pipeline().collection("books") + * .where(gt(Field.of("rating"), 4.5)) + * .select("title", "author", "rating") + * .execute(); + * ``` + * + * @return A Promise representing the asynchronous pipeline execution. + */ + execute(): Promise>> { + const firestore = cast(this._db, Firestore); + const client = ensureFirestoreConfigured(firestore); + return firestoreClientExecutePipeline(client, this).then(result => { + const docs = result.map( + element => + new PipelineResult( + this.userDataWriter, + element.key?.path + ? this.documentReferenceFactory(element.key) + : undefined, + element.fields, + element.executionTime?.toTimestamp(), + element.createTime?.toTimestamp(), + element.updateTime?.toTimestamp() + //this.converter + ) + ); + + return docs; + }); + } +} + +/** + * Experimental Modular API for console testing. + * @param firestore + */ +export function pipeline(firestore: Firestore): PipelineSource; + +/** + * Experimental Modular API for console testing. + * @param query + */ +export function pipeline(query: Query): Pipeline; + +export function pipeline( + firestoreOrQuery: Firestore | Query +): PipelineSource | Pipeline { + return firestoreOrQuery.pipeline(); +} diff --git a/packages/firestore/src/api/reference_impl.ts b/packages/firestore/src/api/reference_impl.ts index e730fb40da7..86956a52785 100644 --- a/packages/firestore/src/api/reference_impl.ts +++ b/packages/firestore/src/api/reference_impl.ts @@ -36,7 +36,6 @@ import { } from '../core/firestore_client'; import { newQueryForPath, Query as InternalQuery } from '../core/query'; import { ViewSnapshot } from '../core/view_snapshot'; -import { Bytes } from '../lite-api/bytes'; import { FieldPath } from '../lite-api/field_path'; import { validateHasExplicitOrderByForLimitToLast } from '../lite-api/query'; import { @@ -58,15 +57,14 @@ import { parseUpdateData, parseUpdateVarargs } from '../lite-api/user_data_reader'; -import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; import { DeleteMutation, Mutation, Precondition } from '../model/mutation'; import { debugAssert } from '../util/assert'; -import { ByteString } from '../util/byte_string'; import { FirestoreError } from '../util/error'; import { cast } from '../util/input_validation'; import { ensureFirestoreConfigured, Firestore } from './database'; import { DocumentSnapshot, QuerySnapshot, SnapshotMetadata } from './snapshot'; +import { ExpUserDataWriter } from './user_data_writer'; /** * An options object that can be passed to {@link (onSnapshot:1)} and {@link @@ -123,21 +121,6 @@ export function getDoc( ).then(snapshot => convertToDocSnapshot(firestore, reference, snapshot)); } -export class ExpUserDataWriter extends AbstractUserDataWriter { - constructor(protected firestore: Firestore) { - super(); - } - - protected convertBytes(bytes: ByteString): Bytes { - return new Bytes(bytes); - } - - protected convertReference(name: string): DocumentReference { - const key = this.convertDocumentKey(name, this.firestore._databaseId); - return new DocumentReference(this.firestore, /* converter= */ null, key); - } -} - /** * Reads the document referred to by this `DocumentReference` from cache. * Returns an error if the document is not currently cached. diff --git a/packages/firestore/src/api/transaction.ts b/packages/firestore/src/api/transaction.ts index 955866f19b4..8f83f527182 100644 --- a/packages/firestore/src/api/transaction.ts +++ b/packages/firestore/src/api/transaction.ts @@ -28,9 +28,9 @@ import { validateReference } from '../lite-api/write_batch'; import { cast } from '../util/input_validation'; import { ensureFirestoreConfigured, Firestore } from './database'; -import { ExpUserDataWriter } from './reference_impl'; import { DocumentSnapshot, SnapshotMetadata } from './snapshot'; import { TransactionOptions } from './transaction_options'; +import { ExpUserDataWriter } from './user_data_writer'; /** * A reference to a transaction. diff --git a/packages/firestore/src/api/user_data_writer.ts b/packages/firestore/src/api/user_data_writer.ts new file mode 100644 index 00000000000..3567f72cd93 --- /dev/null +++ b/packages/firestore/src/api/user_data_writer.ts @@ -0,0 +1,38 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Bytes } from '../lite-api/bytes'; +import { DocumentReference } from '../lite-api/reference'; +import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; +import { ByteString } from '../util/byte_string'; + +import { Firestore } from './database'; + +export class ExpUserDataWriter extends AbstractUserDataWriter { + constructor(protected firestore: Firestore) { + super(); + } + + protected convertBytes(bytes: ByteString): Bytes { + return new Bytes(bytes); + } + + protected convertReference(name: string): DocumentReference { + const key = this.convertDocumentKey(name, this.firestore._databaseId); + return new DocumentReference(this.firestore, /* converter= */ null, key); + } +} diff --git a/packages/firestore/src/core/firestore_client.ts b/packages/firestore/src/core/firestore_client.ts index e2aa19aaba8..ad485c7f77a 100644 --- a/packages/firestore/src/core/firestore_client.ts +++ b/packages/firestore/src/core/firestore_client.ts @@ -23,6 +23,7 @@ import { CredentialsProvider } from '../api/credentials'; import { User } from '../auth/user'; +import { Pipeline } from '../lite-api/pipeline'; import { LocalStore } from '../local/local_store'; import { localStoreConfigureFieldIndexes, @@ -38,11 +39,16 @@ import { Document } from '../model/document'; import { DocumentKey } from '../model/document_key'; import { FieldIndex } from '../model/field_index'; import { Mutation } from '../model/mutation'; +import { PipelineStreamElement } from '../model/pipeline_stream_element'; import { toByteStreamReader } from '../platform/byte_stream_reader'; import { newSerializer } from '../platform/serializer'; import { newTextEncoder } from '../platform/text_serializer'; import { ApiClientObjectMap, Value } from '../protos/firestore_proto_api'; -import { Datastore, invokeRunAggregationQueryRpc } from '../remote/datastore'; +import { + Datastore, + invokeExecutePipeline, + invokeRunAggregationQueryRpc +} from '../remote/datastore'; import { RemoteStore, remoteStoreDisableNetwork, @@ -549,6 +555,23 @@ export function firestoreClientRunAggregateQuery( return deferred.promise; } +export function firestoreClientExecutePipeline( + client: FirestoreClient, + pipeline: Pipeline +): Promise { + const deferred = new Deferred(); + + client.asyncQueue.enqueueAndForget(async () => { + try { + const datastore = await getDatastore(client); + deferred.resolve(invokeExecutePipeline(datastore, pipeline)); + } catch (e) { + deferred.reject(e as Error); + } + }); + return deferred.promise; +} + export function firestoreClientWrite( client: FirestoreClient, mutations: Mutation[] diff --git a/packages/firestore/src/core/pipeline-util.ts b/packages/firestore/src/core/pipeline-util.ts new file mode 100644 index 00000000000..732d2963fcf --- /dev/null +++ b/packages/firestore/src/core/pipeline-util.ts @@ -0,0 +1,252 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + Constant, + Expr, + Field, + FilterCondition, + not, + andFunction, + orFunction +} from '../lite-api/expressions'; +import { isNanValue, isNullValue } from '../model/values'; +import { + ArrayValue as ProtoArrayValue, + Function as ProtoFunction, + LatLng as ProtoLatLng, + MapValue as ProtoMapValue, + Pipeline as ProtoPipeline, + Timestamp as ProtoTimestamp, + Value as ProtoValue +} from '../protos/firestore_proto_api'; +import { fail } from '../util/assert'; +import { isPlainObject } from '../util/input_validation'; + +import { + CompositeFilter as CompositeFilterInternal, + CompositeOperator, + FieldFilter as FieldFilterInternal, + Filter as FilterInternal, + Operator +} from './filter'; + +/* eslint @typescript-eslint/no-explicit-any: 0 */ + +function isITimestamp(obj: any): obj is ProtoTimestamp { + if (typeof obj !== 'object' || obj === null) { + return false; // Must be a non-null object + } + if ( + 'seconds' in obj && + (obj.seconds === null || + typeof obj.seconds === 'number' || + typeof obj.seconds === 'string') && + 'nanos' in obj && + (obj.nanos === null || typeof obj.nanos === 'number') + ) { + return true; + } + + return false; +} +function isILatLng(obj: any): obj is ProtoLatLng { + if (typeof obj !== 'object' || obj === null) { + return false; // Must be a non-null object + } + if ( + 'latitude' in obj && + (obj.latitude === null || typeof obj.latitude === 'number') && + 'longitude' in obj && + (obj.longitude === null || typeof obj.longitude === 'number') + ) { + return true; + } + + return false; +} +function isIArrayValue(obj: any): obj is ProtoArrayValue { + if (typeof obj !== 'object' || obj === null) { + return false; // Must be a non-null object + } + if ('values' in obj && (obj.values === null || Array.isArray(obj.values))) { + return true; + } + + return false; +} +function isIMapValue(obj: any): obj is ProtoMapValue { + if (typeof obj !== 'object' || obj === null) { + return false; // Must be a non-null object + } + if ('fields' in obj && (obj.fields === null || isPlainObject(obj.fields))) { + return true; + } + + return false; +} +function isIFunction(obj: any): obj is ProtoFunction { + if (typeof obj !== 'object' || obj === null) { + return false; // Must be a non-null object + } + if ( + 'name' in obj && + (obj.name === null || typeof obj.name === 'string') && + 'args' in obj && + (obj.args === null || Array.isArray(obj.args)) + ) { + return true; + } + + return false; +} + +function isIPipeline(obj: any): obj is ProtoPipeline { + if (typeof obj !== 'object' || obj === null) { + return false; // Must be a non-null object + } + if ('stages' in obj && (obj.stages === null || Array.isArray(obj.stages))) { + return true; + } + + return false; +} + +export function isFirestoreValue(obj: any): obj is ProtoValue { + if (typeof obj !== 'object' || obj === null) { + return false; // Must be a non-null object + } + + // Check optional properties and their types + if ( + ('nullValue' in obj && + (obj.nullValue === null || obj.nullValue === 'NULL_VALUE')) || + ('booleanValue' in obj && + (obj.booleanValue === null || typeof obj.booleanValue === 'boolean')) || + ('integerValue' in obj && + (obj.integerValue === null || + typeof obj.integerValue === 'number' || + typeof obj.integerValue === 'string')) || + ('doubleValue' in obj && + (obj.doubleValue === null || typeof obj.doubleValue === 'number')) || + ('timestampValue' in obj && + (obj.timestampValue === null || isITimestamp(obj.timestampValue))) || + ('stringValue' in obj && + (obj.stringValue === null || typeof obj.stringValue === 'string')) || + ('bytesValue' in obj && + (obj.bytesValue === null || obj.bytesValue instanceof Uint8Array)) || + ('referenceValue' in obj && + (obj.referenceValue === null || + typeof obj.referenceValue === 'string')) || + ('geoPointValue' in obj && + (obj.geoPointValue === null || isILatLng(obj.geoPointValue))) || + ('arrayValue' in obj && + (obj.arrayValue === null || isIArrayValue(obj.arrayValue))) || + ('mapValue' in obj && + (obj.mapValue === null || isIMapValue(obj.mapValue))) || + ('fieldReferenceValue' in obj && + (obj.fieldReferenceValue === null || + typeof obj.fieldReferenceValue === 'string')) || + ('functionValue' in obj && + (obj.functionValue === null || isIFunction(obj.functionValue))) || + ('pipelineValue' in obj && + (obj.pipelineValue === null || isIPipeline(obj.pipelineValue))) + ) { + return true; + } + + return false; +} + +export function toPipelineFilterCondition( + f: FilterInternal +): FilterCondition & Expr { + if (f instanceof FieldFilterInternal) { + const field = Field.of(f.field.toString()); + if (isNanValue(f.value)) { + if (f.op === Operator.EQUAL) { + return andFunction(field.exists(), field.isNaN()); + } else { + return andFunction(field.exists(), not(field.isNaN())); + } + } else if (isNullValue(f.value)) { + if (f.op === Operator.EQUAL) { + return andFunction(field.exists(), field.eq(null)); + } else { + return andFunction(field.exists(), not(field.eq(null))); + } + } else { + // Comparison filters + const value = f.value; + switch (f.op) { + case Operator.LESS_THAN: + return andFunction(field.exists(), field.lt(value)); + case Operator.LESS_THAN_OR_EQUAL: + return andFunction(field.exists(), field.lte(value)); + case Operator.GREATER_THAN: + return andFunction(field.exists(), field.gt(value)); + case Operator.GREATER_THAN_OR_EQUAL: + return andFunction(field.exists(), field.gte(value)); + case Operator.EQUAL: + return andFunction(field.exists(), field.eq(value)); + case Operator.NOT_EQUAL: + return andFunction(field.exists(), field.neq(value)); + case Operator.ARRAY_CONTAINS: + return andFunction(field.exists(), field.arrayContains(value)); + case Operator.IN: { + const values = value?.arrayValue?.values?.map((val: any) => + Constant.of(val) + ); + return andFunction(field.exists(), field.in(...values!)); + } + case Operator.ARRAY_CONTAINS_ANY: { + const values = value?.arrayValue?.values?.map((val: any) => + Constant.of(val) + ); + return andFunction(field.exists(), field.arrayContainsAny(values!)); + } + case Operator.NOT_IN: { + const values = value?.arrayValue?.values?.map((val: any) => + Constant.of(val) + ); + return andFunction(field.exists(), not(field.in(...values!))); + } + default: + fail('Unexpected operator'); + } + } + } else if (f instanceof CompositeFilterInternal) { + switch (f.op) { + case CompositeOperator.AND: { + const conditions = f + .getFilters() + .map(f => toPipelineFilterCondition(f)); + return andFunction(conditions[0], ...conditions.slice(1)); + } + case CompositeOperator.OR: { + const conditions = f + .getFilters() + .map(f => toPipelineFilterCondition(f)); + return orFunction(conditions[0], ...conditions.slice(1)); + } + default: + fail('Unexpected operator'); + } + } + + throw new Error(`Failed to convert filter to pipeline conditions: ${f}`); +} diff --git a/packages/firestore/src/lite-api/database.ts b/packages/firestore/src/lite-api/database.ts index 9ea4d4ec52e..6ef01bb5172 100644 --- a/packages/firestore/src/lite-api/database.ts +++ b/packages/firestore/src/lite-api/database.ts @@ -41,6 +41,9 @@ import { cast } from '../util/input_validation'; import { logWarn } from '../util/log'; import { FirestoreService, removeComponents } from './components'; +// `import type` to avoid bundling the source for +// pipelines if `useFirestorePipelines()` is not called +import type { PipelineSource } from './pipeline-source'; import { DEFAULT_HOST, FirestoreSettingsImpl, @@ -173,6 +176,15 @@ export class Firestore implements FirestoreService { removeComponents(this); return Promise.resolve(); } + + /** + * Pipeline query. + */ + pipeline(): PipelineSource { + throw new Error( + 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' + ); + } } /** diff --git a/packages/firestore/src/lite-api/database_augmentation.ts b/packages/firestore/src/lite-api/database_augmentation.ts new file mode 100644 index 00000000000..14b9cf101c5 --- /dev/null +++ b/packages/firestore/src/lite-api/database_augmentation.ts @@ -0,0 +1,58 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { DocumentKey } from '../model/document_key'; + +import { Firestore } from './database'; +import { Pipeline } from './pipeline'; +import { PipelineSource } from './pipeline-source'; +import { DocumentReference, Query } from './reference'; +import { LiteUserDataWriter } from './reference_impl'; +import { newUserDataReader } from './user_data_reader'; + +export function useFirestorePipelines(): void { + Firestore.prototype.pipeline = function (): PipelineSource { + const userDataWriter = new LiteUserDataWriter(this); + const userDataReader = newUserDataReader(this); + return new PipelineSource( + this, + userDataReader, + userDataWriter, + (key: DocumentKey) => { + return new DocumentReference(this, null, key); + } + ); + }; + + Query.prototype.pipeline = function (): Pipeline { + let pipeline; + if (this._query.collectionGroup) { + pipeline = this.firestore + .pipeline() + .collectionGroup(this._query.collectionGroup); + } else { + pipeline = this.firestore + .pipeline() + .collection(this._query.path.canonicalString()); + } + + // TODO(pipeline) convert existing query filters, limits, etc into + // pipeline stages + + return pipeline; + }; +} diff --git a/packages/firestore/src/lite-api/expressions.ts b/packages/firestore/src/lite-api/expressions.ts new file mode 100644 index 00000000000..26a2f7c617c --- /dev/null +++ b/packages/firestore/src/lite-api/expressions.ts @@ -0,0 +1,6738 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* eslint @typescript-eslint/no-explicit-any: 0 */ + +import { + DOCUMENT_KEY_NAME, + FieldPath as InternalFieldPath +} from '../model/path'; +import { Value as ProtoValue } from '../protos/firestore_proto_api'; +import { + JsonProtoSerializer, + ProtoSerializable, + toStringValue, + UserData +} from '../remote/serializer'; +import { hardAssert } from '../util/assert'; + +import { documentId, FieldPath } from './field_path'; +import { GeoPoint } from './geo_point'; +import { Pipeline } from './pipeline'; +import { DocumentReference } from './reference'; +import { Timestamp } from './timestamp'; +import { + fieldPathFromArgument, + parseData, + UserDataReader, + UserDataSource +} from './user_data_reader'; +import { VectorValue } from './vector_value'; + +/** + * @beta + * + * An interface that represents a selectable expression. + */ +export interface Selectable { + selectable: true; +} + +/** + * @beta + * + * An interface that represents a filter condition. + */ +export interface FilterCondition { + filterable: true; +} + +/** + * @beta + * + * An interface that represents an accumulator. + */ +export interface Accumulator { + accumulator: true; + /** + * @private + * @internal + */ + _toProto(serializer: JsonProtoSerializer): ProtoValue; +} + +/** + * @beta + * + * An accumulator target, which is an expression with an alias that also implements the Accumulator interface. + */ +export type AccumulatorTarget = ExprWithAlias; + +/** + * @beta + * + * A filter expression, which is an expression that also implements the FilterCondition interface. + */ +export type FilterExpr = Expr & FilterCondition; + +/** + * @beta + * + * A selectable expression, which is an expression that also implements the Selectable interface. + */ +export type SelectableExpr = Expr & Selectable; + +/** + * @beta + * + * An enumeration of the different types of expressions. + */ +export type ExprType = + | 'Field' + | 'Constant' + | 'Function' + | 'ListOfExprs' + | 'ExprWithAlias'; + +/** + * @beta + * + * Represents an expression that can be evaluated to a value within the execution of a {@link + * Pipeline}. + * + * Expressions are the building blocks for creating complex queries and transformations in + * Firestore pipelines. They can represent: + * + * - **Field references:** Access values from document fields. + * - **Literals:** Represent constant values (strings, numbers, booleans). + * - **Function calls:** Apply functions to one or more expressions. + * - **Aggregations:** Calculate aggregate values (e.g., sum, average) over a set of documents. + * + * The `Expr` class provides a fluent API for building expressions. You can chain together + * method calls to create complex expressions. + */ +export abstract class Expr implements ProtoSerializable, UserData { + /** + * Creates an expression that adds this expression to another expression. + * + * ```typescript + * // Add the value of the 'quantity' field and the 'reserve' field. + * Field.of("quantity").add(Field.of("reserve")); + * ``` + * + * @param other The expression to add to this expression. + * @return A new `Expr` representing the addition operation. + */ + add(other: Expr): Add; + + /** + * Creates an expression that adds this expression to a constant value. + * + * ```typescript + * // Add 5 to the value of the 'age' field + * Field.of("age").add(5); + * ``` + * + * @param other The constant value to add. + * @return A new `Expr` representing the addition operation. + */ + add(other: any): Add; + add(other: any): Add { + if (other instanceof Expr) { + return new Add(this, other); + } + return new Add(this, Constant.of(other)); + } + + /** + * Creates an expression that subtracts another expression from this expression. + * + * ```typescript + * // Subtract the 'discount' field from the 'price' field + * Field.of("price").subtract(Field.of("discount")); + * ``` + * + * @param other The expression to subtract from this expression. + * @return A new `Expr` representing the subtraction operation. + */ + subtract(other: Expr): Subtract; + + /** + * Creates an expression that subtracts a constant value from this expression. + * + * ```typescript + * // Subtract 20 from the value of the 'total' field + * Field.of("total").subtract(20); + * ``` + * + * @param other The constant value to subtract. + * @return A new `Expr` representing the subtraction operation. + */ + subtract(other: any): Subtract; + subtract(other: any): Subtract { + if (other instanceof Expr) { + return new Subtract(this, other); + } + return new Subtract(this, Constant.of(other)); + } + + /** + * Creates an expression that multiplies this expression by another expression. + * + * ```typescript + * // Multiply the 'quantity' field by the 'price' field + * Field.of("quantity").multiply(Field.of("price")); + * ``` + * + * @param other The expression to multiply by. + * @return A new `Expr` representing the multiplication operation. + */ + multiply(other: Expr): Multiply; + + /** + * Creates an expression that multiplies this expression by a constant value. + * + * ```typescript + * // Multiply the 'value' field by 2 + * Field.of("value").multiply(2); + * ``` + * + * @param other The constant value to multiply by. + * @return A new `Expr` representing the multiplication operation. + */ + multiply(other: any): Multiply; + multiply(other: any): Multiply { + if (other instanceof Expr) { + return new Multiply(this, other); + } + return new Multiply(this, Constant.of(other)); + } + + /** + * Creates an expression that divides this expression by another expression. + * + * ```typescript + * // Divide the 'total' field by the 'count' field + * Field.of("total").divide(Field.of("count")); + * ``` + * + * @param other The expression to divide by. + * @return A new `Expr` representing the division operation. + */ + divide(other: Expr): Divide; + + /** + * Creates an expression that divides this expression by a constant value. + * + * ```typescript + * // Divide the 'value' field by 10 + * Field.of("value").divide(10); + * ``` + * + * @param other The constant value to divide by. + * @return A new `Expr` representing the division operation. + */ + divide(other: any): Divide; + divide(other: any): Divide { + if (other instanceof Expr) { + return new Divide(this, other); + } + return new Divide(this, Constant.of(other)); + } + + /** + * Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression. + * + * ```typescript + * // Calculate the remainder of dividing the 'value' field by the 'divisor' field + * Field.of("value").mod(Field.of("divisor")); + * ``` + * + * @param other The expression to divide by. + * @return A new `Expr` representing the modulo operation. + */ + mod(other: Expr): Mod; + + /** + * Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. + * + * ```typescript + * // Calculate the remainder of dividing the 'value' field by 10 + * Field.of("value").mod(10); + * ``` + * + * @param other The constant value to divide by. + * @return A new `Expr` representing the modulo operation. + */ + mod(other: any): Mod; + mod(other: any): Mod { + if (other instanceof Expr) { + return new Mod(this, other); + } + return new Mod(this, Constant.of(other)); + } + + // /** + // * Creates an expression that applies a bitwise AND operation between this expression and another expression. + // * + // * ```typescript + // * // Calculate the bitwise AND of 'field1' and 'field2'. + // * Field.of("field1").bitAnd(Field.of("field2")); + // * ``` + // * + // * @param other The right operand expression. + // * @return A new {@code Expr} representing the bitwise AND operation. + // */ + // bitAnd(other: Expr): BitAnd; + // + // /** + // * Creates an expression that applies a bitwise AND operation between this expression and a constant value. + // * + // * ```typescript + // * // Calculate the bitwise AND of 'field1' and 0xFF. + // * Field.of("field1").bitAnd(0xFF); + // * ``` + // * + // * @param other The right operand constant. + // * @return A new {@code Expr} representing the bitwise AND operation. + // */ + // bitAnd(other: any): BitAnd; + // bitAnd(other: any): BitAnd { + // if (other instanceof Expr) { + // return new BitAnd(this, other); + // } + // return new BitAnd(this, Constant.of(other)); + // } + // + // /** + // * Creates an expression that applies a bitwise OR operation between this expression and another expression. + // * + // * ```typescript + // * // Calculate the bitwise OR of 'field1' and 'field2'. + // * Field.of("field1").bitOr(Field.of("field2")); + // * ``` + // * + // * @param other The right operand expression. + // * @return A new {@code Expr} representing the bitwise OR operation. + // */ + // bitOr(other: Expr): BitOr; + // + // /** + // * Creates an expression that applies a bitwise OR operation between this expression and a constant value. + // * + // * ```typescript + // * // Calculate the bitwise OR of 'field1' and 0xFF. + // * Field.of("field1").bitOr(0xFF); + // * ``` + // * + // * @param other The right operand constant. + // * @return A new {@code Expr} representing the bitwise OR operation. + // */ + // bitOr(other: any): BitOr; + // bitOr(other: any): BitOr { + // if (other instanceof Expr) { + // return new BitOr(this, other); + // } + // return new BitOr(this, Constant.of(other)); + // } + // + // /** + // * Creates an expression that applies a bitwise XOR operation between this expression and another expression. + // * + // * ```typescript + // * // Calculate the bitwise XOR of 'field1' and 'field2'. + // * Field.of("field1").bitXor(Field.of("field2")); + // * ``` + // * + // * @param other The right operand expression. + // * @return A new {@code Expr} representing the bitwise XOR operation. + // */ + // bitXor(other: Expr): BitXor; + // + // /** + // * Creates an expression that applies a bitwise XOR operation between this expression and a constant value. + // * + // * ```typescript + // * // Calculate the bitwise XOR of 'field1' and 0xFF. + // * Field.of("field1").bitXor(0xFF); + // * ``` + // * + // * @param other The right operand constant. + // * @return A new {@code Expr} representing the bitwise XOR operation. + // */ + // bitXor(other: any): BitXor; + // bitXor(other: any): BitXor { + // if (other instanceof Expr) { + // return new BitXor(this, other); + // } + // return new BitXor(this, Constant.of(other)); + // } + // + // /** + // * Creates an expression that applies a bitwise NOT operation to this expression. + // * + // * ```typescript + // * // Calculate the bitwise NOT of 'field1'. + // * Field.of("field1").bitNot(); + // * ``` + // * + // * @return A new {@code Expr} representing the bitwise NOT operation. + // */ + // bitNot(): BitNot { + // return new BitNot(this); + // } + // + // /** + // * Creates an expression that applies a bitwise left shift operation between this expression and another expression. + // * + // * ```typescript + // * // Calculate the bitwise left shift of 'field1' by 'field2' bits. + // * Field.of("field1").bitLeftShift(Field.of("field2")); + // * ``` + // * + // * @param other The right operand expression representing the number of bits to shift. + // * @return A new {@code Expr} representing the bitwise left shift operation. + // */ + // bitLeftShift(other: Expr): BitLeftShift; + // + // /** + // * Creates an expression that applies a bitwise left shift operation between this expression and a constant value. + // * + // * ```typescript + // * // Calculate the bitwise left shift of 'field1' by 2 bits. + // * Field.of("field1").bitLeftShift(2); + // * ``` + // * + // * @param other The right operand constant representing the number of bits to shift. + // * @return A new {@code Expr} representing the bitwise left shift operation. + // */ + // bitLeftShift(other: number): BitLeftShift; + // bitLeftShift(other: Expr | number): BitLeftShift { + // if (typeof other === 'number') { + // return new BitLeftShift(this, Constant.of(other)); + // } + // return new BitLeftShift(this, other as Expr); + // } + // + // /** + // * Creates an expression that applies a bitwise right shift operation between this expression and another expression. + // * + // * ```typescript + // * // Calculate the bitwise right shift of 'field1' by 'field2' bits. + // * Field.of("field1").bitRightShift(Field.of("field2")); + // * ``` + // * + // * @param other The right operand expression representing the number of bits to shift. + // * @return A new {@code Expr} representing the bitwise right shift operation. + // */ + // bitRightShift(other: Expr): BitRightShift; + // + // /** + // * Creates an expression that applies a bitwise right shift operation between this expression and a constant value. + // * + // * ```typescript + // * // Calculate the bitwise right shift of 'field1' by 2 bits. + // * Field.of("field1").bitRightShift(2); + // * ``` + // * + // * @param other The right operand constant representing the number of bits to shift. + // * @return A new {@code Expr} representing the bitwise right shift operation. + // */ + // bitRightShift(other: number): BitRightShift; + // bitRightShift(other: Expr | number): BitRightShift { + // if (typeof other === 'number') { + // return new BitRightShift(this, Constant.of(other)); + // } + // return new BitRightShift(this, other as Expr); + // } + + /** + * Creates an expression that checks if this expression is equal to another expression. + * + * ```typescript + * // Check if the 'age' field is equal to 21 + * Field.of("age").eq(21); + * ``` + * + * @param other The expression to compare for equality. + * @return A new `Expr` representing the equality comparison. + */ + eq(other: Expr): Eq; + + /** + * Creates an expression that checks if this expression is equal to a constant value. + * + * ```typescript + * // Check if the 'city' field is equal to "London" + * Field.of("city").eq("London"); + * ``` + * + * @param other The constant value to compare for equality. + * @return A new `Expr` representing the equality comparison. + */ + eq(other: any): Eq; + eq(other: any): Eq { + if (other instanceof Expr) { + return new Eq(this, other); + } + return new Eq(this, Constant.of(other)); + } + + /** + * Creates an expression that checks if this expression is not equal to another expression. + * + * ```typescript + * // Check if the 'status' field is not equal to "completed" + * Field.of("status").neq("completed"); + * ``` + * + * @param other The expression to compare for inequality. + * @return A new `Expr` representing the inequality comparison. + */ + neq(other: Expr): Neq; + + /** + * Creates an expression that checks if this expression is not equal to a constant value. + * + * ```typescript + * // Check if the 'country' field is not equal to "USA" + * Field.of("country").neq("USA"); + * ``` + * + * @param other The constant value to compare for inequality. + * @return A new `Expr` representing the inequality comparison. + */ + neq(other: any): Neq; + neq(other: any): Neq { + if (other instanceof Expr) { + return new Neq(this, other); + } + return new Neq(this, Constant.of(other)); + } + + /** + * Creates an expression that checks if this expression is less than another expression. + * + * ```typescript + * // Check if the 'age' field is less than 'limit' + * Field.of("age").lt(Field.of('limit')); + * ``` + * + * @param other The expression to compare for less than. + * @return A new `Expr` representing the less than comparison. + */ + lt(other: Expr): Lt; + + /** + * Creates an expression that checks if this expression is less than a constant value. + * + * ```typescript + * // Check if the 'price' field is less than 50 + * Field.of("price").lt(50); + * ``` + * + * @param other The constant value to compare for less than. + * @return A new `Expr` representing the less than comparison. + */ + lt(other: any): Lt; + lt(other: any): Lt { + if (other instanceof Expr) { + return new Lt(this, other); + } + return new Lt(this, Constant.of(other)); + } + + /** + * Creates an expression that checks if this expression is less than or equal to another + * expression. + * + * ```typescript + * // Check if the 'quantity' field is less than or equal to 20 + * Field.of("quantity").lte(Constant.of(20)); + * ``` + * + * @param other The expression to compare for less than or equal to. + * @return A new `Expr` representing the less than or equal to comparison. + */ + lte(other: Expr): Lte; + + /** + * Creates an expression that checks if this expression is less than or equal to a constant value. + * + * ```typescript + * // Check if the 'score' field is less than or equal to 70 + * Field.of("score").lte(70); + * ``` + * + * @param other The constant value to compare for less than or equal to. + * @return A new `Expr` representing the less than or equal to comparison. + */ + lte(other: any): Lte; + lte(other: any): Lte { + if (other instanceof Expr) { + return new Lte(this, other); + } + return new Lte(this, Constant.of(other)); + } + + /** + * Creates an expression that checks if this expression is greater than another expression. + * + * ```typescript + * // Check if the 'age' field is greater than the 'limit' field + * Field.of("age").gt(Field.of("limit")); + * ``` + * + * @param other The expression to compare for greater than. + * @return A new `Expr` representing the greater than comparison. + */ + gt(other: Expr): Gt; + + /** + * Creates an expression that checks if this expression is greater than a constant value. + * + * ```typescript + * // Check if the 'price' field is greater than 100 + * Field.of("price").gt(100); + * ``` + * + * @param other The constant value to compare for greater than. + * @return A new `Expr` representing the greater than comparison. + */ + gt(other: any): Gt; + gt(other: any): Gt { + if (other instanceof Expr) { + return new Gt(this, other); + } + return new Gt(this, Constant.of(other)); + } + + /** + * Creates an expression that checks if this expression is greater than or equal to another + * expression. + * + * ```typescript + * // Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 + * Field.of("quantity").gte(Field.of('requirement').add(1)); + * ``` + * + * @param other The expression to compare for greater than or equal to. + * @return A new `Expr` representing the greater than or equal to comparison. + */ + gte(other: Expr): Gte; + + /** + * Creates an expression that checks if this expression is greater than or equal to a constant + * value. + * + * ```typescript + * // Check if the 'score' field is greater than or equal to 80 + * Field.of("score").gte(80); + * ``` + * + * @param other The constant value to compare for greater than or equal to. + * @return A new `Expr` representing the greater than or equal to comparison. + */ + gte(other: any): Gte; + gte(other: any): Gte { + if (other instanceof Expr) { + return new Gte(this, other); + } + return new Gte(this, Constant.of(other)); + } + + /** + * Creates an expression that concatenates an array expression with one or more other arrays. + * + * ```typescript + * // Combine the 'items' array with another array field. + * Field.of("items").arrayConcat(Field.of("otherItems")); + * ``` + * + * @param arrays The array expressions to concatenate. + * @return A new `Expr` representing the concatenated array. + */ + arrayConcat(arrays: Expr[]): ArrayConcat; + + /** + * Creates an expression that concatenates an array expression with one or more other arrays. + * + * ```typescript + * // Combine the 'tags' array with a new array and an array field + * Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); + * ``` + * + * @param arrays The array expressions or values to concatenate. + * @return A new `Expr` representing the concatenated array. + */ + arrayConcat(arrays: any[]): ArrayConcat; + arrayConcat(arrays: any[]): ArrayConcat { + const exprValues = arrays.map(value => + value instanceof Expr ? value : Constant.of(value) + ); + return new ArrayConcat(this, exprValues); + } + + /** + * Creates an expression that checks if an array contains a specific element. + * + * ```typescript + * // Check if the 'sizes' array contains the value from the 'selectedSize' field + * Field.of("sizes").arrayContains(Field.of("selectedSize")); + * ``` + * + * @param element The element to search for in the array. + * @return A new `Expr` representing the 'array_contains' comparison. + */ + arrayContains(element: Expr): ArrayContains; + + /** + * Creates an expression that checks if an array contains a specific value. + * + * ```typescript + * // Check if the 'colors' array contains "red" + * Field.of("colors").arrayContains("red"); + * ``` + * + * @param element The element to search for in the array. + * @return A new `Expr` representing the 'array_contains' comparison. + */ + arrayContains(element: any): ArrayContains; + arrayContains(element: any): ArrayContains { + if (element instanceof Expr) { + return new ArrayContains(this, element); + } + return new ArrayContains(this, Constant.of(element)); + } + + /** + * Creates an expression that checks if an array contains all the specified elements. + * + * ```typescript + * // Check if the 'tags' array contains both "news" and "sports" + * Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + * ``` + * + * @param values The elements to check for in the array. + * @return A new `Expr` representing the 'array_contains_all' comparison. + */ + arrayContainsAll(...values: Expr[]): ArrayContainsAll; + + /** + * Creates an expression that checks if an array contains all the specified elements. + * + * ```typescript + * // Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" + * Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + * ``` + * + * @param values The elements to check for in the array. + * @return A new `Expr` representing the 'array_contains_all' comparison. + */ + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll { + const exprValues = values.map(value => + value instanceof Expr ? value : Constant.of(value) + ); + return new ArrayContainsAll(this, exprValues); + } + + /** + * Creates an expression that checks if an array contains any of the specified elements. + * + * ```typescript + * // Check if the 'categories' array contains either values from field "cate1" or "cate2" + * Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + * ``` + * + * @param values The elements to check for in the array. + * @return A new `Expr` representing the 'array_contains_any' comparison. + */ + arrayContainsAny(...values: Expr[]): ArrayContainsAny; + + /** + * Creates an expression that checks if an array contains any of the specified elements. + * + * ```typescript + * // Check if the 'groups' array contains either the value from the 'userGroup' field + * // or the value "guest" + * Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + * ``` + * + * @param values The elements to check for in the array. + * @return A new `Expr` representing the 'array_contains_any' comparison. + */ + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny { + const exprValues = values.map(value => + value instanceof Expr ? value : Constant.of(value) + ); + return new ArrayContainsAny(this, exprValues); + } + + /** + * Creates an expression that calculates the length of an array. + * + * ```typescript + * // Get the number of items in the 'cart' array + * Field.of("cart").arrayLength(); + * ``` + * + * @return A new `Expr` representing the length of the array. + */ + arrayLength(): ArrayLength { + return new ArrayLength(this); + } + + /** + * Creates an expression that checks if this expression is equal to any of the provided values or + * expressions. + * + * ```typescript + * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' + * Field.of("category").in("Electronics", Field.of("primaryType")); + * ``` + * + * @param others The values or expressions to check against. + * @return A new `Expr` representing the 'IN' comparison. + */ + in(...others: Expr[]): In; + + /** + * Creates an expression that checks if this expression is equal to any of the provided values or + * expressions. + * + * ```typescript + * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' + * Field.of("category").in("Electronics", Field.of("primaryType")); + * ``` + * + * @param others The values or expressions to check against. + * @return A new `Expr` representing the 'IN' comparison. + */ + in(...others: any[]): In; + in(...others: any[]): In { + const exprOthers = others.map(other => + other instanceof Expr ? other : Constant.of(other) + ); + return new In(this, exprOthers); + } + + /** + * Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). + * + * ```typescript + * // Check if the result of a calculation is NaN + * Field.of("value").divide(0).isNaN(); + * ``` + * + * @return A new `Expr` representing the 'isNaN' check. + */ + isNaN(): IsNan { + return new IsNan(this); + } + + /** + * Creates an expression that checks if a field exists in the document. + * + * ```typescript + * // Check if the document has a field named "phoneNumber" + * Field.of("phoneNumber").exists(); + * ``` + * + * @return A new `Expr` representing the 'exists' check. + */ + exists(): Exists { + return new Exists(this); + } + + /** + * Creates an expression that calculates the character length of a string in UTF-8. + * + * ```typescript + * // Get the character length of the 'name' field in its UTF-8 form. + * Field.of("name").charLength(); + * ``` + * + * @return A new `Expr` representing the length of the string. + */ + charLength(): CharLength { + return new CharLength(this); + } + + /** + * Creates an expression that performs a case-sensitive string comparison. + * + * ```typescript + * // Check if the 'title' field contains the word "guide" (case-sensitive) + * Field.of("title").like("%guide%"); + * ``` + * + * @param pattern The pattern to search for. You can use "%" as a wildcard character. + * @return A new `Expr` representing the 'like' comparison. + */ + like(pattern: string): Like; + + /** + * Creates an expression that performs a case-sensitive string comparison. + * + * ```typescript + * // Check if the 'title' field contains the word "guide" (case-sensitive) + * Field.of("title").like("%guide%"); + * ``` + * + * @param pattern The pattern to search for. You can use "%" as a wildcard character. + * @return A new `Expr` representing the 'like' comparison. + */ + like(pattern: Expr): Like; + like(stringOrExpr: string | Expr): Like { + if (typeof stringOrExpr === 'string') { + return new Like(this, Constant.of(stringOrExpr)); + } + return new Like(this, stringOrExpr as Expr); + } + + /** + * Creates an expression that checks if a string contains a specified regular expression as a + * substring. + * + * ```typescript + * // Check if the 'description' field contains "example" (case-insensitive) + * Field.of("description").regexContains("(?i)example"); + * ``` + * + * @param pattern The regular expression to use for the search. + * @return A new `Expr` representing the 'contains' comparison. + */ + regexContains(pattern: string): RegexContains; + + /** + * Creates an expression that checks if a string contains a specified regular expression as a + * substring. + * + * ```typescript + * // Check if the 'description' field contains the regular expression stored in field 'regex' + * Field.of("description").regexContains(Field.of("regex")); + * ``` + * + * @param pattern The regular expression to use for the search. + * @return A new `Expr` representing the 'contains' comparison. + */ + regexContains(pattern: Expr): RegexContains; + regexContains(stringOrExpr: string | Expr): RegexContains { + if (typeof stringOrExpr === 'string') { + return new RegexContains(this, Constant.of(stringOrExpr)); + } + return new RegexContains(this, stringOrExpr as Expr); + } + + /** + * Creates an expression that checks if a string matches a specified regular expression. + * + * ```typescript + * // Check if the 'email' field matches a valid email pattern + * Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + * ``` + * + * @param pattern The regular expression to use for the match. + * @return A new `Expr` representing the regular expression match. + */ + regexMatch(pattern: string): RegexMatch; + + /** + * Creates an expression that checks if a string matches a specified regular expression. + * + * ```typescript + * // Check if the 'email' field matches a regular expression stored in field 'regex' + * Field.of("email").regexMatch(Field.of("regex")); + * ``` + * + * @param pattern The regular expression to use for the match. + * @return A new `Expr` representing the regular expression match. + */ + regexMatch(pattern: Expr): RegexMatch; + regexMatch(stringOrExpr: string | Expr): RegexMatch { + if (typeof stringOrExpr === 'string') { + return new RegexMatch(this, Constant.of(stringOrExpr)); + } + return new RegexMatch(this, stringOrExpr as Expr); + } + + /** + * Creates an expression that checks if a string contains a specified substring. + * + * ```typescript + * // Check if the 'description' field contains "example". + * Field.of("description").strContains("example"); + * ``` + * + * @param substring The substring to search for. + * @return A new `Expr` representing the 'contains' comparison. + */ + strContains(substring: string): StrContains; + + /** + * Creates an expression that checks if a string contains the string represented by another expression. + * + * ```typescript + * // Check if the 'description' field contains the value of the 'keyword' field. + * Field.of("description").strContains(Field.of("keyword")); + * ``` + * + * @param expr The expression representing the substring to search for. + * @return A new `Expr` representing the 'contains' comparison. + */ + strContains(expr: Expr): StrContains; + strContains(stringOrExpr: string | Expr): StrContains { + if (typeof stringOrExpr === 'string') { + return new StrContains(this, Constant.of(stringOrExpr)); + } + return new StrContains(this, stringOrExpr as Expr); + } + + /** + * Creates an expression that checks if a string starts with a given prefix. + * + * ```typescript + * // Check if the 'name' field starts with "Mr." + * Field.of("name").startsWith("Mr."); + * ``` + * + * @param prefix The prefix to check for. + * @return A new `Expr` representing the 'starts with' comparison. + */ + startsWith(prefix: string): StartsWith; + + /** + * Creates an expression that checks if a string starts with a given prefix (represented as an + * expression). + * + * ```typescript + * // Check if the 'fullName' field starts with the value of the 'firstName' field + * Field.of("fullName").startsWith(Field.of("firstName")); + * ``` + * + * @param prefix The prefix expression to check for. + * @return A new `Expr` representing the 'starts with' comparison. + */ + startsWith(prefix: Expr): StartsWith; + startsWith(stringOrExpr: string | Expr): StartsWith { + if (typeof stringOrExpr === 'string') { + return new StartsWith(this, Constant.of(stringOrExpr)); + } + return new StartsWith(this, stringOrExpr as Expr); + } + + /** + * Creates an expression that checks if a string ends with a given postfix. + * + * ```typescript + * // Check if the 'filename' field ends with ".txt" + * Field.of("filename").endsWith(".txt"); + * ``` + * + * @param suffix The postfix to check for. + * @return A new `Expr` representing the 'ends with' comparison. + */ + endsWith(suffix: string): EndsWith; + + /** + * Creates an expression that checks if a string ends with a given postfix (represented as an + * expression). + * + * ```typescript + * // Check if the 'url' field ends with the value of the 'extension' field + * Field.of("url").endsWith(Field.of("extension")); + * ``` + * + * @param suffix The postfix expression to check for. + * @return A new `Expr` representing the 'ends with' comparison. + */ + endsWith(suffix: Expr): EndsWith; + endsWith(stringOrExpr: string | Expr): EndsWith { + if (typeof stringOrExpr === 'string') { + return new EndsWith(this, Constant.of(stringOrExpr)); + } + return new EndsWith(this, stringOrExpr as Expr); + } + + /** + * Creates an expression that converts a string to lowercase. + * + * ```typescript + * // Convert the 'name' field to lowercase + * Field.of("name").toLower(); + * ``` + * + * @return A new `Expr` representing the lowercase string. + */ + toLower(): ToLower { + return new ToLower(this); + } + + /** + * Creates an expression that converts a string to uppercase. + * + * ```typescript + * // Convert the 'title' field to uppercase + * Field.of("title").toUpper(); + * ``` + * + * @return A new `Expr` representing the uppercase string. + */ + toUpper(): ToUpper { + return new ToUpper(this); + } + + /** + * Creates an expression that removes leading and trailing whitespace from a string. + * + * ```typescript + * // Trim whitespace from the 'userInput' field + * Field.of("userInput").trim(); + * ``` + * + * @return A new `Expr` representing the trimmed string. + */ + trim(): Trim { + return new Trim(this); + } + + /** + * Creates an expression that concatenates string expressions together. + * + * ```typescript + * // Combine the 'firstName', " ", and 'lastName' fields into a single string + * Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + * ``` + * + * @param elements The expressions (typically strings) to concatenate. + * @return A new `Expr` representing the concatenated string. + */ + strConcat(...elements: Array): StrConcat { + const exprs = elements.map(e => + typeof e === 'string' ? Constant.of(e) : (e as Expr) + ); + return new StrConcat(this, exprs); + } + + /** + * Creates an expression that reverses this string expression. + * + * ```typescript + * // Reverse the value of the 'myString' field. + * Field.of("myString").reverse(); + * ``` + * + * @return A new {@code Expr} representing the reversed string. + */ + reverse(): Reverse { + return new Reverse(this); + } + + /** + * Creates an expression that replaces the first occurrence of a substring within this string expression with another substring. + * + * ```typescript + * // Replace the first occurrence of "hello" with "hi" in the 'message' field + * Field.of("message").replaceFirst("hello", "hi"); + * ``` + * + * @param find The substring to search for. + * @param replace The substring to replace the first occurrence of 'find' with. + * @return A new {@code Expr} representing the string with the first occurrence replaced. + */ + replaceFirst(find: string, replace: string): ReplaceFirst; + + /** + * Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, + * where the substring to find and the replacement substring are specified by expressions. + * + * ```typescript + * // Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field + * Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + * ``` + * + * @param find The expression representing the substring to search for. + * @param replace The expression representing the substring to replace the first occurrence of 'find' with. + * @return A new {@code Expr} representing the string with the first occurrence replaced. + */ + replaceFirst(find: Expr, replace: Expr): ReplaceFirst; + replaceFirst(find: Expr | string, replace: Expr | string): ReplaceFirst { + const normalizedFind = typeof find === 'string' ? Constant.of(find) : find; + const normalizedReplace = + typeof replace === 'string' ? Constant.of(replace) : replace; + return new ReplaceFirst( + this, + normalizedFind as Expr, + normalizedReplace as Expr + ); + } + + /** + * Creates an expression that replaces all occurrences of a substring within this string expression with another substring. + * + * ```typescript + * // Replace all occurrences of "hello" with "hi" in the 'message' field + * Field.of("message").replaceAll("hello", "hi"); + * ``` + * + * @param find The substring to search for. + * @param replace The substring to replace all occurrences of 'find' with. + * @return A new {@code Expr} representing the string with all occurrences replaced. + */ + replaceAll(find: string, replace: string): ReplaceAll; + + /** + * Creates an expression that replaces all occurrences of a substring within this string expression with another substring, + * where the substring to find and the replacement substring are specified by expressions. + * + * ```typescript + * // Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field + * Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + * ``` + * + * @param find The expression representing the substring to search for. + * @param replace The expression representing the substring to replace all occurrences of 'find' with. + * @return A new {@code Expr} representing the string with all occurrences replaced. + */ + replaceAll(find: Expr, replace: Expr): ReplaceAll; + replaceAll(find: Expr | string, replace: Expr | string): ReplaceAll { + const normalizedFind = typeof find === 'string' ? Constant.of(find) : find; + const normalizedReplace = + typeof replace === 'string' ? Constant.of(replace) : replace; + return new ReplaceAll( + this, + normalizedFind as Expr, + normalizedReplace as Expr + ); + } + + /** + * Creates an expression that calculates the length of this string expression in bytes. + * + * ```typescript + * // Calculate the length of the 'myString' field in bytes. + * Field.of("myString").byteLength(); + * ``` + * + * @return A new {@code Expr} representing the length of the string in bytes. + */ + byteLength(): ByteLength { + return new ByteLength(this); + } + + /** + * Accesses a value from a map (object) field using the provided key. + * + * ```typescript + * // Get the 'city' value from the 'address' map field + * Field.of("address").mapGet("city"); + * ``` + * + * @param subfield The key to access in the map. + * @return A new `Expr` representing the value associated with the given key in the map. + */ + mapGet(subfield: string): MapGet { + return new MapGet(this, subfield); + } + + /** + * Creates an aggregation that counts the number of stage inputs with valid evaluations of the + * expression or field. + * + * ```typescript + * // Count the total number of products + * Field.of("productId").count().as("totalProducts"); + * ``` + * + * @return A new `Accumulator` representing the 'count' aggregation. + */ + count(): Count { + return new Count(this, false); + } + + /** + * Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs. + * + * ```typescript + * // Calculate the total revenue from a set of orders + * Field.of("orderAmount").sum().as("totalRevenue"); + * ``` + * + * @return A new `Accumulator` representing the 'sum' aggregation. + */ + sum(): Sum { + return new Sum(this, false); + } + + /** + * Creates an aggregation that calculates the average (mean) of a numeric field across multiple + * stage inputs. + * + * ```typescript + * // Calculate the average age of users + * Field.of("age").avg().as("averageAge"); + * ``` + * + * @return A new `Accumulator` representing the 'avg' aggregation. + */ + avg(): Avg { + return new Avg(this, false); + } + + /** + * Creates an aggregation that finds the minimum value of a field across multiple stage inputs. + * + * ```typescript + * // Find the lowest price of all products + * Field.of("price").min().as("lowestPrice"); + * ``` + * + * @return A new `Accumulator` representing the 'min' aggregation. + */ + min(): Min { + return new Min(this, false); + } + + /** + * Creates an aggregation that finds the maximum value of a field across multiple stage inputs. + * + * ```typescript + * // Find the highest score in a leaderboard + * Field.of("score").max().as("highestScore"); + * ``` + * + * @return A new `Accumulator` representing the 'max' aggregation. + */ + max(): Max { + return new Max(this, false); + } + + /** + * Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the larger value between the 'timestamp' field and the current timestamp. + * Field.of("timestamp").logicalMax(Function.currentTimestamp()); + * ``` + * + * @param other The expression to compare with. + * @return A new {@code Expr} representing the logical max operation. + */ + logicalMax(other: Expr): LogicalMax; + + /** + * Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the larger value between the 'value' field and 10. + * Field.of("value").logicalMax(10); + * ``` + * + * @param other The constant value to compare with. + * @return A new {@code Expr} representing the logical max operation. + */ + logicalMax(other: any): LogicalMax; + logicalMax(other: any): LogicalMax { + if (other instanceof Expr) { + return new LogicalMax(this, other as Expr); + } + return new LogicalMax(this, Constant.of(other)); + } + + /** + * Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the smaller value between the 'timestamp' field and the current timestamp. + * Field.of("timestamp").logicalMin(Function.currentTimestamp()); + * ``` + * + * @param other The expression to compare with. + * @return A new {@code Expr} representing the logical min operation. + */ + logicalMin(other: Expr): LogicalMin; + + /** + * Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the smaller value between the 'value' field and 10. + * Field.of("value").logicalMin(10); + * ``` + * + * @param other The constant value to compare with. + * @return A new {@code Expr} representing the logical min operation. + */ + logicalMin(other: any): LogicalMin; + logicalMin(other: any): LogicalMin { + if (other instanceof Expr) { + return new LogicalMin(this, other as Expr); + } + return new LogicalMin(this, Constant.of(other)); + } + + /** + * Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression. + * + * ```typescript + * // Get the vector length (dimension) of the field 'embedding'. + * Field.of("embedding").vectorLength(); + * ``` + * + * @return A new {@code Expr} representing the length of the vector. + */ + vectorLength(): VectorLength { + return new VectorLength(this); + } + + /** + * Calculates the cosine distance between two vectors. + * + * ```typescript + * // Calculate the cosine distance between the 'userVector' field and the 'itemVector' field + * Field.of("userVector").cosineDistance(Field.of("itemVector")); + * ``` + * + * @param other The other vector (represented as an Expr) to compare against. + * @return A new `Expr` representing the cosine distance between the two vectors. + */ + cosineDistance(other: Expr): CosineDistance; + /** + * Calculates the Cosine distance between two vectors. + * + * ```typescript + * // Calculate the Cosine distance between the 'location' field and a target location + * Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + * ``` + * + * @param other The other vector (as a VectorValue) to compare against. + * @return A new `Expr` representing the Cosine* distance between the two vectors. + */ + cosineDistance(other: VectorValue): CosineDistance; + /** + * Calculates the Cosine distance between two vectors. + * + * ```typescript + * // Calculate the Cosine distance between the 'location' field and a target location + * Field.of("location").cosineDistance([37.7749, -122.4194]); + * ``` + * + * @param other The other vector (as an array of numbers) to compare against. + * @return A new `Expr` representing the Cosine distance between the two vectors. + */ + cosineDistance(other: number[]): CosineDistance; + cosineDistance(other: Expr | VectorValue | number[]): CosineDistance { + if (other instanceof Expr) { + return new CosineDistance(this, other as Expr); + } else { + return new CosineDistance( + this, + Constant.vector(other as VectorValue | number[]) + ); + } + } + + /** + * Calculates the dot product between two vectors. + * + * ```typescript + * // Calculate the dot product between a feature vector and a target vector + * Field.of("features").dotProduct([0.5, 0.8, 0.2]); + * ``` + * + * @param other The other vector (as an array of numbers) to calculate with. + * @return A new `Expr` representing the dot product between the two vectors. + */ + dotProduct(other: Expr): DotProduct; + + /** + * Calculates the dot product between two vectors. + * + * ```typescript + * // Calculate the dot product between a feature vector and a target vector + * Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + * ``` + * + * @param other The other vector (as an array of numbers) to calculate with. + * @return A new `Expr` representing the dot product between the two vectors. + */ + dotProduct(other: VectorValue): DotProduct; + + /** + * Calculates the dot product between two vectors. + * + * ```typescript + * // Calculate the dot product between a feature vector and a target vector + * Field.of("features").dotProduct([0.5, 0.8, 0.2]); + * ``` + * + * @param other The other vector (as an array of numbers) to calculate with. + * @return A new `Expr` representing the dot product between the two vectors. + */ + dotProduct(other: number[]): DotProduct; + dotProduct(other: Expr | VectorValue | number[]): DotProduct { + if (other instanceof Expr) { + return new DotProduct(this, other as Expr); + } else { + return new DotProduct( + this, + Constant.vector(other as VectorValue | number[]) + ); + } + } + + /** + * Calculates the Euclidean distance between two vectors. + * + * ```typescript + * // Calculate the Euclidean distance between the 'location' field and a target location + * Field.of("location").euclideanDistance([37.7749, -122.4194]); + * ``` + * + * @param other The other vector (as an array of numbers) to calculate with. + * @return A new `Expr` representing the Euclidean distance between the two vectors. + */ + euclideanDistance(other: Expr): EuclideanDistance; + + /** + * Calculates the Euclidean distance between two vectors. + * + * ```typescript + * // Calculate the Euclidean distance between the 'location' field and a target location + * Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + * ``` + * + * @param other The other vector (as a VectorValue) to compare against. + * @return A new `Expr` representing the Euclidean distance between the two vectors. + */ + euclideanDistance(other: VectorValue): EuclideanDistance; + + /** + * Calculates the Euclidean distance between two vectors. + * + * ```typescript + * // Calculate the Euclidean distance between the 'location' field and a target location + * Field.of("location").euclideanDistance([37.7749, -122.4194]); + * ``` + * + * @param other The other vector (as an array of numbers) to compare against. + * @return A new `Expr` representing the Euclidean distance between the two vectors. + */ + euclideanDistance(other: number[]): EuclideanDistance; + euclideanDistance(other: Expr | VectorValue | number[]): EuclideanDistance { + if (other instanceof Expr) { + return new EuclideanDistance(this, other as Expr); + } else { + return new EuclideanDistance( + this, + Constant.vector(other as VectorValue | number[]) + ); + } + } + + /** + * Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) + * and returns a timestamp. + * + * ```typescript + * // Interpret the 'microseconds' field as microseconds since epoch. + * Field.of("microseconds").unixMicrosToTimestamp(); + * ``` + * + * @return A new {@code Expr} representing the timestamp. + */ + unixMicrosToTimestamp(): UnixMicrosToTimestamp { + return new UnixMicrosToTimestamp(this); + } + + /** + * Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + * + * ```typescript + * // Convert the 'timestamp' field to microseconds since epoch. + * Field.of("timestamp").timestampToUnixMicros(); + * ``` + * + * @return A new {@code Expr} representing the number of microseconds since epoch. + */ + timestampToUnixMicros(): TimestampToUnixMicros { + return new TimestampToUnixMicros(this); + } + + /** + * Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) + * and returns a timestamp. + * + * ```typescript + * // Interpret the 'milliseconds' field as milliseconds since epoch. + * Field.of("milliseconds").unixMillisToTimestamp(); + * ``` + * + * @return A new {@code Expr} representing the timestamp. + */ + unixMillisToTimestamp(): UnixMillisToTimestamp { + return new UnixMillisToTimestamp(this); + } + + /** + * Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + * + * ```typescript + * // Convert the 'timestamp' field to milliseconds since epoch. + * Field.of("timestamp").timestampToUnixMillis(); + * ``` + * + * @return A new {@code Expr} representing the number of milliseconds since epoch. + */ + timestampToUnixMillis(): TimestampToUnixMillis { + return new TimestampToUnixMillis(this); + } + + /** + * Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) + * and returns a timestamp. + * + * ```typescript + * // Interpret the 'seconds' field as seconds since epoch. + * Field.of("seconds").unixSecondsToTimestamp(); + * ``` + * + * @return A new {@code Expr} representing the timestamp. + */ + unixSecondsToTimestamp(): UnixSecondsToTimestamp { + return new UnixSecondsToTimestamp(this); + } + + /** + * Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). + * + * ```typescript + * // Convert the 'timestamp' field to seconds since epoch. + * Field.of("timestamp").timestampToUnixSeconds(); + * ``` + * + * @return A new {@code Expr} representing the number of seconds since epoch. + */ + timestampToUnixSeconds(): TimestampToUnixSeconds { + return new TimestampToUnixSeconds(this); + } + + /** + * Creates an expression that adds a specified amount of time to this timestamp expression. + * + * ```typescript + * // Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. + * Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + * ``` + * + * @param unit The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. + * @param amount The expression evaluates to amount of the unit. + * @return A new {@code Expr} representing the resulting timestamp. + */ + timestampAdd(unit: Expr, amount: Expr): TimestampAdd; + + /** + * Creates an expression that adds a specified amount of time to this timestamp expression. + * + * ```typescript + * // Add 1 day to the 'timestamp' field. + * Field.of("timestamp").timestampAdd("day", 1); + * ``` + * + * @param unit The unit of time to add (e.g., "day", "hour"). + * @param amount The amount of time to add. + * @return A new {@code Expr} representing the resulting timestamp. + */ + timestampAdd( + unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', + amount: number + ): TimestampAdd; + timestampAdd( + unit: + | Expr + | 'microsecond' + | 'millisecond' + | 'second' + | 'minute' + | 'hour' + | 'day', + amount: Expr | number + ): TimestampAdd { + const normalizedUnit = typeof unit === 'string' ? Constant.of(unit) : unit; + const normalizedAmount = + typeof amount === 'number' ? Constant.of(amount) : amount; + return new TimestampAdd( + this, + normalizedUnit as Expr, + normalizedAmount as Expr + ); + } + + /** + * Creates an expression that subtracts a specified amount of time from this timestamp expression. + * + * ```typescript + * // Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. + * Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + * ``` + * + * @param unit The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. + * @param amount The expression evaluates to amount of the unit. + * @return A new {@code Expr} representing the resulting timestamp. + */ + timestampSub(unit: Expr, amount: Expr): TimestampSub; + + /** + * Creates an expression that subtracts a specified amount of time from this timestamp expression. + * + * ```typescript + * // Subtract 1 day from the 'timestamp' field. + * Field.of("timestamp").timestampSub("day", 1); + * ``` + * + * @param unit The unit of time to subtract (e.g., "day", "hour"). + * @param amount The amount of time to subtract. + * @return A new {@code Expr} representing the resulting timestamp. + */ + timestampSub( + unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', + amount: number + ): TimestampSub; + timestampSub( + unit: + | Expr + | 'microsecond' + | 'millisecond' + | 'second' + | 'minute' + | 'hour' + | 'day', + amount: Expr | number + ): TimestampSub { + const normalizedUnit = typeof unit === 'string' ? Constant.of(unit) : unit; + const normalizedAmount = + typeof amount === 'number' ? Constant.of(amount) : amount; + return new TimestampSub( + this, + normalizedUnit as Expr, + normalizedAmount as Expr + ); + } + + /** + * Creates an {@link Ordering} that sorts documents in ascending order based on this expression. + * + * ```typescript + * // Sort documents by the 'name' field in ascending order + * pipeline().collection("users") + * .sort(Field.of("name").ascending()); + * ``` + * + * @return A new `Ordering` for ascending sorting. + */ + ascending(): Ordering { + return ascending(this); + } + + /** + * Creates an {@link Ordering} that sorts documents in descending order based on this expression. + * + * ```typescript + * // Sort documents by the 'createdAt' field in descending order + * firestore.pipeline().collection("users") + * .sort(Field.of("createdAt").descending()); + * ``` + * + * @return A new `Ordering` for descending sorting. + */ + descending(): Ordering { + return descending(this); + } + + /** + * Assigns an alias to this expression. + * + * Aliases are useful for renaming fields in the output of a stage or for giving meaningful + * names to calculated values. + * + * ```typescript + * // Calculate the total price and assign it the alias "totalPrice" and add it to the output. + * firestore.pipeline().collection("items") + * .addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + * ``` + * + * @param name The alias to assign to this expression. + * @return A new {@link ExprWithAlias} that wraps this + * expression and associates it with the provided alias. + */ + as(name: string): ExprWithAlias { + return new ExprWithAlias(this, name); + } + + /** + * @private + * @internal + */ + abstract _toProto(serializer: JsonProtoSerializer): ProtoValue; + + /** + * @private + * @internal + */ + abstract _readUserData(dataReader: UserDataReader): void; +} + +/** + * @beta + */ +export class ExprWithAlias extends Expr implements Selectable { + exprType: ExprType = 'ExprWithAlias'; + selectable = true as const; + + constructor(public expr: T, public alias: string) { + super(); + } + + /** + * @private + * @internal + */ + _toProto(serializer: JsonProtoSerializer): ProtoValue { + throw new Error('ExprWithAlias should not be serialized directly.'); + } + + /** + * @private + * @internal + */ + _readUserData(dataReader: UserDataReader): void { + this.expr._readUserData(dataReader); + } +} + +/** + * @internal + */ +class ListOfExprs extends Expr { + exprType: ExprType = 'ListOfExprs'; + constructor(private exprs: Expr[]) { + super(); + } + + /** + * @private + * @internal + */ + _toProto(serializer: JsonProtoSerializer): ProtoValue { + return { + arrayValue: { + values: this.exprs.map(p => p._toProto(serializer)!) + } + }; + } + + /** + * @private + * @internal + */ + _readUserData(dataReader: UserDataReader): void { + this.exprs.forEach((expr: Expr) => expr._readUserData(dataReader)); + } +} + +/** + * @beta + * + * Represents a reference to a field in a Firestore document, or outputs of a {@link Pipeline} stage. + * + *

Field references are used to access document field values in expressions and to specify fields + * for sorting, filtering, and projecting data in Firestore pipelines. + * + *

You can create a `Field` instance using the static {@link #of} method: + * + * ```typescript + * // Create a Field instance for the 'name' field + * const nameField = Field.of("name"); + * + * // Create a Field instance for a nested field 'address.city' + * const cityField = Field.of("address.city"); + * ``` + */ +export class Field extends Expr implements Selectable { + exprType: ExprType = 'Field'; + selectable = true as const; + + private constructor( + private fieldPath: InternalFieldPath, + private pipeline: Pipeline | null = null + ) { + super(); + } + + /** + * Creates a {@code Field} instance representing the field at the given path. + * + * The path can be a simple field name (e.g., "name") or a dot-separated path to a nested field + * (e.g., "address.city"). + * + * ```typescript + * // Create a Field instance for the 'title' field + * const titleField = Field.of("title"); + * + * // Create a Field instance for a nested field 'author.firstName' + * const authorFirstNameField = Field.of("author.firstName"); + * ``` + * + * @param name The path to the field. + * @return A new {@code Field} instance representing the specified field. + */ + static of(name: string): Field; + static of(path: FieldPath): Field; + static of(pipeline: Pipeline, name: string): Field; + static of( + pipelineOrName: Pipeline | string | FieldPath, + name?: string + ): Field { + if (typeof pipelineOrName === 'string') { + if (DOCUMENT_KEY_NAME === pipelineOrName) { + return new Field(documentId()._internalPath); + } + return new Field(fieldPathFromArgument('of', pipelineOrName)); + } else if (pipelineOrName instanceof FieldPath) { + if (documentId().isEqual(pipelineOrName)) { + return new Field(documentId()._internalPath); + } + return new Field(pipelineOrName._internalPath); + } else { + return new Field( + fieldPathFromArgument('of', name!), + pipelineOrName as Pipeline + ); + } + } + + fieldName(): string { + return this.fieldPath.canonicalString(); + } + + /** + * @private + * @internal + */ + _toProto(serializer: JsonProtoSerializer): ProtoValue { + return { + fieldReferenceValue: this.fieldPath.canonicalString() + }; + } + + /** + * @private + * @internal + */ + _readUserData(dataReader: UserDataReader): void {} +} + +/** + * @beta + */ +export class Fields extends Expr implements Selectable { + exprType: ExprType = 'Field'; + selectable = true as const; + + private constructor(private fields: Field[]) { + super(); + } + + static of(name: string, ...others: string[]): Fields { + return new Fields([Field.of(name), ...others.map(Field.of)]); + } + + static ofAll(): Fields { + return new Fields([]); + } + + fieldList(): Field[] { + return this.fields.map(f => f); + } + + /** + * @private + * @internal + */ + _toProto(serializer: JsonProtoSerializer): ProtoValue { + return { + arrayValue: { + values: this.fields.map(f => f._toProto(serializer)) + } + }; + } + + /** + * @private + * @internal + */ + _readUserData(dataReader: UserDataReader): void { + this.fields.forEach(expr => expr._readUserData(dataReader)); + } +} + +/** + * @beta + * + * Represents a constant value that can be used in a Firestore pipeline expression. + * + * You can create a `Constant` instance using the static {@link #of} method: + * + * ```typescript + * // Create a Constant instance for the number 10 + * const ten = Constant.of(10); + * + * // Create a Constant instance for the string "hello" + * const hello = Constant.of("hello"); + * ``` + */ +export class Constant extends Expr { + exprType: ExprType = 'Constant'; + + private _protoValue?: ProtoValue; + + private constructor(private value: any) { + super(); + } + + /** + * Creates a `Constant` instance for a number value. + * + * @param value The number value. + * @return A new `Constant` instance. + */ + static of(value: number): Constant; + + /** + * Creates a `Constant` instance for a string value. + * + * @param value The string value. + * @return A new `Constant` instance. + */ + static of(value: string): Constant; + + /** + * Creates a `Constant` instance for a boolean value. + * + * @param value The boolean value. + * @return A new `Constant` instance. + */ + static of(value: boolean): Constant; + + /** + * Creates a `Constant` instance for a null value. + * + * @param value The null value. + * @return A new `Constant` instance. + */ + static of(value: null): Constant; + + /** + * Creates a `Constant` instance for an undefined value. + * + * @param value The undefined value. + * @return A new `Constant` instance. + */ + static of(value: undefined): Constant; + + /** + * Creates a `Constant` instance for a GeoPoint value. + * + * @param value The GeoPoint value. + * @return A new `Constant` instance. + */ + static of(value: GeoPoint): Constant; + + /** + * Creates a `Constant` instance for a Timestamp value. + * + * @param value The Timestamp value. + * @return A new `Constant` instance. + */ + static of(value: Timestamp): Constant; + + /** + * Creates a `Constant` instance for a Date value. + * + * @param value The Date value. + * @return A new `Constant` instance. + */ + static of(value: Date): Constant; + + /** + * Creates a `Constant` instance for a Uint8Array value. + * + * @param value The Uint8Array value. + * @return A new `Constant` instance. + */ + static of(value: Uint8Array): Constant; + + /** + * Creates a `Constant` instance for a DocumentReference value. + * + * @param value The DocumentReference value. + * @return A new `Constant` instance. + */ + static of(value: DocumentReference): Constant; + + // TODO(pipeline) if we make this public, then the Proto types should also be documented + /** + * Creates a `Constant` instance for a Firestore proto value. + * @private + * @internal + * @param value The Firestore proto value. + * @return A new `Constant` instance. + */ + static of(value: ProtoValue): Constant; + + /** + * Creates a `Constant` instance for an array value. + * + * @param value The array value. + * @return A new `Constant` instance. + */ + static of(value: any[]): Constant; + + /** + * Creates a `Constant` instance for a map value. + * + * @param value The map value. + * @return A new `Constant` instance. + */ + static of(value: Map): Constant; + + /** + * Creates a `Constant` instance for a VectorValue value. + * + * @param value The VectorValue value. + * @return A new `Constant` instance. + */ + static of(value: VectorValue): Constant; + + static of(value: any): Constant { + return new Constant(value); + } + + /** + * Creates a `Constant` instance for a VectorValue value. + * + * ```typescript + * // Create a Constant instance for a vector value + * const vectorConstant = Constant.ofVector([1, 2, 3]); + * ``` + * + * @param value The VectorValue value. + * @return A new `Constant` instance. + */ + static vector(value: number[] | VectorValue): Constant { + if (value instanceof VectorValue) { + return new Constant(value); + } else { + return new Constant(new VectorValue(value as number[])); + } + } + + /** + * @private + * @internal + */ + _toProto(serializer: JsonProtoSerializer): ProtoValue { + hardAssert( + this._protoValue !== undefined, + 'Value of this constant has not been serialized to proto value' + ); + return this._protoValue; + } + + /** + * @private + * @internal + */ + _readUserData(dataReader: UserDataReader): void { + const context = dataReader.createContext( + UserDataSource.Argument, + 'Constant.of' + ); + if (this.value === undefined) { + // TODO how should we treat the value of `undefined`? + this._protoValue = parseData(null, context)!; + } else { + this._protoValue = parseData(this.value, context)!; + } + } +} + +/** + * @beta + * + * This class defines the base class for Firestore {@link Pipeline} functions, which can be evaluated within pipeline + * execution. + * + * Typically, you would not use this class or its children directly. Use either the functions like {@link and}, {@link eq}, + * or the methods on {@link Expr} ({@link Expr#eq}, {@link Expr#lt}, etc) to construct new Function instances. + */ +export class FirestoreFunction extends Expr { + exprType: ExprType = 'Function'; + constructor(private name: string, private params: Expr[]) { + super(); + } + + /** + * @private + * @internal + */ + _toProto(serializer: JsonProtoSerializer): ProtoValue { + return { + functionValue: { + name: this.name, + args: this.params.map(p => p._toProto(serializer)) + } + }; + } + + /** + * @private + * @internal + */ + _readUserData(dataReader: UserDataReader): void { + this.params.forEach(expr => expr._readUserData(dataReader)); + } +} + +/** + * @beta + */ +export class Add extends FirestoreFunction { + constructor(private left: Expr, private right: Expr) { + super('add', [left, right]); + } +} + +/** + * @beta + */ +export class Subtract extends FirestoreFunction { + constructor(private left: Expr, private right: Expr) { + super('subtract', [left, right]); + } +} + +/** + * @beta + */ +export class Multiply extends FirestoreFunction { + constructor(private left: Expr, private right: Expr) { + super('multiply', [left, right]); + } +} + +/** + * @beta + */ +export class Divide extends FirestoreFunction { + constructor(private left: Expr, private right: Expr) { + super('divide', [left, right]); + } +} + +/** + * @beta + */ +export class Mod extends FirestoreFunction { + constructor(private left: Expr, private right: Expr) { + super('mod', [left, right]); + } +} + +// /** +// * @beta +// */ +// export class BitAnd extends FirestoreFunction { +// constructor( +// private left: Expr, +// private right: Expr +// ) { +// super('bit_and', [left, right]); +// } +// } +// +// /** +// * @beta +// */ +// export class BitOr extends FirestoreFunction { +// constructor( +// private left: Expr, +// private right: Expr +// ) { +// super('bit_or', [left, right]); +// } +// } +// +// /** +// * @beta +// */ +// export class BitXor extends FirestoreFunction { +// constructor( +// private left: Expr, +// private right: Expr +// ) { +// super('bit_xor', [left, right]); +// } +// } +// +// /** +// * @beta +// */ +// export class BitNot extends FirestoreFunction { +// constructor(private operand: Expr) { +// super('bit_not', [operand]); +// } +// } +// +// /** +// * @beta +// */ +// export class BitLeftShift extends FirestoreFunction { +// constructor( +// private left: Expr, +// private right: Expr +// ) { +// super('bit_left_shift', [left, right]); +// } +// } +// +// /** +// * @beta +// */ +// export class BitRightShift extends FirestoreFunction { +// constructor( +// private left: Expr, +// private right: Expr +// ) { +// super('bit_right_shift', [left, right]); +// } +// } + +/** + * @beta + */ +export class Eq extends FirestoreFunction implements FilterCondition { + constructor(private left: Expr, private right: Expr) { + super('eq', [left, right]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class Neq extends FirestoreFunction implements FilterCondition { + constructor(private left: Expr, private right: Expr) { + super('neq', [left, right]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class Lt extends FirestoreFunction implements FilterCondition { + constructor(private left: Expr, private right: Expr) { + super('lt', [left, right]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class Lte extends FirestoreFunction implements FilterCondition { + constructor(private left: Expr, private right: Expr) { + super('lte', [left, right]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class Gt extends FirestoreFunction implements FilterCondition { + constructor(private left: Expr, private right: Expr) { + super('gt', [left, right]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class Gte extends FirestoreFunction implements FilterCondition { + constructor(private left: Expr, private right: Expr) { + super('gte', [left, right]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class ArrayConcat extends FirestoreFunction { + constructor(private array: Expr, private elements: Expr[]) { + super('array_concat', [array, ...elements]); + } +} + +/** + * @beta + */ +export class ArrayReverse extends FirestoreFunction { + constructor(private array: Expr) { + super('array_reverse', [array]); + } +} + +/** + * @beta + */ +export class ArrayContains + extends FirestoreFunction + implements FilterCondition +{ + constructor(private array: Expr, private element: Expr) { + super('array_contains', [array, element]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class ArrayContainsAll + extends FirestoreFunction + implements FilterCondition +{ + constructor(private array: Expr, private values: Expr[]) { + super('array_contains_all', [array, new ListOfExprs(values)]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class ArrayContainsAny + extends FirestoreFunction + implements FilterCondition +{ + constructor(private array: Expr, private values: Expr[]) { + super('array_contains_any', [array, new ListOfExprs(values)]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class ArrayLength extends FirestoreFunction { + constructor(private array: Expr) { + super('array_length', [array]); + } +} + +/** + * @beta + */ +export class ArrayElement extends FirestoreFunction { + constructor() { + super('array_element', []); + } +} + +/** + * @beta + */ +export class In extends FirestoreFunction implements FilterCondition { + constructor(private left: Expr, private others: Expr[]) { + super('in', [left, new ListOfExprs(others)]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class IsNan extends FirestoreFunction implements FilterCondition { + constructor(private expr: Expr) { + super('is_nan', [expr]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class Exists extends FirestoreFunction implements FilterCondition { + constructor(private expr: Expr) { + super('exists', [expr]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class Not extends FirestoreFunction implements FilterCondition { + constructor(private expr: Expr) { + super('not', [expr]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class And extends FirestoreFunction implements FilterCondition { + constructor(private conditions: FilterExpr[]) { + super('and', conditions); + } + + filterable = true as const; +} + +/** + * @beta + */ +export class Or extends FirestoreFunction implements FilterCondition { + constructor(private conditions: FilterExpr[]) { + super('or', conditions); + } + filterable = true as const; +} + +/** + * @beta + */ +export class Xor extends FirestoreFunction implements FilterCondition { + constructor(private conditions: FilterExpr[]) { + super('xor', conditions); + } + filterable = true as const; +} + +/** + * @beta + */ +export class If extends FirestoreFunction implements FilterCondition { + constructor( + private condition: FilterExpr, + private thenExpr: Expr, + private elseExpr: Expr + ) { + super('if', [condition, thenExpr, elseExpr]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class LogicalMax extends FirestoreFunction { + constructor(private left: Expr, private right: Expr) { + super('logical_max', [left, right]); + } +} + +/** + * @beta + */ +export class LogicalMin extends FirestoreFunction { + constructor(private left: Expr, private right: Expr) { + super('logical_min', [left, right]); + } +} + +/** + * @beta + */ +export class Reverse extends FirestoreFunction { + constructor(private value: Expr) { + super('reverse', [value]); + } +} + +/** + * @beta + */ +export class ReplaceFirst extends FirestoreFunction { + constructor(private value: Expr, private find: Expr, private replace: Expr) { + super('replace_first', [value, find, replace]); + } +} + +/** + * @beta + */ +export class ReplaceAll extends FirestoreFunction { + constructor(private value: Expr, private find: Expr, private replace: Expr) { + super('replace_all', [value, find, replace]); + } +} + +/** + * @beta + */ +export class CharLength extends FirestoreFunction { + constructor(private value: Expr) { + super('char_length', [value]); + } +} + +/** + * @beta + */ +export class ByteLength extends FirestoreFunction { + constructor(private value: Expr) { + super('byte_length', [value]); + } +} + +/** + * @beta + */ +export class Like extends FirestoreFunction implements FilterCondition { + constructor(private expr: Expr, private pattern: Expr) { + super('like', [expr, pattern]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class RegexContains + extends FirestoreFunction + implements FilterCondition +{ + constructor(private expr: Expr, private pattern: Expr) { + super('regex_contains', [expr, pattern]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class RegexMatch extends FirestoreFunction implements FilterCondition { + constructor(private expr: Expr, private pattern: Expr) { + super('regex_match', [expr, pattern]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class StrContains extends FirestoreFunction implements FilterCondition { + constructor(private expr: Expr, private substring: Expr) { + super('str_contains', [expr, substring]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class StartsWith extends FirestoreFunction implements FilterCondition { + constructor(private expr: Expr, private prefix: Expr) { + super('starts_with', [expr, prefix]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class EndsWith extends FirestoreFunction implements FilterCondition { + constructor(private expr: Expr, private suffix: Expr) { + super('ends_with', [expr, suffix]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class ToLower extends FirestoreFunction { + constructor(private expr: Expr) { + super('to_lower', [expr]); + } +} + +/** + * @beta + */ +export class ToUpper extends FirestoreFunction { + constructor(private expr: Expr) { + super('to_upper', [expr]); + } +} + +/** + * @beta + */ +export class Trim extends FirestoreFunction { + constructor(private expr: Expr) { + super('trim', [expr]); + } +} + +/** + * @beta + */ +export class StrConcat extends FirestoreFunction { + constructor(private first: Expr, private rest: Expr[]) { + super('str_concat', [first, ...rest]); + } +} + +/** + * @beta + */ +export class MapGet extends FirestoreFunction { + constructor(map: Expr, name: string) { + super('map_get', [map, Constant.of(name)]); + } +} + +/** + * @beta + */ +export class Count extends FirestoreFunction implements Accumulator { + accumulator = true as const; + constructor(private value: Expr | undefined, private distinct: boolean) { + super('count', value === undefined ? [] : [value]); + } +} + +/** + * @beta + */ +export class Sum extends FirestoreFunction implements Accumulator { + accumulator = true as const; + constructor(private value: Expr, private distinct: boolean) { + super('sum', [value]); + } +} + +/** + * @beta + */ +export class Avg extends FirestoreFunction implements Accumulator { + accumulator = true as const; + constructor(private value: Expr, private distinct: boolean) { + super('avg', [value]); + } +} + +/** + * @beta + */ +export class Min extends FirestoreFunction implements Accumulator { + accumulator = true as const; + constructor(private value: Expr, private distinct: boolean) { + super('min', [value]); + } +} + +/** + * @beta + */ +export class Max extends FirestoreFunction implements Accumulator { + accumulator = true as const; + constructor(private value: Expr, private distinct: boolean) { + super('max', [value]); + } +} + +/** + * @beta + */ +export class CosineDistance extends FirestoreFunction { + constructor(private vector1: Expr, private vector2: Expr) { + super('cosine_distance', [vector1, vector2]); + } +} + +/** + * @beta + */ +export class DotProduct extends FirestoreFunction { + constructor(private vector1: Expr, private vector2: Expr) { + super('dot_product', [vector1, vector2]); + } +} + +/** + * @beta + */ +export class EuclideanDistance extends FirestoreFunction { + constructor(private vector1: Expr, private vector2: Expr) { + super('euclidean_distance', [vector1, vector2]); + } +} + +/** + * @beta + */ +export class VectorLength extends FirestoreFunction { + constructor(private value: Expr) { + super('vector_length', [value]); + } +} + +/** + * @beta + */ +export class UnixMicrosToTimestamp extends FirestoreFunction { + constructor(private input: Expr) { + super('unix_micros_to_timestamp', [input]); + } +} + +/** + * @beta + */ +export class TimestampToUnixMicros extends FirestoreFunction { + constructor(private input: Expr) { + super('timestamp_to_unix_micros', [input]); + } +} + +/** + * @beta + */ +export class UnixMillisToTimestamp extends FirestoreFunction { + constructor(private input: Expr) { + super('unix_millis_to_timestamp', [input]); + } +} + +/** + * @beta + */ +export class TimestampToUnixMillis extends FirestoreFunction { + constructor(private input: Expr) { + super('timestamp_to_unix_millis', [input]); + } +} + +/** + * @beta + */ +export class UnixSecondsToTimestamp extends FirestoreFunction { + constructor(private input: Expr) { + super('unix_seconds_to_timestamp', [input]); + } +} + +/** + * @beta + */ +export class TimestampToUnixSeconds extends FirestoreFunction { + constructor(private input: Expr) { + super('timestamp_to_unix_seconds', [input]); + } +} + +/** + * @beta + */ +export class TimestampAdd extends FirestoreFunction { + constructor( + private timestamp: Expr, + private unit: Expr, + private amount: Expr + ) { + super('timestamp_add', [timestamp, unit, amount]); + } +} + +/** + * @beta + */ +export class TimestampSub extends FirestoreFunction { + constructor( + private timestamp: Expr, + private unit: Expr, + private amount: Expr + ) { + super('timestamp_sub', [timestamp, unit, amount]); + } +} + +/** + * @beta + * + * Creates an expression that adds two expressions together. + * + * ```typescript + * // Add the value of the 'quantity' field and the 'reserve' field. + * add(Field.of("quantity"), Field.of("reserve")); + * ``` + * + * @param left The first expression to add. + * @param right The second expression to add. + * @return A new {@code Expr} representing the addition operation. + */ +export function add(left: Expr, right: Expr): Add; + +/** + * @beta + * + * Creates an expression that adds an expression to a constant value. + * + * ```typescript + * // Add 5 to the value of the 'age' field + * add(Field.of("age"), 5); + * ``` + * + * @param left The expression to add to. + * @param right The constant value to add. + * @return A new {@code Expr} representing the addition operation. + */ +export function add(left: Expr, right: any): Add; + +/** + * @beta + * + * Creates an expression that adds a field's value to an expression. + * + * ```typescript + * // Add the value of the 'quantity' field and the 'reserve' field. + * add("quantity", Field.of("reserve")); + * ``` + * + * @param left The field name to add to. + * @param right The expression to add. + * @return A new {@code Expr} representing the addition operation. + */ +export function add(left: string, right: Expr): Add; + +/** + * @beta + * + * Creates an expression that adds a field's value to a constant value. + * + * ```typescript + * // Add 5 to the value of the 'age' field + * add("age", 5); + * ``` + * + * @param left The field name to add to. + * @param right The constant value to add. + * @return A new {@code Expr} representing the addition operation. + */ +export function add(left: string, right: any): Add; +export function add(left: Expr | string, right: Expr | any): Add { + const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; + const normalizedRight = right instanceof Expr ? right : Constant.of(right); + return new Add(normalizedLeft, normalizedRight); +} + +/** + * @beta + * + * Creates an expression that subtracts two expressions. + * + * ```typescript + * // Subtract the 'discount' field from the 'price' field + * subtract(Field.of("price"), Field.of("discount")); + * ``` + * + * @param left The expression to subtract from. + * @param right The expression to subtract. + * @return A new {@code Expr} representing the subtraction operation. + */ +export function subtract(left: Expr, right: Expr): Subtract; + +/** + * @beta + * + * Creates an expression that subtracts a constant value from an expression. + * + * ```typescript + * // Subtract the constant value 2 from the 'value' field + * subtract(Field.of("value"), 2); + * ``` + * + * @param left The expression to subtract from. + * @param right The constant value to subtract. + * @return A new {@code Expr} representing the subtraction operation. + */ +export function subtract(left: Expr, right: any): Subtract; + +/** + * @beta + * + * Creates an expression that subtracts an expression from a field's value. + * + * ```typescript + * // Subtract the 'discount' field from the 'price' field + * subtract("price", Field.of("discount")); + * ``` + * + * @param left The field name to subtract from. + * @param right The expression to subtract. + * @return A new {@code Expr} representing the subtraction operation. + */ +export function subtract(left: string, right: Expr): Subtract; + +/** + * @beta + * + * Creates an expression that subtracts a constant value from a field's value. + * + * ```typescript + * // Subtract 20 from the value of the 'total' field + * subtract("total", 20); + * ``` + * + * @param left The field name to subtract from. + * @param right The constant value to subtract. + * @return A new {@code Expr} representing the subtraction operation. + */ +export function subtract(left: string, right: any): Subtract; +export function subtract(left: Expr | string, right: Expr | any): Subtract { + const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; + const normalizedRight = right instanceof Expr ? right : Constant.of(right); + return new Subtract(normalizedLeft, normalizedRight); +} + +/** + * @beta + * + * Creates an expression that multiplies two expressions together. + * + * ```typescript + * // Multiply the 'quantity' field by the 'price' field + * multiply(Field.of("quantity"), Field.of("price")); + * ``` + * + * @param left The first expression to multiply. + * @param right The second expression to multiply. + * @return A new {@code Expr} representing the multiplication operation. + */ +export function multiply(left: Expr, right: Expr): Multiply; + +/** + * @beta + * + * Creates an expression that multiplies an expression by a constant value. + * + * ```typescript + * // Multiply the value of the 'price' field by 2 + * multiply(Field.of("price"), 2); + * ``` + * + * @param left The expression to multiply. + * @param right The constant value to multiply by. + * @return A new {@code Expr} representing the multiplication operation. + */ +export function multiply(left: Expr, right: any): Multiply; + +/** + * @beta + * + * Creates an expression that multiplies a field's value by an expression. + * + * ```typescript + * // Multiply the 'quantity' field by the 'price' field + * multiply("quantity", Field.of("price")); + * ``` + * + * @param left The field name to multiply. + * @param right The expression to multiply by. + * @return A new {@code Expr} representing the multiplication operation. + */ +export function multiply(left: string, right: Expr): Multiply; + +/** + * @beta + * + * Creates an expression that multiplies a field's value by a constant value. + * + * ```typescript + * // Multiply the 'value' field by 2 + * multiply("value", 2); + * ``` + * + * @param left The field name to multiply. + * @param right The constant value to multiply by. + * @return A new {@code Expr} representing the multiplication operation. + */ +export function multiply(left: string, right: any): Multiply; +export function multiply(left: Expr | string, right: Expr | any): Multiply { + const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; + const normalizedRight = right instanceof Expr ? right : Constant.of(right); + return new Multiply(normalizedLeft, normalizedRight); +} + +/** + * @beta + * + * Creates an expression that divides two expressions. + * + * ```typescript + * // Divide the 'total' field by the 'count' field + * divide(Field.of("total"), Field.of("count")); + * ``` + * + * @param left The expression to be divided. + * @param right The expression to divide by. + * @return A new {@code Expr} representing the division operation. + */ +export function divide(left: Expr, right: Expr): Divide; + +/** + * @beta + * + * Creates an expression that divides an expression by a constant value. + * + * ```typescript + * // Divide the 'value' field by 10 + * divide(Field.of("value"), 10); + * ``` + * + * @param left The expression to be divided. + * @param right The constant value to divide by. + * @return A new {@code Expr} representing the division operation. + */ +export function divide(left: Expr, right: any): Divide; + +/** + * @beta + * + * Creates an expression that divides a field's value by an expression. + * + * ```typescript + * // Divide the 'total' field by the 'count' field + * divide("total", Field.of("count")); + * ``` + * + * @param left The field name to be divided. + * @param right The expression to divide by. + * @return A new {@code Expr} representing the division operation. + */ +export function divide(left: string, right: Expr): Divide; + +/** + * @beta + * + * Creates an expression that divides a field's value by a constant value. + * + * ```typescript + * // Divide the 'value' field by 10 + * divide("value", 10); + * ``` + * + * @param left The field name to be divided. + * @param right The constant value to divide by. + * @return A new {@code Expr} representing the division operation. + */ +export function divide(left: string, right: any): Divide; +export function divide(left: Expr | string, right: Expr | any): Divide { + const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; + const normalizedRight = right instanceof Expr ? right : Constant.of(right); + return new Divide(normalizedLeft, normalizedRight); +} + +/** + * @beta + * + * Creates an expression that calculates the modulo (remainder) of dividing two expressions. + * + * ```typescript + * // Calculate the remainder of dividing 'field1' by 'field2'. + * mod(Field.of("field1"), Field.of("field2")); + * ``` + * + * @param left The dividend expression. + * @param right The divisor expression. + * @return A new {@code Expr} representing the modulo operation. + */ +export function mod(left: Expr, right: Expr): Mod; + +/** + * @beta + * + * Creates an expression that calculates the modulo (remainder) of dividing an expression by a constant. + * + * ```typescript + * // Calculate the remainder of dividing 'field1' by 5. + * mod(Field.of("field1"), 5); + * ``` + * + * @param left The dividend expression. + * @param right The divisor constant. + * @return A new {@code Expr} representing the modulo operation. + */ +export function mod(left: Expr, right: any): Mod; + +/** + * @beta + * + * Creates an expression that calculates the modulo (remainder) of dividing a field's value by an expression. + * + * ```typescript + * // Calculate the remainder of dividing 'field1' by 'field2'. + * mod("field1", Field.of("field2")); + * ``` + * + * @param left The dividend field name. + * @param right The divisor expression. + * @return A new {@code Expr} representing the modulo operation. + */ +export function mod(left: string, right: Expr): Mod; + +/** + * @beta + * + * Creates an expression that calculates the modulo (remainder) of dividing a field's value by a constant. + * + * ```typescript + * // Calculate the remainder of dividing 'field1' by 5. + * mod("field1", 5); + * ``` + * + * @param left The dividend field name. + * @param right The divisor constant. + * @return A new {@code Expr} representing the modulo operation. + */ +export function mod(left: string, right: any): Mod; +export function mod(left: Expr | string, right: Expr | any): Mod { + const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; + const normalizedRight = right instanceof Expr ? right : Constant.of(right); + return new Mod(normalizedLeft, normalizedRight); +} + +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise AND operation between two expressions. +// * +// * ```typescript +// * // Calculate the bitwise AND of 'field1' and 'field2'. +// * bitAnd(Field.of("field1"), Field.of("field2")); +// * ``` +// * +// * @param left The left operand expression. +// * @param right The right operand expression. +// * @return A new {@code Expr} representing the bitwise AND operation. +// */ +// export function bitAnd(left: Expr, right: Expr): BitAnd; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise AND operation between an expression and a constant. +// * +// * ```typescript +// * // Calculate the bitwise AND of 'field1' and 0xFF. +// * bitAnd(Field.of("field1"), 0xFF); +// * ``` +// * +// * @param left The left operand expression. +// * @param right The right operand constant. +// * @return A new {@code Expr} representing the bitwise AND operation. +// */ +// export function bitAnd(left: Expr, right: any): BitAnd; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise AND operation between a field and an expression. +// * +// * ```typescript +// * // Calculate the bitwise AND of 'field1' and 'field2'. +// * bitAnd("field1", Field.of("field2")); +// * ``` +// * +// * @param left The left operand field name. +// * @param right The right operand expression. +// * @return A new {@code Expr} representing the bitwise AND operation. +// */ +// export function bitAnd(left: string, right: Expr): BitAnd; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise AND operation between a field and a constant. +// * +// * ```typescript +// * // Calculate the bitwise AND of 'field1' and 0xFF. +// * bitAnd("field1", 0xFF); +// * ``` +// * +// * @param left The left operand field name. +// * @param right The right operand constant. +// * @return A new {@code Expr} representing the bitwise AND operation. +// */ +// export function bitAnd(left: string, right: any): BitAnd; +// export function bitAnd(left: Expr | string, right: Expr | any): BitAnd { +// const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; +// const normalizedRight = right instanceof Expr ? right : Constant.of(right); +// return new BitAnd(normalizedLeft, normalizedRight); +// } +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise OR operation between two expressions. +// * +// * ```typescript +// * // Calculate the bitwise OR of 'field1' and 'field2'. +// * bitOr(Field.of("field1"), Field.of("field2")); +// * ``` +// * +// * @param left The left operand expression. +// * @param right The right operand expression. +// * @return A new {@code Expr} representing the bitwise OR operation. +// */ +// export function bitOr(left: Expr, right: Expr): BitOr; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise OR operation between an expression and a constant. +// * +// * ```typescript +// * // Calculate the bitwise OR of 'field1' and 0xFF. +// * bitOr(Field.of("field1"), 0xFF); +// * ``` +// * +// * @param left The left operand expression. +// * @param right The right operand constant. +// * @return A new {@code Expr} representing the bitwise OR operation. +// */ +// export function bitOr(left: Expr, right: any): BitOr; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise OR operation between a field and an expression. +// * +// * ```typescript +// * // Calculate the bitwise OR of 'field1' and 'field2'. +// * bitOr("field1", Field.of("field2")); +// * ``` +// * +// * @param left The left operand field name. +// * @param right The right operand expression. +// * @return A new {@code Expr} representing the bitwise OR operation. +// */ +// export function bitOr(left: string, right: Expr): BitOr; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise OR operation between a field and a constant. +// * +// * ```typescript +// * // Calculate the bitwise OR of 'field1' and 0xFF. +// * bitOr("field1", 0xFF); +// * ``` +// * +// * @param left The left operand field name. +// * @param right The right operand constant. +// * @return A new {@code Expr} representing the bitwise OR operation. +// */ +// export function bitOr(left: string, right: any): BitOr; +// export function bitOr(left: Expr | string, right: Expr | any): BitOr { +// const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; +// const normalizedRight = right instanceof Expr ? right : Constant.of(right); +// return new BitOr(normalizedLeft, normalizedRight); +// } +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise XOR operation between two expressions. +// * +// * ```typescript +// * // Calculate the bitwise XOR of 'field1' and 'field2'. +// * bitXor(Field.of("field1"), Field.of("field2")); +// * ``` +// * +// * @param left The left operand expression. +// * @param right The right operand expression. +// * @return A new {@code Expr} representing the bitwise XOR operation. +// */ +// export function bitXor(left: Expr, right: Expr): BitXor; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise XOR operation between an expression and a constant. +// * +// * ```typescript +// * // Calculate the bitwise XOR of 'field1' and 0xFF. +// * bitXor(Field.of("field1"), 0xFF); +// * ``` +// * +// * @param left The left operand expression. +// * @param right The right operand constant. +// * @return A new {@code Expr} representing the bitwise XOR operation. +// */ +// export function bitXor(left: Expr, right: any): BitXor; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise XOR operation between a field and an expression. +// * +// * ```typescript +// * // Calculate the bitwise XOR of 'field1' and 'field2'. +// * bitXor("field1", Field.of("field2")); +// * ``` +// * +// * @param left The left operand field name. +// * @param right The right operand expression. +// * @return A new {@code Expr} representing the bitwise XOR operation. +// */ +// export function bitXor(left: string, right: Expr): BitXor; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise XOR operation between a field and a constant. +// * +// * ```typescript +// * // Calculate the bitwise XOR of 'field1' and 0xFF. +// * bitXor("field1", 0xFF); +// * ``` +// * +// * @param left The left operand field name. +// * @param right The right operand constant. +// * @return A new {@code Expr} representing the bitwise XOR operation. +// */ +// export function bitXor(left: string, right: any): BitXor; +// export function bitXor(left: Expr | string, right: Expr | any): BitXor { +// const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; +// const normalizedRight = right instanceof Expr ? right : Constant.of(right); +// return new BitXor(normalizedLeft, normalizedRight); +// } +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise NOT operation to an expression. +// * +// * ```typescript +// * // Calculate the bitwise NOT of 'field1'. +// * bitNot(Field.of("field1")); +// * ``` +// * +// * @param operand The operand expression. +// * @return A new {@code Expr} representing the bitwise NOT operation. +// */ +// export function bitNot(operand: Expr): BitNot; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise NOT operation to a field. +// * +// * ```typescript +// * // Calculate the bitwise NOT of 'field1'. +// * bitNot("field1"); +// * ``` +// * +// * @param operand The operand field name. +// * @return A new {@code Expr} representing the bitwise NOT operation. +// */ +// export function bitNot(operand: string): BitNot; +// export function bitNot(operand: Expr | string): BitNot { +// const normalizedOperand = +// typeof operand === 'string' ? Field.of(operand) : operand; +// return new BitNot(normalizedOperand); +// } +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise left shift operation between two expressions. +// * +// * ```typescript +// * // Calculate the bitwise left shift of 'field1' by 'field2' bits. +// * bitLeftShift(Field.of("field1"), Field.of("field2")); +// * ``` +// * +// * @param left The left operand expression. +// * @param right The right operand expression representing the number of bits to shift. +// * @return A new {@code Expr} representing the bitwise left shift operation. +// */ +// export function bitLeftShift(left: Expr, right: Expr): BitLeftShift; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise left shift operation between an expression and a constant. +// * +// * ```typescript +// * // Calculate the bitwise left shift of 'field1' by 2 bits. +// * bitLeftShift(Field.of("field1"), 2); +// * ``` +// * +// * @param left The left operand expression. +// * @param right The right operand constant representing the number of bits to shift. +// * @return A new {@code Expr} representing the bitwise left shift operation. +// */ +// export function bitLeftShift(left: Expr, right: any): BitLeftShift; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise left shift operation between a field and an expression. +// * +// * ```typescript +// * // Calculate the bitwise left shift of 'field1' by 'field2' bits. +// * bitLeftShift("field1", Field.of("field2")); +// * ``` +// * +// * @param left The left operand field name. +// * @param right The right operand expression representing the number of bits to shift. +// * @return A new {@code Expr} representing the bitwise left shift operation. +// */ +// export function bitLeftShift(left: string, right: Expr): BitLeftShift; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise left shift operation between a field and a constant. +// * +// * ```typescript +// * // Calculate the bitwise left shift of 'field1' by 2 bits. +// * bitLeftShift("field1", 2); +// * ``` +// * +// * @param left The left operand field name. +// * @param right The right operand constant representing the number of bits to shift. +// * @return A new {@code Expr} representing the bitwise left shift operation. +// */ +// export function bitLeftShift(left: string, right: any): BitLeftShift; +// export function bitLeftShift( +// left: Expr | string, +// right: Expr | any +// ): BitLeftShift { +// const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; +// const normalizedRight = right instanceof Expr ? right : Constant.of(right); +// return new BitLeftShift(normalizedLeft, normalizedRight); +// } +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise right shift operation between two expressions. +// * +// * ```typescript +// * // Calculate the bitwise right shift of 'field1' by 'field2' bits. +// * bitRightShift(Field.of("field1"), Field.of("field2")); +// * ``` +// * +// * @param left The left operand expression. +// * @param right The right operand expression representing the number of bits to shift. +// * @return A new {@code Expr} representing the bitwise right shift operation. +// */ +// export function bitRightShift(left: Expr, right: Expr): BitRightShift; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise right shift operation between an expression and a constant. +// * +// * ```typescript +// * // Calculate the bitwise right shift of 'field1' by 2 bits. +// * bitRightShift(Field.of("field1"), 2); +// * ``` +// * +// * @param left The left operand expression. +// * @param right The right operand constant representing the number of bits to shift. +// * @return A new {@code Expr} representing the bitwise right shift operation. +// */ +// export function bitRightShift(left: Expr, right: any): BitRightShift; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise right shift operation between a field and an expression. +// * +// * ```typescript +// * // Calculate the bitwise right shift of 'field1' by 'field2' bits. +// * bitRightShift("field1", Field.of("field2")); +// * ``` +// * +// * @param left The left operand field name. +// * @param right The right operand expression representing the number of bits to shift. +// * @return A new {@code Expr} representing the bitwise right shift operation. +// */ +// export function bitRightShift(left: string, right: Expr): BitRightShift; +// +// /** +// * @beta +// * +// * Creates an expression that applies a bitwise right shift operation between a field and a constant. +// * +// * ```typescript +// * // Calculate the bitwise right shift of 'field1' by 2 bits. +// * bitRightShift("field1", 2); +// * ``` +// * +// * @param left The left operand field name. +// * @param right The right operand constant representing the number of bits to shift. +// * @return A new {@code Expr} representing the bitwise right shift operation. +// */ +// export function bitRightShift(left: string, right: any): BitRightShift; +// export function bitRightShift( +// left: Expr | string, +// right: Expr | any +// ): BitRightShift { +// const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; +// const normalizedRight = right instanceof Expr ? right : Constant.of(right); +// return new BitRightShift(normalizedLeft, normalizedRight); +// } + +/** + * @beta + * + * Creates an expression that checks if two expressions are equal. + * + * ```typescript + * // Check if the 'age' field is equal to an expression + * eq(Field.of("age"), Field.of("minAge").add(10)); + * ``` + * + * @param left The first expression to compare. + * @param right The second expression to compare. + * @return A new `Expr` representing the equality comparison. + */ +export function eq(left: Expr, right: Expr): Eq; + +/** + * @beta + * + * Creates an expression that checks if an expression is equal to a constant value. + * + * ```typescript + * // Check if the 'age' field is equal to 21 + * eq(Field.of("age"), 21); + * ``` + * + * @param left The expression to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the equality comparison. + */ +export function eq(left: Expr, right: any): Eq; + +/** + * @beta + * + * Creates an expression that checks if a field's value is equal to an expression. + * + * ```typescript + * // Check if the 'age' field is equal to the 'limit' field + * eq("age", Field.of("limit")); + * ``` + * + * @param left The field name to compare. + * @param right The expression to compare to. + * @return A new `Expr` representing the equality comparison. + */ +export function eq(left: string, right: Expr): Eq; + +/** + * @beta + * + * Creates an expression that checks if a field's value is equal to a constant value. + * + * ```typescript + * // Check if the 'city' field is equal to string constant "London" + * eq("city", "London"); + * ``` + * + * @param left The field name to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the equality comparison. + */ +export function eq(left: string, right: any): Eq; +export function eq(left: Expr | string, right: any): Eq { + const leftExpr = left instanceof Expr ? left : Field.of(left); + const rightExpr = right instanceof Expr ? right : Constant.of(right); + return new Eq(leftExpr, rightExpr); +} + +/** + * @beta + * + * Creates an expression that checks if two expressions are not equal. + * + * ```typescript + * // Check if the 'status' field is not equal to field 'finalState' + * neq(Field.of("status"), Field.of("finalState")); + * ``` + * + * @param left The first expression to compare. + * @param right The second expression to compare. + * @return A new `Expr` representing the inequality comparison. + */ +export function neq(left: Expr, right: Expr): Neq; + +/** + * @beta + * + * Creates an expression that checks if an expression is not equal to a constant value. + * + * ```typescript + * // Check if the 'status' field is not equal to "completed" + * neq(Field.of("status"), "completed"); + * ``` + * + * @param left The expression to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the inequality comparison. + */ +export function neq(left: Expr, right: any): Neq; + +/** + * @beta + * + * Creates an expression that checks if a field's value is not equal to an expression. + * + * ```typescript + * // Check if the 'status' field is not equal to the value of 'expectedStatus' + * neq("status", Field.of("expectedStatus")); + * ``` + * + * @param left The field name to compare. + * @param right The expression to compare to. + * @return A new `Expr` representing the inequality comparison. + */ +export function neq(left: string, right: Expr): Neq; + +/** + * @beta + * + * Creates an expression that checks if a field's value is not equal to a constant value. + * + * ```typescript + * // Check if the 'country' field is not equal to "USA" + * neq("country", "USA"); + * ``` + * + * @param left The field name to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the inequality comparison. + */ +export function neq(left: string, right: any): Neq; +export function neq(left: Expr | string, right: any): Neq { + const leftExpr = left instanceof Expr ? left : Field.of(left); + const rightExpr = right instanceof Expr ? right : Constant.of(right); + return new Neq(leftExpr, rightExpr); +} + +/** + * @beta + * + * Creates an expression that checks if the first expression is less than the second expression. + * + * ```typescript + * // Check if the 'age' field is less than 30 + * lt(Field.of("age"), Field.of("limit")); + * ``` + * + * @param left The first expression to compare. + * @param right The second expression to compare. + * @return A new `Expr` representing the less than comparison. + */ +export function lt(left: Expr, right: Expr): Lt; + +/** + * @beta + * + * Creates an expression that checks if an expression is less than a constant value. + * + * ```typescript + * // Check if the 'age' field is less than 30 + * lt(Field.of("age"), 30); + * ``` + * + * @param left The expression to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the less than comparison. + */ +export function lt(left: Expr, right: any): Lt; + +/** + * @beta + * + * Creates an expression that checks if a field's value is less than an expression. + * + * ```typescript + * // Check if the 'age' field is less than the 'limit' field + * lt("age", Field.of("limit")); + * ``` + * + * @param left The field name to compare. + * @param right The expression to compare to. + * @return A new `Expr` representing the less than comparison. + */ +export function lt(left: string, right: Expr): Lt; + +/** + * @beta + * + * Creates an expression that checks if a field's value is less than a constant value. + * + * ```typescript + * // Check if the 'price' field is less than 50 + * lt("price", 50); + * ``` + * + * @param left The field name to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the less than comparison. + */ +export function lt(left: string, right: any): Lt; +export function lt(left: Expr | string, right: any): Lt { + const leftExpr = left instanceof Expr ? left : Field.of(left); + const rightExpr = right instanceof Expr ? right : Constant.of(right); + return new Lt(leftExpr, rightExpr); +} + +/** + * @beta + * + * Creates an expression that checks if the first expression is less than or equal to the second + * expression. + * + * ```typescript + * // Check if the 'quantity' field is less than or equal to 20 + * lte(Field.of("quantity"), Field.of("limit")); + * ``` + * + * @param left The first expression to compare. + * @param right The second expression to compare. + * @return A new `Expr` representing the less than or equal to comparison. + */ +export function lte(left: Expr, right: Expr): Lte; + +/** + * @beta + * + * Creates an expression that checks if an expression is less than or equal to a constant value. + * + * ```typescript + * // Check if the 'quantity' field is less than or equal to 20 + * lte(Field.of("quantity"), 20); + * ``` + * + * @param left The expression to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the less than or equal to comparison. + */ +export function lte(left: Expr, right: any): Lte; + +/** + * Creates an expression that checks if a field's value is less than or equal to an expression. + * + * ```typescript + * // Check if the 'quantity' field is less than or equal to the 'limit' field + * lte("quantity", Field.of("limit")); + * ``` + * + * @param left The field name to compare. + * @param right The expression to compare to. + * @return A new `Expr` representing the less than or equal to comparison. + */ +export function lte(left: string, right: Expr): Lte; + +/** + * @beta + * + * Creates an expression that checks if a field's value is less than or equal to a constant value. + * + * ```typescript + * // Check if the 'score' field is less than or equal to 70 + * lte("score", 70); + * ``` + * + * @param left The field name to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the less than or equal to comparison. + */ +export function lte(left: string, right: any): Lte; +export function lte(left: Expr | string, right: any): Lte { + const leftExpr = left instanceof Expr ? left : Field.of(left); + const rightExpr = right instanceof Expr ? right : Constant.of(right); + return new Lte(leftExpr, rightExpr); +} + +/** + * @beta + * + * Creates an expression that checks if the first expression is greater than the second + * expression. + * + * ```typescript + * // Check if the 'age' field is greater than 18 + * gt(Field.of("age"), Constant(9).add(9)); + * ``` + * + * @param left The first expression to compare. + * @param right The second expression to compare. + * @return A new `Expr` representing the greater than comparison. + */ +export function gt(left: Expr, right: Expr): Gt; + +/** + * @beta + * + * Creates an expression that checks if an expression is greater than a constant value. + * + * ```typescript + * // Check if the 'age' field is greater than 18 + * gt(Field.of("age"), 18); + * ``` + * + * @param left The expression to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the greater than comparison. + */ +export function gt(left: Expr, right: any): Gt; + +/** + * @beta + * + * Creates an expression that checks if a field's value is greater than an expression. + * + * ```typescript + * // Check if the value of field 'age' is greater than the value of field 'limit' + * gt("age", Field.of("limit")); + * ``` + * + * @param left The field name to compare. + * @param right The expression to compare to. + * @return A new `Expr` representing the greater than comparison. + */ +export function gt(left: string, right: Expr): Gt; + +/** + * @beta + * + * Creates an expression that checks if a field's value is greater than a constant value. + * + * ```typescript + * // Check if the 'price' field is greater than 100 + * gt("price", 100); + * ``` + * + * @param left The field name to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the greater than comparison. + */ +export function gt(left: string, right: any): Gt; +export function gt(left: Expr | string, right: any): Gt { + const leftExpr = left instanceof Expr ? left : Field.of(left); + const rightExpr = right instanceof Expr ? right : Constant.of(right); + return new Gt(leftExpr, rightExpr); +} + +/** + * @beta + * + * Creates an expression that checks if the first expression is greater than or equal to the + * second expression. + * + * ```typescript + * // Check if the 'quantity' field is greater than or equal to the field "threshold" + * gte(Field.of("quantity"), Field.of("threshold")); + * ``` + * + * @param left The first expression to compare. + * @param right The second expression to compare. + * @return A new `Expr` representing the greater than or equal to comparison. + */ +export function gte(left: Expr, right: Expr): Gte; + +/** + * @beta + * + * Creates an expression that checks if an expression is greater than or equal to a constant + * value. + * + * ```typescript + * // Check if the 'quantity' field is greater than or equal to 10 + * gte(Field.of("quantity"), 10); + * ``` + * + * @param left The expression to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the greater than or equal to comparison. + */ +export function gte(left: Expr, right: any): Gte; + +/** + * @beta + * + * Creates an expression that checks if a field's value is greater than or equal to an expression. + * + * ```typescript + * // Check if the value of field 'age' is greater than or equal to the value of field 'limit' + * gte("age", Field.of("limit")); + * ``` + * + * @param left The field name to compare. + * @param right The expression to compare to. + * @return A new `Expr` representing the greater than or equal to comparison. + */ +export function gte(left: string, right: Expr): Gte; + +/** + * @beta + * + * Creates an expression that checks if a field's value is greater than or equal to a constant + * value. + * + * ```typescript + * // Check if the 'score' field is greater than or equal to 80 + * gte("score", 80); + * ``` + * + * @param left The field name to compare. + * @param right The constant value to compare to. + * @return A new `Expr` representing the greater than or equal to comparison. + */ +export function gte(left: string, right: any): Gte; +export function gte(left: Expr | string, right: any): Gte { + const leftExpr = left instanceof Expr ? left : Field.of(left); + const rightExpr = right instanceof Expr ? right : Constant.of(right); + return new Gte(leftExpr, rightExpr); +} + +/** + * @beta + * + * Creates an expression that concatenates an array expression with other arrays. + * + * ```typescript + * // Combine the 'items' array with two new item arrays + * arrayConcat(Field.of("items"), [Field.of("newItems"), Field.of("otherItems")]); + * ``` + * + * @param array The array expression to concatenate to. + * @param elements The array expressions to concatenate. + * @return A new {@code Expr} representing the concatenated array. + */ +export function arrayConcat(array: Expr, elements: Expr[]): ArrayConcat; + +/** + * @beta + * + * Creates an expression that concatenates an array expression with other arrays and/or values. + * + * ```typescript + * // Combine the 'tags' array with a new array + * arrayConcat(Field.of("tags"), ["newTag1", "newTag2"]); + * ``` + * + * @param array The array expression to concatenate to. + * @param elements The array expressions or single values to concatenate. + * @return A new {@code Expr} representing the concatenated array. + */ +export function arrayConcat(array: Expr, elements: any[]): ArrayConcat; + +/** + * @beta + * + * Creates an expression that concatenates a field's array value with other arrays. + * + * ```typescript + * // Combine the 'items' array with two new item arrays + * arrayConcat("items", [Field.of("newItems"), Field.of("otherItems")]); + * ``` + * + * @param array The field name containing array values. + * @param elements The array expressions to concatenate. + * @return A new {@code Expr} representing the concatenated array. + */ +export function arrayConcat(array: string, elements: Expr[]): ArrayConcat; + +/** + * @beta + * + * Creates an expression that concatenates a field's array value with other arrays and/or values. + * + * ```typescript + * // Combine the 'tags' array with a new array + * arrayConcat("tags", ["newTag1", "newTag2"]); + * ``` + * + * @param array The field name containing array values. + * @param elements The array expressions or single values to concatenate. + * @return A new {@code Expr} representing the concatenated array. + */ +export function arrayConcat(array: string, elements: any[]): ArrayConcat; +export function arrayConcat( + array: Expr | string, + elements: any[] +): ArrayConcat { + const arrayExpr = array instanceof Expr ? array : Field.of(array); + const exprValues = elements.map(element => + element instanceof Expr ? element : Constant.of(element) + ); + return new ArrayConcat(arrayExpr, exprValues); +} + +/** + * @beta + * + * Creates an expression that checks if an array expression contains a specific element. + * + * ```typescript + * // Check if the 'colors' array contains the value of field 'selectedColor' + * arrayContains(Field.of("colors"), Field.of("selectedColor")); + * ``` + * + * @param array The array expression to check. + * @param element The element to search for in the array. + * @return A new {@code Expr} representing the 'array_contains' comparison. + */ +export function arrayContains(array: Expr, element: Expr): ArrayContains; + +/** + * @beta + * + * Creates an expression that checks if an array expression contains a specific element. + * + * ```typescript + * // Check if the 'colors' array contains "red" + * arrayContains(Field.of("colors"), "red"); + * ``` + * + * @param array The array expression to check. + * @param element The element to search for in the array. + * @return A new {@code Expr} representing the 'array_contains' comparison. + */ +export function arrayContains(array: Expr, element: any): ArrayContains; + +/** + * @beta + * + * Creates an expression that checks if a field's array value contains a specific element. + * + * ```typescript + * // Check if the 'colors' array contains the value of field 'selectedColor' + * arrayContains("colors", Field.of("selectedColor")); + * ``` + * + * @param array The field name to check. + * @param element The element to search for in the array. + * @return A new {@code Expr} representing the 'array_contains' comparison. + */ +export function arrayContains(array: string, element: Expr): ArrayContains; + +/** + * @beta + * + * Creates an expression that checks if a field's array value contains a specific value. + * + * ```typescript + * // Check if the 'colors' array contains "red" + * arrayContains("colors", "red"); + * ``` + * + * @param array The field name to check. + * @param element The element to search for in the array. + * @return A new {@code Expr} representing the 'array_contains' comparison. + */ +export function arrayContains(array: string, element: any): ArrayContains; +export function arrayContains( + array: Expr | string, + element: any +): ArrayContains { + const arrayExpr = array instanceof Expr ? array : Field.of(array); + const elementExpr = element instanceof Expr ? element : Constant.of(element); + return new ArrayContains(arrayExpr, elementExpr); +} + +/** + * @beta + * + * Creates an expression that checks if an array expression contains any of the specified + * elements. + * + * ```typescript + * // Check if the 'categories' array contains either values from field "cate1" or "Science" + * arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); + * ``` + * + * @param array The array expression to check. + * @param values The elements to check for in the array. + * @return A new {@code Expr} representing the 'array_contains_any' comparison. + */ +export function arrayContainsAny(array: Expr, values: Expr[]): ArrayContainsAny; + +/** + * @beta + * + * Creates an expression that checks if an array expression contains any of the specified + * elements. + * + * ```typescript + * // Check if the 'categories' array contains either values from field "cate1" or "Science" + * arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); + * ``` + * + * @param array The array expression to check. + * @param values The elements to check for in the array. + * @return A new {@code Expr} representing the 'array_contains_any' comparison. + */ +export function arrayContainsAny(array: Expr, values: any[]): ArrayContainsAny; + +/** + * @beta + * + * Creates an expression that checks if a field's array value contains any of the specified + * elements. + * + * ```typescript + * // Check if the 'groups' array contains either the value from the 'userGroup' field + * // or the value "guest" + * arrayContainsAny("categories", [Field.of("cate1"), "Science"]); + * ``` + * + * @param array The field name to check. + * @param values The elements to check for in the array. + * @return A new {@code Expr} representing the 'array_contains_any' comparison. + */ +export function arrayContainsAny( + array: string, + values: Expr[] +): ArrayContainsAny; + +/** + * @beta + * + * Creates an expression that checks if a field's array value contains any of the specified + * elements. + * + * ```typescript + * // Check if the 'groups' array contains either the value from the 'userGroup' field + * // or the value "guest" + * arrayContainsAny("categories", [Field.of("cate1"), "Science"]); + * ``` + * + * @param array The field name to check. + * @param values The elements to check for in the array. + * @return A new {@code Expr} representing the 'array_contains_any' comparison. + */ +export function arrayContainsAny( + array: string, + values: any[] +): ArrayContainsAny; +export function arrayContainsAny( + array: Expr | string, + values: any[] +): ArrayContainsAny { + const arrayExpr = array instanceof Expr ? array : Field.of(array); + const exprValues = values.map(value => + value instanceof Expr ? value : Constant.of(value) + ); + return new ArrayContainsAny(arrayExpr, exprValues); +} + +/** + * @beta + * + * Creates an expression that checks if an array expression contains all the specified elements. + * + * ```typescript + * // Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" + * arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); + * ``` + * + * @param array The array expression to check. + * @param values The elements to check for in the array. + * @return A new {@code Expr} representing the 'array_contains_all' comparison. + */ +export function arrayContainsAll(array: Expr, values: Expr[]): ArrayContainsAll; + +/** + * @beta + * + * Creates an expression that checks if an array expression contains all the specified elements. + * + * ```typescript + * // Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" + * arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); + * ``` + * + * @param array The array expression to check. + * @param values The elements to check for in the array. + * @return A new {@code Expr} representing the 'array_contains_all' comparison. + */ +export function arrayContainsAll(array: Expr, values: any[]): ArrayContainsAll; + +/** + * @beta + * + * Creates an expression that checks if a field's array value contains all the specified values or + * expressions. + * + * ```typescript + * // Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" + * arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); + * ``` + * + * @param array The field name to check. + * @param values The elements to check for in the array. + * @return A new {@code Expr} representing the 'array_contains_all' comparison. + */ +export function arrayContainsAll( + array: string, + values: Expr[] +): ArrayContainsAll; + +/** + * @beta + * + * Creates an expression that checks if a field's array value contains all the specified values or + * expressions. + * + * ```typescript + * // Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" + * arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); + * ``` + * + * @param array The field name to check. + * @param values The elements to check for in the array. + * @return A new {@code Expr} representing the 'array_contains_all' comparison. + */ +export function arrayContainsAll( + array: string, + values: any[] +): ArrayContainsAll; +export function arrayContainsAll( + array: Expr | string, + values: any[] +): ArrayContainsAll { + const arrayExpr = array instanceof Expr ? array : Field.of(array); + const exprValues = values.map(value => + value instanceof Expr ? value : Constant.of(value) + ); + return new ArrayContainsAll(arrayExpr, exprValues); +} + +/** + * @beta + * + * Creates an expression that calculates the length of an array expression. + * + * ```typescript + * // Get the number of items in the 'cart' array + * arrayLength(Field.of("cart")); + * ``` + * + * @param array The array expression to calculate the length of. + * @return A new {@code Expr} representing the length of the array. + */ +export function arrayLength(array: Expr): ArrayLength { + return new ArrayLength(array); +} + +/** + * @beta + * + * Creates an expression that checks if an expression is equal to any of the provided values or + * expressions. + * + * ```typescript + * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' + * inAny(Field.of("category"), [Constant.of("Electronics"), Field.of("primaryType")]); + * ``` + * + * @param element The expression to compare. + * @param others The values to check against. + * @return A new {@code Expr} representing the 'IN' comparison. + */ +export function inAny(element: Expr, others: Expr[]): In; + +/** + * @beta + * + * Creates an expression that checks if an expression is equal to any of the provided values or + * expressions. + * + * ```typescript + * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' + * inAny(Field.of("category"), ["Electronics", Field.of("primaryType")]); + * ``` + * + * @param element The expression to compare. + * @param others The values to check against. + * @return A new {@code Expr} representing the 'IN' comparison. + */ +export function inAny(element: Expr, others: any[]): In; + +/** + * @beta + * + * Creates an expression that checks if a field's value is equal to any of the provided values or + * expressions. + * + * ```typescript + * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' + * inAny("category", [Constant.of("Electronics"), Field.of("primaryType")]); + * ``` + * + * @param element The field to compare. + * @param others The values to check against. + * @return A new {@code Expr} representing the 'IN' comparison. + */ +export function inAny(element: string, others: Expr[]): In; + +/** + * @beta + * + * Creates an expression that checks if a field's value is equal to any of the provided values or + * expressions. + * + * ```typescript + * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' + * inAny("category", ["Electronics", Field.of("primaryType")]); + * ``` + * + * @param element The field to compare. + * @param others The values to check against. + * @return A new {@code Expr} representing the 'IN' comparison. + */ +export function inAny(element: string, others: any[]): In; +export function inAny(element: Expr | string, others: any[]): In { + const elementExpr = element instanceof Expr ? element : Field.of(element); + const exprOthers = others.map(other => + other instanceof Expr ? other : Constant.of(other) + ); + return new In(elementExpr, exprOthers); +} + +/** + * @beta + * + * Creates an expression that checks if an expression is not equal to any of the provided values + * or expressions. + * + * ```typescript + * // Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' + * notInAny(Field.of("status"), [Constant.of("pending"), Field.of("rejectedStatus")]); + * ``` + * + * @param element The expression to compare. + * @param others The values to check against. + * @return A new {@code Expr} representing the 'NOT IN' comparison. + */ +export function notInAny(element: Expr, others: Expr[]): Not; + +/** + * @beta + * + * Creates an expression that checks if an expression is not equal to any of the provided values + * or expressions. + * + * ```typescript + * // Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' + * notInAny(Field.of("status"), ["pending", Field.of("rejectedStatus")]); + * ``` + * + * @param element The expression to compare. + * @param others The values to check against. + * @return A new {@code Expr} representing the 'NOT IN' comparison. + */ +export function notInAny(element: Expr, others: any[]): Not; + +/** + * @beta + * + * Creates an expression that checks if a field's value is not equal to any of the provided values + * or expressions. + * + * ```typescript + * // Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' + * notInAny("status", [Constant.of("pending"), Field.of("rejectedStatus")]); + * ``` + * + * @param element The field name to compare. + * @param others The values to check against. + * @return A new {@code Expr} representing the 'NOT IN' comparison. + */ +export function notInAny(element: string, others: Expr[]): Not; + +/** + * @beta + * + * Creates an expression that checks if a field's value is not equal to any of the provided values + * or expressions. + * + * ```typescript + * // Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' + * notInAny("status", ["pending", Field.of("rejectedStatus")]); + * ``` + * + * @param element The field name to compare. + * @param others The values to check against. + * @return A new {@code Expr} representing the 'NOT IN' comparison. + */ +export function notInAny(element: string, others: any[]): Not; +export function notInAny(element: Expr | string, others: any[]): Not { + const elementExpr = element instanceof Expr ? element : Field.of(element); + const exprOthers = others.map(other => + other instanceof Expr ? other : Constant.of(other) + ); + return new Not(new In(elementExpr, exprOthers)); +} + +/** + * @beta + * + * Creates an expression that performs a logical 'XOR' (exclusive OR) operation on multiple filter + * conditions. + * + * ```typescript + * // Check if only one of the conditions is true: 'age' greater than 18, 'city' is "London", + * // or 'status' is "active". + * const condition = xor( + * gt("age", 18), + * eq("city", "London"), + * eq("status", "active")); + * ``` + * + * @param left The first filter condition. + * @param right Additional filter conditions to 'XOR' together. + * @return A new {@code Expr} representing the logical 'XOR' operation. + */ +export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor { + return new Xor([left, ...right]); +} + +/** + * @beta + * + * Creates a conditional expression that evaluates to a 'then' expression if a condition is true + * and an 'else' expression if the condition is false. + * + * ```typescript + * // If 'age' is greater than 18, return "Adult"; otherwise, return "Minor". + * ifFunction( + * gt("age", 18), Constant.of("Adult"), Constant.of("Minor")); + * ``` + * + * @param condition The condition to evaluate. + * @param thenExpr The expression to evaluate if the condition is true. + * @param elseExpr The expression to evaluate if the condition is false. + * @return A new {@code Expr} representing the conditional expression. + */ +export function ifFunction( + condition: FilterExpr, + thenExpr: Expr, + elseExpr: Expr +): If { + return new If(condition, thenExpr, elseExpr); +} + +/** + * @beta + * + * Creates an expression that negates a filter condition. + * + * ```typescript + * // Find documents where the 'completed' field is NOT true + * not(eq("completed", true)); + * ``` + * + * @param filter The filter condition to negate. + * @return A new {@code Expr} representing the negated filter condition. + */ +export function not(filter: FilterExpr): Not { + return new Not(filter); +} + +/** + * @beta + * + * Creates an expression that returns the larger value between two expressions, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the larger value between the 'field1' field and the 'field2' field. + * logicalMax(Field.of("field1"), Field.of("field2")); + * ``` + * + * @param left The left operand expression. + * @param right The right operand expression. + * @return A new {@code Expr} representing the logical max operation. + */ +export function logicalMax(left: Expr, right: Expr): LogicalMax; + +/** + * @beta + * + * Creates an expression that returns the larger value between an expression and a constant value, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the larger value between the 'value' field and 10. + * logicalMax(Field.of("value"), 10); + * ``` + * + * @param left The left operand expression. + * @param right The right operand constant. + * @return A new {@code Expr} representing the logical max operation. + */ +export function logicalMax(left: Expr, right: any): LogicalMax; + +/** + * @beta + * + * Creates an expression that returns the larger value between a field and an expression, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the larger value between the 'field1' field and the 'field2' field. + * logicalMax("field1", Field.of('field2')); + * ``` + * + * @param left The left operand field name. + * @param right The right operand expression. + * @return A new {@code Expr} representing the logical max operation. + */ +export function logicalMax(left: string, right: Expr): LogicalMax; + +/** + * @beta + * + * Creates an expression that returns the larger value between a field and a constant value, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the larger value between the 'value' field and 10. + * logicalMax("value", 10); + * ``` + * + * @param left The left operand field name. + * @param right The right operand constant. + * @return A new {@code Expr} representing the logical max operation. + */ +export function logicalMax(left: string, right: any): LogicalMax; +export function logicalMax(left: Expr | string, right: Expr | any): LogicalMax { + const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; + const normalizedRight = right instanceof Expr ? right : Constant.of(right); + return new LogicalMax(normalizedLeft, normalizedRight); +} + +/** + * @beta + * + * Creates an expression that returns the smaller value between two expressions, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the smaller value between the 'field1' field and the 'field2' field. + * logicalMin(Field.of("field1"), Field.of("field2")); + * ``` + * + * @param left The left operand expression. + * @param right The right operand expression. + * @return A new {@code Expr} representing the logical min operation. + */ +export function logicalMin(left: Expr, right: Expr): LogicalMin; + +/** + * @beta + * + * Creates an expression that returns the smaller value between an expression and a constant value, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the smaller value between the 'value' field and 10. + * logicalMin(Field.of("value"), 10); + * ``` + * + * @param left The left operand expression. + * @param right The right operand constant. + * @return A new {@code Expr} representing the logical min operation. + */ +export function logicalMin(left: Expr, right: any): LogicalMin; + +/** + * @beta + * + * Creates an expression that returns the smaller value between a field and an expression, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the smaller value between the 'field1' field and the 'field2' field. + * logicalMin("field1", Field.of("field2")); + * ``` + * + * @param left The left operand field name. + * @param right The right operand expression. + * @return A new {@code Expr} representing the logical min operation. + */ +export function logicalMin(left: string, right: Expr): LogicalMin; + +/** + * @beta + * + * Creates an expression that returns the smaller value between a field and a constant value, based on Firestore's value type ordering. + * + * ```typescript + * // Returns the smaller value between the 'value' field and 10. + * logicalMin("value", 10); + * ``` + * + * @param left The left operand field name. + * @param right The right operand constant. + * @return A new {@code Expr} representing the logical min operation. + */ +export function logicalMin(left: string, right: any): LogicalMin; +export function logicalMin(left: Expr | string, right: Expr | any): LogicalMin { + const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; + const normalizedRight = right instanceof Expr ? right : Constant.of(right); + return new LogicalMin(normalizedLeft, normalizedRight); +} + +/** + * @beta + * + * Creates an expression that checks if a field exists. + * + * ```typescript + * // Check if the document has a field named "phoneNumber" + * exists(Field.of("phoneNumber")); + * ``` + * + * @param value An expression evaluates to the name of the field to check. + * @return A new {@code Expr} representing the 'exists' check. + */ +export function exists(value: Expr): Exists; + +/** + * @beta + * + * Creates an expression that checks if a field exists. + * + * ```typescript + * // Check if the document has a field named "phoneNumber" + * exists("phoneNumber"); + * ``` + * + * @param field The field name to check. + * @return A new {@code Expr} representing the 'exists' check. + */ +export function exists(field: string): Exists; +export function exists(valueOrField: Expr | string): Exists { + const valueExpr = + valueOrField instanceof Expr ? valueOrField : Field.of(valueOrField); + return new Exists(valueExpr); +} + +/** + * @beta + * + * Creates an expression that checks if an expression evaluates to 'NaN' (Not a Number). + * + * ```typescript + * // Check if the result of a calculation is NaN + * isNaN(Field.of("value").divide(0)); + * ``` + * + * @param value The expression to check. + * @return A new {@code Expr} representing the 'isNaN' check. + */ +export function isNan(value: Expr): IsNan; + +/** + * @beta + * + * Creates an expression that checks if a field's value evaluates to 'NaN' (Not a Number). + * + * ```typescript + * // Check if the result of a calculation is NaN + * isNaN("value"); + * ``` + * + * @param value The name of the field to check. + * @return A new {@code Expr} representing the 'isNaN' check. + */ +export function isNan(value: string): IsNan; +export function isNan(value: Expr | string): IsNan { + const valueExpr = value instanceof Expr ? value : Field.of(value); + return new IsNan(valueExpr); +} + +/** + * @beta + * + * Creates an expression that reverses a string. + * + * ```typescript + * // Reverse the value of the 'myString' field. + * reverse(Field.of("myString")); + * ``` + * + * @param expr The expression representing the string to reverse. + * @return A new {@code Expr} representing the reversed string. + */ +export function reverse(expr: Expr): Reverse; + +/** + * @beta + * + * Creates an expression that reverses a string represented by a field. + * + * ```typescript + * // Reverse the value of the 'myString' field. + * reverse("myString"); + * ``` + * + * @param field The name of the field representing the string to reverse. + * @return A new {@code Expr} representing the reversed string. + */ +export function reverse(field: string): Reverse; +export function reverse(expr: Expr | string): Reverse { + const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; + return new Reverse(normalizedExpr); +} + +/** + * @beta + * + * Creates an expression that replaces the first occurrence of a substring within a string with another substring. + * + * ```typescript + * // Replace the first occurrence of "hello" with "hi" in the 'message' field. + * replaceFirst(Field.of("message"), "hello", "hi"); + * ``` + * + * @param value The expression representing the string to perform the replacement on. + * @param find The substring to search for. + * @param replace The substring to replace the first occurrence of 'find' with. + * @return A new {@code Expr} representing the string with the first occurrence replaced. + */ +export function replaceFirst( + value: Expr, + find: string, + replace: string +): ReplaceFirst; + +/** + * @beta + * + * Creates an expression that replaces the first occurrence of a substring within a string with another substring, + * where the substring to find and the replacement substring are specified by expressions. + * + * ```typescript + * // Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field. + * replaceFirst(Field.of("message"), Field.of("findField"), Field.of("replaceField")); + * ``` + * + * @param value The expression representing the string to perform the replacement on. + * @param find The expression representing the substring to search for. + * @param replace The expression representing the substring to replace the first occurrence of 'find' with. + * @return A new {@code Expr} representing the string with the first occurrence replaced. + */ +export function replaceFirst( + value: Expr, + find: Expr, + replace: Expr +): ReplaceFirst; + +/** + * @beta + * + * Creates an expression that replaces the first occurrence of a substring within a string represented by a field with another substring. + * + * ```typescript + * // Replace the first occurrence of "hello" with "hi" in the 'message' field. + * replaceFirst("message", "hello", "hi"); + * ``` + * + * @param field The name of the field representing the string to perform the replacement on. + * @param find The substring to search for. + * @param replace The substring to replace the first occurrence of 'find' with. + * @return A new {@code Expr} representing the string with the first occurrence replaced. + */ +export function replaceFirst( + field: string, + find: string, + replace: string +): ReplaceFirst; +export function replaceFirst( + value: Expr | string, + find: Expr | string, + replace: Expr | string +): ReplaceFirst { + const normalizedValue = typeof value === 'string' ? Field.of(value) : value; + const normalizedFind = typeof find === 'string' ? Constant.of(find) : find; + const normalizedReplace = + typeof replace === 'string' ? Constant.of(replace) : replace; + return new ReplaceFirst(normalizedValue, normalizedFind, normalizedReplace); +} + +/** + * @beta + * + * Creates an expression that replaces all occurrences of a substring within a string with another substring. + * + * ```typescript + * // Replace all occurrences of "hello" with "hi" in the 'message' field. + * replaceAll(Field.of("message"), "hello", "hi"); + * ``` + * + * @param value The expression representing the string to perform the replacement on. + * @param find The substring to search for. + * @param replace The substring to replace all occurrences of 'find' with. + * @return A new {@code Expr} representing the string with all occurrences replaced. + */ +export function replaceAll( + value: Expr, + find: string, + replace: string +): ReplaceAll; + +/** + * @beta + * + * Creates an expression that replaces all occurrences of a substring within a string with another substring, + * where the substring to find and the replacement substring are specified by expressions. + * + * ```typescript + * // Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field. + * replaceAll(Field.of("message"), Field.of("findField"), Field.of("replaceField")); + * ``` + * + * @param value The expression representing the string to perform the replacement on. + * @param find The expression representing the substring to search for. + * @param replace The expression representing the substring to replace all occurrences of 'find' with. + * @return A new {@code Expr} representing the string with all occurrences replaced. + */ +export function replaceAll(value: Expr, find: Expr, replace: Expr): ReplaceAll; + +/** + * @beta + * + * Creates an expression that replaces all occurrences of a substring within a string represented by a field with another substring. + * + * ```typescript + * // Replace all occurrences of "hello" with "hi" in the 'message' field. + * replaceAll("message", "hello", "hi"); + * ``` + * + * @param field The name of the field representing the string to perform the replacement on. + * @param find The substring to search for. + * @param replace The substring to replace all occurrences of 'find' with. + * @return A new {@code Expr} representing the string with all occurrences replaced. + */ +export function replaceAll( + field: string, + find: string, + replace: string +): ReplaceAll; +export function replaceAll( + value: Expr | string, + find: Expr | string, + replace: Expr | string +): ReplaceAll { + const normalizedValue = typeof value === 'string' ? Field.of(value) : value; + const normalizedFind = typeof find === 'string' ? Constant.of(find) : find; + const normalizedReplace = + typeof replace === 'string' ? Constant.of(replace) : replace; + return new ReplaceAll(normalizedValue, normalizedFind, normalizedReplace); +} + +/** + * @beta + * + * Creates an expression that calculates the byte length of a string in UTF-8, or just the length of a Blob. + * + * ```typescript + * // Calculate the length of the 'myString' field in bytes. + * byteLength(Field.of("myString")); + * ``` + * + * @param expr The expression representing the string. + * @return A new {@code Expr} representing the length of the string in bytes. + */ +export function byteLength(expr: Expr): ByteLength; + +/** + * @beta + * + * Creates an expression that calculates the length of a string represented by a field in UTF-8 bytes, or just the length of a Blob. + * + * ```typescript + * // Calculate the length of the 'myString' field in bytes. + * byteLength("myString"); + * ``` + * + * @param field The name of the field representing the string. + * @return A new {@code Expr} representing the length of the string in bytes. + */ +export function byteLength(field: string): ByteLength; +export function byteLength(expr: Expr | string): ByteLength { + const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; + return new ByteLength(normalizedExpr); +} + +/** + * @beta + * + * Creates an expression that calculates the character length of a string field in UTF8. + * + * ```typescript + * // Get the character length of the 'name' field in UTF-8. + * strLength("name"); + * ``` + * + * @param field The name of the field containing the string. + * @return A new {@code Expr} representing the length of the string. + */ +export function charLength(field: string): CharLength; + +/** + * @beta + * + * Creates an expression that calculates the character length of a string expression in UTF-8. + * + * ```typescript + * // Get the character length of the 'name' field in UTF-8. + * strLength(Field.of("name")); + * ``` + * + * @param expr The expression representing the string to calculate the length of. + * @return A new {@code Expr} representing the length of the string. + */ +export function charLength(expr: Expr): CharLength; +export function charLength(value: Expr | string): CharLength { + const valueExpr = value instanceof Expr ? value : Field.of(value); + return new CharLength(valueExpr); +} + +/** + * @beta + * + * Creates an expression that performs a case-sensitive wildcard string comparison against a + * field. + * + * ```typescript + * // Check if the 'title' field contains the string "guide" + * like("title", "%guide%"); + * ``` + * + * @param left The name of the field containing the string. + * @param pattern The pattern to search for. You can use "%" as a wildcard character. + * @return A new {@code Expr} representing the 'like' comparison. + */ +export function like(left: string, pattern: string): Like; + +/** + * @beta + * + * Creates an expression that performs a case-sensitive wildcard string comparison against a + * field. + * + * ```typescript + * // Check if the 'title' field contains the string "guide" + * like("title", Field.of("pattern")); + * ``` + * + * @param left The name of the field containing the string. + * @param pattern The pattern to search for. You can use "%" as a wildcard character. + * @return A new {@code Expr} representing the 'like' comparison. + */ +export function like(left: string, pattern: Expr): Like; + +/** + * @beta + * + * Creates an expression that performs a case-sensitive wildcard string comparison. + * + * ```typescript + * // Check if the 'title' field contains the string "guide" + * like(Field.of("title"), "%guide%"); + * ``` + * + * @param left The expression representing the string to perform the comparison on. + * @param pattern The pattern to search for. You can use "%" as a wildcard character. + * @return A new {@code Expr} representing the 'like' comparison. + */ +export function like(left: Expr, pattern: string): Like; + +/** + * @beta + * + * Creates an expression that performs a case-sensitive wildcard string comparison. + * + * ```typescript + * // Check if the 'title' field contains the string "guide" + * like(Field.of("title"), Field.of("pattern")); + * ``` + * + * @param left The expression representing the string to perform the comparison on. + * @param pattern The pattern to search for. You can use "%" as a wildcard character. + * @return A new {@code Expr} representing the 'like' comparison. + */ +export function like(left: Expr, pattern: Expr): Like; +export function like(left: Expr | string, pattern: Expr | string): Like { + const leftExpr = left instanceof Expr ? left : Field.of(left); + const patternExpr = pattern instanceof Expr ? pattern : Constant.of(pattern); + return new Like(leftExpr, patternExpr); +} + +/** + * @beta + * + * Creates an expression that checks if a string field contains a specified regular expression as + * a substring. + * + * ```typescript + * // Check if the 'description' field contains "example" (case-insensitive) + * regexContains("description", "(?i)example"); + * ``` + * + * @param left The name of the field containing the string. + * @param pattern The regular expression to use for the search. + * @return A new {@code Expr} representing the 'contains' comparison. + */ +export function regexContains(left: string, pattern: string): RegexContains; + +/** + * @beta + * + * Creates an expression that checks if a string field contains a specified regular expression as + * a substring. + * + * ```typescript + * // Check if the 'description' field contains "example" (case-insensitive) + * regexContains("description", Field.of("pattern")); + * ``` + * + * @param left The name of the field containing the string. + * @param pattern The regular expression to use for the search. + * @return A new {@code Expr} representing the 'contains' comparison. + */ +export function regexContains(left: string, pattern: Expr): RegexContains; + +/** + * @beta + * + * Creates an expression that checks if a string expression contains a specified regular + * expression as a substring. + * + * ```typescript + * // Check if the 'description' field contains "example" (case-insensitive) + * regexContains(Field.of("description"), "(?i)example"); + * ``` + * + * @param left The expression representing the string to perform the comparison on. + * @param pattern The regular expression to use for the search. + * @return A new {@code Expr} representing the 'contains' comparison. + */ +export function regexContains(left: Expr, pattern: string): RegexContains; + +/** + * @beta + * + * Creates an expression that checks if a string expression contains a specified regular + * expression as a substring. + * + * ```typescript + * // Check if the 'description' field contains "example" (case-insensitive) + * regexContains(Field.of("description"), Field.of("pattern")); + * ``` + * + * @param left The expression representing the string to perform the comparison on. + * @param pattern The regular expression to use for the search. + * @return A new {@code Expr} representing the 'contains' comparison. + */ +export function regexContains(left: Expr, pattern: Expr): RegexContains; +export function regexContains( + left: Expr | string, + pattern: Expr | string +): RegexContains { + const leftExpr = left instanceof Expr ? left : Field.of(left); + const patternExpr = pattern instanceof Expr ? pattern : Constant.of(pattern); + return new RegexContains(leftExpr, patternExpr); +} + +/** + * @beta + * + * Creates an expression that checks if a string field matches a specified regular expression. + * + * ```typescript + * // Check if the 'email' field matches a valid email pattern + * regexMatch("email", "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + * ``` + * + * @param left The name of the field containing the string. + * @param pattern The regular expression to use for the match. + * @return A new {@code Expr} representing the regular expression match. + */ +export function regexMatch(left: string, pattern: string): RegexMatch; + +/** + * @beta + * + * Creates an expression that checks if a string field matches a specified regular expression. + * + * ```typescript + * // Check if the 'email' field matches a valid email pattern + * regexMatch("email", Field.of("pattern")); + * ``` + * + * @param left The name of the field containing the string. + * @param pattern The regular expression to use for the match. + * @return A new {@code Expr} representing the regular expression match. + */ +export function regexMatch(left: string, pattern: Expr): RegexMatch; + +/** + * @beta + * + * Creates an expression that checks if a string expression matches a specified regular + * expression. + * + * ```typescript + * // Check if the 'email' field matches a valid email pattern + * regexMatch(Field.of("email"), "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + * ``` + * + * @param left The expression representing the string to match against. + * @param pattern The regular expression to use for the match. + * @return A new {@code Expr} representing the regular expression match. + */ +export function regexMatch(left: Expr, pattern: string): RegexMatch; + +/** + * @beta + * + * Creates an expression that checks if a string expression matches a specified regular + * expression. + * + * ```typescript + * // Check if the 'email' field matches a valid email pattern + * regexMatch(Field.of("email"), Field.of("pattern")); + * ``` + * + * @param left The expression representing the string to match against. + * @param pattern The regular expression to use for the match. + * @return A new {@code Expr} representing the regular expression match. + */ +export function regexMatch(left: Expr, pattern: Expr): RegexMatch; +export function regexMatch( + left: Expr | string, + pattern: Expr | string +): RegexMatch { + const leftExpr = left instanceof Expr ? left : Field.of(left); + const patternExpr = pattern instanceof Expr ? pattern : Constant.of(pattern); + return new RegexMatch(leftExpr, patternExpr); +} + +/** + * @beta + * + * Creates an expression that checks if a string field contains a specified substring. + * + * ```typescript + * // Check if the 'description' field contains "example". + * strContains("description", "example"); + * ``` + * + * @param left The name of the field containing the string. + * @param substring The substring to search for. + * @return A new {@code Expr} representing the 'contains' comparison. + */ +export function strContains(left: string, substring: string): StrContains; + +/** + * @beta + * + * Creates an expression that checks if a string field contains a substring specified by an expression. + * + * ```typescript + * // Check if the 'description' field contains the value of the 'keyword' field. + * strContains("description", Field.of("keyword")); + * ``` + * + * @param left The name of the field containing the string. + * @param substring The expression representing the substring to search for. + * @return A new {@code Expr} representing the 'contains' comparison. + */ +export function strContains(left: string, substring: Expr): StrContains; + +/** + * @beta + * + * Creates an expression that checks if a string expression contains a specified substring. + * + * ```typescript + * // Check if the 'description' field contains "example". + * strContains(Field.of("description"), "example"); + * ``` + * + * @param left The expression representing the string to perform the comparison on. + * @param substring The substring to search for. + * @return A new {@code Expr} representing the 'contains' comparison. + */ +export function strContains(left: Expr, substring: string): StrContains; + +/** + * @beta + * + * Creates an expression that checks if a string expression contains a substring specified by another expression. + * + * ```typescript + * // Check if the 'description' field contains the value of the 'keyword' field. + * strContains(Field.of("description"), Field.of("keyword")); + * ``` + * + * @param left The expression representing the string to perform the comparison on. + * @param substring The expression representing the substring to search for. + * @return A new {@code Expr} representing the 'contains' comparison. + */ +export function strContains(left: Expr, substring: Expr): StrContains; +export function strContains( + left: Expr | string, + substring: Expr | string +): StrContains { + const leftExpr = left instanceof Expr ? left : Field.of(left); + const substringExpr = + substring instanceof Expr ? substring : Constant.of(substring); + return new StrContains(leftExpr, substringExpr); +} + +/** + * @beta + * + * Creates an expression that checks if a field's value starts with a given prefix. + * + * ```typescript + * // Check if the 'name' field starts with "Mr." + * startsWith("name", "Mr."); + * ``` + * + * @param expr The field name to check. + * @param prefix The prefix to check for. + * @return A new {@code Expr} representing the 'starts with' comparison. + */ +export function startsWith(expr: string, prefix: string): StartsWith; + +/** + * @beta + * + * Creates an expression that checks if a field's value starts with a given prefix. + * + * ```typescript + * // Check if the 'fullName' field starts with the value of the 'firstName' field + * startsWith("fullName", Field.of("firstName")); + * ``` + * + * @param expr The field name to check. + * @param prefix The expression representing the prefix. + * @return A new {@code Expr} representing the 'starts with' comparison. + */ +export function startsWith(expr: string, prefix: Expr): StartsWith; + +/** + * @beta + * + * Creates an expression that checks if a string expression starts with a given prefix. + * + * ```typescript + * // Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." + * startsWith(Field.of("fullName"), "Mr."); + * ``` + * + * @param expr The expression to check. + * @param prefix The prefix to check for. + * @return A new {@code Expr} representing the 'starts with' comparison. + */ +export function startsWith(expr: Expr, prefix: string): StartsWith; + +/** + * @beta + * + * Creates an expression that checks if a string expression starts with a given prefix. + * + * ```typescript + * // Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." + * startsWith(Field.of("fullName"), Field.of("prefix")); + * ``` + * + * @param expr The expression to check. + * @param prefix The prefix to check for. + * @return A new {@code Expr} representing the 'starts with' comparison. + */ +export function startsWith(expr: Expr, prefix: Expr): StartsWith; +export function startsWith( + expr: Expr | string, + prefix: Expr | string +): StartsWith { + const exprLeft = expr instanceof Expr ? expr : Field.of(expr); + const prefixExpr = prefix instanceof Expr ? prefix : Constant.of(prefix); + return new StartsWith(exprLeft, prefixExpr); +} + +/** + * @beta + * + * Creates an expression that checks if a field's value ends with a given postfix. + * + * ```typescript + * // Check if the 'filename' field ends with ".txt" + * endsWith("filename", ".txt"); + * ``` + * + * @param expr The field name to check. + * @param suffix The postfix to check for. + * @return A new {@code Expr} representing the 'ends with' comparison. + */ +export function endsWith(expr: string, suffix: string): EndsWith; + +/** + * @beta + * + * Creates an expression that checks if a field's value ends with a given postfix. + * + * ```typescript + * // Check if the 'url' field ends with the value of the 'extension' field + * endsWith("url", Field.of("extension")); + * ``` + * + * @param expr The field name to check. + * @param suffix The expression representing the postfix. + * @return A new {@code Expr} representing the 'ends with' comparison. + */ +export function endsWith(expr: string, suffix: Expr): EndsWith; + +/** + * @beta + * + * Creates an expression that checks if a string expression ends with a given postfix. + * + * ```typescript + * // Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." + * endsWith(Field.of("fullName"), "Jr."); + * ``` + * + * @param expr The expression to check. + * @param suffix The postfix to check for. + * @return A new {@code Expr} representing the 'ends with' comparison. + */ +export function endsWith(expr: Expr, suffix: string): EndsWith; + +/** + * @beta + * + * Creates an expression that checks if a string expression ends with a given postfix. + * + * ```typescript + * // Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." + * endsWith(Field.of("fullName"), Constant.of("Jr.")); + * ``` + * + * @param expr The expression to check. + * @param suffix The postfix to check for. + * @return A new {@code Expr} representing the 'ends with' comparison. + */ +export function endsWith(expr: Expr, suffix: Expr): EndsWith; +export function endsWith(expr: Expr | string, suffix: Expr | string): EndsWith { + const exprLeft = expr instanceof Expr ? expr : Field.of(expr); + const suffixExpr = suffix instanceof Expr ? suffix : Constant.of(suffix); + return new EndsWith(exprLeft, suffixExpr); +} + +/** + * @beta + * + * Creates an expression that converts a string field to lowercase. + * + * ```typescript + * // Convert the 'name' field to lowercase + * toLower("name"); + * ``` + * + * @param expr The name of the field containing the string. + * @return A new {@code Expr} representing the lowercase string. + */ +export function toLower(expr: string): ToLower; + +/** + * @beta + * + * Creates an expression that converts a string expression to lowercase. + * + * ```typescript + * // Convert the 'name' field to lowercase + * toLower(Field.of("name")); + * ``` + * + * @param expr The expression representing the string to convert to lowercase. + * @return A new {@code Expr} representing the lowercase string. + */ +export function toLower(expr: Expr): ToLower; +export function toLower(expr: Expr | string): ToLower { + return new ToLower(expr instanceof Expr ? expr : Field.of(expr)); +} + +/** + * @beta + * + * Creates an expression that converts a string field to uppercase. + * + * ```typescript + * // Convert the 'title' field to uppercase + * toUpper("title"); + * ``` + * + * @param expr The name of the field containing the string. + * @return A new {@code Expr} representing the uppercase string. + */ +export function toUpper(expr: string): ToUpper; + +/** + * @beta + * + * Creates an expression that converts a string expression to uppercase. + * + * ```typescript + * // Convert the 'title' field to uppercase + * toUppercase(Field.of("title")); + * ``` + * + * @param expr The expression representing the string to convert to uppercase. + * @return A new {@code Expr} representing the uppercase string. + */ +export function toUpper(expr: Expr): ToUpper; +export function toUpper(expr: Expr | string): ToUpper { + return new ToUpper(expr instanceof Expr ? expr : Field.of(expr)); +} + +/** + * @beta + * + * Creates an expression that removes leading and trailing whitespace from a string field. + * + * ```typescript + * // Trim whitespace from the 'userInput' field + * trim("userInput"); + * ``` + * + * @param expr The name of the field containing the string. + * @return A new {@code Expr} representing the trimmed string. + */ +export function trim(expr: string): Trim; + +/** + * @beta + * + * Creates an expression that removes leading and trailing whitespace from a string expression. + * + * ```typescript + * // Trim whitespace from the 'userInput' field + * trim(Field.of("userInput")); + * ``` + * + * @param expr The expression representing the string to trim. + * @return A new {@code Expr} representing the trimmed string. + */ +export function trim(expr: Expr): Trim; +export function trim(expr: Expr | string): Trim { + return new Trim(expr instanceof Expr ? expr : Field.of(expr)); +} + +/** + * @beta + * + * Creates an expression that concatenates string functions, fields or constants together. + * + * ```typescript + * // Combine the 'firstName', " ", and 'lastName' fields into a single string + * strConcat("firstName", " ", Field.of("lastName")); + * ``` + * + * @param first The field name containing the initial string value. + * @param elements The expressions (typically strings) to concatenate. + * @return A new {@code Expr} representing the concatenated string. + */ +export function strConcat( + first: string, + ...elements: Array +): StrConcat; + +/** + * @beta + * Creates an expression that concatenates string expressions together. + * + * ```typescript + * // Combine the 'firstName', " ", and 'lastName' fields into a single string + * strConcat(Field.of("firstName"), " ", Field.of("lastName")); + * ``` + * + * @param first The initial string expression to concatenate to. + * @param elements The expressions (typically strings) to concatenate. + * @return A new {@code Expr} representing the concatenated string. + */ +export function strConcat( + first: Expr, + ...elements: Array +): StrConcat; +export function strConcat( + first: string | Expr, + ...elements: Array +): StrConcat { + const exprs = elements.map(e => (e instanceof Expr ? e : Constant.of(e))); + return new StrConcat(first instanceof Expr ? first : Field.of(first), exprs); +} + +/** + * @beta + * + * Accesses a value from a map (object) field using the provided key. + * + * ```typescript + * // Get the 'city' value from the 'address' map field + * mapGet("address", "city"); + * ``` + * + * @param mapField The field name of the map field. + * @param subField The key to access in the map. + * @return A new {@code Expr} representing the value associated with the given key in the map. + */ +export function mapGet(mapField: string, subField: string): MapGet; + +/** + * @beta + * + * Accesses a value from a map (object) expression using the provided key. + * + * ```typescript + * // Get the 'city' value from the 'address' map field + * mapGet(Field.of("address"), "city"); + * ``` + * + * @param mapExpr The expression representing the map. + * @param subField The key to access in the map. + * @return A new {@code Expr} representing the value associated with the given key in the map. + */ +export function mapGet(mapExpr: Expr, subField: string): MapGet; +export function mapGet(fieldOrExpr: string | Expr, subField: string): MapGet { + return new MapGet( + typeof fieldOrExpr === 'string' ? Field.of(fieldOrExpr) : fieldOrExpr, + subField + ); +} + +/** + * @beta + * + * Creates an aggregation that counts the total number of stage inputs. + * + * ```typescript + * // Count the total number of users + * countAll().as("totalUsers"); + * ``` + * + * @return A new {@code Accumulator} representing the 'countAll' aggregation. + */ +export function countAll(): Count { + return new Count(undefined, false); +} + +/** + * @beta + * + * Creates an aggregation that counts the number of stage inputs with valid evaluations of the + * provided expression. + * + * ```typescript + * // Count the number of items where the price is greater than 10 + * count(Field.of("price").gt(10)).as("expensiveItemCount"); + * ``` + * + * @param value The expression to count. + * @return A new {@code Accumulator} representing the 'count' aggregation. + */ +export function countFunction(value: Expr): Count; + +/** + * Creates an aggregation that counts the number of stage inputs with valid evaluations of the + * provided field. + * + * ```typescript + * // Count the total number of products + * count("productId").as("totalProducts"); + * ``` + * + * @param value The name of the field to count. + * @return A new {@code Accumulator} representing the 'count' aggregation. + */ +export function countFunction(value: string): Count; +export function countFunction(value: Expr | string): Count { + const exprValue = value instanceof Expr ? value : Field.of(value); + return new Count(exprValue, false); +} + +/** + * @beta + * + * Creates an aggregation that calculates the sum of values from an expression across multiple + * stage inputs. + * + * ```typescript + * // Calculate the total revenue from a set of orders + * sum(Field.of("orderAmount")).as("totalRevenue"); + * ``` + * + * @param value The expression to sum up. + * @return A new {@code Accumulator} representing the 'sum' aggregation. + */ +export function sumFunction(value: Expr): Sum; + +/** + * @beta + * + * Creates an aggregation that calculates the sum of a field's values across multiple stage + * inputs. + * + * ```typescript + * // Calculate the total revenue from a set of orders + * sum("orderAmount").as("totalRevenue"); + * ``` + * + * @param value The name of the field containing numeric values to sum up. + * @return A new {@code Accumulator} representing the 'sum' aggregation. + */ +export function sumFunction(value: string): Sum; +export function sumFunction(value: Expr | string): Sum { + const exprValue = value instanceof Expr ? value : Field.of(value); + return new Sum(exprValue, false); +} + +/** + * @beta + * + * Creates an aggregation that calculates the average (mean) of values from an expression across + * multiple stage inputs. + * + * ```typescript + * // Calculate the average age of users + * avg(Field.of("age")).as("averageAge"); + * ``` + * + * @param value The expression representing the values to average. + * @return A new {@code Accumulator} representing the 'avg' aggregation. + */ +export function avgFunction(value: Expr): Avg; + +/** + * @beta + * + * Creates an aggregation that calculates the average (mean) of a field's values across multiple + * stage inputs. + * + * ```typescript + * // Calculate the average age of users + * avg("age").as("averageAge"); + * ``` + * + * @param value The name of the field containing numeric values to average. + * @return A new {@code Accumulator} representing the 'avg' aggregation. + */ +export function avgFunction(value: string): Avg; +export function avgFunction(value: Expr | string): Avg { + const exprValue = value instanceof Expr ? value : Field.of(value); + return new Avg(exprValue, false); +} + +/** + * @beta + * + * Creates an aggregation that finds the minimum value of an expression across multiple stage + * inputs. + * + * ```typescript + * // Find the lowest price of all products + * min(Field.of("price")).as("lowestPrice"); + * ``` + * + * @param value The expression to find the minimum value of. + * @return A new {@code Accumulator} representing the 'min' aggregation. + */ +export function min(value: Expr): Min; + +/** + * @beta + * + * Creates an aggregation that finds the minimum value of a field across multiple stage inputs. + * + * ```typescript + * // Find the lowest price of all products + * min("price").as("lowestPrice"); + * ``` + * + * @param value The name of the field to find the minimum value of. + * @return A new {@code Accumulator} representing the 'min' aggregation. + */ +export function min(value: string): Min; +export function min(value: Expr | string): Min { + const exprValue = value instanceof Expr ? value : Field.of(value); + return new Min(exprValue, false); +} + +/** + * @beta + * + * Creates an aggregation that finds the maximum value of an expression across multiple stage + * inputs. + * + * ```typescript + * // Find the highest score in a leaderboard + * max(Field.of("score")).as("highestScore"); + * ``` + * + * @param value The expression to find the maximum value of. + * @return A new {@code Accumulator} representing the 'max' aggregation. + */ +export function max(value: Expr): Max; + +/** + * @beta + * + * Creates an aggregation that finds the maximum value of a field across multiple stage inputs. + * + * ```typescript + * // Find the highest score in a leaderboard + * max("score").as("highestScore"); + * ``` + * + * @param value The name of the field to find the maximum value of. + * @return A new {@code Accumulator} representing the 'max' aggregation. + */ +export function max(value: string): Max; +export function max(value: Expr | string): Max { + const exprValue = value instanceof Expr ? value : Field.of(value); + return new Max(exprValue, false); +} + +/** + * @beta + * + * Calculates the Cosine distance between a field's vector value and a double array. + * + * ```typescript + * // Calculate the Cosine distance between the 'location' field and a target location + * cosineDistance("location", [37.7749, -122.4194]); + * ``` + * + * @param expr The name of the field containing the first vector. + * @param other The other vector (as an array of doubles) to compare against. + * @return A new {@code Expr} representing the Cosine distance between the two vectors. + */ +export function cosineDistance(expr: string, other: number[]): CosineDistance; + +/** + * @beta + * + * Calculates the Cosine distance between a field's vector value and a VectorValue. + * + * ```typescript + * // Calculate the Cosine distance between the 'location' field and a target location + * cosineDistance("location", new VectorValue([37.7749, -122.4194])); + * ``` + * + * @param expr The name of the field containing the first vector. + * @param other The other vector (as a VectorValue) to compare against. + * @return A new {@code Expr} representing the Cosine distance between the two vectors. + */ +export function cosineDistance( + expr: string, + other: VectorValue +): CosineDistance; + +/** + * @beta + * + * Calculates the Cosine distance between a field's vector value and a vector expression. + * + * ```typescript + * // Calculate the cosine distance between the 'userVector' field and the 'itemVector' field + * cosineDistance("userVector", Field.of("itemVector")); + * ``` + * + * @param expr The name of the field containing the first vector. + * @param other The other vector (represented as an Expr) to compare against. + * @return A new {@code Expr} representing the cosine distance between the two vectors. + */ +export function cosineDistance(expr: string, other: Expr): CosineDistance; + +/** + * @beta + * + * Calculates the Cosine distance between a vector expression and a double array. + * + * ```typescript + * // Calculate the cosine distance between the 'location' field and a target location + * cosineDistance(Field.of("location"), [37.7749, -122.4194]); + * ``` + * + * @param expr The first vector (represented as an Expr) to compare against. + * @param other The other vector (as an array of doubles) to compare against. + * @return A new {@code Expr} representing the cosine distance between the two vectors. + */ +export function cosineDistance(expr: Expr, other: number[]): CosineDistance; + +/** + * @beta + * + * Calculates the Cosine distance between a vector expression and a VectorValue. + * + * ```typescript + * // Calculate the cosine distance between the 'location' field and a target location + * cosineDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); + * ``` + * + * @param expr The first vector (represented as an Expr) to compare against. + * @param other The other vector (as a VectorValue) to compare against. + * @return A new {@code Expr} representing the cosine distance between the two vectors. + */ +export function cosineDistance(expr: Expr, other: VectorValue): CosineDistance; + +/** + * @beta + * + * Calculates the Cosine distance between two vector expressions. + * + * ```typescript + * // Calculate the cosine distance between the 'userVector' field and the 'itemVector' field + * cosineDistance(Field.of("userVector"), Field.of("itemVector")); + * ``` + * + * @param expr The first vector (represented as an Expr) to compare against. + * @param other The other vector (represented as an Expr) to compare against. + * @return A new {@code Expr} representing the cosine distance between the two vectors. + */ +export function cosineDistance(expr: Expr, other: Expr): CosineDistance; +export function cosineDistance( + expr: Expr | string, + other: Expr | number[] | VectorValue +): CosineDistance { + const expr1 = expr instanceof Expr ? expr : Field.of(expr); + const expr2 = other instanceof Expr ? other : Constant.vector(other); + return new CosineDistance(expr1, expr2); +} + +/** + * @beta + * + * Calculates the dot product between a field's vector value and a double array. + * + * ```typescript + * // Calculate the dot product distance between a feature vector and a target vector + * dotProduct("features", [0.5, 0.8, 0.2]); + * ``` + * + * @param expr The name of the field containing the first vector. + * @param other The other vector (as an array of doubles) to calculate with. + * @return A new {@code Expr} representing the dot product between the two vectors. + */ +export function dotProduct(expr: string, other: number[]): DotProduct; + +/** + * @beta + * + * Calculates the dot product between a field's vector value and a VectorValue. + * + * ```typescript + * // Calculate the dot product distance between a feature vector and a target vector + * dotProduct("features", new VectorValue([0.5, 0.8, 0.2])); + * ``` + * + * @param expr The name of the field containing the first vector. + * @param other The other vector (as a VectorValue) to calculate with. + * @return A new {@code Expr} representing the dot product between the two vectors. + */ +export function dotProduct(expr: string, other: VectorValue): DotProduct; + +/** + * @beta + * + * Calculates the dot product between a field's vector value and a vector expression. + * + * ```typescript + * // Calculate the dot product distance between two document vectors: 'docVector1' and 'docVector2' + * dotProduct("docVector1", Field.of("docVector2")); + * ``` + * + * @param expr The name of the field containing the first vector. + * @param other The other vector (represented as an Expr) to calculate with. + * @return A new {@code Expr} representing the dot product between the two vectors. + */ +export function dotProduct(expr: string, other: Expr): DotProduct; + +/** + * @beta + * + * Calculates the dot product between a vector expression and a double array. + * + * ```typescript + * // Calculate the dot product between a feature vector and a target vector + * dotProduct(Field.of("features"), [0.5, 0.8, 0.2]); + * ``` + * + * @param expr The first vector (represented as an Expr) to calculate with. + * @param other The other vector (as an array of doubles) to calculate with. + * @return A new {@code Expr} representing the dot product between the two vectors. + */ +export function dotProduct(expr: Expr, other: number[]): DotProduct; + +/** + * @beta + * + * Calculates the dot product between a vector expression and a VectorValue. + * + * ```typescript + * // Calculate the dot product between a feature vector and a target vector + * dotProduct(Field.of("features"), new VectorValue([0.5, 0.8, 0.2])); + * ``` + * + * @param expr The first vector (represented as an Expr) to calculate with. + * @param other The other vector (as a VectorValue) to calculate with. + * @return A new {@code Expr} representing the dot product between the two vectors. + */ +export function dotProduct(expr: Expr, other: VectorValue): DotProduct; + +/** + * @beta + * + * Calculates the dot product between two vector expressions. + * + * ```typescript + * // Calculate the dot product between two document vectors: 'docVector1' and 'docVector2' + * dotProduct(Field.of("docVector1"), Field.of("docVector2")); + * ``` + * + * @param expr The first vector (represented as an Expr) to calculate with. + * @param other The other vector (represented as an Expr) to calculate with. + * @return A new {@code Expr} representing the dot product between the two vectors. + */ +export function dotProduct(expr: Expr, other: Expr): DotProduct; +export function dotProduct( + expr: Expr | string, + other: Expr | number[] | VectorValue +): DotProduct { + const expr1 = expr instanceof Expr ? expr : Field.of(expr); + const expr2 = other instanceof Expr ? other : Constant.vector(other); + return new DotProduct(expr1, expr2); +} + +/** + * @beta + * + * Calculates the Euclidean distance between a field's vector value and a double array. + * + * ```typescript + * // Calculate the Euclidean distance between the 'location' field and a target location + * euclideanDistance("location", [37.7749, -122.4194]); + * ``` + * + * @param expr The name of the field containing the first vector. + * @param other The other vector (as an array of doubles) to compare against. + * @return A new {@code Expr} representing the Euclidean distance between the two vectors. + */ +export function euclideanDistance( + expr: string, + other: number[] +): EuclideanDistance; + +/** + * @beta + * + * Calculates the Euclidean distance between a field's vector value and a VectorValue. + * + * ```typescript + * // Calculate the Euclidean distance between the 'location' field and a target location + * euclideanDistance("location", new VectorValue([37.7749, -122.4194])); + * ``` + * + * @param expr The name of the field containing the first vector. + * @param other The other vector (as a VectorValue) to compare against. + * @return A new {@code Expr} representing the Euclidean distance between the two vectors. + */ +export function euclideanDistance( + expr: string, + other: VectorValue +): EuclideanDistance; + +/** + * @beta + * + * Calculates the Euclidean distance between a field's vector value and a vector expression. + * + * ```typescript + * // Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' + * euclideanDistance("pointA", Field.of("pointB")); + * ``` + * + * @param expr The name of the field containing the first vector. + * @param other The other vector (represented as an Expr) to compare against. + * @return A new {@code Expr} representing the Euclidean distance between the two vectors. + */ +export function euclideanDistance(expr: string, other: Expr): EuclideanDistance; + +/** + * @beta + * + * Calculates the Euclidean distance between a vector expression and a double array. + * + * ```typescript + * // Calculate the Euclidean distance between the 'location' field and a target location + * + * euclideanDistance(Field.of("location"), [37.7749, -122.4194]); + * ``` + * + * @param expr The first vector (represented as an Expr) to compare against. + * @param other The other vector (as an array of doubles) to compare against. + * @return A new {@code Expr} representing the Euclidean distance between the two vectors. + */ +export function euclideanDistance( + expr: Expr, + other: number[] +): EuclideanDistance; + +/** + * @beta + * + * Calculates the Euclidean distance between a vector expression and a VectorValue. + * + * ```typescript + * // Calculate the Euclidean distance between the 'location' field and a target location + * euclideanDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); + * ``` + * + * @param expr The first vector (represented as an Expr) to compare against. + * @param other The other vector (as a VectorValue) to compare against. + * @return A new {@code Expr} representing the Euclidean distance between the two vectors. + */ +export function euclideanDistance( + expr: Expr, + other: VectorValue +): EuclideanDistance; + +/** + * @beta + * + * Calculates the Euclidean distance between two vector expressions. + * + * ```typescript + * // Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' + * euclideanDistance(Field.of("pointA"), Field.of("pointB")); + * ``` + * + * @param expr The first vector (represented as an Expr) to compare against. + * @param other The other vector (represented as an Expr) to compare against. + * @return A new {@code Expr} representing the Euclidean distance between the two vectors. + */ +export function euclideanDistance(expr: Expr, other: Expr): EuclideanDistance; +export function euclideanDistance( + expr: Expr | string, + other: Expr | number[] | VectorValue +): EuclideanDistance { + const expr1 = expr instanceof Expr ? expr : Field.of(expr); + const expr2 = other instanceof Expr ? other : Constant.vector(other); + return new EuclideanDistance(expr1, expr2); +} + +/** + * @beta + * + * Creates an expression that calculates the length of a Firestore Vector. + * + * ```typescript + * // Get the vector length (dimension) of the field 'embedding'. + * vectorLength(Field.of("embedding")); + * ``` + * + * @param expr The expression representing the Firestore Vector. + * @return A new {@code Expr} representing the length of the array. + */ +export function vectorLength(expr: Expr): VectorLength; + +/** + * @beta + * + * Creates an expression that calculates the length of a Firestore Vector represented by a field. + * + * ```typescript + * // Get the vector length (dimension) of the field 'embedding'. + * vectorLength("embedding"); + * ``` + * + * @param field The name of the field representing the Firestore Vector. + * @return A new {@code Expr} representing the length of the array. + */ +export function vectorLength(field: string): VectorLength; +export function vectorLength(expr: Expr | string): VectorLength { + const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; + return new VectorLength(normalizedExpr); +} + +/** + * @beta + * + * Creates an expression that interprets an expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) + * and returns a timestamp. + * + * ```typescript + * // Interpret the 'microseconds' field as microseconds since epoch. + * unixMicrosToTimestamp(Field.of("microseconds")); + * ``` + * + * @param expr The expression representing the number of microseconds since epoch. + * @return A new {@code Expr} representing the timestamp. + */ +export function unixMicrosToTimestamp(expr: Expr): UnixMicrosToTimestamp; + +/** + * @beta + * + * Creates an expression that interprets a field's value as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) + * and returns a timestamp. + * + * ```typescript + * // Interpret the 'microseconds' field as microseconds since epoch. + * unixMicrosToTimestamp("microseconds"); + * ``` + * + * @param field The name of the field representing the number of microseconds since epoch. + * @return A new {@code Expr} representing the timestamp. + */ +export function unixMicrosToTimestamp(field: string): UnixMicrosToTimestamp; +export function unixMicrosToTimestamp( + expr: Expr | string +): UnixMicrosToTimestamp { + const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; + return new UnixMicrosToTimestamp(normalizedExpr); +} + +/** + * @beta + * + * Creates an expression that converts a timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + * + * ```typescript + * // Convert the 'timestamp' field to microseconds since epoch. + * timestampToUnixMicros(Field.of("timestamp")); + * ``` + * + * @param expr The expression representing the timestamp. + * @return A new {@code Expr} representing the number of microseconds since epoch. + */ +export function timestampToUnixMicros(expr: Expr): TimestampToUnixMicros; + +/** + * @beta + * + * Creates an expression that converts a timestamp field to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + * + * ```typescript + * // Convert the 'timestamp' field to microseconds since epoch. + * timestampToUnixMicros("timestamp"); + * ``` + * + * @param field The name of the field representing the timestamp. + * @return A new {@code Expr} representing the number of microseconds since epoch. + */ +export function timestampToUnixMicros(field: string): TimestampToUnixMicros; +export function timestampToUnixMicros( + expr: Expr | string +): TimestampToUnixMicros { + const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; + return new TimestampToUnixMicros(normalizedExpr); +} + +/** + * @beta + * + * Creates an expression that interprets an expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) + * and returns a timestamp. + * + * ```typescript + * // Interpret the 'milliseconds' field as milliseconds since epoch. + * unixMillisToTimestamp(Field.of("milliseconds")); + * ``` + * + * @param expr The expression representing the number of milliseconds since epoch. + * @return A new {@code Expr} representing the timestamp. + */ +export function unixMillisToTimestamp(expr: Expr): UnixMillisToTimestamp; + +/** + * @beta + * + * Creates an expression that interprets a field's value as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) + * and returns a timestamp. + * + * ```typescript + * // Interpret the 'milliseconds' field as milliseconds since epoch. + * unixMillisToTimestamp("milliseconds"); + * ``` + * + * @param field The name of the field representing the number of milliseconds since epoch. + * @return A new {@code Expr} representing the timestamp. + */ +export function unixMillisToTimestamp(field: string): UnixMillisToTimestamp; +export function unixMillisToTimestamp( + expr: Expr | string +): UnixMillisToTimestamp { + const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; + return new UnixMillisToTimestamp(normalizedExpr); +} + +/** + * @beta + * + * Creates an expression that converts a timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + * + * ```typescript + * // Convert the 'timestamp' field to milliseconds since epoch. + * timestampToUnixMillis(Field.of("timestamp")); + * ``` + * + * @param expr The expression representing the timestamp. + * @return A new {@code Expr} representing the number of milliseconds since epoch. + */ +export function timestampToUnixMillis(expr: Expr): TimestampToUnixMillis; + +/** + * @beta + * + * Creates an expression that converts a timestamp field to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC). + * + * ```typescript + * // Convert the 'timestamp' field to milliseconds since epoch. + * timestampToUnixMillis("timestamp"); + * ``` + * + * @param field The name of the field representing the timestamp. + * @return A new {@code Expr} representing the number of milliseconds since epoch. + */ +export function timestampToUnixMillis(field: string): TimestampToUnixMillis; +export function timestampToUnixMillis( + expr: Expr | string +): TimestampToUnixMillis { + const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; + return new TimestampToUnixMillis(normalizedExpr); +} + +/** + * @beta + * + * Creates an expression that interprets an expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) + * and returns a timestamp. + * + * ```typescript + * // Interpret the 'seconds' field as seconds since epoch. + * unixSecondsToTimestamp(Field.of("seconds")); + * ``` + * + * @param expr The expression representing the number of seconds since epoch. + * @return A new {@code Expr} representing the timestamp. + */ +export function unixSecondsToTimestamp(expr: Expr): UnixSecondsToTimestamp; + +/** + * @beta + * + * Creates an expression that interprets a field's value as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) + * and returns a timestamp. + * + * ```typescript + * // Interpret the 'seconds' field as seconds since epoch. + * unixSecondsToTimestamp("seconds"); + * ``` + * + * @param field The name of the field representing the number of seconds since epoch. + * @return A new {@code Expr} representing the timestamp. + */ +export function unixSecondsToTimestamp(field: string): UnixSecondsToTimestamp; +export function unixSecondsToTimestamp( + expr: Expr | string +): UnixSecondsToTimestamp { + const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; + return new UnixSecondsToTimestamp(normalizedExpr); +} + +/** + * @beta + * + * Creates an expression that converts a timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). + * + * ```typescript + * // Convert the 'timestamp' field to seconds since epoch. + * timestampToUnixSeconds(Field.of("timestamp")); + * ``` + * + * @param expr The expression representing the timestamp. + * @return A new {@code Expr} representing the number of seconds since epoch. + */ +export function timestampToUnixSeconds(expr: Expr): TimestampToUnixSeconds; + +/** + * @beta + * + * Creates an expression that converts a timestamp field to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). + * + * ```typescript + * // Convert the 'timestamp' field to seconds since epoch. + * timestampToUnixSeconds("timestamp"); + * ``` + * + * @param field The name of the field representing the timestamp. + * @return A new {@code Expr} representing the number of seconds since epoch. + */ +export function timestampToUnixSeconds(field: string): TimestampToUnixSeconds; +export function timestampToUnixSeconds( + expr: Expr | string +): TimestampToUnixSeconds { + const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; + return new TimestampToUnixSeconds(normalizedExpr); +} + +/** + * @beta + * + * Creates an expression that adds a specified amount of time to a timestamp. + * + * ```typescript + * // Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. + * timestampAdd(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); + * ``` + * + * @param timestamp The expression representing the timestamp. + * @param unit The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. + * @param amount The expression evaluates to amount of the unit. + * @return A new {@code Expr} representing the resulting timestamp. + */ +export function timestampAdd( + timestamp: Expr, + unit: Expr, + amount: Expr +): TimestampAdd; + +/** + * @beta + * + * Creates an expression that adds a specified amount of time to a timestamp. + * + * ```typescript + * // Add 1 day to the 'timestamp' field. + * timestampAdd(Field.of("timestamp"), "day", 1); + * ``` + * + * @param timestamp The expression representing the timestamp. + * @param unit The unit of time to add (e.g., "day", "hour"). + * @param amount The amount of time to add. + * @return A new {@code Expr} representing the resulting timestamp. + */ +export function timestampAdd( + timestamp: Expr, + unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', + amount: number +): TimestampAdd; + +/** + * @beta + * + * Creates an expression that adds a specified amount of time to a timestamp represented by a field. + * + * ```typescript + * // Add 1 day to the 'timestamp' field. + * timestampAdd("timestamp", "day", 1); + * ``` + * + * @param field The name of the field representing the timestamp. + * @param unit The unit of time to add (e.g., "day", "hour"). + * @param amount The amount of time to add. + * @return A new {@code Expr} representing the resulting timestamp. + */ +export function timestampAdd( + field: string, + unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', + amount: number +): TimestampAdd; +export function timestampAdd( + timestamp: Expr | string, + unit: + | Expr + | 'microsecond' + | 'millisecond' + | 'second' + | 'minute' + | 'hour' + | 'day', + amount: Expr | number +): TimestampAdd { + const normalizedTimestamp = + typeof timestamp === 'string' ? Field.of(timestamp) : timestamp; + const normalizedUnit = unit instanceof Expr ? unit : Constant.of(unit); + const normalizedAmount = + typeof amount === 'number' ? Constant.of(amount) : amount; + return new TimestampAdd( + normalizedTimestamp, + normalizedUnit, + normalizedAmount + ); +} + +/** + * @beta + * + * Creates an expression that subtracts a specified amount of time from a timestamp. + * + * ```typescript + * // Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. + * timestampSub(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); + * ``` + * + * @param timestamp The expression representing the timestamp. + * @param unit The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. + * @param amount The expression evaluates to amount of the unit. + * @return A new {@code Expr} representing the resulting timestamp. + */ +export function timestampSub( + timestamp: Expr, + unit: Expr, + amount: Expr +): TimestampSub; + +/** + * @beta + * + * Creates an expression that subtracts a specified amount of time from a timestamp. + * + * ```typescript + * // Subtract 1 day from the 'timestamp' field. + * timestampSub(Field.of("timestamp"), "day", 1); + * ``` + * + * @param timestamp The expression representing the timestamp. + * @param unit The unit of time to subtract (e.g., "day", "hour"). + * @param amount The amount of time to subtract. + * @return A new {@code Expr} representing the resulting timestamp. + */ +export function timestampSub( + timestamp: Expr, + unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', + amount: number +): TimestampSub; + +/** + * @beta + * + * Creates an expression that subtracts a specified amount of time from a timestamp represented by a field. + * + * ```typescript + * // Subtract 1 day from the 'timestamp' field. + * timestampSub("timestamp", "day", 1); + * ``` + * + * @param field The name of the field representing the timestamp. + * @param unit The unit of time to subtract (e.g., "day", "hour"). + * @param amount The amount of time to subtract. + * @return A new {@code Expr} representing the resulting timestamp. + */ +export function timestampSub( + field: string, + unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', + amount: number +): TimestampSub; +export function timestampSub( + timestamp: Expr | string, + unit: + | Expr + | 'microsecond' + | 'millisecond' + | 'second' + | 'minute' + | 'hour' + | 'day', + amount: Expr | number +): TimestampSub { + const normalizedTimestamp = + typeof timestamp === 'string' ? Field.of(timestamp) : timestamp; + const normalizedUnit = unit instanceof Expr ? unit : Constant.of(unit); + const normalizedAmount = + typeof amount === 'number' ? Constant.of(amount) : amount; + return new TimestampSub( + normalizedTimestamp, + normalizedUnit, + normalizedAmount + ); +} + +/** + * @beta + * + * Creates functions that work on the backend but do not exist in the SDK yet. + * + * ```typescript + * // Call a user defined function named "myFunc" with the arguments 10 and 20 + * // This is the same of the 'sum(Field.of("price"))', if it did not exist + * genericFunction("sum", [Field.of("price")]); + * ``` + * + * @param name The name of the user defined function. + * @param params The arguments to pass to the function. + * @return A new {@code Function} representing the function call. + */ +export function genericFunction( + name: string, + params: Expr[] +): FirestoreFunction { + return new FirestoreFunction(name, params); +} + +/** + * @beta + * + * Creates an expression that performs a logical 'AND' operation on multiple filter conditions. + * + * ```typescript + * // Check if the 'age' field is greater than 18 AND the 'city' field is "London" AND + * // the 'status' field is "active" + * const condition = and(gt("age", 18), eq("city", "London"), eq("status", "active")); + * ``` + * + * @param left The first filter condition. + * @param right Additional filter conditions to 'AND' together. + * @return A new {@code Expr} representing the logical 'AND' operation. + */ +export function andFunction(left: FilterExpr, ...right: FilterExpr[]): And { + return new And([left, ...right]); +} + +/** + * @beta + * + * Creates an expression that performs a logical 'OR' operation on multiple filter conditions. + * + * ```typescript + * // Check if the 'age' field is greater than 18 OR the 'city' field is "London" OR + * // the 'status' field is "active" + * const condition = or(gt("age", 18), eq("city", "London"), eq("status", "active")); + * ``` + * + * @param left The first filter condition. + * @param right Additional filter conditions to 'OR' together. + * @return A new {@code Expr} representing the logical 'OR' operation. + */ +export function orFunction(left: FilterExpr, ...right: FilterExpr[]): Or { + return new Or([left, ...right]); +} + +/** + * @beta + * + * Creates an {@link Ordering} that sorts documents in ascending order based on this expression. + * + * ```typescript + * // Sort documents by the 'name' field in ascending order + * firestore.pipeline().collection("users") + * .sort(ascending(Field.of("name"))); + * ``` + * + * @param expr The expression to create an ascending ordering for. + * @return A new `Ordering` for ascending sorting. + */ +export function ascending(expr: Expr): Ordering { + return new Ordering(expr, 'ascending'); +} + +/** + * @beta + * + * Creates an {@link Ordering} that sorts documents in descending order based on this expression. + * + * ```typescript + * // Sort documents by the 'createdAt' field in descending order + * firestore.pipeline().collection("users") + * .sort(descending(Field.of("createdAt"))); + * ``` + * + * @param expr The expression to create a descending ordering for. + * @return A new `Ordering` for descending sorting. + */ +export function descending(expr: Expr): Ordering { + return new Ordering(expr, 'descending'); +} + +/** + * @beta + * + * Represents an ordering criterion for sorting documents in a Firestore pipeline. + * + * You create `Ordering` instances using the `ascending` and `descending` helper functions. + */ +export class Ordering { + constructor( + private expr: Expr, + private direction: 'ascending' | 'descending' + ) {} + + /** + * @private + * @internal + */ + _toProto(serializer: JsonProtoSerializer): ProtoValue { + return { + mapValue: { + fields: { + direction: toStringValue(this.direction), + expression: this.expr._toProto(serializer) + } + } + }; + } + + /** + * @private + * @internal + */ + _readUserData(dataReader: UserDataReader): void { + this.expr._readUserData(dataReader); + } +} diff --git a/packages/firestore/src/lite-api/pipeline-result.ts b/packages/firestore/src/lite-api/pipeline-result.ts new file mode 100644 index 00000000000..f3951099ba2 --- /dev/null +++ b/packages/firestore/src/lite-api/pipeline-result.ts @@ -0,0 +1,232 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ObjectValue } from '../model/object_value'; +import { isOptionalEqual } from '../util/misc'; + +import { FieldPath } from './field_path'; +import { DocumentData, DocumentReference, refEqual } from './reference'; +import { fieldPathFromArgument } from './snapshot'; +import { Timestamp } from './timestamp'; +import { AbstractUserDataWriter } from './user_data_writer'; + +/** + * @beta + * + * A PipelineResult contains data read from a Firestore Pipeline. The data can be extracted with the + * {@link #data()} or {@link #get(String)} methods. + * + *

If the PipelineResult represents a non-document result, `ref` will return a undefined + * value. + */ +export class PipelineResult { + private readonly _userDataWriter: AbstractUserDataWriter; + + private readonly _executionTime: Timestamp | undefined; + private readonly _createTime: Timestamp | undefined; + private readonly _updateTime: Timestamp | undefined; + + /** + * @internal + * @private + */ + readonly _ref: DocumentReference | undefined; + + /** + * @internal + * @private + */ + readonly _fields: ObjectValue | undefined; + + /** + * @private + * @internal + * + * @param userDataWriter The serializer used to encode/decode protobuf. + * @param ref The reference to the document. + * @param _fieldsProto The fields of the Firestore `Document` Protobuf backing + * this document (or undefined if the document does not exist). + * @param readTime The time when this result was read (or undefined if + * the document exists only locally). + * @param createTime The time when the document was created if the result is a document, undefined otherwise. + * @param updateTime The time when the document was last updated if the result is a document, undefined otherwise. + */ + constructor( + userDataWriter: AbstractUserDataWriter, + ref?: DocumentReference, + fields?: ObjectValue, + executionTime?: Timestamp, + createTime?: Timestamp, + updateTime?: Timestamp + // TODO converter + //readonly converter: FirestorePipelineConverter = defaultPipelineConverter() + ) { + this._ref = ref; + this._userDataWriter = userDataWriter; + this._executionTime = executionTime; + this._createTime = createTime; + this._updateTime = updateTime; + this._fields = fields; + } + + /** + * The reference of the document, if it is a document; otherwise `undefined`. + */ + get ref(): DocumentReference | undefined { + return this._ref; + } + + /** + * The ID of the document for which this PipelineResult contains data, if it is a document; otherwise `undefined`. + * + * @type {string} + * @readonly + * + */ + get id(): string | undefined { + return this._ref?.id; + } + + /** + * The time the document was created. Undefined if this result is not a document. + * + * @type {Timestamp|undefined} + * @readonly + */ + get createTime(): Timestamp | undefined { + return this._createTime; + } + + /** + * The time the document was last updated (at the time the snapshot was + * generated). Undefined if this result is not a document. + * + * @type {Timestamp|undefined} + * @readonly + */ + get updateTime(): Timestamp | undefined { + return this._updateTime; + } + + /** + * The time at which the pipeline producing this result is executed. + * + * @type {Timestamp} + * @readonly + * + */ + get executionTime(): Timestamp { + if (this._executionTime === undefined) { + throw new Error( + "'executionTime' is expected to exist, but it is undefined" + ); + } + return this._executionTime; + } + + /** + * Retrieves all fields in the result as an object. Returns 'undefined' if + * the document doesn't exist. + * + * @returns {T|undefined} An object containing all fields in the document or + * 'undefined' if the document doesn't exist. + * + * @example + * ``` + * let p = firestore.pipeline().collection('col'); + * + * p.execute().then(results => { + * let data = results[0].data(); + * console.log(`Retrieved data: ${JSON.stringify(data)}`); + * }); + * ``` + */ + data(): AppModelType | undefined { + if (this._fields === undefined) { + return undefined; + } + + // TODO(pipelines) + // We only want to use the converter and create a new QueryDocumentSnapshot + // if a converter has been provided. + // if (!!this.converter && this.converter !== defaultPipelineConverter()) { + // return this.converter.fromFirestore( + // new PipelineResult< DocumentData>( + // this._serializer, + // this.ref, + // this._fieldsProto, + // this._executionTime, + // this.createTime, + // this.updateTime, + // defaultPipelineConverter() + // ) + // ); + // } else {{ + return this._userDataWriter.convertValue( + this._fields.value + ) as AppModelType; + //} + } + + /** + * Retrieves the field specified by `field`. + * + * @param {string|FieldPath} field The field path + * (e.g. 'foo' or 'foo.bar') to a specific field. + * @returns {*} The data at the specified field location or undefined if no + * such field exists. + * + * @example + * ``` + * let p = firestore.pipeline().collection('col'); + * + * p.execute().then(results => { + * let field = results[0].get('a.b'); + * console.log(`Retrieved field value: ${field}`); + * }); + * ``` + */ + // We deliberately use `any` in the external API to not impose type-checking + // on end users. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + get(fieldPath: string | FieldPath): any { + if (this._fields === undefined) { + return undefined; + } + + const value = this._fields.field( + fieldPathFromArgument('DocumentSnapshot.get', fieldPath) + ); + if (value !== null) { + return this._userDataWriter.convertValue(value); + } + } +} + +export function pipelineResultEqual( + left: PipelineResult, + right: PipelineResult +): boolean { + if (left === right) { + return true; + } + + return ( + isOptionalEqual(left._ref, right._ref, refEqual) && + isOptionalEqual(left._fields, right._fields, (l, r) => l.isEqual(r)) + ); +} diff --git a/packages/firestore/src/lite-api/pipeline-source.ts b/packages/firestore/src/lite-api/pipeline-source.ts new file mode 100644 index 00000000000..a79c5cafc31 --- /dev/null +++ b/packages/firestore/src/lite-api/pipeline-source.ts @@ -0,0 +1,91 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { DocumentKey } from '../model/document_key'; + +import { Firestore } from './database'; +import { Pipeline } from './pipeline'; +import { DocumentReference } from './reference'; +import { + CollectionGroupSource, + CollectionSource, + DatabaseSource, + DocumentsSource +} from './stage'; +import { UserDataReader } from './user_data_reader'; +import { AbstractUserDataWriter } from './user_data_writer'; + +/** + * Represents the source of a Firestore {@link Pipeline}. + * @beta + */ +export class PipelineSource { + /** + * @internal + * @private + * @param db + * @param userDataReader + * @param userDataWriter + * @param documentReferenceFactory + */ + constructor( + private db: Firestore, + private userDataReader: UserDataReader, + private userDataWriter: AbstractUserDataWriter, + private documentReferenceFactory: (id: DocumentKey) => DocumentReference + ) {} + + collection(collectionPath: string): Pipeline { + return new Pipeline( + this.db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + [new CollectionSource(collectionPath)] + ); + } + + collectionGroup(collectionId: string): Pipeline { + return new Pipeline( + this.db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + [new CollectionGroupSource(collectionId)] + ); + } + + database(): Pipeline { + return new Pipeline( + this.db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + [new DatabaseSource()] + ); + } + + documents(docs: DocumentReference[]): Pipeline { + return new Pipeline( + this.db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + [DocumentsSource.of(docs)] + ); + } +} diff --git a/packages/firestore/src/lite-api/pipeline.ts b/packages/firestore/src/lite-api/pipeline.ts new file mode 100644 index 00000000000..4d13d5dfddd --- /dev/null +++ b/packages/firestore/src/lite-api/pipeline.ts @@ -0,0 +1,853 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* eslint @typescript-eslint/no-explicit-any: 0 */ + +import { DocumentKey } from '../model/document_key'; +import { ObjectValue } from '../model/object_value'; +import { + ExecutePipelineRequest, + StructuredPipeline, + Stage as ProtoStage +} from '../protos/firestore_proto_api'; +import { invokeExecutePipeline } from '../remote/datastore'; +import { + getEncodedDatabaseId, + JsonProtoSerializer, + ProtoSerializable +} from '../remote/serializer'; + +import { getDatastore } from './components'; +import { Firestore } from './database'; +import { + Accumulator, + AccumulatorTarget, + Expr, + ExprWithAlias, + Field, + Fields, + FilterCondition, + Ordering, + Selectable +} from './expressions'; +import { PipelineResult } from './pipeline-result'; +import { PipelineSource } from './pipeline-source'; +import { DocumentData, DocumentReference, Query } from './reference'; +import { + AddFields, + Aggregate, + Distinct, + FindNearest, + FindNearestOptions, + GenericStage, + Limit, + Offset, + Select, + Sort, + Stage, + Where +} from './stage'; +import { + parseVectorValue, + UserDataReader, + UserDataSource +} from './user_data_reader'; +import { AbstractUserDataWriter } from './user_data_writer'; + +interface ReadableUserData { + _readUserData(dataReader: UserDataReader): void; +} + +function isReadableUserData(value: any): value is ReadableUserData { + return typeof (value as ReadableUserData)._readUserData === 'function'; +} + +/** + * @beta + * + * The Pipeline class provides a flexible and expressive framework for building complex data + * transformation and query pipelines for Firestore. + * + * A pipeline takes data sources, such as Firestore collections or collection groups, and applies + * a series of stages that are chained together. Each stage takes the output from the previous stage + * (or the data source) and produces an output for the next stage (or as the final output of the + * pipeline). + * + * Expressions can be used within each stage to filter and transform data through the stage. + * + * NOTE: The chained stages do not prescribe exactly how Firestore will execute the pipeline. + * Instead, Firestore only guarantees that the result is the same as if the chained stages were + * executed in order. + * + * Usage Examples: + * + * ```typescript + * const db: Firestore; // Assumes a valid firestore instance. + * + * // Example 1: Select specific fields and rename 'rating' to 'bookRating' + * const results1 = await db.pipeline() + * .collection("books") + * .select("title", "author", Field.of("rating").as("bookRating")) + * .execute(); + * + * // Example 2: Filter documents where 'genre' is "Science Fiction" and 'published' is after 1950 + * const results2 = await db.pipeline() + * .collection("books") + * .where(and(Field.of("genre").eq("Science Fiction"), Field.of("published").gt(1950))) + * .execute(); + * + * // Example 3: Calculate the average rating of books published after 1980 + * const results3 = await db.pipeline() + * .collection("books") + * .where(Field.of("published").gt(1980)) + * .aggregate(avg(Field.of("rating")).as("averageRating")) + * .execute(); + * ``` + */ + +/** + * Base-class implementation + */ +export class Pipeline + implements ProtoSerializable +{ + /** + * @internal + * @private + * @param _db + * @param userDataReader + * @param userDataWriter + * @param documentReferenceFactory + * @param stages + * @param converter + */ + constructor( + /** + * @internal + * @private + */ + public _db: Firestore, + private userDataReader: UserDataReader, + /** + * @internal + * @private + */ + protected userDataWriter: AbstractUserDataWriter, + /** + * @internal + * @private + */ + protected documentReferenceFactory: (id: DocumentKey) => DocumentReference, + private stages: Stage[], + // TODO(pipeline) support converter + //private converter: FirestorePipelineConverter = defaultPipelineConverter() + private converter: unknown = {} + ) {} + + /** + * Adds new fields to outputs from previous stages. + * + * This stage allows you to compute values on-the-fly based on existing data from previous + * stages or constants. You can use this to create new fields or overwrite existing ones (if there + * is name overlaps). + * + * The added fields are defined using {@link Selectable}s, which can be: + * + * - {@link Field}: References an existing document field. + * - {@link Function}: Performs a calculation using functions like `add`, `multiply` with + * assigned aliases using {@link Expr#as}. + * + * Example: + * + * ```typescript + * firestore.pipeline().collection("books") + * .addFields( + * Field.of("rating").as("bookRating"), // Rename 'rating' to 'bookRating' + * add(5, Field.of("quantity")).as("totalCost") // Calculate 'totalCost' + * ); + * ``` + * + * @param fields The fields to add to the documents, specified as {@link Selectable}s. + * @return A new Pipeline object with this stage appended to the stage list. + */ + addFields(...fields: Selectable[]): Pipeline { + const copy = this.stages.map(s => s); + copy.push( + new AddFields( + this.readUserData('addFields', this.selectablesToMap(fields)) + ) + ); + return new Pipeline( + this._db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + copy, + this.converter + ); + } + + /** + * Selects or creates a set of fields from the outputs of previous stages. + * + *

The selected fields are defined using {@link Selectable} expressions, which can be: + * + *

    + *
  • {@code string}: Name of an existing field
  • + *
  • {@link Field}: References an existing field.
  • + *
  • {@link Function}: Represents the result of a function with an assigned alias name using + * {@link Expr#as}
  • + *
+ * + *

If no selections are provided, the output of this stage is empty. Use {@link + * com.google.cloud.firestore.Pipeline#addFields} instead if only additions are + * desired. + * + *

Example: + * + * ```typescript + * firestore.pipeline().collection("books") + * .select( + * "firstName", + * Field.of("lastName"), + * Field.of("address").toUppercase().as("upperAddress"), + * ); + * ``` + * + * @param selections The fields to include in the output documents, specified as {@link + * Selectable} expressions or {@code string} values representing field names. + * @return A new Pipeline object with this stage appended to the stage list. + */ + select(...selections: Array): Pipeline { + const copy = this.stages.map(s => s); + let projections: Map = this.selectablesToMap(selections); + projections = this.readUserData('select', projections); + copy.push(new Select(projections)); + return new Pipeline( + this._db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + copy, + this.converter + ); + } + + private selectablesToMap( + selectables: Array + ): Map { + const result = new Map(); + for (const selectable of selectables) { + if (typeof selectable === 'string') { + result.set(selectable as string, Field.of(selectable)); + } else if (selectable instanceof Field) { + result.set((selectable as Field).fieldName(), selectable); + } else if (selectable instanceof Fields) { + const fields = selectable as Fields; + for (const field of fields.fieldList()) { + result.set(field.fieldName(), field); + } + } else if (selectable instanceof ExprWithAlias) { + const expr = selectable as ExprWithAlias; + result.set(expr.alias, expr.expr); + } + } + return result; + } + + /** + * Reads user data for each expression in the expressionMap. + * @param name Name of the calling function. Used for error messages when invalid user data is encountered. + * @param expressionMap + * @return the expressionMap argument. + * @private + */ + private readUserData< + T extends + | Map + | ReadableUserData[] + | ReadableUserData + >(name: string, expressionMap: T): T { + if (isReadableUserData(expressionMap)) { + expressionMap._readUserData(this.userDataReader); + } else if (Array.isArray(expressionMap)) { + expressionMap.forEach(readableData => + readableData._readUserData(this.userDataReader) + ); + } else { + expressionMap.forEach(expr => expr._readUserData(this.userDataReader)); + } + return expressionMap; + } + + /** + * Filters the documents from previous stages to only include those matching the specified {@link + * FilterCondition}. + * + *

This stage allows you to apply conditions to the data, similar to a "WHERE" clause in SQL. + * You can filter documents based on their field values, using implementations of {@link + * FilterCondition}, typically including but not limited to: + * + *

    + *
  • field comparators: {@link Function#eq}, {@link Function#lt} (less than), {@link + * Function#gt} (greater than), etc.
  • + *
  • logical operators: {@link Function#and}, {@link Function#or}, {@link Function#not}, etc.
  • + *
  • advanced functions: {@link Function#regexMatch}, {@link + * Function#arrayContains}, etc.
  • + *
+ * + *

Example: + * + * ```typescript + * firestore.pipeline().collection("books") + * .where( + * and( + * gt(Field.of("rating"), 4.0), // Filter for ratings greater than 4.0 + * Field.of("genre").eq("Science Fiction") // Equivalent to gt("genre", "Science Fiction") + * ) + * ); + * ``` + * + * @param condition The {@link FilterCondition} to apply. + * @return A new Pipeline object with this stage appended to the stage list. + */ + where(condition: FilterCondition & Expr): Pipeline { + const copy = this.stages.map(s => s); + this.readUserData('where', condition); + copy.push(new Where(condition)); + return new Pipeline( + this._db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + copy, + this.converter + ); + } + + /** + * Skips the first `offset` number of documents from the results of previous stages. + * + *

This stage is useful for implementing pagination in your pipelines, allowing you to retrieve + * results in chunks. It is typically used in conjunction with {@link #limit} to control the + * size of each page. + * + *

Example: + * + * ```typescript + * // Retrieve the second page of 20 results + * firestore.pipeline().collection("books") + * .sort(Field.of("published").descending()) + * .offset(20) // Skip the first 20 results + * .limit(20); // Take the next 20 results + * ``` + * + * @param offset The number of documents to skip. + * @return A new Pipeline object with this stage appended to the stage list. + */ + offset(offset: number): Pipeline { + const copy = this.stages.map(s => s); + copy.push(new Offset(offset)); + return new Pipeline( + this._db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + copy, + this.converter + ); + } + + /** + * Limits the maximum number of documents returned by previous stages to `limit`. + * + *

This stage is particularly useful when you want to retrieve a controlled subset of data from + * a potentially large result set. It's often used for: + * + *

    + *
  • **Pagination:** In combination with {@link #offset} to retrieve specific pages of + * results.
  • + *
  • **Limiting Data Retrieval:** To prevent excessive data transfer and improve performance, + * especially when dealing with large collections.
  • + *
+ * + *

Example: + * + * ```typescript + * // Limit the results to the top 10 highest-rated books + * firestore.pipeline().collection("books") + * .sort(Field.of("rating").descending()) + * .limit(10); + * ``` + * + * @param limit The maximum number of documents to return. + * @return A new Pipeline object with this stage appended to the stage list. + */ + limit(limit: number): Pipeline { + const copy = this.stages.map(s => s); + copy.push(new Limit(limit)); + return new Pipeline( + this._db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + copy, + this.converter + ); + } + + /** + * Returns a set of distinct {@link Expr} values from the inputs to this stage. + * + *

This stage run through the results from previous stages to include only results with unique + * combinations of {@link Expr} values ({@link Field}, {@link Function}, etc). + * + *

The parameters to this stage are defined using {@link Selectable} expressions or {@code string}s: + * + *

    + *
  • {@code string}: Name of an existing field
  • + *
  • {@link Field}: References an existing document field.
  • + *
  • {@link Function}: Represents the result of a function with an assigned alias name using + * {@link Expr#as}
  • + *
+ * + *

Example: + * + * ```typescript + * // Get a list of unique author names in uppercase and genre combinations. + * firestore.pipeline().collection("books") + * .distinct(toUppercase(Field.of("author")).as("authorName"), Field.of("genre"), "publishedAt") + * .select("authorName"); + * ``` + * + * @param selectables The {@link Selectable} expressions to consider when determining distinct + * value combinations or {@code string}s representing field names. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + distinct(...groups: Array): Pipeline { + const copy = this.stages.map(s => s); + copy.push( + new Distinct( + this.readUserData('distinct', this.selectablesToMap(groups || [])) + ) + ); + return new Pipeline( + this._db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + copy, + this.converter + ); + } + + /** + * Performs aggregation operations on the documents from previous stages. + * + *

This stage allows you to calculate aggregate values over a set of documents. You define the + * aggregations to perform using {@link AccumulatorTarget} expressions which are typically results of + * calling {@link Expr#as} on {@link Accumulator} instances. + * + *

Example: + * + * ```typescript + * // Calculate the average rating and the total number of books + * firestore.pipeline().collection("books") + * .aggregate( + * Field.of("rating").avg().as("averageRating"), + * countAll().as("totalBooks") + * ); + * ``` + * + * @param accumulators The {@link AccumulatorTarget} expressions, each wrapping an {@link Accumulator} + * and provide a name for the accumulated results. + * @return A new Pipeline object with this stage appended to the stage list. + */ + aggregate(...accumulators: AccumulatorTarget[]): Pipeline; + /** + * Performs optionally grouped aggregation operations on the documents from previous stages. + * + *

This stage allows you to calculate aggregate values over a set of documents, optionally + * grouped by one or more fields or functions. You can specify: + * + *

    + *
  • **Grouping Fields or Functions:** One or more fields or functions to group the documents + * by. For each distinct combination of values in these fields, a separate group is created. + * If no grouping fields are provided, a single group containing all documents is used. Not + * specifying groups is the same as putting the entire inputs into one group.
  • + *
  • **Accumulators:** One or more accumulation operations to perform within each group. These + * are defined using {@link AccumulatorTarget} expressions, which are typically created by + * calling {@link Expr#as} on {@link Accumulator} instances. Each aggregation + * calculates a value (e.g., sum, average, count) based on the documents within its group.
  • + *
+ * + *

Example: + * + * ```typescript + * // Calculate the average rating for each genre. + * firestore.pipeline().collection("books") + * .aggregate({ + * accumulators: [avg(Field.of("rating")).as("avg_rating")] + * groups: ["genre"] + * }); + * ``` + * + * @param aggregate An {@link Aggregate} object that specifies the grouping fields (if any) and + * the aggregation operations to perform. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + aggregate(options: { + accumulators: AccumulatorTarget[]; + groups?: Array; + }): Pipeline; + aggregate( + optionsOrTarget: + | AccumulatorTarget + | { + accumulators: AccumulatorTarget[]; + groups?: Array; + }, + ...rest: AccumulatorTarget[] + ): Pipeline { + const copy = this.stages.map(s => s); + if ('accumulators' in optionsOrTarget) { + copy.push( + new Aggregate( + new Map( + optionsOrTarget.accumulators.map((target: AccumulatorTarget) => [ + (target as unknown as AccumulatorTarget).alias, + this.readUserData( + 'aggregate', + (target as unknown as AccumulatorTarget).expr + ) + ]) + ), + this.readUserData( + 'aggregate', + this.selectablesToMap(optionsOrTarget.groups || []) + ) + ) + ); + } else { + copy.push( + new Aggregate( + new Map( + [optionsOrTarget, ...rest].map(target => [ + (target as unknown as AccumulatorTarget).alias, + this.readUserData( + 'aggregate', + (target as unknown as AccumulatorTarget).expr + ) + ]) + ), + new Map() + ) + ); + } + return new Pipeline( + this._db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + copy, + this.converter + ); + } + + findNearest(options: FindNearestOptions): Pipeline; + findNearest(options: FindNearestOptions): Pipeline { + const copy = this.stages.map(s => s); + const parseContext = this.userDataReader.createContext( + UserDataSource.Argument, + 'findNearest' + ); + const value = parseVectorValue(options.vectorValue, parseContext); + const vectorObjectValue = new ObjectValue(value); + copy.push( + new FindNearest( + options.field, + vectorObjectValue, + options.distanceMeasure, + options.limit, + options.distanceField + ) + ); + return new Pipeline( + this._db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + copy + ); + } + + /** + * Sorts the documents from previous stages based on one or more {@link Ordering} criteria. + * + *

This stage allows you to order the results of your pipeline. You can specify multiple {@link + * Ordering} instances to sort by multiple fields in ascending or descending order. If documents + * have the same value for a field used for sorting, the next specified ordering will be used. If + * all orderings result in equal comparison, the documents are considered equal and the order is + * unspecified. + * + *

Example: + * + * ```typescript + * // Sort books by rating in descending order, and then by title in ascending order for books + * // with the same rating + * firestore.pipeline().collection("books") + * .sort( + * Ordering.of(Field.of("rating")).descending(), + * Ordering.of(Field.of("title")) // Ascending order is the default + * ); + * ``` + * + * @param orders One or more {@link Ordering} instances specifying the sorting criteria. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + sort(...orderings: Ordering[]): Pipeline; + sort(options: { orderings: Ordering[] }): Pipeline; + sort( + optionsOrOrderings: + | Ordering + | { + orderings: Ordering[]; + }, + ...rest: Ordering[] + ): Pipeline { + const copy = this.stages.map(s => s); + // Option object + if ('orderings' in optionsOrOrderings) { + copy.push( + new Sort( + this.readUserData( + 'sort', + this.readUserData('sort', optionsOrOrderings.orderings) + ) + ) + ); + } else { + // Ordering object + copy.push( + new Sort(this.readUserData('sort', [optionsOrOrderings, ...rest])) + ); + } + + return new Pipeline( + this._db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + copy, + this.converter + ); + } + + /** + * Adds a generic stage to the pipeline. + * + *

This method provides a flexible way to extend the pipeline's functionality by adding custom + * stages. Each generic stage is defined by a unique `name` and a set of `params` that control its + * behavior. + * + *

Example (Assuming there is no "where" stage available in SDK): + * + * ```typescript + * // Assume we don't have a built-in "where" stage + * firestore.pipeline().collection("books") + * .genericStage("where", [Field.of("published").lt(1900)]) // Custom "where" stage + * .select("title", "author"); + * ``` + * + * @param name The unique name of the generic stage to add. + * @param params A list of parameters to configure the generic stage's behavior. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + genericStage(name: string, params: any[]): Pipeline { + const copy = this.stages.map(s => s); + params.forEach(param => { + if (isReadableUserData(param)) { + param._readUserData(this.userDataReader); + } + }); + copy.push(new GenericStage(name, params)); + return new Pipeline( + this._db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + copy, + this.converter + ); + } + + // TODO(pipeline) support converter + // withConverter(converter: null): Pipeline; + // withConverter( + // converter: FirestorePipelineConverter + // ): Pipeline; + // /** + // * Applies a custom data converter to this Query, allowing you to use your + // * own custom model objects with Firestore. When you call get() on the + // * returned Query, the provided converter will convert between Firestore + // * data of type `NewDbModelType` and your custom type `NewAppModelType`. + // * + // * Using the converter allows you to specify generic type arguments when + // * storing and retrieving objects from Firestore. + // * + // * Passing in `null` as the converter parameter removes the current + // * converter. + // * + // * @example + // * ``` + // * class Post { + // * constructor(readonly title: string, readonly author: string) {} + // * + // * toString(): string { + // * return this.title + ', by ' + this.author; + // * } + // * } + // * + // * const postConverter = { + // * toFirestore(post: Post): FirebaseFirestore.DocumentData { + // * return {title: post.title, author: post.author}; + // * }, + // * fromFirestore( + // * snapshot: FirebaseFirestore.QueryDocumentSnapshot + // * ): Post { + // * const data = snapshot.data(); + // * return new Post(data.title, data.author); + // * } + // * }; + // * + // * const postSnap = await Firestore() + // * .collection('posts') + // * .withConverter(postConverter) + // * .doc().get(); + // * const post = postSnap.data(); + // * if (post !== undefined) { + // * post.title; // string + // * post.toString(); // Should be defined + // * post.someNonExistentProperty; // TS error + // * } + // * + // * ``` + // * @param {FirestoreDataConverter | null} converter Converts objects to and + // * from Firestore. Passing in `null` removes the current converter. + // * @return A Query that uses the provided converter. + // */ + // withConverter( + // converter: FirestorePipelineConverter | null + // ): Pipeline { + // const copy = this.stages.map(s => s); + // return new Pipeline( + // this.db, + // copy, + // converter ?? defaultPipelineConverter() + // ); + // } + + /** + * Executes this pipeline and returns a Promise to represent the asynchronous operation. + * + *

The returned Promise can be used to track the progress of the pipeline execution + * and retrieve the results (or handle any errors) asynchronously. + * + *

The pipeline results are returned as a list of {@link PipelineResult} objects. Each {@link + * PipelineResult} typically represents a single key/value map that has passed through all the + * stages of the pipeline, however this might differ depending on the stages involved in the + * pipeline. For example: + * + *

    + *
  • If there are no stages or only transformation stages, each {@link PipelineResult} + * represents a single document.
  • + *
  • If there is an aggregation, only a single {@link PipelineResult} is returned, + * representing the aggregated results over the entire dataset .
  • + *
  • If there is an aggregation stage with grouping, each {@link PipelineResult} represents a + * distinct group and its associated aggregated values.
  • + *
+ * + *

Example: + * + * ```typescript + * const futureResults = await firestore.pipeline().collection("books") + * .where(gt(Field.of("rating"), 4.5)) + * .select("title", "author", "rating") + * .execute(); + * ``` + * + * @return A Promise representing the asynchronous pipeline execution. + */ + execute(): Promise>> { + const datastore = getDatastore(this._db); + return invokeExecutePipeline(datastore, this).then(result => { + const docs = result + // Currently ignore any response from ExecutePipeline that does + // not contain any document data in the `fields` property. + .filter(element => !!element.fields) + .map( + element => + new PipelineResult( + this.userDataWriter, + element.key?.path + ? this.documentReferenceFactory(element.key) + : undefined, + element.fields, + element.executionTime?.toTimestamp(), + element.createTime?.toTimestamp(), + element.updateTime?.toTimestamp() + //this.converter + ) + ); + + return docs; + }); + } + + /** + * @internal + * @private + */ + _toProto(jsonProtoSerializer: JsonProtoSerializer): ExecutePipelineRequest { + const stages: ProtoStage[] = this.stages.map(stage => + stage._toProto(jsonProtoSerializer) + ); + const structuredPipeline: StructuredPipeline = { pipeline: { stages } }; + return { + database: getEncodedDatabaseId(jsonProtoSerializer), + structuredPipeline + }; + } +} + +/** + * Experimental Modular API for console testing. + * @param firestore + */ +export function pipeline(firestore: Firestore): PipelineSource; + +/** + * Experimental Modular API for console testing. + * @param query + */ +export function pipeline(query: Query): Pipeline; + +export function pipeline( + firestoreOrQuery: Firestore | Query +): PipelineSource | Pipeline { + return firestoreOrQuery.pipeline(); +} diff --git a/packages/firestore/src/lite-api/pipeline_impl.ts b/packages/firestore/src/lite-api/pipeline_impl.ts new file mode 100644 index 00000000000..cd490d31871 --- /dev/null +++ b/packages/firestore/src/lite-api/pipeline_impl.ts @@ -0,0 +1,30 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Pipeline } from './pipeline'; +import { PipelineResult } from './pipeline-result'; + +/** + * Modular API for console experimentation. + * @param pipeline Execute this pipeline. + * @beta + */ +export function execute( + pipeline: Pipeline +): Promise>> { + return pipeline.execute(); +} diff --git a/packages/firestore/src/lite-api/reference.ts b/packages/firestore/src/lite-api/reference.ts index 26ae2fbd433..71b789227fc 100644 --- a/packages/firestore/src/lite-api/reference.ts +++ b/packages/firestore/src/lite-api/reference.ts @@ -37,6 +37,7 @@ import { AutoId } from '../util/misc'; import { Firestore } from './database'; import { FieldPath } from './field_path'; import { FieldValue } from './field_value'; +import type { Pipeline } from './pipeline'; import { FirestoreDataConverter } from './snapshot'; import { NestedUpdateFields, Primitive } from './types'; @@ -177,6 +178,15 @@ export class Query< this._query ); } + + /** + * Pipeline query. + */ + pipeline(): Pipeline { + throw new Error( + 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' + ); + } } /** diff --git a/packages/firestore/src/lite-api/stage.ts b/packages/firestore/src/lite-api/stage.ts new file mode 100644 index 00000000000..b4fe237f79c --- /dev/null +++ b/packages/firestore/src/lite-api/stage.ts @@ -0,0 +1,380 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ObjectValue } from '../model/object_value'; +import { + Stage as ProtoStage, + Value as ProtoValue +} from '../protos/firestore_proto_api'; +import { toNumber } from '../remote/number_serializer'; +import { + JsonProtoSerializer, + ProtoSerializable, + toMapValue, + toStringValue +} from '../remote/serializer'; + +import { + Accumulator, + Expr, + Field, + FilterCondition, + Ordering +} from './expressions'; +import { DocumentReference } from './reference'; +import { VectorValue } from './vector_value'; + +/** + * @beta + */ +export interface Stage extends ProtoSerializable { + name: string; +} + +/** + * @beta + */ +export class AddFields implements Stage { + name = 'add_fields'; + + constructor(private fields: Map) {} + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: [toMapValue(serializer, this.fields)] + }; + } +} + +/** + * @beta + */ +export class Aggregate implements Stage { + name = 'aggregate'; + + constructor( + private accumulators: Map, + private groups: Map + ) {} + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: [ + toMapValue(serializer, this.accumulators), + toMapValue(serializer, this.groups) + ] + }; + } +} + +/** + * @beta + */ +export class Distinct implements Stage { + name = 'distinct'; + + constructor(private groups: Map) {} + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: [toMapValue(serializer, this.groups)] + }; + } +} + +/** + * @beta + */ +export class CollectionSource implements Stage { + name = 'collection'; + + constructor(private collectionPath: string) { + if (!this.collectionPath.startsWith('/')) { + this.collectionPath = '/' + this.collectionPath; + } + } + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: [{ referenceValue: this.collectionPath }] + }; + } +} + +/** + * @beta + */ +export class CollectionGroupSource implements Stage { + name = 'collection_group'; + + constructor(private collectionId: string) {} + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: [{ referenceValue: '' }, { stringValue: this.collectionId }] + }; + } +} + +/** + * @beta + */ +export class DatabaseSource implements Stage { + name = 'database'; + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name + }; + } +} + +/** + * @beta + */ +export class DocumentsSource implements Stage { + name = 'documents'; + + constructor(private docPaths: string[]) {} + + static of(refs: DocumentReference[]): DocumentsSource { + return new DocumentsSource(refs.map(ref => '/' + ref.path)); + } + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: this.docPaths.map(p => { + return { referenceValue: p }; + }) + }; + } +} + +/** + * @beta + */ +export class Where implements Stage { + name = 'where'; + + constructor(private condition: FilterCondition & Expr) {} + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: [(this.condition as unknown as Expr)._toProto(serializer)] + }; + } +} + +/** + * @beta + */ +export interface FindNearestOptions { + field: Field; + vectorValue: VectorValue | number[]; + distanceMeasure: 'euclidean' | 'cosine' | 'dot_product'; + limit?: number; + distanceField?: string; +} + +/** + * @beta + */ +export class FindNearest implements Stage { + name = 'find_nearest'; + + /** + * @private + * @internal + * + * @param _field + * @param _vectorValue + * @param _distanceMeasure + * @param _limit + * @param _distanceField + */ + constructor( + private _field: Field, + private _vectorValue: ObjectValue, + private _distanceMeasure: 'euclidean' | 'cosine' | 'dot_product', + private _limit?: number, + private _distanceField?: string + ) {} + + /** + * @private + * @internal + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + const options: { [k: string]: ProtoValue } = {}; + + if (this._limit) { + options.limit = toNumber(serializer, this._limit)!; + } + + if (this._distanceField) { + // eslint-disable-next-line camelcase + options.distance_field = Field.of(this._distanceField)._toProto( + serializer + ); + } + + return { + name: this.name, + args: [ + this._field._toProto(serializer), + this._vectorValue.value, + toStringValue(this._distanceMeasure) + ], + options + }; + } +} + +/** + * @beta + */ +export class Limit implements Stage { + name = 'limit'; + + constructor(private limit: number) {} + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: [toNumber(serializer, this.limit)] + }; + } +} + +/** + * @beta + */ +export class Offset implements Stage { + name = 'offset'; + + constructor(private offset: number) {} + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: [toNumber(serializer, this.offset)] + }; + } +} + +/** + * @beta + */ +export class Select implements Stage { + name = 'select'; + + constructor(private projections: Map) {} + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: [toMapValue(serializer, this.projections)] + }; + } +} + +/** + * @beta + */ +export class Sort implements Stage { + name = 'sort'; + + constructor(private orders: Ordering[]) {} + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: this.orders.map(o => o._toProto(serializer)) + }; + } +} + +/** + * @beta + */ +export class GenericStage implements Stage { + constructor(public name: string, params: unknown[]) {} + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + // TODO support generic stage + return {}; + } +} diff --git a/packages/firestore/src/lite-api/user_data_reader.ts b/packages/firestore/src/lite-api/user_data_reader.ts index ebd4b49085f..42f905d5cab 100644 --- a/packages/firestore/src/lite-api/user_data_reader.ts +++ b/packages/firestore/src/lite-api/user_data_reader.ts @@ -852,7 +852,7 @@ function parseSentinelFieldValue( * * @returns The parsed value */ -function parseScalarValue( +export function parseScalarValue( value: unknown, context: ParseContextImpl ): ProtoValue | null { @@ -920,9 +920,10 @@ function parseScalarValue( * Creates a new VectorValue proto value (using the internal format). */ export function parseVectorValue( - value: VectorValue, + value: VectorValue | number[], context: ParseContextImpl -): ProtoValue { +): { mapValue: ProtoMapValue } { + const values = value instanceof VectorValue ? value.toArray() : value; const mapValue: ProtoMapValue = { fields: { [TYPE_KEY]: { @@ -930,7 +931,7 @@ export function parseVectorValue( }, [VECTOR_MAP_VECTORS_KEY]: { arrayValue: { - values: value.toArray().map(value => { + values: values.map(value => { if (typeof value !== 'number') { throw context.createError( 'VectorValues must only contain numeric values.' diff --git a/packages/firestore/src/model/aggregate_result_value.ts b/packages/firestore/src/model/aggregate_result_value.ts new file mode 100644 index 00000000000..042dc29d345 --- /dev/null +++ b/packages/firestore/src/model/aggregate_result_value.ts @@ -0,0 +1,42 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + MapValue as ProtoMapValue, + Value as ProtoValue +} from '../protos/firestore_proto_api'; + +import { valueEquals } from './values'; + +/** + * An AggregateResultValue represents a MapValue in the Firestore Proto. + */ +export class AggregateResultValue { + constructor(readonly value: { mapValue: ProtoMapValue }) {} + + static empty(): AggregateResultValue { + return new AggregateResultValue({ mapValue: {} }); + } + + aggregate(alias: string): ProtoValue | null { + return this.value.mapValue.fields?.[alias] ?? null; + } + + isEqual(other: AggregateResultValue): boolean { + return valueEquals(this.value, other.value); + } +} diff --git a/packages/firestore/src/model/pipeline_stream_element.ts b/packages/firestore/src/model/pipeline_stream_element.ts new file mode 100644 index 00000000000..efa27e2cc44 --- /dev/null +++ b/packages/firestore/src/model/pipeline_stream_element.ts @@ -0,0 +1,30 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { SnapshotVersion } from '../core/snapshot_version'; + +import { DocumentKey } from './document_key'; +import { ObjectValue } from './object_value'; + +export interface PipelineStreamElement { + transaction?: string; + key?: DocumentKey; + executionTime?: SnapshotVersion; + createTime?: SnapshotVersion; + updateTime?: SnapshotVersion; + fields?: ObjectValue; +} diff --git a/packages/firestore/src/protos/compile.sh b/packages/firestore/src/protos/compile.sh index 26c46d1a40d..9f9fb4b3217 100755 --- a/packages/firestore/src/protos/compile.sh +++ b/packages/firestore/src/protos/compile.sh @@ -18,10 +18,17 @@ set -euo pipefail # Variables PROTOS_DIR="." -PBJS="$(npm bin)/pbjs" +PBJS="../../node_modules/.bin/pbjs" +PBTS="../../node_modules/.bin/pbts" -"${PBJS}" --proto_path=. --target=json -o protos.json \ - -r firestore_v1 \ - "${PROTOS_DIR}/google/firestore/v1/*.proto" \ +"${PBJS}" --path=. --target=json -o protos.json \ + -r firestore/v1 "${PROTOS_DIR}/google/firestore/v1/*.proto" \ "${PROTOS_DIR}/google/protobuf/*.proto" "${PROTOS_DIR}/google/type/*.proto" \ "${PROTOS_DIR}/google/rpc/*.proto" "${PROTOS_DIR}/google/api/*.proto" + +"${PBJS}" --path="${PROTOS_DIR}" --target=static -o temp.js \ + -r firestore/v1 "${PROTOS_DIR}/google/firestore/v1/*.proto" \ + "${PROTOS_DIR}/google/protobuf/*.proto" "${PROTOS_DIR}/google/type/*.proto" \ + "${PROTOS_DIR}/google/rpc/*.proto" "${PROTOS_DIR}/google/api/*.proto" + +"${PBTS}" -o temp.d.ts --no-comments temp.js diff --git a/packages/firestore/src/protos/firestore_proto_api.ts b/packages/firestore/src/protos/firestore_proto_api.ts index 9618d71b86a..cc1c57259f5 100644 --- a/packages/firestore/src/protos/firestore_proto_api.ts +++ b/packages/firestore/src/protos/firestore_proto_api.ts @@ -145,9 +145,21 @@ export interface IValueNullValueEnum { } export declare const ValueNullValueEnum: IValueNullValueEnum; export declare namespace firestoreV1ApiClientInterfaces { + interface Aggregation { + count?: Count; + sum?: Sum; + avg?: Avg; + alias?: string; + } + interface AggregationResult { + aggregateFields?: ApiClientObjectMap; + } interface ArrayValue { values?: Value[]; } + interface Avg { + field?: FieldReference; + } interface BatchGetDocumentsRequest { database?: string; documents?: string[]; @@ -168,6 +180,14 @@ export declare namespace firestoreV1ApiClientInterfaces { interface BeginTransactionResponse { transaction?: string; } + interface BitSequence { + bitmap?: string | Uint8Array; + padding?: number; + } + interface BloomFilter { + bits?: BitSequence; + hashCount?: number; + } interface CollectionSelector { collectionId?: string; allDescendants?: boolean; @@ -185,6 +205,9 @@ export declare namespace firestoreV1ApiClientInterfaces { op?: CompositeFilterOp; filters?: Filter[]; } + interface Count { + upTo?: number; + } interface Cursor { values?: Value[]; before?: boolean; @@ -221,19 +244,23 @@ export declare namespace firestoreV1ApiClientInterfaces { documents?: string[]; } interface Empty {} + interface ExecutePipelineRequest { + database?: string; + structuredPipeline?: StructuredPipeline; + transaction?: string; + newTransaction?: TransactionOptions; + readTime?: string; + } + interface ExecutePipelineResponse { + transaction?: string; + results?: Document[]; + executionTime?: string; + } interface ExistenceFilter { targetId?: number; count?: number; unchangedNames?: BloomFilter; } - interface BloomFilter { - bits?: BitSequence; - hashCount?: number; - } - interface BitSequence { - bitmap?: string | Uint8Array; - padding?: number; - } interface FieldFilter { field?: FieldReference; op?: FieldFilterOp; @@ -254,6 +281,11 @@ export declare namespace firestoreV1ApiClientInterfaces { fieldFilter?: FieldFilter; unaryFilter?: UnaryFilter; } + interface Function { + name?: string; + args?: Value[]; + options?: ApiClientObjectMap; + } interface Index { name?: string; collectionId?: string; @@ -310,6 +342,9 @@ export declare namespace firestoreV1ApiClientInterfaces { field?: FieldReference; direction?: OrderDirection; } + interface Pipeline { + stages?: Stage[]; + } interface Precondition { exists?: boolean; updateTime?: Timestamp; @@ -355,33 +390,24 @@ export declare namespace firestoreV1ApiClientInterfaces { transaction?: string; readTime?: string; } - interface AggregationResult { - aggregateFields?: ApiClientObjectMap; - } interface StructuredAggregationQuery { structuredQuery?: StructuredQuery; aggregations?: Aggregation[]; } - interface Aggregation { - count?: Count; - sum?: Sum; - avg?: Avg; - alias?: string; - } - interface Count { - upTo?: number; - } - interface Sum { - field?: FieldReference; - } - interface Avg { - field?: FieldReference; + interface Stage { + name?: string; + args?: Value[]; + options?: ApiClientObjectMap; } interface Status { code?: number; message?: string; details?: Array>; } + interface StructuredPipeline { + pipeline?: Pipeline; + options?: ApiClientObjectMap; + } interface StructuredQuery { select?: Projection; from?: CollectionSelector[]; @@ -392,6 +418,9 @@ export declare namespace firestoreV1ApiClientInterfaces { offset?: number; limit?: number | { value: number }; } + interface Sum { + field?: FieldReference; + } interface Target { query?: QueryTarget; documents?: DocumentsTarget; @@ -428,6 +457,10 @@ export declare namespace firestoreV1ApiClientInterfaces { geoPointValue?: LatLng; arrayValue?: ArrayValue; mapValue?: MapValue; + fieldReferenceValue?: string; + // eslint-disable-next-line @typescript-eslint/ban-types + functionValue?: Function; + pipelineValue?: Pipeline; } interface Write { update?: Document; @@ -489,12 +522,17 @@ export declare type DocumentsTarget = export declare type Empty = firestoreV1ApiClientInterfaces.Empty; export declare type ExistenceFilter = firestoreV1ApiClientInterfaces.ExistenceFilter; +export declare type ExecutePipelineRequest = + firestoreV1ApiClientInterfaces.ExecutePipelineRequest; +export declare type ExecutePipelineResponse = + firestoreV1ApiClientInterfaces.ExecutePipelineResponse; export declare type FieldFilter = firestoreV1ApiClientInterfaces.FieldFilter; export declare type FieldReference = firestoreV1ApiClientInterfaces.FieldReference; export declare type FieldTransform = firestoreV1ApiClientInterfaces.FieldTransform; export declare type Filter = firestoreV1ApiClientInterfaces.Filter; +export declare type Function = firestoreV1ApiClientInterfaces.Function; export declare type Index = firestoreV1ApiClientInterfaces.Index; export declare type IndexField = firestoreV1ApiClientInterfaces.IndexField; export declare type LatLng = firestoreV1ApiClientInterfaces.LatLng; @@ -513,6 +551,7 @@ export declare type ListenResponse = export declare type MapValue = firestoreV1ApiClientInterfaces.MapValue; export declare type Operation = firestoreV1ApiClientInterfaces.Operation; export declare type Order = firestoreV1ApiClientInterfaces.Order; +export declare type Pipeline = firestoreV1ApiClientInterfaces.Pipeline; export declare type Precondition = firestoreV1ApiClientInterfaces.Precondition; export declare type Projection = firestoreV1ApiClientInterfaces.Projection; export declare type QueryTarget = firestoreV1ApiClientInterfaces.QueryTarget; @@ -529,9 +568,12 @@ export declare type RunAggregationQueryRequest = export declare type Aggregation = firestoreV1ApiClientInterfaces.Aggregation; export declare type RunAggregationQueryResponse = firestoreV1ApiClientInterfaces.RunAggregationQueryResponse; +export declare type Stage = firestoreV1ApiClientInterfaces.Stage; export declare type Status = firestoreV1ApiClientInterfaces.Status; export declare type StructuredQuery = firestoreV1ApiClientInterfaces.StructuredQuery; +export declare type StructuredPipeline = + firestoreV1ApiClientInterfaces.StructuredPipeline; export declare type Target = firestoreV1ApiClientInterfaces.Target; export declare type TargetChange = firestoreV1ApiClientInterfaces.TargetChange; export declare type TransactionOptions = diff --git a/packages/firestore/src/protos/google/api/launch_stage.proto b/packages/firestore/src/protos/google/api/launch_stage.proto new file mode 100644 index 00000000000..9863fc23d42 --- /dev/null +++ b/packages/firestore/src/protos/google/api/launch_stage.proto @@ -0,0 +1,72 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +option go_package = "google.golang.org/genproto/googleapis/api;api"; +option java_multiple_files = true; +option java_outer_classname = "LaunchStageProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +// The launch stage as defined by [Google Cloud Platform +// Launch Stages](https://cloud.google.com/terms/launch-stages). +enum LaunchStage { + // Do not use this default value. + LAUNCH_STAGE_UNSPECIFIED = 0; + + // The feature is not yet implemented. Users can not use it. + UNIMPLEMENTED = 6; + + // Prelaunch features are hidden from users and are only visible internally. + PRELAUNCH = 7; + + // Early Access features are limited to a closed group of testers. To use + // these features, you must sign up in advance and sign a Trusted Tester + // agreement (which includes confidentiality provisions). These features may + // be unstable, changed in backward-incompatible ways, and are not + // guaranteed to be released. + EARLY_ACCESS = 1; + + // Alpha is a limited availability test for releases before they are cleared + // for widespread use. By Alpha, all significant design issues are resolved + // and we are in the process of verifying functionality. Alpha customers + // need to apply for access, agree to applicable terms, and have their + // projects allowlisted. Alpha releases don't have to be feature complete, + // no SLAs are provided, and there are no technical support obligations, but + // they will be far enough along that customers can actually use them in + // test environments or for limited-use tests -- just like they would in + // normal production cases. + ALPHA = 2; + + // Beta is the point at which we are ready to open a release for any + // customer to use. There are no SLA or technical support obligations in a + // Beta release. Products will be complete from a feature perspective, but + // may have some open outstanding issues. Beta releases are suitable for + // limited production use cases. + BETA = 3; + + // GA features are open to all developers and are considered stable and + // fully qualified for production use. + GA = 4; + + // Deprecated features are scheduled to be shut down and removed. For more + // information, see the "Deprecation Policy" section of our [Terms of + // Service](https://cloud.google.com/terms/) + // and the [Google Cloud Platform Subject to the Deprecation + // Policy](https://cloud.google.com/terms/deprecation) documentation. + DEPRECATED = 5; +} diff --git a/packages/firestore/src/protos/google/firestore/v1/document.proto b/packages/firestore/src/protos/google/firestore/v1/document.proto index 5238a943ce4..f7605750502 100644 --- a/packages/firestore/src/protos/google/firestore/v1/document.proto +++ b/packages/firestore/src/protos/google/firestore/v1/document.proto @@ -129,6 +129,48 @@ message Value { // A map value. MapValue map_value = 6; + // Value which references a field. + // + // This is considered relative (vs absolute) since it only refers to a field + // and not a field within a particular document. + // + // **Requires:** + // + // * Must follow [field reference][FieldReference.field_path] limitations. + // + // * Not allowed to be used when writing documents. + // + // (-- NOTE(batchik): long term, there is no reason this type should not be + // allowed to be used on the write path. --) + string field_reference_value = 19; + + // A value that represents an unevaluated expression. + // + // **Requires:** + // + // * Not allowed to be used when writing documents. + // + // (-- NOTE(batchik): similar to above, there is no reason to not allow + // storing expressions into the database, just no plan to support in + // the near term. + // + // This would actually be an interesting way to represent user-defined + // functions or more expressive rules-based systems. --) + Function function_value = 20; + + // A value that represents an unevaluated pipeline. + // + // **Requires:** + // + // * Not allowed to be used when writing documents. + // + // (-- NOTE(batchik): similar to above, there is no reason to not allow + // storing expressions into the database, just no plan to support in + // the near term. + // + // This would actually be an interesting way to represent user-defined + // functions or more expressive rules-based systems. --) + Pipeline pipeline_value = 21; } } @@ -148,3 +190,73 @@ message MapValue { // not exceed 1,500 bytes and cannot be empty. map fields = 1; } + + +// Represents an unevaluated scalar expression. +// +// For example, the expression `like(user_name, "%alice%")` is represented as: +// +// ``` +// name: "like" +// args { field_reference: "user_name" } +// args { string_value: "%alice%" } +// ``` +// +// (-- api-linter: core::0123::resource-annotation=disabled +// aip.dev/not-precedent: this is not a One Platform API resource. --) +message Function { + // The name of the function to evaluate. + // + // **Requires:** + // + // * must be in snake case (lower case with underscore separator). + // + string name = 1; + + // Ordered list of arguments the given function expects. + repeated Value args = 2; + + // Optional named arguments that certain functions may support. + map options = 3; +} + +// A Firestore query represented as an ordered list of operations / stages. +message Pipeline { + // A single operation within a pipeline. + // + // A stage is made up of a unique name, and a list of arguments. The exact + // number of arguments & types is dependent on the stage type. + // + // To give an example, the stage `filter(state = "MD")` would be encoded as: + // + // ``` + // name: "filter" + // args { + // function_value { + // name: "eq" + // args { field_reference_value: "state" } + // args { string_value: "MD" } + // } + // } + // ``` + // + // See public documentation for the full list. + message Stage { + // The name of the stage to evaluate. + // + // **Requires:** + // + // * must be in snake case (lower case with underscore separator). + // + string name = 1; + + // Ordered list of arguments the given stage expects. + repeated Value args = 2; + + // Optional named arguments that certain functions may support. + map options = 3; + } + + // Ordered list of stages to evaluate. + repeated Stage stages = 1; +} diff --git a/packages/firestore/src/protos/google/firestore/v1/firestore.proto b/packages/firestore/src/protos/google/firestore/v1/firestore.proto index a8fc0d54b51..3e7b62e0609 100644 --- a/packages/firestore/src/protos/google/firestore/v1/firestore.proto +++ b/packages/firestore/src/protos/google/firestore/v1/firestore.proto @@ -22,6 +22,7 @@ import "google/api/field_behavior.proto"; import "google/firestore/v1/aggregation_result.proto"; import "google/firestore/v1/common.proto"; import "google/firestore/v1/document.proto"; +import "google/firestore/v1/pipeline.proto"; import "google/firestore/v1/query.proto"; import "google/firestore/v1/write.proto"; import "google/protobuf/empty.proto"; @@ -135,6 +136,15 @@ service Firestore { }; } + // Executes a pipeline query. + rpc ExecutePipeline(ExecutePipelineRequest) + returns (stream ExecutePipelineResponse) { + option (google.api.http) = { + post: "/v1/{database=projects/*/databases/*}/documents:executePipeline" + body: "*" + }; + } + // Runs an aggregation query. // // Rather than producing [Document][google.firestore.v1.Document] results like [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery], @@ -157,7 +167,7 @@ service Firestore { } }; } - + // Partitions a query by returning partition cursors that can be used to run // the query in parallel. The returned partition cursors are split points that // can be used by RunQuery as starting/end points for the query results. @@ -547,6 +557,82 @@ message RunQueryResponse { int32 skipped_results = 4; } +// The request for [Firestore.ExecutePipeline][]. +message ExecutePipelineRequest { + // Database identifier, in the form `projects/{project}/databases/{database}`. + string database = 1 [ + (google.api.field_behavior) = REQUIRED + ]; + + oneof pipeline_type { + // A pipelined operation. + StructuredPipeline structured_pipeline = 2; + } + + // Optional consistency arguments, defaults to strong consistency. + oneof consistency_selector { + // Run the query within an already active transaction. + // + // The value here is the opaque transaction ID to execute the query in. + bytes transaction = 5; + + // Execute the pipeline in a new transaction. + // + // The identifier of the newly created transaction will be returned in the + // first response on the stream. This defaults to a read-only transaction. + TransactionOptions new_transaction = 6; + + // Execute the pipeline in a snapshot transaction at the given time. + // + // This must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + google.protobuf.Timestamp read_time = 7; + } + + // Explain / analyze options for the pipeline. + // ExplainOptions explain_options = 8 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response for [Firestore.Execute][]. +message ExecutePipelineResponse { + // Newly created transaction identifier. + // + // This field is only specified on the first response from the server when + // the request specified [ExecuteRequest.new_transaction][]. + bytes transaction = 1; + + // An ordered batch of results returned executing a pipeline. + // + // The batch size is variable, and can even be zero for when only a partial + // progress message is returned. + // + // The fields present in the returned documents are only those that were + // explicitly requested in the pipeline, this include those like + // [`__name__`][Document.name] & [`__update_time__`][Document.update_time]. + // This is explicitly a divergence from `Firestore.RunQuery` / + // `Firestore.GetDocument` RPCs which always return such fields even when they + // are not specified in the [`mask`][DocumentMask]. + repeated Document results = 2; + + // The time at which the document(s) were read. + // + // This may be monotonically increasing; in this case, the previous documents + // in the result stream are guaranteed not to have changed between their + // `execution_time` and this one. + // + // If the query returns no results, a response with `execution_time` and no + // `results` will be sent, and this represents the time at which the operation + // was run. + google.protobuf.Timestamp execution_time = 3; + + // Query explain metrics. + // + // Set on the last response when [ExecutePipelineRequest.explain_options][] + // was specified on the request. + // ExplainMetrics explain_metrics = 4; +} + // The request for [Firestore.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery]. message RunAggregationQueryRequest { // Required. The parent resource name. In the format: diff --git a/packages/firestore/src/protos/google/firestore/v1/pipeline.proto b/packages/firestore/src/protos/google/firestore/v1/pipeline.proto new file mode 100644 index 00000000000..ea5b2309331 --- /dev/null +++ b/packages/firestore/src/protos/google/firestore/v1/pipeline.proto @@ -0,0 +1,41 @@ +/*! + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +syntax = "proto3"; +package google.firestore.v1; +import "google/firestore/v1/document.proto"; +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; +option java_multiple_files = true; +option java_package = "com.google.firestore.v1"; +option java_outer_classname = "PipelineProto"; +option objc_class_prefix = "GCFS"; +// A Firestore query represented as an ordered list of operations / stages. +// +// This is considered the top-level function which plans & executes a query. +// It is logically equivalent to `query(stages, options)`, but prevents the +// client from having to build a function wrapper. +message StructuredPipeline { + // The pipeline query to execute. + Pipeline pipeline = 1; + // Optional query-level arguments. + // + // (-- Think query statement hints. --) + // + // (-- TODO(batchik): define the api contract of using an unsupported hint --) + map options = 2; +} diff --git a/packages/firestore/src/protos/google/firestore/v1/query_profile.proto b/packages/firestore/src/protos/google/firestore/v1/query_profile.proto new file mode 100644 index 00000000000..de27144a038 --- /dev/null +++ b/packages/firestore/src/protos/google/firestore/v1/query_profile.proto @@ -0,0 +1,92 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.v1; + +import "google/api/field_behavior.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +option java_multiple_files = true; +option java_outer_classname = "QueryProfileProto"; +option java_package = "com.google.firestore.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; + +// Specification of the Firestore Query Profile fields. + +// Explain options for the query. +message ExplainOptions { + // Optional. Whether to execute this query. + // + // When false (the default), the query will be planned, returning only + // metrics from the planning stages. + // + // When true, the query will be planned and executed, returning the full + // query results along with both planning and execution stage metrics. + bool analyze = 1 [(google.api.field_behavior) = OPTIONAL]; +} + +// Explain metrics for the query. +message ExplainMetrics { + // Planning phase information for the query. + PlanSummary plan_summary = 1; + + // Aggregated stats from the execution of the query. Only present when + // [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set + // to true. + ExecutionStats execution_stats = 2; +} + +// Planning phase information for the query. +message PlanSummary { + // The indexes selected for the query. For example: + // [ + // {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"}, + // {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"} + // ] + repeated google.protobuf.Struct indexes_used = 1; +} + +// Execution statistics for the query. +message ExecutionStats { + // Total number of results returned, including documents, projections, + // aggregation results, keys. + int64 results_returned = 1; + + // Total time to execute the query in the backend. + google.protobuf.Duration execution_duration = 3; + + // Total billable read operations. + int64 read_operations = 4; + + // Debugging statistics from the execution of the query. Note that the + // debugging stats are subject to change as Firestore evolves. It could + // include: + // { + // "indexes_entries_scanned": "1000", + // "documents_scanned": "20", + // "billing_details" : { + // "documents_billable": "20", + // "index_entries_billable": "1000", + // "min_query_cost": "0" + // } + // } + google.protobuf.Struct debug_stats = 5; +} diff --git a/packages/firestore/src/protos/protos.json b/packages/firestore/src/protos/protos.json index b2c50ccaeeb..5b73c4647f8 100644 --- a/packages/firestore/src/protos/protos.json +++ b/packages/firestore/src/protos/protos.json @@ -4,16 +4,78 @@ "nested": { "protobuf": { "options": { - "csharp_namespace": "Google.Protobuf.WellKnownTypes", - "go_package": "github.com/golang/protobuf/ptypes/wrappers", + "go_package": "github.com/golang/protobuf/protoc-gen-go/descriptor;descriptor", "java_package": "com.google.protobuf", - "java_outer_classname": "WrappersProto", - "java_multiple_files": true, + "java_outer_classname": "DescriptorProtos", + "csharp_namespace": "Google.Protobuf.Reflection", "objc_class_prefix": "GPB", "cc_enable_arenas": true, "optimize_for": "SPEED" }, "nested": { + "Struct": { + "fields": { + "fields": { + "keyType": "string", + "type": "Value", + "id": 1 + } + } + }, + "Value": { + "oneofs": { + "kind": { + "oneof": [ + "nullValue", + "numberValue", + "stringValue", + "boolValue", + "structValue", + "listValue" + ] + } + }, + "fields": { + "nullValue": { + "type": "NullValue", + "id": 1 + }, + "numberValue": { + "type": "double", + "id": 2 + }, + "stringValue": { + "type": "string", + "id": 3 + }, + "boolValue": { + "type": "bool", + "id": 4 + }, + "structValue": { + "type": "Struct", + "id": 5 + }, + "listValue": { + "type": "ListValue", + "id": 6 + } + } + }, + "NullValue": { + "values": { + "NULL_VALUE": 0 + } + }, + "ListValue": { + "fields": { + "values": { + "rule": "repeated", + "type": "Value", + "id": 1 + } + } + }, "Timestamp": { "fields": { "seconds": { @@ -161,6 +223,10 @@ "end": { "type": "int32", "id": 2 + }, + "options": { + "type": "ExtensionRangeOptions", + "id": 3 } } }, @@ -178,6 +244,21 @@ } } }, + "ExtensionRangeOptions": { + "fields": { + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ] + }, "FieldDescriptorProto": { "fields": { "name": { @@ -279,6 +360,30 @@ "options": { "type": "EnumOptions", "id": 3 + }, + "reservedRange": { + "rule": "repeated", + "type": "EnumReservedRange", + "id": 4 + }, + "reservedName": { + "rule": "repeated", + "type": "string", + "id": 5 + } + }, + "nested": { + "EnumReservedRange": { + "fields": { + "start": { + "type": "int32", + "id": 1 + }, + "end": { + "type": "int32", + "id": 2 + } + } } } }, @@ -335,11 +440,17 @@ }, "clientStreaming": { "type": "bool", - "id": 5 + "id": 5, + "options": { + "default": false + } }, "serverStreaming": { "type": "bool", - "id": 6 + "id": 6, + "options": { + "default": false + } } } }, @@ -355,7 +466,10 @@ }, "javaMultipleFiles": { "type": "bool", - "id": 10 + "id": 10, + "options": { + "default": false + } }, "javaGenerateEqualsAndHash": { "type": "bool", @@ -366,7 +480,10 @@ }, "javaStringCheckUtf8": { "type": "bool", - "id": 27 + "id": 27, + "options": { + "default": false + } }, "optimizeFor": { "type": "OptimizeMode", @@ -381,23 +498,45 @@ }, "ccGenericServices": { "type": "bool", - "id": 16 + "id": 16, + "options": { + "default": false + } }, "javaGenericServices": { "type": "bool", - "id": 17 + "id": 17, + "options": { + "default": false + } }, "pyGenericServices": { "type": "bool", - "id": 18 + "id": 18, + "options": { + "default": false + } + }, + "phpGenericServices": { + "type": "bool", + "id": 42, + "options": { + "default": false + } }, "deprecated": { "type": "bool", - "id": 23 + "id": 23, + "options": { + "default": false + } }, "ccEnableArenas": { "type": "bool", - "id": 31 + "id": 31, + "options": { + "default": false + } }, "objcClassPrefix": { "type": "string", @@ -407,6 +546,26 @@ "type": "string", "id": 37 }, + "swiftPrefix": { + "type": "string", + "id": 39 + }, + "phpClassPrefix": { + "type": "string", + "id": 40 + }, + "phpNamespace": { + "type": "string", + "id": 41 + }, + "phpMetadataNamespace": { + "type": "string", + "id": 44 + }, + "rubyPackage": { + "type": "string", + "id": 45 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -439,15 +598,24 @@ "fields": { "messageSetWireFormat": { "type": "bool", - "id": 1 + "id": 1, + "options": { + "default": false + } }, "noStandardDescriptorAccessor": { "type": "bool", - "id": 2 + "id": 2, + "options": { + "default": false + } }, "deprecated": { "type": "bool", - "id": 3 + "id": 3, + "options": { + "default": false + } }, "mapEntry": { "type": "bool", @@ -469,6 +637,10 @@ [ 8, 8 + ], + [ + 9, + 9 ] ] }, @@ -494,15 +666,24 @@ }, "lazy": { "type": "bool", - "id": 5 + "id": 5, + "options": { + "default": false + } }, "deprecated": { "type": "bool", - "id": 3 + "id": 3, + "options": { + "default": false + } }, "weak": { "type": "bool", - "id": 10 + "id": 10, + "options": { + "default": false + } }, "uninterpretedOption": { "rule": "repeated", @@ -562,7 +743,10 @@ }, "deprecated": { "type": "bool", - "id": 3 + "id": 3, + "options": { + "default": false + } }, "uninterpretedOption": { "rule": "repeated", @@ -575,13 +759,22 @@ 1000, 536870911 ] + ], + "reserved": [ + [ + 5, + 5 + ] ] }, "EnumValueOptions": { "fields": { "deprecated": { "type": "bool", - "id": 1 + "id": 1, + "options": { + "default": false + } }, "uninterpretedOption": { "rule": "repeated", @@ -600,7 +793,10 @@ "fields": { "deprecated": { "type": "bool", - "id": 33 + "id": 33, + "options": { + "default": false + } }, "uninterpretedOption": { "rule": "repeated", @@ -619,7 +815,17 @@ "fields": { "deprecated": { "type": "bool", - "id": 33 + "id": 33, + "options": { + "default": false + } + }, + "idempotencyLevel": { + "type": "IdempotencyLevel", + "id": 34, + "options": { + "default": "IDEMPOTENCY_UNKNOWN" + } }, "uninterpretedOption": { "rule": "repeated", @@ -632,7 +838,16 @@ 1000, 536870911 ] - ] + ], + "nested": { + "IdempotencyLevel": { + "values": { + "IDEMPOTENCY_UNKNOWN": 0, + "NO_SIDE_EFFECTS": 1, + "IDEMPOTENT": 2 + } + } + } }, "UninterpretedOption": { "fields": { @@ -753,72 +968,6 @@ } } }, - "Struct": { - "fields": { - "fields": { - "keyType": "string", - "type": "Value", - "id": 1 - } - } - }, - "Value": { - "oneofs": { - "kind": { - "oneof": [ - "nullValue", - "numberValue", - "stringValue", - "boolValue", - "structValue", - "listValue" - ] - } - }, - "fields": { - "nullValue": { - "type": "NullValue", - "id": 1 - }, - "numberValue": { - "type": "double", - "id": 2 - }, - "stringValue": { - "type": "string", - "id": 3 - }, - "boolValue": { - "type": "bool", - "id": 4 - }, - "structValue": { - "type": "Struct", - "id": 5 - }, - "listValue": { - "type": "ListValue", - "id": 6 - } - } - }, - "NullValue": { - "values": { - "NULL_VALUE": 0 - } - }, - "ListValue": { - "fields": { - "values": { - "rule": "repeated", - "type": "Value", - "id": 1 - } - } - }, - "Empty": { - "fields": {} - }, "DoubleValue": { "fields": { "value": { @@ -891,9 +1040,12 @@ } } }, + "Empty": { + "fields": {} + }, "Any": { "fields": { - "typeUrl": { + "type_url": { "type": "string", "id": 1 }, @@ -902,6 +1054,18 @@ "id": 2 } } + }, + "Duration": { + "fields": { + "seconds": { + "type": "int64", + "id": 1 + }, + "nanos": { + "type": "int32", + "id": 2 + } + } } } }, @@ -910,9 +1074,9 @@ "v1": { "options": { "csharp_namespace": "Google.Cloud.Firestore.V1", - "go_package": "google.golang.org/genproto/googleapis/firestore/v1;firestore", + "go_package": "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb", "java_multiple_files": true, - "java_outer_classname": "WriteProto", + "java_outer_classname": "QueryProfileProto", "java_package": "com.google.firestore.v1", "objc_class_prefix": "GCFS", "php_namespace": "Google\\Cloud\\Firestore\\V1", @@ -928,104 +1092,6 @@ } } }, - "BitSequence": { - "fields": { - "bitmap": { - "type": "bytes", - "id": 1 - }, - "padding": { - "type": "int32", - "id": 2 - } - } - }, - "BloomFilter": { - "fields": { - "bits": { - "type": "BitSequence", - "id": 1 - }, - "hashCount": { - "type": "int32", - "id": 2 - } - } - }, - "DocumentMask": { - "fields": { - "fieldPaths": { - "rule": "repeated", - "type": "string", - "id": 1 - } - } - }, - "Precondition": { - "oneofs": { - "conditionType": { - "oneof": [ - "exists", - "updateTime" - ] - } - }, - "fields": { - "exists": { - "type": "bool", - "id": 1 - }, - "updateTime": { - "type": "google.protobuf.Timestamp", - "id": 2 - } - } - }, - "TransactionOptions": { - "oneofs": { - "mode": { - "oneof": [ - "readOnly", - "readWrite" - ] - } - }, - "fields": { - "readOnly": { - "type": "ReadOnly", - "id": 2 - }, - "readWrite": { - "type": "ReadWrite", - "id": 3 - } - }, - "nested": { - "ReadWrite": { - "fields": { - "retryTransaction": { - "type": "bytes", - "id": 1 - } - } - }, - "ReadOnly": { - "oneofs": { - "consistencySelector": { - "oneof": [ - "readTime" - ] - } - }, - "fields": { - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 2 - } - } - } - } - }, "Document": { "fields": { "name": { @@ -1061,7 +1127,10 @@ "referenceValue", "geoPointValue", "arrayValue", - "mapValue" + "mapValue", + "fieldReferenceValue", + "functionValue", + "pipelineValue" ] } }, @@ -1106,27 +1175,184 @@ "type": "ArrayValue", "id": 9 }, - "mapValue": { - "type": "MapValue", - "id": 6 + "mapValue": { + "type": "MapValue", + "id": 6 + }, + "fieldReferenceValue": { + "type": "string", + "id": 19 + }, + "functionValue": { + "type": "Function", + "id": 20 + }, + "pipelineValue": { + "type": "Pipeline", + "id": 21 + } + } + }, + "ArrayValue": { + "fields": { + "values": { + "rule": "repeated", + "type": "Value", + "id": 1 + } + } + }, + "MapValue": { + "fields": { + "fields": { + "keyType": "string", + "type": "Value", + "id": 1 + } + } + }, + "Function": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "args": { + "rule": "repeated", + "type": "Value", + "id": 2 + }, + "options": { + "keyType": "string", + "type": "Value", + "id": 3 + } + } + }, + "Pipeline": { + "fields": { + "stages": { + "rule": "repeated", + "type": "Stage", + "id": 1 + } + }, + "nested": { + "Stage": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "args": { + "rule": "repeated", + "type": "Value", + "id": 2 + }, + "options": { + "keyType": "string", + "type": "Value", + "id": 3 + } + } + } + } + }, + "BitSequence": { + "fields": { + "bitmap": { + "type": "bytes", + "id": 1 + }, + "padding": { + "type": "int32", + "id": 2 + } + } + }, + "BloomFilter": { + "fields": { + "bits": { + "type": "BitSequence", + "id": 1 + }, + "hashCount": { + "type": "int32", + "id": 2 } } }, - "ArrayValue": { + "DocumentMask": { "fields": { - "values": { + "fieldPaths": { "rule": "repeated", - "type": "Value", + "type": "string", "id": 1 } } }, - "MapValue": { + "Precondition": { + "oneofs": { + "conditionType": { + "oneof": [ + "exists", + "updateTime" + ] + } + }, "fields": { - "fields": { - "keyType": "string", - "type": "Value", + "exists": { + "type": "bool", "id": 1 + }, + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + } + } + }, + "TransactionOptions": { + "oneofs": { + "mode": { + "oneof": [ + "readOnly", + "readWrite" + ] + } + }, + "fields": { + "readOnly": { + "type": "ReadOnly", + "id": 2 + }, + "readWrite": { + "type": "ReadWrite", + "id": 3 + } + }, + "nested": { + "ReadWrite": { + "fields": { + "retryTransaction": { + "type": "bytes", + "id": 1 + } + } + }, + "ReadOnly": { + "oneofs": { + "consistencySelector": { + "oneof": [ + "readTime" + ] + } + }, + "fields": { + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + } + } } } }, @@ -1302,6 +1528,23 @@ } ] }, + "ExecutePipeline": { + "requestType": "ExecutePipelineRequest", + "responseType": "ExecutePipelineResponse", + "responseStream": true, + "options": { + "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:executePipeline", + "(google.api.http).body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{database=projects/*/databases/*}/documents:executePipeline", + "body": "*" + } + } + ] + }, "RunAggregationQuery": { "requestType": "RunAggregationQueryRequest", "responseType": "RunAggregationQueryResponse", @@ -1816,6 +2059,64 @@ } } }, + "ExecutePipelineRequest": { + "oneofs": { + "pipelineType": { + "oneof": [ + "structuredPipeline" + ] + }, + "consistencySelector": { + "oneof": [ + "transaction", + "newTransaction", + "readTime" + ] + } + }, + "fields": { + "database": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "structuredPipeline": { + "type": "StructuredPipeline", + "id": 2 + }, + "transaction": { + "type": "bytes", + "id": 5 + }, + "newTransaction": { + "type": "TransactionOptions", + "id": 6 + }, + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 7 + } + } + }, + "ExecutePipelineResponse": { + "fields": { + "transaction": { + "type": "bytes", + "id": 1 + }, + "results": { + "rule": "repeated", + "type": "Document", + "id": 2 + }, + "executionTime": { + "type": "google.protobuf.Timestamp", + "id": 3 + } + } + }, "RunAggregationQueryRequest": { "oneofs": { "queryType": { @@ -2216,6 +2517,19 @@ } } }, + "StructuredPipeline": { + "fields": { + "pipeline": { + "type": "Pipeline", + "id": 1 + }, + "options": { + "keyType": "string", + "type": "Value", + "id": 2 + } + } + }, "StructuredQuery": { "fields": { "select": { @@ -2474,7 +2788,7 @@ "Sum": { "fields": { "field": { - "type": "FieldReference", + "type": "StructuredQuery.FieldReference", "id": 1 } } @@ -2482,7 +2796,7 @@ "Avg": { "fields": { "field": { - "type": "FieldReference", + "type": "StructuredQuery.FieldReference", "id": 1 } } @@ -2694,6 +3008,82 @@ "id": 3 } } + }, + "ExplainOptions": { + "fields": { + "analyze": { + "type": "bool", + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "ExplainMetrics": { + "fields": { + "planSummary": { + "type": "PlanSummary", + "id": 1 + }, + "executionStats": { + "type": "ExecutionStats", + "id": 2 + } + } + }, + "PlanSummary": { + "fields": { + "indexesUsed": { + "rule": "repeated", + "type": "google.protobuf.Struct", + "id": 1 + } + } + }, + "ExecutionStats": { + "fields": { + "resultsReturned": { + "type": "int64", + "id": 1 + }, + "executionDuration": { + "type": "google.protobuf.Duration", + "id": 3 + }, + "readOperations": { + "type": "int64", + "id": 4 + }, + "debugStats": { + "type": "google.protobuf.Struct", + "id": 5 + } + } + } + } + } + } + }, + "type": { + "options": { + "cc_enable_arenas": true, + "go_package": "google.golang.org/genproto/googleapis/type/latlng;latlng", + "java_multiple_files": true, + "java_outer_classname": "LatLngProto", + "java_package": "com.google.type", + "objc_class_prefix": "GTP" + }, + "nested": { + "LatLng": { + "fields": { + "latitude": { + "type": "double", + "id": 1 + }, + "longitude": { + "type": "double", + "id": 2 } } } @@ -2701,9 +3091,9 @@ }, "api": { "options": { - "go_package": "google.golang.org/genproto/googleapis/api/annotations;annotations", + "go_package": "google.golang.org/genproto/googleapis/api;api", "java_multiple_files": true, - "java_outer_classname": "HttpProto", + "java_outer_classname": "LaunchStageProto", "java_package": "com.google.api", "objc_class_prefix": "GAPI", "cc_enable_arenas": true @@ -2720,6 +3110,10 @@ "rule": "repeated", "type": "HttpRule", "id": 1 + }, + "fullyDecodeReservedExpansion": { + "type": "bool", + "id": 2 } } }, @@ -2737,6 +3131,10 @@ } }, "fields": { + "selector": { + "type": "string", + "id": 1 + }, "get": { "type": "string", "id": 2 @@ -2761,14 +3159,14 @@ "type": "CustomHttpPattern", "id": 8 }, - "selector": { - "type": "string", - "id": 1 - }, "body": { "type": "string", "id": 7 }, + "responseBody": { + "type": "string", + "id": 12 + }, "additionalBindings": { "rule": "repeated", "type": "HttpRule", @@ -2821,29 +3219,17 @@ "UNORDERED_LIST": 6, "NON_EMPTY_DEFAULT": 7 } - } - } - }, - "type": { - "options": { - "cc_enable_arenas": true, - "go_package": "google.golang.org/genproto/googleapis/type/latlng;latlng", - "java_multiple_files": true, - "java_outer_classname": "LatLngProto", - "java_package": "com.google.type", - "objc_class_prefix": "GTP" - }, - "nested": { - "LatLng": { - "fields": { - "latitude": { - "type": "double", - "id": 1 - }, - "longitude": { - "type": "double", - "id": 2 - } + }, + "LaunchStage": { + "values": { + "LAUNCH_STAGE_UNSPECIFIED": 0, + "UNIMPLEMENTED": 6, + "PRELAUNCH": 7, + "EARLY_ACCESS": 1, + "ALPHA": 2, + "BETA": 3, + "GA": 4, + "DEPRECATED": 5 } } } @@ -2880,4 +3266,4 @@ } } } -} +} \ No newline at end of file diff --git a/packages/firestore/src/remote/datastore.ts b/packages/firestore/src/remote/datastore.ts index ac47f0cb931..5fbff4392ac 100644 --- a/packages/firestore/src/remote/datastore.ts +++ b/packages/firestore/src/remote/datastore.ts @@ -20,10 +20,12 @@ import { User } from '../auth/user'; import { Aggregate } from '../core/aggregate'; import { DatabaseId } from '../core/database_info'; import { queryToAggregateTarget, Query, queryToTarget } from '../core/query'; +import { Pipeline } from '../lite-api/pipeline'; import { Document } from '../model/document'; import { DocumentKey } from '../model/document_key'; import { Mutation } from '../model/mutation'; import { ResourcePath } from '../model/path'; +import { PipelineStreamElement } from '../model/pipeline_stream_element'; import { ApiClientObjectMap, BatchGetDocumentsRequest as ProtoBatchGetDocumentsRequest, @@ -32,6 +34,8 @@ import { RunAggregationQueryResponse as ProtoRunAggregationQueryResponse, RunQueryRequest as ProtoRunQueryRequest, RunQueryResponse as ProtoRunQueryResponse, + ExecutePipelineRequest as ProtoExecutePipelineRequest, + ExecutePipelineResponse as ProtoExecutePipelineResponse, Value } from '../protos/firestore_proto_api'; import { debugAssert, debugCast, hardAssert } from '../util/assert'; @@ -54,7 +58,8 @@ import { toName, toQueryTarget, toResourcePath, - toRunAggregationQueryRequest + toRunAggregationQueryRequest, + fromPipelineResponse } from './serializer'; /** @@ -234,6 +239,36 @@ export async function invokeBatchGetDocumentsRpc( return result; } +export async function invokeExecutePipeline( + datastore: Datastore, + pipeline: Pipeline +): Promise { + const datastoreImpl = debugCast(datastore, DatastoreImpl); + const executePipelineRequest = pipeline._toProto(datastoreImpl.serializer); + + const response = await datastoreImpl.invokeStreamingRPC< + ProtoExecutePipelineRequest, + ProtoExecutePipelineResponse + >( + 'ExecutePipeline', + datastoreImpl.serializer.databaseId, + ResourcePath.emptyPath(), + executePipelineRequest + ); + + return response + .filter(proto => !!proto.results) + .flatMap(proto => { + if (proto.results!.length === 0) { + return fromPipelineResponse(datastoreImpl.serializer, proto); + } else { + return proto.results!.map(result => + fromPipelineResponse(datastoreImpl.serializer, proto, result) + ); + } + }); +} + export async function invokeRunQueryRpc( datastore: Datastore, query: Query diff --git a/packages/firestore/src/remote/internal_serializer.ts b/packages/firestore/src/remote/internal_serializer.ts index 8f278247581..29a68620efc 100644 --- a/packages/firestore/src/remote/internal_serializer.ts +++ b/packages/firestore/src/remote/internal_serializer.ts @@ -19,6 +19,8 @@ import { ensureFirestoreConfigured, Firestore } from '../api/database'; import { AggregateImpl } from '../core/aggregate'; import { queryToAggregateTarget, queryToTarget } from '../core/query'; import { AggregateSpec } from '../lite-api/aggregate_types'; +import { getDatastore } from '../lite-api/components'; +import { Pipeline } from '../lite-api/pipeline'; import { Query } from '../lite-api/reference'; import { cast } from '../util/input_validation'; import { mapToArray } from '../util/obj'; @@ -87,3 +89,28 @@ export function _internalAggregationQueryToProtoRunAggregationQueryRequest< /* skipAliasing= */ true ).request; } + +/** + * @internal + * @private + * + * This function is for internal use only. + * + * Returns the `ExecutePipelineRequest` representation of the given query. + * Returns `null` if the Firestore client associated with the given query has + * not been initialized or has been terminated. + * + * @param pipeline - The Pipeline to convert to proto representation. + */ +export function _internalPipelineToExecutePipelineRequestProto( + pipeline: Pipeline + // eslint-disable-next-line @typescript-eslint/no-explicit-any +): any { + const firestore = cast(pipeline._db, Firestore); + const datastore = getDatastore(firestore); + const serializer = datastore.serializer; + if (serializer === undefined) { + return null; + } + return pipeline._toProto(serializer); +} diff --git a/packages/firestore/src/remote/rest_connection.ts b/packages/firestore/src/remote/rest_connection.ts index 470cb332ce2..d1fa98f7e63 100644 --- a/packages/firestore/src/remote/rest_connection.ts +++ b/packages/firestore/src/remote/rest_connection.ts @@ -44,6 +44,7 @@ RPC_NAME_URL_MAPPING['BatchGetDocuments'] = 'batchGet'; RPC_NAME_URL_MAPPING['Commit'] = 'commit'; RPC_NAME_URL_MAPPING['RunQuery'] = 'runQuery'; RPC_NAME_URL_MAPPING['RunAggregationQuery'] = 'runAggregationQuery'; +RPC_NAME_URL_MAPPING['ExecutePipeline'] = 'executePipeline'; const RPC_URL_VERSION = 'v1'; diff --git a/packages/firestore/src/remote/serializer.ts b/packages/firestore/src/remote/serializer.ts index 811c2ac4df6..4759571b4a5 100644 --- a/packages/firestore/src/remote/serializer.ts +++ b/packages/firestore/src/remote/serializer.ts @@ -37,7 +37,10 @@ import { import { SnapshotVersion } from '../core/snapshot_version'; import { targetIsDocumentTarget, Target } from '../core/target'; import { TargetId } from '../core/types'; +import { Bytes } from '../lite-api/bytes'; +import { GeoPoint } from '../lite-api/geo_point'; import { Timestamp } from '../lite-api/timestamp'; +import { UserDataReader } from '../lite-api/user_data_reader'; import { TargetData, TargetPurpose } from '../local/target_data'; import { MutableDocument } from '../model/document'; import { DocumentKey } from '../model/document_key'; @@ -55,6 +58,7 @@ import { import { normalizeTimestamp } from '../model/normalize'; import { ObjectValue } from '../model/object_value'; import { FieldPath, ResourcePath } from '../model/path'; +import { PipelineStreamElement } from '../model/pipeline_stream_element'; import { ArrayRemoveTransformOperation, ArrayUnionTransformOperation, @@ -87,7 +91,10 @@ import { TargetChangeTargetChangeType as ProtoTargetChangeTargetChangeType, Timestamp as ProtoTimestamp, Write as ProtoWrite, - WriteResult as ProtoWriteResult + WriteResult as ProtoWriteResult, + Value as ProtoValue, + MapValue as ProtoMapValue, + ExecutePipelineResponse as ProtoExecutePipelineResponse } from '../protos/firestore_proto_api'; import { debugAssert, fail, hardAssert } from '../util/assert'; import { ByteString } from '../util/byte_string'; @@ -173,7 +180,7 @@ function fromRpcStatus(status: ProtoStatus): FirestoreError { * our generated proto interfaces say Int32Value must be. But GRPC actually * expects a { value: } struct. */ -function toInt32Proto( +export function toInt32Proto( serializer: JsonProtoSerializer, val: number | null ): number | { value: number } | null { @@ -226,7 +233,7 @@ export function toTimestamp( } } -function fromTimestamp(date: ProtoTimestamp): Timestamp { +export function fromTimestamp(date: ProtoTimestamp): Timestamp { const timestamp = normalizeTimestamp(date); return new Timestamp(timestamp.seconds, timestamp.nanos); } @@ -422,6 +429,37 @@ export function toDocument( }; } +export function fromPipelineResponse( + serializer: JsonProtoSerializer, + proto: ProtoExecutePipelineResponse, + document?: ProtoDocument +): PipelineStreamElement { + const output: PipelineStreamElement = {}; + if (proto.transaction?.length) { + output.transaction = proto.transaction; + } + const executionTime = proto.executionTime + ? fromVersion(proto.executionTime) + : undefined; + output.executionTime = executionTime; + + if (!!document) { + output.key = document.name + ? fromName(serializer, document.name) + : undefined; + + output.fields = new ObjectValue({ mapValue: { fields: document.fields } }); + + output.createTime = document.createTime + ? fromVersion(document.createTime!) + : undefined; + output.updateTime = document.updateTime + ? fromVersion(document.updateTime!) + : undefined; + } + return output; +} + export function fromDocument( serializer: JsonProtoSerializer, document: ProtoDocument, @@ -1390,3 +1428,82 @@ export function isValidResourceName(path: ResourcePath): boolean { path.get(2) === 'databases' ); } + +export interface ProtoSerializable { + _toProto(serializer: JsonProtoSerializer): ProtoType; +} + +export interface UserData { + _readUserData(dataReader: UserDataReader): void; +} + +export function toMapValue( + serializer: JsonProtoSerializer, + input: Map> +): ProtoValue { + const map: ProtoMapValue = { fields: {} }; + input.forEach((exp: ProtoSerializable, key: string) => { + if (typeof key !== 'string') { + throw new Error(`Cannot encode map with non-string key: ${key}`); + } + + map.fields![key] = exp._toProto(serializer)!; + }); + return { + mapValue: map + }; +} + +export function toNullValue(value: null): ProtoValue { + return { nullValue: 'NULL_VALUE' }; +} + +export function toBooleanValue(value: boolean): ProtoValue { + return { booleanValue: value }; +} + +export function toStringValue(value: string): ProtoValue { + return { stringValue: value }; +} + +export function dateToTimestampValue( + serializer: JsonProtoSerializer, + value: Date +): ProtoValue { + const timestamp = Timestamp.fromDate(value); + return { + timestampValue: toTimestamp(serializer, timestamp) + }; +} + +export function timestampToTimestampValue( + serializer: JsonProtoSerializer, + value: Timestamp +): ProtoValue { + // Firestore backend truncates precision down to microseconds. To ensure + // offline mode works the same in regards to truncation, perform the + // truncation immediately without waiting for the backend to do that. + const timestamp = new Timestamp( + value.seconds, + Math.floor(value.nanoseconds / 1000) * 1000 + ); + return { + timestampValue: toTimestamp(serializer, timestamp) + }; +} + +export function toGeoPointValue(value: GeoPoint): ProtoValue { + return { + geoPointValue: { + latitude: value.latitude, + longitude: value.longitude + } + }; +} + +export function toBytesValue( + serializer: JsonProtoSerializer, + value: Bytes +): ProtoValue { + return { bytesValue: toBytes(serializer, value._byteString) }; +} diff --git a/packages/firestore/src/util/misc.ts b/packages/firestore/src/util/misc.ts index acaff77abb6..baed7e98a7d 100644 --- a/packages/firestore/src/util/misc.ts +++ b/packages/firestore/src/util/misc.ts @@ -89,6 +89,26 @@ export function arrayEquals( } return left.every((value, index) => comparator(value, right[index])); } + +/** + * Verifies equality for an optional value. + */ +export function isOptionalEqual( + left: T | undefined, + right: T | undefined, + equalityTest: (left: T, right: T) => boolean +): boolean { + if (left === undefined && right === undefined) { + return true; + } + + if (left === undefined || right === undefined) { + return false; + } + + return equalityTest(left, right); +} + /** * Returns the immediate lexicographically-following string. This is useful to * construct an inclusive range for indexeddb iterators. diff --git a/packages/firestore/src/util/obj.ts b/packages/firestore/src/util/obj.ts index c40bc86bc5c..2b61da9447f 100644 --- a/packages/firestore/src/util/obj.ts +++ b/packages/firestore/src/util/obj.ts @@ -32,7 +32,7 @@ export function objectSize(obj: object): number { } export function forEach( - obj: Dict | undefined, + obj: Record | undefined, fn: (key: string, val: V) => void ): void { for (const key in obj) { diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts new file mode 100644 index 00000000000..a954d9b53e1 --- /dev/null +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -0,0 +1,892 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { expect, use } from 'chai'; +import chaiAsPromised from 'chai-as-promised'; + +import { addEqualityMatcher } from '../../util/equality_matcher'; +import { Deferred } from '../../util/promise'; +import { + pipeline, + execute, + _internalPipelineToExecutePipelineRequestProto, + add, + andFunction, + arrayContains, + arrayContainsAny, + avgFunction, + CollectionReference, + Constant, + cosineDistance, + countAll, + doc, + DocumentData, + dotProduct, + endsWith, + eq, + euclideanDistance, + Field, + Firestore, + gt, + like, + lt, + lte, + mapGet, + neq, + not, + orFunction, + PipelineResult, + regexContains, + regexMatch, + setDoc, + startsWith, + subtract, + useFirestorePipelines +} from '../util/firebase_export'; +import { apiDescribe, withTestCollection } from '../util/helpers'; + +use(chaiAsPromised); +useFirestorePipelines(); + +apiDescribe.skip('Pipelines', persistence => { + addEqualityMatcher(); + let firestore: Firestore; + let randomCol: CollectionReference; + + // async function addDocs( + // ...docs: DocumentData[] + // ): Promise { + // let id = 0; // Guarantees consistent ordering for the first documents + // const refs: DocumentReference[] = []; + // for (const data of docs) { + // const ref = doc(randomCol, 'doc' + id++); + // await setDoc(ref, data); + // refs.push(ref); + // } + // return refs; + // } + + async function testCollectionWithDocs(docs: { + [id: string]: DocumentData; + }): Promise> { + for (const id in docs) { + if (docs.hasOwnProperty(id)) { + const ref = doc(randomCol, id); + await setDoc(ref, docs[id]); + } + } + return randomCol; + } + + function expectResults( + result: Array>, + ...docs: string[] + ): void; + function expectResults( + result: Array>, + ...data: DocumentData[] + ): void; + + function expectResults( + result: Array>, + ...data: DocumentData[] | string[] + ): void { + expect(result.length).to.equal(data.length); + + if (data.length > 0) { + if (typeof data[0] === 'string') { + const actualIds = result.map(result => result.ref?.id); + expect(actualIds).to.deep.equal(data); + } else { + result.forEach(r => { + expect(r.data()).to.deep.equal(data.shift()); + }); + } + } + } + + // async function compareQueryAndPipeline(query: Query): Promise { + // const queryResults = await getDocs(query); + // const pipeline = query.pipeline(); + // const pipelineResults = await pipeline.execute(); + // + // expect(queryResults.docs.map(s => s._fieldsProto)).to.deep.equal( + // pipelineResults.map(r => r._fieldsProto) + // ); + // return queryResults; + // } + + async function setupBookDocs(): Promise> { + const bookDocs: { [id: string]: DocumentData } = { + book1: { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams', + genre: 'Science Fiction', + published: 1979, + rating: 4.2, + tags: ['comedy', 'space', 'adventure'], + awards: { + hugo: true, + nebula: false, + others: { unknown: { year: 1980 } } + }, + nestedField: { 'level.1': { 'level.2': true } } + }, + book2: { + title: 'Pride and Prejudice', + author: 'Jane Austen', + genre: 'Romance', + published: 1813, + rating: 4.5, + tags: ['classic', 'social commentary', 'love'], + awards: { none: true } + }, + book3: { + title: 'One Hundred Years of Solitude', + author: 'Gabriel García Márquez', + genre: 'Magical Realism', + published: 1967, + rating: 4.3, + tags: ['family', 'history', 'fantasy'], + awards: { nobel: true, nebula: false } + }, + book4: { + title: 'The Lord of the Rings', + author: 'J.R.R. Tolkien', + genre: 'Fantasy', + published: 1954, + rating: 4.7, + tags: ['adventure', 'magic', 'epic'], + awards: { hugo: false, nebula: false } + }, + book5: { + title: "The Handmaid's Tale", + author: 'Margaret Atwood', + genre: 'Dystopian', + published: 1985, + rating: 4.1, + tags: ['feminism', 'totalitarianism', 'resistance'], + awards: { 'arthur c. clarke': true, 'booker prize': false } + }, + book6: { + title: 'Crime and Punishment', + author: 'Fyodor Dostoevsky', + genre: 'Psychological Thriller', + published: 1866, + rating: 4.3, + tags: ['philosophy', 'crime', 'redemption'], + awards: { none: true } + }, + book7: { + title: 'To Kill a Mockingbird', + author: 'Harper Lee', + genre: 'Southern Gothic', + published: 1960, + rating: 4.2, + tags: ['racism', 'injustice', 'coming-of-age'], + awards: { pulitzer: true } + }, + book8: { + title: '1984', + author: 'George Orwell', + genre: 'Dystopian', + published: 1949, + rating: 4.2, + tags: ['surveillance', 'totalitarianism', 'propaganda'], + awards: { prometheus: true } + }, + book9: { + title: 'The Great Gatsby', + author: 'F. Scott Fitzgerald', + genre: 'Modernist', + published: 1925, + rating: 4.0, + tags: ['wealth', 'american dream', 'love'], + awards: { none: true } + }, + book10: { + title: 'Dune', + author: 'Frank Herbert', + genre: 'Science Fiction', + published: 1965, + rating: 4.6, + tags: ['politics', 'desert', 'ecology'], + awards: { hugo: true, nebula: true } + } + }; + return testCollectionWithDocs(bookDocs); + } + + let testDeferred: Deferred | undefined; + let withTestCollectionPromise: Promise | undefined; + + beforeEach(async () => { + const setupDeferred = new Deferred(); + testDeferred = new Deferred(); + withTestCollectionPromise = withTestCollection( + persistence, + {}, + async (collectionRef, firestoreInstance) => { + randomCol = collectionRef; + firestore = firestoreInstance; + await setupBookDocs(); + setupDeferred.resolve(); + + return testDeferred?.promise; + } + ); + + await setupDeferred.promise; + }); + + afterEach(async () => { + testDeferred?.resolve(); + await withTestCollectionPromise; + }); + + // setLogLevel('debug') + + it('empty results as expected', async () => { + const result = await firestore + .pipeline() + .collection(randomCol.path) + .limit(0) + .execute(); + expect(result.length).to.equal(0); + }); + + it('full results as expected', async () => { + const result = await firestore + .pipeline() + .collection(randomCol.path) + .execute(); + expect(result.length).to.equal(10); + }); + + it('returns aggregate results as expected', async () => { + let result = await firestore + .pipeline() + .collection(randomCol.path) + .aggregate(countAll().as('count')) + .execute(); + expectResults(result, { count: 10 }); + + result = await randomCol + .pipeline() + .where(eq('genre', 'Science Fiction')) + .aggregate( + countAll().as('count'), + avgFunction('rating').as('avgRating'), + Field.of('rating').max().as('maxRating') + ) + .execute(); + expectResults(result, { count: 2, avgRating: 4.4, maxRating: 4.6 }); + }); + + it('rejects groups without accumulators', async () => { + await expect( + randomCol + .pipeline() + .where(lt('published', 1900)) + .aggregate({ + accumulators: [], + groups: ['genre'] + }) + .execute() + ).to.be.rejected; + }); + + // skip: toLower not supported + // it.skip('returns distinct values as expected', async () => { + // const results = await randomCol + // .pipeline() + // .where(lt('published', 1900)) + // .distinct(Field.of('genre').toLower().as('lowerGenre')) + // .execute(); + // expectResults( + // results, + // { lowerGenre: 'romance' }, + // { lowerGenre: 'psychological thriller' } + // ); + // }); + + it('returns group and accumulate results', async () => { + const results = await randomCol + .pipeline() + .where(lt(Field.of('published'), 1984)) + .aggregate({ + accumulators: [avgFunction('rating').as('avgRating')], + groups: ['genre'] + }) + .where(gt('avgRating', 4.3)) + .sort(Field.of('avgRating').descending()) + .execute(); + expectResults( + results, + { avgRating: 4.7, genre: 'Fantasy' }, + { avgRating: 4.5, genre: 'Romance' }, + { avgRating: 4.4, genre: 'Science Fiction' } + ); + }); + + it('returns min and max accumulations', async () => { + const results = await randomCol + .pipeline() + .aggregate( + countAll().as('count'), + Field.of('rating').max().as('maxRating'), + Field.of('published').min().as('minPublished') + ) + .execute(); + expectResults(results, { + count: 10, + maxRating: 4.7, + minPublished: 1813 + }); + }); + + it('can select fields', async () => { + const results = await firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'author') + .sort(Field.of('author').ascending()) + .execute(); + expectResults( + results, + { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams' + }, + { title: 'The Great Gatsby', author: 'F. Scott Fitzgerald' }, + { title: 'Dune', author: 'Frank Herbert' }, + { title: 'Crime and Punishment', author: 'Fyodor Dostoevsky' }, + { + title: 'One Hundred Years of Solitude', + author: 'Gabriel García Márquez' + }, + { title: '1984', author: 'George Orwell' }, + { title: 'To Kill a Mockingbird', author: 'Harper Lee' }, + { title: 'The Lord of the Rings', author: 'J.R.R. Tolkien' }, + { title: 'Pride and Prejudice', author: 'Jane Austen' }, + { title: "The Handmaid's Tale", author: 'Margaret Atwood' } + ); + }); + + it('where with and', async () => { + const results = await randomCol + .pipeline() + .where(andFunction(gt('rating', 4.5), eq('genre', 'Science Fiction'))) + .execute(); + expectResults(results, 'book10'); + }); + + it('where with or', async () => { + const results = await randomCol + .pipeline() + .where(orFunction(eq('genre', 'Romance'), eq('genre', 'Dystopian'))) + .select('title') + .execute(); + expectResults( + results, + { title: 'Pride and Prejudice' }, + { title: "The Handmaid's Tale" }, + { title: '1984' } + ); + }); + + it('offset and limits', async () => { + const results = await firestore + .pipeline() + .collection(randomCol.path) + .sort(Field.of('author').ascending()) + .offset(5) + .limit(3) + .select('title', 'author') + .execute(); + expectResults( + results, + { title: '1984', author: 'George Orwell' }, + { title: 'To Kill a Mockingbird', author: 'Harper Lee' }, + { title: 'The Lord of the Rings', author: 'J.R.R. Tolkien' } + ); + }); + + it('arrayContains works', async () => { + const results = await randomCol + .pipeline() + .where(arrayContains('tags', 'comedy')) + .select('title') + .execute(); + expectResults(results, { title: "The Hitchhiker's Guide to the Galaxy" }); + }); + + it('arrayContainsAny works', async () => { + const results = await randomCol + .pipeline() + .where(arrayContainsAny('tags', ['comedy', 'classic'])) + .select('title') + .execute(); + expectResults( + results, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'Pride and Prejudice' } + ); + }); + + it('arrayContainsAll works', async () => { + const results = await randomCol + .pipeline() + .where(Field.of('tags').arrayContainsAll('adventure', 'magic')) + .select('title') + .execute(); + expectResults(results, { title: 'The Lord of the Rings' }); + }); + + it('arrayLength works', async () => { + const results = await randomCol + .pipeline() + .select(Field.of('tags').arrayLength().as('tagsCount')) + .where(eq('tagsCount', 3)) + .execute(); + expect(results.length).to.equal(10); + }); + + // skip: arrayConcat not supported + // it.skip('arrayConcat works', async () => { + // const results = await randomCol + // .pipeline() + // .select( + // Field.of('tags').arrayConcat(['newTag1', 'newTag2']).as('modifiedTags') + // ) + // .limit(1) + // .execute(); + // expectResults(results, { + // modifiedTags: ['comedy', 'space', 'adventure', 'newTag1', 'newTag2'] + // }); + // }); + + it('testStrConcat', async () => { + const results = await randomCol + .pipeline() + .select( + Field.of('author').strConcat(' - ', Field.of('title')).as('bookInfo') + ) + .limit(1) + .execute(); + expectResults(results, { + bookInfo: "Douglas Adams - The Hitchhiker's Guide to the Galaxy" + }); + }); + + it('testStartsWith', async () => { + const results = await randomCol + .pipeline() + .where(startsWith('title', 'The')) + .select('title') + .sort(Field.of('title').ascending()) + .execute(); + expectResults( + results, + { title: 'The Great Gatsby' }, + { title: "The Handmaid's Tale" }, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'The Lord of the Rings' } + ); + }); + + it('testEndsWith', async () => { + const results = await randomCol + .pipeline() + .where(endsWith('title', 'y')) + .select('title') + .sort(Field.of('title').descending()) + .execute(); + expectResults( + results, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'The Great Gatsby' } + ); + }); + + it('testLength', async () => { + const results = await randomCol + .pipeline() + .select( + Field.of('title').charLength().as('titleLength'), + Field.of('title') + ) + .where(gt('titleLength', 20)) + .sort(Field.of('title').ascending()) + .execute(); + + expectResults( + results, + + { + titleLength: 29, + title: 'One Hundred Years of Solitude' + }, + { + titleLength: 36, + title: "The Hitchhiker's Guide to the Galaxy" + }, + { + titleLength: 21, + title: 'The Lord of the Rings' + }, + { + titleLength: 21, + title: 'To Kill a Mockingbird' + } + ); + }); + + // skip: toLower not supported + // it.skip('testToLowercase', async () => { + // const results = await randomCol + // .pipeline() + // .select(Field.of('title').toLower().as('lowercaseTitle')) + // .limit(1) + // .execute(); + // expectResults(results, { + // lowercaseTitle: "the hitchhiker's guide to the galaxy" + // }); + // }); + + // skip: toUpper not supported + // it.skip('testToUppercase', async () => { + // const results = await randomCol + // .pipeline() + // .select(Field.of('author').toUpper().as('uppercaseAuthor')) + // .limit(1) + // .execute(); + // expectResults(results, { uppercaseAuthor: 'DOUGLAS ADAMS' }); + // }); + + // skip: trim not supported + // it.skip('testTrim', async () => { + // const results = await randomCol + // .pipeline() + // .addFields(strConcat(' ', Field.of('title'), ' ').as('spacedTitle')) + // .select( + // Field.of('spacedTitle').trim().as('trimmedTitle'), + // Field.of('spacedTitle') + // ) + // .limit(1) + // .execute(); + // expectResults(results, { + // spacedTitle: " The Hitchhiker's Guide to the Galaxy ", + // trimmedTitle: "The Hitchhiker's Guide to the Galaxy" + // }); + // }); + + it('testLike', async () => { + const results = await randomCol + .pipeline() + .where(like('title', '%Guide%')) + .select('title') + .execute(); + expectResults(results, { title: "The Hitchhiker's Guide to the Galaxy" }); + }); + + it('testRegexContains', async () => { + const results = await randomCol + .pipeline() + .where(regexContains('title', '(?i)(the|of)')) + .execute(); + expect(results.length).to.equal(5); + }); + + it('testRegexMatches', async () => { + const results = await randomCol + .pipeline() + .where(regexMatch('title', '.*(?i)(the|of).*')) + .execute(); + expect(results.length).to.equal(5); + }); + + it('testArithmeticOperations', async () => { + const results = await randomCol + .pipeline() + .select( + add(Field.of('rating'), 1).as('ratingPlusOne'), + subtract(Field.of('published'), 1900).as('yearsSince1900'), + Field.of('rating').multiply(10).as('ratingTimesTen'), + Field.of('rating').divide(2).as('ratingDividedByTwo') + ) + .limit(1) + .execute(); + expectResults(results, { + ratingPlusOne: 5.2, + yearsSince1900: 79, + ratingTimesTen: 42, + ratingDividedByTwo: 2.1 + }); + }); + + it('testComparisonOperators', async () => { + const results = await randomCol + .pipeline() + .where( + andFunction( + gt('rating', 4.2), + lte(Field.of('rating'), 4.5), + neq('genre', 'Science Fiction') + ) + ) + .select('rating', 'title') + .sort(Field.of('title').ascending()) + .execute(); + expectResults( + results, + { rating: 4.3, title: 'Crime and Punishment' }, + { + rating: 4.3, + title: 'One Hundred Years of Solitude' + }, + { rating: 4.5, title: 'Pride and Prejudice' } + ); + }); + + it('testLogicalOperators', async () => { + const results = await randomCol + .pipeline() + .where( + orFunction( + andFunction(gt('rating', 4.5), eq('genre', 'Science Fiction')), + lt('published', 1900) + ) + ) + .select('title') + .sort(Field.of('title').ascending()) + .execute(); + expectResults( + results, + { title: 'Crime and Punishment' }, + { title: 'Dune' }, + { title: 'Pride and Prejudice' } + ); + }); + + it('testChecks', async () => { + const results = await randomCol + .pipeline() + .where(not(Field.of('rating').isNaN())) + .select( + Field.of('rating').eq(null).as('ratingIsNull'), + not(Field.of('rating').isNaN()).as('ratingIsNotNaN') + ) + .limit(1) + .execute(); + expectResults(results, { ratingIsNull: false, ratingIsNotNaN: true }); + }); + + it('testMapGet', async () => { + const results = await randomCol + .pipeline() + .select( + Field.of('awards').mapGet('hugo').as('hugoAward'), + Field.of('awards').mapGet('others').as('others'), + Field.of('title') + ) + .where(eq('hugoAward', true)) + .execute(); + expectResults( + results, + { + hugoAward: true, + title: "The Hitchhiker's Guide to the Galaxy", + others: { unknown: { year: 1980 } } + }, + { hugoAward: true, title: 'Dune', others: null } + ); + }); + + // it('testParent', async () => { + // const results = await randomCol + // .pipeline() + // .select( + // parent(randomCol.doc('chile').collection('subCollection').path).as( + // 'parent' + // ) + // ) + // .limit(1) + // .execute(); + // expect(results[0].data().parent.endsWith('/books')).to.be.true; + // }); + // + // it('testCollectionId', async () => { + // const results = await randomCol + // .pipeline() + // .select(collectionId(randomCol.doc('chile')).as('collectionId')) + // .limit(1) + // .execute(); + // expectResults(results, {collectionId: 'books'}); + // }); + + it('testDistanceFunctions', async () => { + const sourceVector = [0.1, 0.1]; + const targetVector = [0.5, 0.8]; + const results = await randomCol + .pipeline() + .select( + cosineDistance(Constant.vector(sourceVector), targetVector).as( + 'cosineDistance' + ), + dotProduct(Constant.vector(sourceVector), targetVector).as( + 'dotProductDistance' + ), + euclideanDistance(Constant.vector(sourceVector), targetVector).as( + 'euclideanDistance' + ) + ) + .limit(1) + .execute(); + + expectResults(results, { + cosineDistance: 0.02560880430538015, + dotProductDistance: 0.13, + euclideanDistance: 0.806225774829855 + }); + }); + + it('testNestedFields', async () => { + const results = await randomCol + .pipeline() + .where(eq('awards.hugo', true)) + .select('title', 'awards.hugo') + .execute(); + expectResults( + results, + { title: "The Hitchhiker's Guide to the Galaxy", 'awards.hugo': true }, + { title: 'Dune', 'awards.hugo': true } + ); + }); + + it('test mapGet with field name including . notation', async () => { + const results = await randomCol + .pipeline() + .where(eq('awards.hugo', true)) + .select( + 'title', + Field.of('nestedField.level.1'), + mapGet('nestedField', 'level.1').mapGet('level.2').as('nested') + ) + .execute(); + expectResults( + results, + { + title: "The Hitchhiker's Guide to the Galaxy", + 'nestedField.level.`1`': null, + nested: true + }, + { title: 'Dune', 'nestedField.level.`1`': null, nested: null } + ); + }); + + it('supports internal serialization to proto', async () => { + const pipeline = firestore + .pipeline() + .collection('books') + .where(eq('awards.hugo', true)) + .select( + 'title', + Field.of('nestedField.level.1'), + mapGet('nestedField', 'level.1').mapGet('level.2').as('nested') + ); + + const proto = _internalPipelineToExecutePipelineRequestProto(pipeline); + expect(proto).not.to.be.null; + }); + + // TODO(pipeline) support converter + // it('pipeline converter works', async () => { + // interface AppModel {myTitle: string; myAuthor: string; myPublished: number} + // const converter: FirestorePipelineConverter = { + // fromFirestore(result: FirebaseFirestore.PipelineResult): AppModel { + // return { + // myTitle: result.data()!.title as string, + // myAuthor: result.data()!.author as string, + // myPublished: result.data()!.published as number, + // }; + // }, + // }; + // + // const results = await firestore + // .pipeline() + // .collection(randomCol.path) + // .sort(Field.of('published').ascending()) + // .limit(2) + // .withConverter(converter) + // .execute(); + // + // const objs = results.map(r => r.data()); + // expect(objs[0]).to.deep.equal({ + // myAuthor: 'Jane Austen', + // myPublished: 1813, + // myTitle: 'Pride and Prejudice', + // }); + // expect(objs[1]).to.deep.equal({ + // myAuthor: 'Fyodor Dostoevsky', + // myPublished: 1866, + // myTitle: 'Crime and Punishment', + // }); + // }); + describe('modular API', () => { + it('works when creating a pipeline from a Firestore instance', async () => { + const myPipeline = pipeline(firestore) + .collection(randomCol.path) + .where(lt(Field.of('published'), 1984)) + .aggregate({ + accumulators: [avgFunction('rating').as('avgRating')], + groups: ['genre'] + }) + .where(gt('avgRating', 4.3)) + .sort(Field.of('avgRating').descending()); + + const results = await execute(myPipeline); + + expectResults( + results, + { avgRating: 4.7, genre: 'Fantasy' }, + { avgRating: 4.5, genre: 'Romance' }, + { avgRating: 4.4, genre: 'Science Fiction' } + ); + }); + + it('works when creating a pipeline from a collection', async () => { + const myPipeline = pipeline(randomCol) + .where(lt(Field.of('published'), 1984)) + .aggregate({ + accumulators: [avgFunction('rating').as('avgRating')], + groups: ['genre'] + }) + .where(gt('avgRating', 4.3)) + .sort(Field.of('avgRating').descending()); + + const results = await execute(myPipeline); + + expectResults( + results, + { avgRating: 4.7, genre: 'Fantasy' }, + { avgRating: 4.5, genre: 'Romance' }, + { avgRating: 4.4, genre: 'Science Fiction' } + ); + }); + }); +}); diff --git a/packages/firestore/test/unit/api/document_change.test.ts b/packages/firestore/test/unit/api/document_change.test.ts index faae8b4d4c8..8ce40f599b8 100644 --- a/packages/firestore/test/unit/api/document_change.test.ts +++ b/packages/firestore/test/unit/api/document_change.test.ts @@ -18,8 +18,8 @@ import { expect } from 'chai'; import { Query } from '../../../src/api/reference'; -import { ExpUserDataWriter } from '../../../src/api/reference_impl'; import { QuerySnapshot } from '../../../src/api/snapshot'; +import { ExpUserDataWriter } from '../../../src/api/user_data_writer'; import { Query as InternalQuery } from '../../../src/core/query'; import { View } from '../../../src/core/view'; import { documentKeySet } from '../../../src/model/collections'; diff --git a/packages/firestore/test/unit/remote/serializer.helper.ts b/packages/firestore/test/unit/remote/serializer.helper.ts index d523c8fab83..451f7ddf7ae 100644 --- a/packages/firestore/test/unit/remote/serializer.helper.ts +++ b/packages/firestore/test/unit/remote/serializer.helper.ts @@ -28,7 +28,7 @@ import { serverTimestamp, Timestamp } from '../../../src'; -import { ExpUserDataWriter } from '../../../src/api/reference_impl'; +import { ExpUserDataWriter } from '../../../src/api/user_data_writer'; import { DatabaseId } from '../../../src/core/database_info'; import { ArrayContainsAnyFilter, diff --git a/packages/firestore/test/unit/specs/spec_builder.ts b/packages/firestore/test/unit/specs/spec_builder.ts index 80dcd6519de..52dea003e60 100644 --- a/packages/firestore/test/unit/specs/spec_builder.ts +++ b/packages/firestore/test/unit/specs/spec_builder.ts @@ -16,7 +16,7 @@ */ import { IndexConfiguration } from '../../../src/api/index_configuration'; -import { ExpUserDataWriter } from '../../../src/api/reference_impl'; +import { ExpUserDataWriter } from '../../../src/api/user_data_writer'; import { ListenOptions, ListenerDataSource as Source diff --git a/packages/firestore/test/util/api_helpers.ts b/packages/firestore/test/util/api_helpers.ts index 762b5258a29..517167be323 100644 --- a/packages/firestore/test/util/api_helpers.ts +++ b/packages/firestore/test/util/api_helpers.ts @@ -32,7 +32,7 @@ import { EmptyAppCheckTokenProvider, EmptyAuthCredentialsProvider } from '../../src/api/credentials'; -import { ExpUserDataWriter } from '../../src/api/reference_impl'; +import { ExpUserDataWriter } from '../../src/api/user_data_writer'; import { DatabaseId } from '../../src/core/database_info'; import { newQueryForPath, Query as InternalQuery } from '../../src/core/query'; import { diff --git a/repo-scripts/size-analysis/bundle-definitions/firestore.json b/repo-scripts/size-analysis/bundle-definitions/firestore.json index f5ddafd167c..6c1adcad52c 100644 --- a/repo-scripts/size-analysis/bundle-definitions/firestore.json +++ b/repo-scripts/size-analysis/bundle-definitions/firestore.json @@ -128,6 +128,71 @@ } ] }, + { + "name": "Pipeline Query with lt filter", + "dependencies": [ + { + "packageName": "firebase", + "versionOrTag": "latest", + "imports": [ + { + "path": "app", + "imports": [ + "initializeApp" + ] + } + ] + }, + { + "packageName": "firebase", + "versionOrTag": "latest", + "imports": [ + { + "path": "firestore", + "imports": [ + "getFirestore", + "lt", + "Field", + "useFirestorePipelines" + ] + } + ] + } + ] + }, + { + "name": "Pipeline Query with lt plus and function", + "dependencies": [ + { + "packageName": "firebase", + "versionOrTag": "latest", + "imports": [ + { + "path": "app", + "imports": [ + "initializeApp" + ] + } + ] + }, + { + "packageName": "firebase", + "versionOrTag": "latest", + "imports": [ + { + "path": "firestore", + "imports": [ + "getFirestore", + "lt", + "Field", + "useFirestorePipelines", + "andFunction" + ] + } + ] + } + ] + }, { "name": "Query Cursors", "dependencies": [ diff --git a/yarn.lock b/yarn.lock index bd59a038213..cb53a9075cb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -430,6 +430,11 @@ resolved "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.24.1.tgz#f99c36d3593db9540705d0739a1f10b5e20c696e" integrity sha512-2ofRCjnnA9y+wk8b9IAREroeUP02KHp431N2mhKniy2yKIDKpbrHv9eXwm8cBeWQYcJmzv5qKCu65P47eCF7CQ== +"@babel/helper-string-parser@^7.25.7": + version "7.25.7" + resolved "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.7.tgz#d50e8d37b1176207b4fe9acedec386c565a44a54" + integrity sha512-CbkjYdsJNHFk8uqpEkpCvRs3YRp9tY6FmFY7wLMSYuGYkrdUi7r2lc4/wqsvlHoMznX3WJ9IP8giGPq68T/Y6g== + "@babel/helper-validator-identifier@^7.14.5", "@babel/helper-validator-identifier@^7.22.20", "@babel/helper-validator-identifier@^7.22.5": version "7.22.20" resolved "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz" @@ -450,6 +455,11 @@ resolved "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.5.tgz#918b1a7fa23056603506370089bd990d8720db62" integrity sha512-3q93SSKX2TWCG30M2G2kwaKeTYgEUp5Snjuj8qm729SObL6nbtUldAi37qbxkD5gg3xnBio+f9nqpSepGZMvxA== +"@babel/helper-validator-identifier@^7.25.7": + version "7.25.7" + resolved "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.7.tgz#77b7f60c40b15c97df735b38a66ba1d7c3e93da5" + integrity sha512-AM6TzwYqGChO45oiuPqwL2t20/HdMC1rTPAesnBCgPCSF1x3oN9MVUwQV2iyz4xqWrctwK5RNC8LV22kaQCNYg== + "@babel/helper-validator-option@^7.14.5": version "7.14.5" resolved "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.14.5.tgz" @@ -525,6 +535,13 @@ resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.15.7.tgz" integrity sha512-rycZXvQ+xS9QyIcJ9HXeDWf1uxqlbVFAUq0Rq0dbc50Zb/+wUe/ehyfzGfm9KZZF0kBejYgxltBXocP+gKdL2g== +"@babel/parser@^7.20.15": + version "7.25.8" + resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.25.8.tgz#f6aaf38e80c36129460c1657c0762db584c9d5e2" + integrity sha512-HcttkxzdPucv3nNFmfOOMfFf64KgdJVqm1KaCm25dPGMLElo9nsLvXeJECQg8UzPuBGLyTSA0ZzqCtDSzKTEoQ== + dependencies: + "@babel/types" "^7.25.8" + "@babel/parser@^7.24.0", "@babel/parser@^7.24.1": version "7.24.1" resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.24.1.tgz#1e416d3627393fab1cb5b0f2f1796a100ae9133a" @@ -1364,6 +1381,15 @@ "@babel/helper-validator-identifier" "^7.22.20" to-fast-properties "^2.0.0" +"@babel/types@^7.25.8": + version "7.25.8" + resolved "https://registry.npmjs.org/@babel/types/-/types-7.25.8.tgz#5cf6037258e8a9bcad533f4979025140cb9993e1" + integrity sha512-JWtuCu8VQsMladxVz/P4HzHUGCAwpuqacmowgXFs5XjxIgKuNjnLokQzuVjlTvIzODaDmpjT3oxcC48vyk9EWg== + dependencies: + "@babel/helper-string-parser" "^7.25.7" + "@babel/helper-validator-identifier" "^7.25.7" + to-fast-properties "^2.0.0" + "@changesets/apply-release-plan@^6.1.4": version "6.1.4" resolved "https://registry.npmjs.org/@changesets/apply-release-plan/-/apply-release-plan-6.1.4.tgz" @@ -1928,6 +1954,13 @@ resolved "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz" integrity sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg== +"@jsdoc/salty@^0.2.1": + version "0.2.8" + resolved "https://registry.npmjs.org/@jsdoc/salty/-/salty-0.2.8.tgz#8d29923a9429694a437a50ab75004b576131d597" + integrity sha512-5e+SFVavj1ORKlKaKr2BmTOekmXbelU7dC0cDkQLqag7xfuTPuGMUFx7KWJuv4bYZrTsoL2Z18VVCOKYxzoHcg== + dependencies: + lodash "^4.17.21" + "@kwsites/file-exists@^1.1.1": version "1.1.1" resolved "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz" @@ -3435,6 +3468,11 @@ dependencies: "@types/node" "*" +"@types/linkify-it@^5": + version "5.0.0" + resolved "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-5.0.0.tgz#21413001973106cda1c3a9b91eedd4ccd5469d76" + integrity sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q== + "@types/listr@0.14.9": version "0.14.9" resolved "https://registry.npmjs.org/@types/listr/-/listr-0.14.9.tgz#736581cfdfcdb821bace0a3e5b05e91182e00c85" @@ -3448,6 +3486,19 @@ resolved "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz" integrity sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA== +"@types/markdown-it@^14.1.1": + version "14.1.2" + resolved "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-14.1.2.tgz#57f2532a0800067d9b934f3521429a2e8bfb4c61" + integrity sha512-promo4eFwuiW+TfGxhi+0x3czqTYJkG8qB17ZUJiVF10Xm7NLVRSLUsfRTU/6h1e24VvRnXCx+hG7li58lkzog== + dependencies: + "@types/linkify-it" "^5" + "@types/mdurl" "^2" + +"@types/mdurl@^2": + version "2.0.0" + resolved "https://registry.npmjs.org/@types/mdurl/-/mdurl-2.0.0.tgz#d43878b5b20222682163ae6f897b20447233bdfd" + integrity sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg== + "@types/mime@*": version "3.0.1" resolved "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz" @@ -5044,9 +5095,9 @@ blocking-proxy@^1.0.0: dependencies: minimist "^1.2.0" -bluebird@3.7.2: +bluebird@3.7.2, bluebird@^3.7.2: version "3.7.2" - resolved "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz" + resolved "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9: @@ -5529,6 +5580,13 @@ caseless@~0.12.0: resolved "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz" integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= +catharsis@^0.9.0: + version "0.9.0" + resolved "https://registry.npmjs.org/catharsis/-/catharsis-0.9.0.tgz#40382a168be0e6da308c277d3a2b3eb40c7d2121" + integrity sha512-prMTQVpcns/tzFgFVkVp6ak6RykZyWb3gu8ckUpd6YkTlacOd3DXGJjIpD4Q6zJirizvaiAjSSHlOsA+6sNh2A== + dependencies: + lodash "^4.17.15" + chai-as-promised@7.1.1: version "7.1.1" resolved "https://registry.npmjs.org/chai-as-promised/-/chai-as-promised-7.1.1.tgz" @@ -7247,6 +7305,11 @@ ent@~2.2.0: resolved "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz" integrity sha1-6WQhkyWiHQX0RGai9obtbOX13R0= +entities@^4.4.0: + version "4.5.0" + resolved "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz#5d268ea5e7113ec74c4d033b79ea5a35a488fb48" + integrity sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw== + env-paths@^2.2.0: version "2.2.1" resolved "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz" @@ -7532,7 +7595,7 @@ escape-string-regexp@^2.0.0: resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz" integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== -escodegen@^1.8.1: +escodegen@^1.13.0, escodegen@^1.8.1: version "1.14.3" resolved "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz" integrity sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw== @@ -7671,7 +7734,7 @@ esniff@^2.0.1: event-emitter "^0.3.5" type "^2.7.2" -espree@^9.6.0, espree@^9.6.1: +espree@^9.0.0, espree@^9.6.0, espree@^9.6.1: version "9.6.1" resolved "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f" integrity sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ== @@ -9034,7 +9097,7 @@ glob@7.2.3, glob@~7.2.0: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^8.0.1: +glob@^8.0.0, glob@^8.0.1: version "8.1.0" resolved "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz" integrity sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ== @@ -9255,7 +9318,7 @@ graceful-fs@^4.1.6, graceful-fs@^4.2.0: resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz" integrity sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ== -graceful-fs@^4.2.10, graceful-fs@^4.2.9: +graceful-fs@^4.1.9, graceful-fs@^4.2.10, graceful-fs@^4.2.9: version "4.2.11" resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz" integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== @@ -11052,11 +11115,39 @@ js-yaml@~3.13.1: argparse "^1.0.7" esprima "^4.0.0" +js2xmlparser@^4.0.2: + version "4.0.2" + resolved "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.2.tgz#2a1fdf01e90585ef2ae872a01bc169c6a8d5e60a" + integrity sha512-6n4D8gLlLf1n5mNLQPRfViYzu9RATblzPEtm1SthMX1Pjao0r9YI9nw7ZIfRxQMERS87mcswrg+r/OYrPRX6jA== + dependencies: + xmlcreate "^2.0.4" + jsbn@~0.1.0: version "0.1.1" resolved "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz" integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM= +jsdoc@^4.0.0: + version "4.0.3" + resolved "https://registry.npmjs.org/jsdoc/-/jsdoc-4.0.3.tgz#bfee86c6a82f6823e12b5e8be698fd99ae46c061" + integrity sha512-Nu7Sf35kXJ1MWDZIMAuATRQTg1iIPdzh7tqJ6jjvaU/GfDf+qi5UV8zJR3Mo+/pYFvm8mzay4+6O5EWigaQBQw== + dependencies: + "@babel/parser" "^7.20.15" + "@jsdoc/salty" "^0.2.1" + "@types/markdown-it" "^14.1.1" + bluebird "^3.7.2" + catharsis "^0.9.0" + escape-string-regexp "^2.0.0" + js2xmlparser "^4.0.2" + klaw "^3.0.0" + markdown-it "^14.1.0" + markdown-it-anchor "^8.6.7" + marked "^4.0.10" + mkdirp "^1.0.4" + requizzle "^0.2.3" + strip-json-comments "^3.1.0" + underscore "~1.13.2" + jsesc@^1.3.0: version "1.3.0" resolved "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz" @@ -11472,6 +11563,13 @@ klaw-sync@^6.0.0: dependencies: graceful-fs "^4.1.11" +klaw@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz#b11bec9cf2492f06756d6e809ab73a2910259146" + integrity sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g== + dependencies: + graceful-fs "^4.1.9" + kleur@^4.1.4: version "4.1.5" resolved "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz" @@ -11630,6 +11728,13 @@ lines-and-columns@^1.1.6: resolved "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz" integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA= +linkify-it@^5.0.0: + version "5.0.0" + resolved "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz#9ef238bfa6dc70bd8e7f9572b52d369af569b421" + integrity sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ== + dependencies: + uc.micro "^2.0.0" + listr-silent-renderer@^1.1.1: version "1.1.1" resolved "https://registry.npmjs.org/listr-silent-renderer/-/listr-silent-renderer-1.1.1.tgz" @@ -12174,6 +12279,23 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" +markdown-it-anchor@^8.6.7: + version "8.6.7" + resolved "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-8.6.7.tgz#ee6926daf3ad1ed5e4e3968b1740eef1c6399634" + integrity sha512-FlCHFwNnutLgVTflOYHPW2pPcl2AACqVzExlkGQNsi4CJgqOHN7YTgDd4LuhgN1BFO3TS0vLAruV1Td6dwWPJA== + +markdown-it@^14.1.0: + version "14.1.0" + resolved "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz#3c3c5992883c633db4714ccb4d7b5935d98b7d45" + integrity sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg== + dependencies: + argparse "^2.0.1" + entities "^4.4.0" + linkify-it "^5.0.0" + mdurl "^2.0.0" + punycode.js "^2.3.1" + uc.micro "^2.1.0" + marked-terminal@^5.1.1: version "5.1.1" resolved "https://registry.npmjs.org/marked-terminal/-/marked-terminal-5.1.1.tgz" @@ -12191,6 +12313,11 @@ marked@^0.8.0: resolved "https://registry.npmjs.org/marked/-/marked-0.8.2.tgz" integrity sha512-EGwzEeCcLniFX51DhTpmTom+dSA/MG/OBUDjnWtHbEnjAH180VzUeAw+oE4+Zv+CoYBWyRlYOTR0N8SO9R1PVw== +marked@^4.0.10: + version "4.3.0" + resolved "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz#796362821b019f734054582038b116481b456cf3" + integrity sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A== + marked@^4.0.14: version "4.0.18" resolved "https://registry.npmjs.org/marked/-/marked-4.0.18.tgz" @@ -12215,6 +12342,11 @@ md5.js@^1.3.4: inherits "^2.0.1" safe-buffer "^5.1.2" +mdurl@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz#80676ec0433025dd3e17ee983d0fe8de5a2237e0" + integrity sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w== + media-typer@0.3.0: version "0.3.0" resolved "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz" @@ -14280,6 +14412,22 @@ proto3-json-serializer@^1.0.0: dependencies: protobufjs "^6.11.3" +protobufjs-cli@^1.1.3: + version "1.1.3" + resolved "https://registry.npmjs.org/protobufjs-cli/-/protobufjs-cli-1.1.3.tgz#c58b8566784f0fa1aff11e8d875a31de999637fe" + integrity sha512-MqD10lqF+FMsOayFiNOdOGNlXc4iKDCf0ZQPkPR+gizYh9gqUeGTWulABUCdI+N67w5RfJ6xhgX4J8pa8qmMXQ== + dependencies: + chalk "^4.0.0" + escodegen "^1.13.0" + espree "^9.0.0" + estraverse "^5.1.0" + glob "^8.0.0" + jsdoc "^4.0.0" + minimist "^1.2.0" + semver "^7.1.2" + tmp "^0.2.1" + uglify-js "^3.7.7" + protobufjs@6.11.3: version "6.11.3" resolved "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.3.tgz#637a527205a35caa4f3e2a9a4a13ddffe0e7af74" @@ -14441,6 +14589,11 @@ pumpify@^1.3.5: inherits "^2.0.3" pump "^2.0.0" +punycode.js@^2.3.1: + version "2.3.1" + resolved "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz#6b53e56ad75588234e79f4affa90972c7dd8cdb7" + integrity sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA== + punycode@1.3.2: version "1.3.2" resolved "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz" @@ -15074,6 +15227,13 @@ requires-port@^1.0.0: resolved "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz" integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8= +requizzle@^0.2.3: + version "0.2.4" + resolved "https://registry.npmjs.org/requizzle/-/requizzle-0.2.4.tgz#319eb658b28c370f0c20f968fa8ceab98c13d27c" + integrity sha512-JRrFk1D4OQ4SqovXOgdav+K8EAhSB/LJZqCz8tbX0KObcdeM15Ss59ozWMBWmmINMagCwmqn4ZNryUGpBsl6Jw== + dependencies: + lodash "^4.17.21" + resolve-alpn@^1.0.0: version "1.2.1" resolved "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz" @@ -15569,7 +15729,7 @@ semver@^7.0.0, semver@^7.1.1, semver@^7.1.3, semver@^7.3.2, semver@^7.3.4, semve dependencies: lru-cache "^6.0.0" -semver@^7.5.4, semver@^7.6.0: +semver@^7.1.2, semver@^7.5.4, semver@^7.6.0: version "7.6.3" resolved "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143" integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A== @@ -16497,7 +16657,7 @@ strip-indent@^3.0.0: dependencies: min-indent "^1.0.0" -strip-json-comments@3.1.1, strip-json-comments@^3.1.1, strip-json-comments@~3.1.1: +strip-json-comments@3.1.1, strip-json-comments@^3.1.0, strip-json-comments@^3.1.1, strip-json-comments@~3.1.1: version "3.1.1" resolved "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== @@ -17319,11 +17479,21 @@ ua-parser-js@^0.7.30: resolved "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.37.tgz#e464e66dac2d33a7a1251d7d7a99d6157ec27832" integrity sha512-xV8kqRKM+jhMvcHWUKthV9fNebIzrNy//2O9ZwWcfiBFR5f25XVZPLlEajk/sf3Ra15V92isyQqnIEXRDaZWEA== +uc.micro@^2.0.0, uc.micro@^2.1.0: + version "2.1.0" + resolved "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz#f8d3f7d0ec4c3dea35a7e3c8efa4cb8b45c9e7ee" + integrity sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A== + uglify-js@^3.1.4, uglify-js@^3.4.9: version "3.14.2" resolved "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.2.tgz" integrity sha512-rtPMlmcO4agTUfz10CbgJ1k6UAoXM2gWb3GoMPPZB/+/Ackf8lNWk11K4rYi2D0apgoFRLtQOZhb+/iGNJq26A== +uglify-js@^3.7.7: + version "3.19.3" + resolved "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz#82315e9bbc6f2b25888858acd1fff8441035b77f" + integrity sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ== + uid-number@0.0.6: version "0.0.6" resolved "https://registry.npmjs.org/uid-number/-/uid-number-0.0.6.tgz" @@ -17364,6 +17534,11 @@ underscore@>=1.8.3, underscore@^1.9.1: resolved "https://registry.npmjs.org/underscore/-/underscore-1.13.1.tgz" integrity sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g== +underscore@~1.13.2: + version "1.13.7" + resolved "https://registry.npmjs.org/underscore/-/underscore-1.13.7.tgz#970e33963af9a7dda228f17ebe8399e5fbe63a10" + integrity sha512-GMXzWtsc57XAtguZgaQViUOzs0KTkk8ojr3/xAxXLITqf/3EMwxC0inyETfDFjH/Krbhuep0HNbbjI9i/q3F3g== + undertaker-registry@^1.0.0: version "1.0.1" resolved "https://registry.npmjs.org/undertaker-registry/-/undertaker-registry-1.0.1.tgz" @@ -18310,6 +18485,11 @@ xmlbuilder@~11.0.0: resolved "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz" integrity sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA== +xmlcreate@^2.0.4: + version "2.0.4" + resolved "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.4.tgz#0c5ab0f99cdd02a81065fa9cd8f8ae87624889be" + integrity sha512-nquOebG4sngPmGPICTS5EnxqhKbCmz5Ox5hsszI2T6U5qdrJizBc+0ilYSEjTSzU0yZcmvppztXe/5Al5fUwdg== + xregexp@2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz" From ecd931d70ca593574f2df8e802d6465d8dbb3e06 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Mon, 25 Nov 2024 15:22:09 -0700 Subject: [PATCH 45/59] New bundle analysis to evaluate useFirestorePipelines vs execute --- packages/firestore/src/api.ts | 31 +- .../src/api/database_augmentation.ts | 57 - packages/firestore/src/api/pipeline-source.ts | 100 ++ packages/firestore/src/api/pipeline.ts | 66 +- packages/firestore/src/api/pipeline_impl.ts | 112 ++ packages/firestore/src/api_pipelines.ts | 184 +++ .../src/lite-api/database_augmentation.ts | 42 - .../firestore/src/lite-api/expressions.ts | 238 ++-- .../firestore/src/lite-api/pipeline-source.ts | 8 +- packages/firestore/src/lite-api/pipeline.ts | 137 +- .../firestore/src/lite-api/pipeline_impl.ts | 90 +- .../test/integration/api/pipeline.test.ts | 1195 +++++++++-------- .../bundle-definitions/firestore.json | 34 +- 13 files changed, 1410 insertions(+), 884 deletions(-) create mode 100644 packages/firestore/src/api/pipeline-source.ts create mode 100644 packages/firestore/src/api/pipeline_impl.ts create mode 100644 packages/firestore/src/api_pipelines.ts diff --git a/packages/firestore/src/api.ts b/packages/firestore/src/api.ts index 4d33b925706..4a35ed07760 100644 --- a/packages/firestore/src/api.ts +++ b/packages/firestore/src/api.ts @@ -19,9 +19,9 @@ export { PipelineSource } from './lite-api/pipeline-source'; export { PipelineResult } from './lite-api/pipeline-result'; -export { Pipeline, pipeline } from './api/pipeline'; +export { Pipeline } from './api/pipeline'; -export { useFirestorePipelines } from './api/database_augmentation'; +export { useFirestorePipelines, pipeline } from './api/pipeline_impl'; export { execute } from './lite-api/pipeline_impl'; @@ -61,13 +61,13 @@ export { arrayContainsAny, arrayContainsAll, arrayLength, - inAny, - notInAny, + eqAny, + notEqAny, xor, - ifFunction, + cond, not, - logicalMax, - logicalMin, + logicalMaximum, + logicalMinimum, exists, isNan, reverse, @@ -92,8 +92,8 @@ export { avgFunction, andFunction, orFunction, - min, - max, + minimum, + maximum, cosineDistance, dotProduct, euclideanDistance, @@ -132,16 +132,17 @@ export { ArrayContainsAny, ArrayLength, ArrayElement, - In, + EqAny, + NotEqAny, IsNan, Exists, Not, And, Or, Xor, - If, - LogicalMax, - LogicalMin, + Cond, + LogicalMaximum, + LogicalMinimum, Reverse, ReplaceFirst, ReplaceAll, @@ -161,8 +162,8 @@ export { Count, Sum, Avg, - Min, - Max, + Minimum, + Maximum, CosineDistance, DotProduct, EuclideanDistance, diff --git a/packages/firestore/src/api/database_augmentation.ts b/packages/firestore/src/api/database_augmentation.ts index 0eb8c91a034..e69de29bb2d 100644 --- a/packages/firestore/src/api/database_augmentation.ts +++ b/packages/firestore/src/api/database_augmentation.ts @@ -1,57 +0,0 @@ -/** - * @license - * Copyright 2024 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Pipeline } from '../lite-api/pipeline'; -import { PipelineSource } from '../lite-api/pipeline-source'; -import { newUserDataReader } from '../lite-api/user_data_reader'; -import { DocumentKey } from '../model/document_key'; - -import { Firestore } from './database'; -import { DocumentReference, Query } from './reference'; -import { ExpUserDataWriter } from './user_data_writer'; - -export function useFirestorePipelines(): void { - Firestore.prototype.pipeline = function (): PipelineSource { - const firestore = this; - return new PipelineSource( - this, - newUserDataReader(firestore), - new ExpUserDataWriter(firestore), - (key: DocumentKey) => { - return new DocumentReference(firestore, null, key); - } - ); - }; - - Query.prototype.pipeline = function (): Pipeline { - let pipeline; - if (this._query.collectionGroup) { - pipeline = this.firestore - .pipeline() - .collectionGroup(this._query.collectionGroup); - } else { - pipeline = this.firestore - .pipeline() - .collection(this._query.path.canonicalString()); - } - - // TODO(pipeline) convert existing query filters, limits, etc into - // pipeline stages - - return pipeline; - }; -} diff --git a/packages/firestore/src/api/pipeline-source.ts b/packages/firestore/src/api/pipeline-source.ts new file mode 100644 index 00000000000..31a2d9d69a5 --- /dev/null +++ b/packages/firestore/src/api/pipeline-source.ts @@ -0,0 +1,100 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { PipelineSource as LitePipelineSoure } from '../lite-api/pipeline-source'; +import { + CollectionGroupSource, + CollectionSource, + DatabaseSource, + DocumentsSource +} from '../lite-api/stage'; +import { UserDataReader } from '../lite-api/user_data_reader'; +import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; +import { DocumentKey } from '../model/document_key'; +import { cast } from '../util/input_validation'; + +import { Firestore } from './database'; +import { Pipeline } from './pipeline'; +import { DocumentReference } from './reference'; + +/** + * Represents the source of a Firestore {@link Pipeline}. + * @beta + */ +export class PipelineSource extends LitePipelineSoure { + /** + * @internal + * @private + * @param db + * @param userDataReader + * @param userDataWriter + * @param documentReferenceFactory + */ + // eslint-disable-next-line @typescript-eslint/no-useless-constructor + constructor( + db: Firestore, + userDataReader: UserDataReader, + userDataWriter: AbstractUserDataWriter, + documentReferenceFactory: (id: DocumentKey) => DocumentReference + ) { + super(db, userDataReader, userDataWriter, documentReferenceFactory); + } + + collection(collectionPath: string): Pipeline { + const db = cast(this.db, Firestore); + return new Pipeline( + db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + [new CollectionSource(collectionPath)] + ); + } + + collectionGroup(collectionId: string): Pipeline { + const db = cast(this.db, Firestore); + return new Pipeline( + db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + [new CollectionGroupSource(collectionId)] + ); + } + + database(): Pipeline { + const db = cast(this.db, Firestore); + return new Pipeline( + db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + [new DatabaseSource()] + ); + } + + documents(docs: DocumentReference[]): Pipeline { + const db = cast(this.db, Firestore); + return new Pipeline( + db, + this.userDataReader, + this.userDataWriter, + this.documentReferenceFactory, + [DocumentsSource.of(docs)] + ); + } +} diff --git a/packages/firestore/src/api/pipeline.ts b/packages/firestore/src/api/pipeline.ts index 14532ba85c0..029e2d53eeb 100644 --- a/packages/firestore/src/api/pipeline.ts +++ b/packages/firestore/src/api/pipeline.ts @@ -15,18 +15,15 @@ * limitations under the License. */ -import { firestoreClientExecutePipeline } from '../core/firestore_client'; import { Pipeline as LitePipeline } from '../lite-api/pipeline'; import { PipelineResult } from '../lite-api/pipeline-result'; -import { PipelineSource } from '../lite-api/pipeline-source'; -import { DocumentData, DocumentReference, Query } from '../lite-api/reference'; +import { DocumentData, DocumentReference } from '../lite-api/reference'; import { Stage } from '../lite-api/stage'; import { UserDataReader } from '../lite-api/user_data_reader'; import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; import { DocumentKey } from '../model/document_key'; -import { cast } from '../util/input_validation'; -import { ensureFirestoreConfigured, Firestore } from './database'; +import { Firestore } from './database'; export class Pipeline< AppModelType = DocumentData @@ -61,6 +58,24 @@ export class Pipeline< ); } + protected newPipeline( + db: Firestore, + userDataReader: UserDataReader, + userDataWriter: AbstractUserDataWriter, + documentReferenceFactory: (id: DocumentKey) => DocumentReference, + stages: Stage[], + converter: unknown = {} + ): Pipeline { + return new Pipeline( + db, + userDataReader, + userDataWriter, + documentReferenceFactory, + stages, + converter + ); + } + /** * Executes this pipeline and returns a Promise to represent the asynchronous operation. * @@ -93,43 +108,8 @@ export class Pipeline< * @return A Promise representing the asynchronous pipeline execution. */ execute(): Promise>> { - const firestore = cast(this._db, Firestore); - const client = ensureFirestoreConfigured(firestore); - return firestoreClientExecutePipeline(client, this).then(result => { - const docs = result.map( - element => - new PipelineResult( - this.userDataWriter, - element.key?.path - ? this.documentReferenceFactory(element.key) - : undefined, - element.fields, - element.executionTime?.toTimestamp(), - element.createTime?.toTimestamp(), - element.updateTime?.toTimestamp() - //this.converter - ) - ); - - return docs; - }); + throw new Error( + 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' + ); } } - -/** - * Experimental Modular API for console testing. - * @param firestore - */ -export function pipeline(firestore: Firestore): PipelineSource; - -/** - * Experimental Modular API for console testing. - * @param query - */ -export function pipeline(query: Query): Pipeline; - -export function pipeline( - firestoreOrQuery: Firestore | Query -): PipelineSource | Pipeline { - return firestoreOrQuery.pipeline(); -} diff --git a/packages/firestore/src/api/pipeline_impl.ts b/packages/firestore/src/api/pipeline_impl.ts new file mode 100644 index 00000000000..91163eff3c2 --- /dev/null +++ b/packages/firestore/src/api/pipeline_impl.ts @@ -0,0 +1,112 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Pipeline } from '../api/pipeline'; +import { PipelineSource } from '../api/pipeline-source'; +import { PipelineResult } from '../api_pipelines'; +import { firestoreClientExecutePipeline } from '../core/firestore_client'; +import { newUserDataReader } from '../lite-api/user_data_reader'; +import { DocumentKey } from '../model/document_key'; +import { cast } from '../util/input_validation'; + +import { Firestore, ensureFirestoreConfigured } from './database'; +import { DocumentReference, Query } from './reference'; +import { ExpUserDataWriter } from './user_data_writer'; + +/** + * Experimental Modular API for console testing. + * @param firestore + */ +export function pipeline(firestore: Firestore): PipelineSource; + +/** + * Experimental Modular API for console testing. + * @param query + */ +export function pipeline(query: Query): Pipeline; + +export function pipeline( + firestoreOrQuery: Firestore | Query +): PipelineSource | Pipeline { + if (firestoreOrQuery instanceof Firestore) { + const firestore = firestoreOrQuery; + return new PipelineSource( + firestore, + newUserDataReader(firestore), + new ExpUserDataWriter(firestore), + (key: DocumentKey) => { + return new DocumentReference(firestore, null, key); + } + ); + } else { + let result; + const query = firestoreOrQuery; + const db = cast(query.firestore, Firestore); + if (query._query.collectionGroup) { + result = pipeline(db).collectionGroup(query._query.collectionGroup); + } else { + result = pipeline(db).collection(query._query.path.canonicalString()); + } + + // TODO(pipeline) convert existing query filters, limits, etc into + // pipeline stages + + return result; + } +} +export function useFirestorePipelines(): void { + Firestore.prototype.pipeline = function (): PipelineSource { + return pipeline(this); + }; + + Query.prototype.pipeline = function (): Pipeline { + return pipeline(this); + }; + + Pipeline.prototype.execute = function (): Promise { + return execute(this); + }; +} + +export function execute( + pipeline: Pipeline +): Promise>> { + const firestore = cast(pipeline._db, Firestore); + const client = ensureFirestoreConfigured(firestore); + return firestoreClientExecutePipeline(client, pipeline).then(result => { + const docs = result + // Currently ignore any response from ExecutePipeline that does + // not contain any document data in the `fields` property. + .filter(element => !!element.fields) + .map( + element => + new PipelineResult( + pipeline._userDataWriter, + element.key?.path + ? pipeline._documentReferenceFactory(element.key) + : undefined, + element.fields, + element.executionTime?.toTimestamp(), + element.createTime?.toTimestamp(), + element.updateTime?.toTimestamp() + //this.converter + ) + ); + + return docs; + }); +} diff --git a/packages/firestore/src/api_pipelines.ts b/packages/firestore/src/api_pipelines.ts new file mode 100644 index 00000000000..658794098ea --- /dev/null +++ b/packages/firestore/src/api_pipelines.ts @@ -0,0 +1,184 @@ +/** + * @license + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export { PipelineSource } from './lite-api/pipeline-source'; + +export { PipelineResult } from './lite-api/pipeline-result'; + +export { Pipeline } from './lite-api/pipeline'; + +export { useFirestorePipelines } from './api/database_augmentation'; + +export { + Stage, + FindNearestOptions, + AddFields, + Aggregate, + Distinct, + CollectionSource, + CollectionGroupSource, + DatabaseSource, + DocumentsSource, + Where, + FindNearest, + Limit, + Offset, + Select, + Sort, + GenericStage +} from './lite-api/stage'; + +export { + add, + subtract, + multiply, + divide, + mod, + eq, + neq, + lt, + lte, + gt, + gte, + arrayConcat, + arrayContains, + arrayContainsAny, + arrayContainsAll, + arrayLength, + eqAny, + notEqAny, + xor, + cond, + not, + logicalMaximum, + logicalMinimum, + exists, + isNan, + reverse, + replaceFirst, + replaceAll, + byteLength, + charLength, + like, + regexContains, + regexMatch, + strContains, + startsWith, + endsWith, + toLower, + toUpper, + trim, + strConcat, + mapGet, + countAll, + countFunction, + sumFunction, + avgFunction, + andFunction, + orFunction, + minimum, + maximum, + cosineDistance, + dotProduct, + euclideanDistance, + vectorLength, + unixMicrosToTimestamp, + timestampToUnixMicros, + unixMillisToTimestamp, + timestampToUnixMillis, + unixSecondsToTimestamp, + timestampToUnixSeconds, + timestampAdd, + timestampSub, + genericFunction, + ascending, + descending, + ExprWithAlias, + Field, + Fields, + Constant, + FirestoreFunction, + Add, + Subtract, + Multiply, + Divide, + Mod, + Eq, + Neq, + Lt, + Lte, + Gt, + Gte, + ArrayConcat, + ArrayReverse, + ArrayContains, + ArrayContainsAll, + ArrayContainsAny, + ArrayLength, + ArrayElement, + EqAny, + NotEqAny, + IsNan, + Exists, + Not, + And, + Or, + Xor, + Cond, + LogicalMaximum, + LogicalMinimum, + Reverse, + ReplaceFirst, + ReplaceAll, + CharLength, + ByteLength, + Like, + RegexContains, + RegexMatch, + StrContains, + StartsWith, + EndsWith, + ToLower, + ToUpper, + Trim, + StrConcat, + MapGet, + Count, + Sum, + Avg, + Minimum, + Maximum, + CosineDistance, + DotProduct, + EuclideanDistance, + VectorLength, + UnixMicrosToTimestamp, + TimestampToUnixMicros, + UnixMillisToTimestamp, + TimestampToUnixMillis, + UnixSecondsToTimestamp, + TimestampToUnixSeconds, + TimestampAdd, + TimestampSub, + Ordering, + ExprType, + AccumulatorTarget, + FilterExpr, + SelectableExpr, + Selectable, + FilterCondition, + Accumulator +} from './lite-api/expressions'; diff --git a/packages/firestore/src/lite-api/database_augmentation.ts b/packages/firestore/src/lite-api/database_augmentation.ts index 14b9cf101c5..bf25e9c59c8 100644 --- a/packages/firestore/src/lite-api/database_augmentation.ts +++ b/packages/firestore/src/lite-api/database_augmentation.ts @@ -14,45 +14,3 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -import { DocumentKey } from '../model/document_key'; - -import { Firestore } from './database'; -import { Pipeline } from './pipeline'; -import { PipelineSource } from './pipeline-source'; -import { DocumentReference, Query } from './reference'; -import { LiteUserDataWriter } from './reference_impl'; -import { newUserDataReader } from './user_data_reader'; - -export function useFirestorePipelines(): void { - Firestore.prototype.pipeline = function (): PipelineSource { - const userDataWriter = new LiteUserDataWriter(this); - const userDataReader = newUserDataReader(this); - return new PipelineSource( - this, - userDataReader, - userDataWriter, - (key: DocumentKey) => { - return new DocumentReference(this, null, key); - } - ); - }; - - Query.prototype.pipeline = function (): Pipeline { - let pipeline; - if (this._query.collectionGroup) { - pipeline = this.firestore - .pipeline() - .collectionGroup(this._query.collectionGroup); - } else { - pipeline = this.firestore - .pipeline() - .collection(this._query.path.canonicalString()); - } - - // TODO(pipeline) convert existing query filters, limits, etc into - // pipeline stages - - return pipeline; - }; -} diff --git a/packages/firestore/src/lite-api/expressions.ts b/packages/firestore/src/lite-api/expressions.ts index 26a2f7c617c..3ec68601e9e 100644 --- a/packages/firestore/src/lite-api/expressions.ts +++ b/packages/firestore/src/lite-api/expressions.ts @@ -804,13 +804,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' - * Field.of("category").in("Electronics", Field.of("primaryType")); + * Field.of("category").eqAny("Electronics", Field.of("primaryType")); * ``` * * @param others The values or expressions to check against. * @return A new `Expr` representing the 'IN' comparison. */ - in(...others: Expr[]): In; + eqAny(...others: Expr[]): EqAny; /** * Creates an expression that checks if this expression is equal to any of the provided values or @@ -818,18 +818,52 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' - * Field.of("category").in("Electronics", Field.of("primaryType")); + * Field.of("category").eqAny("Electronics", Field.of("primaryType")); * ``` * * @param others The values or expressions to check against. * @return A new `Expr` representing the 'IN' comparison. */ - in(...others: any[]): In; - in(...others: any[]): In { + eqAny(...others: any[]): EqAny; + eqAny(...others: any[]): EqAny { const exprOthers = others.map(other => other instanceof Expr ? other : Constant.of(other) ); - return new In(this, exprOthers); + return new EqAny(this, exprOthers); + } + + /** + * Creates an expression that checks if this expression is not equal to any of the provided values or + * expressions. + * + * ```typescript + * // Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' + * Field.of("status").notEqAny("pending", Field.of("rejectedStatus")); + * ``` + * + * @param others The values or expressions to check against. + * @return A new `Expr` representing the 'NotEqAny' comparison. + */ + notEqAny(...others: Expr[]): NotEqAny; + + /** + * Creates an expression that checks if this expression is not equal to any of the provided values or + * expressions. + * + * ```typescript + * // Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' + * Field.of("status").notEqAny("pending", Field.of("rejectedStatus")); + * ``` + * + * @param others The values or expressions to check against. + * @return A new `Expr` representing the 'NotEqAny' comparison. + */ + notEqAny(...others: any[]): NotEqAny; + notEqAny(...others: any[]): NotEqAny { + const exprOthers = others.map(other => + other instanceof Expr ? other : Constant.of(other) + ); + return new NotEqAny(this, exprOthers); } /** @@ -1300,13 +1334,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Find the lowest price of all products - * Field.of("price").min().as("lowestPrice"); + * Field.of("price").minimum().as("lowestPrice"); * ``` * * @return A new `Accumulator` representing the 'min' aggregation. */ - min(): Min { - return new Min(this, false); + minimum(): Minimum { + return new Minimum(this, false); } /** @@ -1314,13 +1348,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Find the highest score in a leaderboard - * Field.of("score").max().as("highestScore"); + * Field.of("score").maximum().as("highestScore"); * ``` * * @return A new `Accumulator` representing the 'max' aggregation. */ - max(): Max { - return new Max(this, false); + maximum(): Maximum { + return new Maximum(this, false); } /** @@ -1328,31 +1362,31 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Returns the larger value between the 'timestamp' field and the current timestamp. - * Field.of("timestamp").logicalMax(Function.currentTimestamp()); + * Field.of("timestamp").logicalMaximum(Function.currentTimestamp()); * ``` * * @param other The expression to compare with. * @return A new {@code Expr} representing the logical max operation. */ - logicalMax(other: Expr): LogicalMax; + logicalMaximum(other: Expr): LogicalMaximum; /** * Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. * * ```typescript * // Returns the larger value between the 'value' field and 10. - * Field.of("value").logicalMax(10); + * Field.of("value").logicalMaximum(10); * ``` * * @param other The constant value to compare with. * @return A new {@code Expr} representing the logical max operation. */ - logicalMax(other: any): LogicalMax; - logicalMax(other: any): LogicalMax { + logicalMaximum(other: any): LogicalMaximum; + logicalMaximum(other: any): LogicalMaximum { if (other instanceof Expr) { - return new LogicalMax(this, other as Expr); + return new LogicalMaximum(this, other as Expr); } - return new LogicalMax(this, Constant.of(other)); + return new LogicalMaximum(this, Constant.of(other)); } /** @@ -1360,31 +1394,31 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Returns the smaller value between the 'timestamp' field and the current timestamp. - * Field.of("timestamp").logicalMin(Function.currentTimestamp()); + * Field.of("timestamp").logicalMinimum(Function.currentTimestamp()); * ``` * * @param other The expression to compare with. * @return A new {@code Expr} representing the logical min operation. */ - logicalMin(other: Expr): LogicalMin; + logicalMinimum(other: Expr): LogicalMinimum; /** * Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. * * ```typescript * // Returns the smaller value between the 'value' field and 10. - * Field.of("value").logicalMin(10); + * Field.of("value").logicalMinimum(10); * ``` * * @param other The constant value to compare with. * @return A new {@code Expr} representing the logical min operation. */ - logicalMin(other: any): LogicalMin; - logicalMin(other: any): LogicalMin { + logicalMinimum(other: any): LogicalMinimum; + logicalMinimum(other: any): LogicalMinimum { if (other instanceof Expr) { - return new LogicalMin(this, other as Expr); + return new LogicalMinimum(this, other as Expr); } - return new LogicalMin(this, Constant.of(other)); + return new LogicalMinimum(this, Constant.of(other)); } /** @@ -2472,9 +2506,19 @@ export class ArrayElement extends FirestoreFunction { /** * @beta */ -export class In extends FirestoreFunction implements FilterCondition { +export class EqAny extends FirestoreFunction implements FilterCondition { + constructor(private left: Expr, private others: Expr[]) { + super('eq_any', [left, new ListOfExprs(others)]); + } + filterable = true as const; +} + +/** + * @beta + */ +export class NotEqAny extends FirestoreFunction implements FilterCondition { constructor(private left: Expr, private others: Expr[]) { - super('in', [left, new ListOfExprs(others)]); + super('not_eq_any', [left, new ListOfExprs(others)]); } filterable = true as const; } @@ -2543,13 +2587,13 @@ export class Xor extends FirestoreFunction implements FilterCondition { /** * @beta */ -export class If extends FirestoreFunction implements FilterCondition { +export class Cond extends FirestoreFunction implements FilterCondition { constructor( private condition: FilterExpr, private thenExpr: Expr, private elseExpr: Expr ) { - super('if', [condition, thenExpr, elseExpr]); + super('cond', [condition, thenExpr, elseExpr]); } filterable = true as const; } @@ -2557,18 +2601,18 @@ export class If extends FirestoreFunction implements FilterCondition { /** * @beta */ -export class LogicalMax extends FirestoreFunction { +export class LogicalMaximum extends FirestoreFunction { constructor(private left: Expr, private right: Expr) { - super('logical_max', [left, right]); + super('logical_maximum', [left, right]); } } /** * @beta */ -export class LogicalMin extends FirestoreFunction { +export class LogicalMinimum extends FirestoreFunction { constructor(private left: Expr, private right: Expr) { - super('logical_min', [left, right]); + super('logical_minimum', [left, right]); } } @@ -2758,20 +2802,20 @@ export class Avg extends FirestoreFunction implements Accumulator { /** * @beta */ -export class Min extends FirestoreFunction implements Accumulator { +export class Minimum extends FirestoreFunction implements Accumulator { accumulator = true as const; constructor(private value: Expr, private distinct: boolean) { - super('min', [value]); + super('minimum', [value]); } } /** * @beta */ -export class Max extends FirestoreFunction implements Accumulator { +export class Maximum extends FirestoreFunction implements Accumulator { accumulator = true as const; constructor(private value: Expr, private distinct: boolean) { - super('max', [value]); + super('maximum', [value]); } } @@ -4378,14 +4422,14 @@ export function arrayLength(array: Expr): ArrayLength { * * ```typescript * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' - * inAny(Field.of("category"), [Constant.of("Electronics"), Field.of("primaryType")]); + * eqAny(Field.of("category"), [Constant.of("Electronics"), Field.of("primaryType")]); * ``` * * @param element The expression to compare. * @param others The values to check against. * @return A new {@code Expr} representing the 'IN' comparison. */ -export function inAny(element: Expr, others: Expr[]): In; +export function eqAny(element: Expr, others: Expr[]): EqAny; /** * @beta @@ -4395,14 +4439,14 @@ export function inAny(element: Expr, others: Expr[]): In; * * ```typescript * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' - * inAny(Field.of("category"), ["Electronics", Field.of("primaryType")]); + * eqAny(Field.of("category"), ["Electronics", Field.of("primaryType")]); * ``` * * @param element The expression to compare. * @param others The values to check against. * @return A new {@code Expr} representing the 'IN' comparison. */ -export function inAny(element: Expr, others: any[]): In; +export function eqAny(element: Expr, others: any[]): EqAny; /** * @beta @@ -4412,14 +4456,14 @@ export function inAny(element: Expr, others: any[]): In; * * ```typescript * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' - * inAny("category", [Constant.of("Electronics"), Field.of("primaryType")]); + * eqAny("category", [Constant.of("Electronics"), Field.of("primaryType")]); * ``` * * @param element The field to compare. * @param others The values to check against. * @return A new {@code Expr} representing the 'IN' comparison. */ -export function inAny(element: string, others: Expr[]): In; +export function eqAny(element: string, others: Expr[]): EqAny; /** * @beta @@ -4429,20 +4473,20 @@ export function inAny(element: string, others: Expr[]): In; * * ```typescript * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' - * inAny("category", ["Electronics", Field.of("primaryType")]); + * eqAny("category", ["Electronics", Field.of("primaryType")]); * ``` * * @param element The field to compare. * @param others The values to check against. * @return A new {@code Expr} representing the 'IN' comparison. */ -export function inAny(element: string, others: any[]): In; -export function inAny(element: Expr | string, others: any[]): In { +export function eqAny(element: string, others: any[]): EqAny; +export function eqAny(element: Expr | string, others: any[]): EqAny { const elementExpr = element instanceof Expr ? element : Field.of(element); const exprOthers = others.map(other => other instanceof Expr ? other : Constant.of(other) ); - return new In(elementExpr, exprOthers); + return new EqAny(elementExpr, exprOthers); } /** @@ -4453,14 +4497,14 @@ export function inAny(element: Expr | string, others: any[]): In { * * ```typescript * // Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' - * notInAny(Field.of("status"), [Constant.of("pending"), Field.of("rejectedStatus")]); + * notEqAny(Field.of("status"), [Constant.of("pending"), Field.of("rejectedStatus")]); * ``` * * @param element The expression to compare. * @param others The values to check against. * @return A new {@code Expr} representing the 'NOT IN' comparison. */ -export function notInAny(element: Expr, others: Expr[]): Not; +export function notEqAny(element: Expr, others: Expr[]): NotEqAny; /** * @beta @@ -4470,14 +4514,14 @@ export function notInAny(element: Expr, others: Expr[]): Not; * * ```typescript * // Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' - * notInAny(Field.of("status"), ["pending", Field.of("rejectedStatus")]); + * notEqAny(Field.of("status"), ["pending", Field.of("rejectedStatus")]); * ``` * * @param element The expression to compare. * @param others The values to check against. * @return A new {@code Expr} representing the 'NOT IN' comparison. */ -export function notInAny(element: Expr, others: any[]): Not; +export function notEqAny(element: Expr, others: any[]): NotEqAny; /** * @beta @@ -4487,14 +4531,14 @@ export function notInAny(element: Expr, others: any[]): Not; * * ```typescript * // Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' - * notInAny("status", [Constant.of("pending"), Field.of("rejectedStatus")]); + * notEqAny("status", [Constant.of("pending"), Field.of("rejectedStatus")]); * ``` * * @param element The field name to compare. * @param others The values to check against. * @return A new {@code Expr} representing the 'NOT IN' comparison. */ -export function notInAny(element: string, others: Expr[]): Not; +export function notEqAny(element: string, others: Expr[]): NotEqAny; /** * @beta @@ -4504,20 +4548,20 @@ export function notInAny(element: string, others: Expr[]): Not; * * ```typescript * // Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' - * notInAny("status", ["pending", Field.of("rejectedStatus")]); + * notEqAny("status", ["pending", Field.of("rejectedStatus")]); * ``` * * @param element The field name to compare. * @param others The values to check against. * @return A new {@code Expr} representing the 'NOT IN' comparison. */ -export function notInAny(element: string, others: any[]): Not; -export function notInAny(element: Expr | string, others: any[]): Not { +export function notEqAny(element: string, others: any[]): NotEqAny; +export function notEqAny(element: Expr | string, others: any[]): NotEqAny { const elementExpr = element instanceof Expr ? element : Field.of(element); const exprOthers = others.map(other => other instanceof Expr ? other : Constant.of(other) ); - return new Not(new In(elementExpr, exprOthers)); + return new NotEqAny(elementExpr, exprOthers); } /** @@ -4551,7 +4595,7 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor { * * ```typescript * // If 'age' is greater than 18, return "Adult"; otherwise, return "Minor". - * ifFunction( + * cond( * gt("age", 18), Constant.of("Adult"), Constant.of("Minor")); * ``` * @@ -4560,12 +4604,12 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor { * @param elseExpr The expression to evaluate if the condition is false. * @return A new {@code Expr} representing the conditional expression. */ -export function ifFunction( +export function cond( condition: FilterExpr, thenExpr: Expr, elseExpr: Expr -): If { - return new If(condition, thenExpr, elseExpr); +): Cond { + return new Cond(condition, thenExpr, elseExpr); } /** @@ -4592,14 +4636,14 @@ export function not(filter: FilterExpr): Not { * * ```typescript * // Returns the larger value between the 'field1' field and the 'field2' field. - * logicalMax(Field.of("field1"), Field.of("field2")); + * logicalMaximum(Field.of("field1"), Field.of("field2")); * ``` * * @param left The left operand expression. * @param right The right operand expression. * @return A new {@code Expr} representing the logical max operation. */ -export function logicalMax(left: Expr, right: Expr): LogicalMax; +export function logicalMaximum(left: Expr, right: Expr): LogicalMaximum; /** * @beta @@ -4608,14 +4652,14 @@ export function logicalMax(left: Expr, right: Expr): LogicalMax; * * ```typescript * // Returns the larger value between the 'value' field and 10. - * logicalMax(Field.of("value"), 10); + * logicalMaximum(Field.of("value"), 10); * ``` * * @param left The left operand expression. * @param right The right operand constant. * @return A new {@code Expr} representing the logical max operation. */ -export function logicalMax(left: Expr, right: any): LogicalMax; +export function logicalMaximum(left: Expr, right: any): LogicalMaximum; /** * @beta @@ -4624,14 +4668,14 @@ export function logicalMax(left: Expr, right: any): LogicalMax; * * ```typescript * // Returns the larger value between the 'field1' field and the 'field2' field. - * logicalMax("field1", Field.of('field2')); + * logicalMaximum("field1", Field.of('field2')); * ``` * * @param left The left operand field name. * @param right The right operand expression. * @return A new {@code Expr} representing the logical max operation. */ -export function logicalMax(left: string, right: Expr): LogicalMax; +export function logicalMaximum(left: string, right: Expr): LogicalMaximum; /** * @beta @@ -4640,18 +4684,21 @@ export function logicalMax(left: string, right: Expr): LogicalMax; * * ```typescript * // Returns the larger value between the 'value' field and 10. - * logicalMax("value", 10); + * logicalMaximum("value", 10); * ``` * * @param left The left operand field name. * @param right The right operand constant. * @return A new {@code Expr} representing the logical max operation. */ -export function logicalMax(left: string, right: any): LogicalMax; -export function logicalMax(left: Expr | string, right: Expr | any): LogicalMax { +export function logicalMaximum(left: string, right: any): LogicalMaximum; +export function logicalMaximum( + left: Expr | string, + right: Expr | any +): LogicalMaximum { const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; const normalizedRight = right instanceof Expr ? right : Constant.of(right); - return new LogicalMax(normalizedLeft, normalizedRight); + return new LogicalMaximum(normalizedLeft, normalizedRight); } /** @@ -4661,14 +4708,14 @@ export function logicalMax(left: Expr | string, right: Expr | any): LogicalMax { * * ```typescript * // Returns the smaller value between the 'field1' field and the 'field2' field. - * logicalMin(Field.of("field1"), Field.of("field2")); + * logicalMinimum(Field.of("field1"), Field.of("field2")); * ``` * * @param left The left operand expression. * @param right The right operand expression. * @return A new {@code Expr} representing the logical min operation. */ -export function logicalMin(left: Expr, right: Expr): LogicalMin; +export function logicalMinimum(left: Expr, right: Expr): LogicalMinimum; /** * @beta @@ -4677,14 +4724,14 @@ export function logicalMin(left: Expr, right: Expr): LogicalMin; * * ```typescript * // Returns the smaller value between the 'value' field and 10. - * logicalMin(Field.of("value"), 10); + * logicalMinimum(Field.of("value"), 10); * ``` * * @param left The left operand expression. * @param right The right operand constant. * @return A new {@code Expr} representing the logical min operation. */ -export function logicalMin(left: Expr, right: any): LogicalMin; +export function logicalMinimum(left: Expr, right: any): LogicalMinimum; /** * @beta @@ -4693,14 +4740,14 @@ export function logicalMin(left: Expr, right: any): LogicalMin; * * ```typescript * // Returns the smaller value between the 'field1' field and the 'field2' field. - * logicalMin("field1", Field.of("field2")); + * logicalMinimum("field1", Field.of("field2")); * ``` * * @param left The left operand field name. * @param right The right operand expression. * @return A new {@code Expr} representing the logical min operation. */ -export function logicalMin(left: string, right: Expr): LogicalMin; +export function logicalMinimum(left: string, right: Expr): LogicalMinimum; /** * @beta @@ -4709,18 +4756,21 @@ export function logicalMin(left: string, right: Expr): LogicalMin; * * ```typescript * // Returns the smaller value between the 'value' field and 10. - * logicalMin("value", 10); + * logicalMinimum("value", 10); * ``` * * @param left The left operand field name. * @param right The right operand constant. * @return A new {@code Expr} representing the logical min operation. */ -export function logicalMin(left: string, right: any): LogicalMin; -export function logicalMin(left: Expr | string, right: Expr | any): LogicalMin { +export function logicalMinimum(left: string, right: any): LogicalMinimum; +export function logicalMinimum( + left: Expr | string, + right: Expr | any +): LogicalMinimum { const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; const normalizedRight = right instanceof Expr ? right : Constant.of(right); - return new LogicalMin(normalizedLeft, normalizedRight); + return new LogicalMinimum(normalizedLeft, normalizedRight); } /** @@ -5786,13 +5836,13 @@ export function avgFunction(value: Expr | string): Avg { * * ```typescript * // Find the lowest price of all products - * min(Field.of("price")).as("lowestPrice"); + * minimum(Field.of("price")).as("lowestPrice"); * ``` * * @param value The expression to find the minimum value of. * @return A new {@code Accumulator} representing the 'min' aggregation. */ -export function min(value: Expr): Min; +export function minimum(value: Expr): Minimum; /** * @beta @@ -5801,16 +5851,16 @@ export function min(value: Expr): Min; * * ```typescript * // Find the lowest price of all products - * min("price").as("lowestPrice"); + * minimum("price").as("lowestPrice"); * ``` * * @param value The name of the field to find the minimum value of. * @return A new {@code Accumulator} representing the 'min' aggregation. */ -export function min(value: string): Min; -export function min(value: Expr | string): Min { +export function minimum(value: string): Minimum; +export function minimum(value: Expr | string): Minimum { const exprValue = value instanceof Expr ? value : Field.of(value); - return new Min(exprValue, false); + return new Minimum(exprValue, false); } /** @@ -5821,13 +5871,13 @@ export function min(value: Expr | string): Min { * * ```typescript * // Find the highest score in a leaderboard - * max(Field.of("score")).as("highestScore"); + * maximum(Field.of("score")).as("highestScore"); * ``` * * @param value The expression to find the maximum value of. * @return A new {@code Accumulator} representing the 'max' aggregation. */ -export function max(value: Expr): Max; +export function maximum(value: Expr): Maximum; /** * @beta @@ -5836,16 +5886,16 @@ export function max(value: Expr): Max; * * ```typescript * // Find the highest score in a leaderboard - * max("score").as("highestScore"); + * maximum("score").as("highestScore"); * ``` * * @param value The name of the field to find the maximum value of. * @return A new {@code Accumulator} representing the 'max' aggregation. */ -export function max(value: string): Max; -export function max(value: Expr | string): Max { +export function maximum(value: string): Maximum; +export function maximum(value: Expr | string): Maximum { const exprValue = value instanceof Expr ? value : Field.of(value); - return new Max(exprValue, false); + return new Maximum(exprValue, false); } /** diff --git a/packages/firestore/src/lite-api/pipeline-source.ts b/packages/firestore/src/lite-api/pipeline-source.ts index a79c5cafc31..da62a229adc 100644 --- a/packages/firestore/src/lite-api/pipeline-source.ts +++ b/packages/firestore/src/lite-api/pipeline-source.ts @@ -43,10 +43,10 @@ export class PipelineSource { * @param documentReferenceFactory */ constructor( - private db: Firestore, - private userDataReader: UserDataReader, - private userDataWriter: AbstractUserDataWriter, - private documentReferenceFactory: (id: DocumentKey) => DocumentReference + protected db: Firestore, + protected userDataReader: UserDataReader, + protected userDataWriter: AbstractUserDataWriter, + protected documentReferenceFactory: (id: DocumentKey) => DocumentReference ) {} collection(collectionPath: string): Pipeline { diff --git a/packages/firestore/src/lite-api/pipeline.ts b/packages/firestore/src/lite-api/pipeline.ts index 4d13d5dfddd..f835f709551 100644 --- a/packages/firestore/src/lite-api/pipeline.ts +++ b/packages/firestore/src/lite-api/pipeline.ts @@ -24,14 +24,12 @@ import { StructuredPipeline, Stage as ProtoStage } from '../protos/firestore_proto_api'; -import { invokeExecutePipeline } from '../remote/datastore'; import { getEncodedDatabaseId, JsonProtoSerializer, ProtoSerializable } from '../remote/serializer'; -import { getDatastore } from './components'; import { Firestore } from './database'; import { Accumulator, @@ -45,8 +43,7 @@ import { Selectable } from './expressions'; import { PipelineResult } from './pipeline-result'; -import { PipelineSource } from './pipeline-source'; -import { DocumentData, DocumentReference, Query } from './reference'; +import { DocumentData, DocumentReference } from './reference'; import { AddFields, Aggregate, @@ -130,8 +127,8 @@ export class Pipeline * @private * @param _db * @param userDataReader - * @param userDataWriter - * @param documentReferenceFactory + * @param _userDataWriter + * @param _documentReferenceFactory * @param stages * @param converter */ @@ -146,12 +143,12 @@ export class Pipeline * @internal * @private */ - protected userDataWriter: AbstractUserDataWriter, + public _userDataWriter: AbstractUserDataWriter, /** * @internal * @private */ - protected documentReferenceFactory: (id: DocumentKey) => DocumentReference, + public _documentReferenceFactory: (id: DocumentKey) => DocumentReference, private stages: Stage[], // TODO(pipeline) support converter //private converter: FirestorePipelineConverter = defaultPipelineConverter() @@ -191,11 +188,11 @@ export class Pipeline this.readUserData('addFields', this.selectablesToMap(fields)) ) ); - return new Pipeline( + return this.newPipeline( this._db, this.userDataReader, - this.userDataWriter, - this.documentReferenceFactory, + this._userDataWriter, + this._documentReferenceFactory, copy, this.converter ); @@ -237,11 +234,11 @@ export class Pipeline let projections: Map = this.selectablesToMap(selections); projections = this.readUserData('select', projections); copy.push(new Select(projections)); - return new Pipeline( + return this.newPipeline( this._db, this.userDataReader, - this.userDataWriter, - this.documentReferenceFactory, + this._userDataWriter, + this._documentReferenceFactory, copy, this.converter ); @@ -294,6 +291,24 @@ export class Pipeline return expressionMap; } + protected newPipeline( + db: Firestore, + userDataReader: UserDataReader, + userDataWriter: AbstractUserDataWriter, + documentReferenceFactory: (id: DocumentKey) => DocumentReference, + stages: Stage[], + converter: unknown = {} + ): Pipeline { + return new Pipeline( + db, + userDataReader, + userDataWriter, + documentReferenceFactory, + stages, + converter + ); + } + /** * Filters the documents from previous stages to only include those matching the specified {@link * FilterCondition}. @@ -329,11 +344,11 @@ export class Pipeline const copy = this.stages.map(s => s); this.readUserData('where', condition); copy.push(new Where(condition)); - return new Pipeline( + return this.newPipeline( this._db, this.userDataReader, - this.userDataWriter, - this.documentReferenceFactory, + this._userDataWriter, + this._documentReferenceFactory, copy, this.converter ); @@ -362,11 +377,11 @@ export class Pipeline offset(offset: number): Pipeline { const copy = this.stages.map(s => s); copy.push(new Offset(offset)); - return new Pipeline( + return this.newPipeline( this._db, this.userDataReader, - this.userDataWriter, - this.documentReferenceFactory, + this._userDataWriter, + this._documentReferenceFactory, copy, this.converter ); @@ -400,11 +415,11 @@ export class Pipeline limit(limit: number): Pipeline { const copy = this.stages.map(s => s); copy.push(new Limit(limit)); - return new Pipeline( + return this.newPipeline( this._db, this.userDataReader, - this.userDataWriter, - this.documentReferenceFactory, + this._userDataWriter, + this._documentReferenceFactory, copy, this.converter ); @@ -445,11 +460,11 @@ export class Pipeline this.readUserData('distinct', this.selectablesToMap(groups || [])) ) ); - return new Pipeline( + return this.newPipeline( this._db, this.userDataReader, - this.userDataWriter, - this.documentReferenceFactory, + this._userDataWriter, + this._documentReferenceFactory, copy, this.converter ); @@ -558,11 +573,11 @@ export class Pipeline ) ); } - return new Pipeline( + return this.newPipeline( this._db, this.userDataReader, - this.userDataWriter, - this.documentReferenceFactory, + this._userDataWriter, + this._documentReferenceFactory, copy, this.converter ); @@ -586,11 +601,11 @@ export class Pipeline options.distanceField ) ); - return new Pipeline( + return this.newPipeline( this._db, this.userDataReader, - this.userDataWriter, - this.documentReferenceFactory, + this._userDataWriter, + this._documentReferenceFactory, copy ); } @@ -647,11 +662,11 @@ export class Pipeline ); } - return new Pipeline( + return this.newPipeline( this._db, this.userDataReader, - this.userDataWriter, - this.documentReferenceFactory, + this._userDataWriter, + this._documentReferenceFactory, copy, this.converter ); @@ -685,11 +700,11 @@ export class Pipeline } }); copy.push(new GenericStage(name, params)); - return new Pipeline( + return this.newPipeline( this._db, this.userDataReader, - this.userDataWriter, - this.documentReferenceFactory, + this._userDataWriter, + this._documentReferenceFactory, copy, this.converter ); @@ -754,7 +769,7 @@ export class Pipeline // converter: FirestorePipelineConverter | null // ): Pipeline { // const copy = this.stages.map(s => s); - // return new Pipeline( + // return this.newPipeline( // this.db, // copy, // converter ?? defaultPipelineConverter() @@ -793,29 +808,9 @@ export class Pipeline * @return A Promise representing the asynchronous pipeline execution. */ execute(): Promise>> { - const datastore = getDatastore(this._db); - return invokeExecutePipeline(datastore, this).then(result => { - const docs = result - // Currently ignore any response from ExecutePipeline that does - // not contain any document data in the `fields` property. - .filter(element => !!element.fields) - .map( - element => - new PipelineResult( - this.userDataWriter, - element.key?.path - ? this.documentReferenceFactory(element.key) - : undefined, - element.fields, - element.executionTime?.toTimestamp(), - element.createTime?.toTimestamp(), - element.updateTime?.toTimestamp() - //this.converter - ) - ); - - return docs; - }); + throw new Error( + 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' + ); } /** @@ -833,21 +828,3 @@ export class Pipeline }; } } - -/** - * Experimental Modular API for console testing. - * @param firestore - */ -export function pipeline(firestore: Firestore): PipelineSource; - -/** - * Experimental Modular API for console testing. - * @param query - */ -export function pipeline(query: Query): Pipeline; - -export function pipeline( - firestoreOrQuery: Firestore | Query -): PipelineSource | Pipeline { - return firestoreOrQuery.pipeline(); -} diff --git a/packages/firestore/src/lite-api/pipeline_impl.ts b/packages/firestore/src/lite-api/pipeline_impl.ts index cd490d31871..d049bbba05c 100644 --- a/packages/firestore/src/lite-api/pipeline_impl.ts +++ b/packages/firestore/src/lite-api/pipeline_impl.ts @@ -15,8 +15,17 @@ * limitations under the License. */ +import { DocumentKey } from '../model/document_key'; +import { invokeExecutePipeline } from '../remote/datastore'; + +import { getDatastore } from './components'; +import { Firestore } from './database'; import { Pipeline } from './pipeline'; import { PipelineResult } from './pipeline-result'; +import { PipelineSource } from './pipeline-source'; +import { DocumentReference, Query } from './reference'; +import { LiteUserDataWriter } from './reference_impl'; +import { newUserDataReader } from './user_data_reader'; /** * Modular API for console experimentation. @@ -26,5 +35,84 @@ import { PipelineResult } from './pipeline-result'; export function execute( pipeline: Pipeline ): Promise>> { - return pipeline.execute(); + const datastore = getDatastore(pipeline._db); + return invokeExecutePipeline(datastore, pipeline).then(result => { + const docs = result + // Currently ignore any response from ExecutePipeline that does + // not contain any document data in the `fields` property. + .filter(element => !!element.fields) + .map( + element => + new PipelineResult( + pipeline._userDataWriter, + element.key?.path + ? pipeline._documentReferenceFactory(element.key) + : undefined, + element.fields, + element.executionTime?.toTimestamp(), + element.createTime?.toTimestamp(), + element.updateTime?.toTimestamp() + //this.converter + ) + ); + + return docs; + }); +} + +/** + * Experimental Modular API for console testing. + * @param firestore + */ +export function pipeline(firestore: Firestore): PipelineSource; + +/** + * Experimental Modular API for console testing. + * @param query + */ +export function pipeline(query: Query): Pipeline; + +export function pipeline( + firestoreOrQuery: Firestore | Query +): PipelineSource | Pipeline { + if (firestoreOrQuery instanceof Firestore) { + const db = firestoreOrQuery; + const userDataWriter = new LiteUserDataWriter(db); + const userDataReader = newUserDataReader(db); + return new PipelineSource( + db, + userDataReader, + userDataWriter, + (key: DocumentKey) => { + return new DocumentReference(db, null, key); + } + ); + } else { + let pipeline; + const query = firestoreOrQuery; + if (query._query.collectionGroup) { + pipeline = query.firestore + .pipeline() + .collectionGroup(query._query.collectionGroup); + } else { + pipeline = query.firestore + .pipeline() + .collection(query._query.path.canonicalString()); + } + + // TODO(pipeline) convert existing query filters, limits, etc into + // pipeline stages + + return pipeline; + } +} + +export function useFirestorePipelines(): void { + Firestore.prototype.pipeline = function (): PipelineSource { + return pipeline(this); + }; + + Query.prototype.pipeline = function (): Pipeline { + return pipeline(this); + }; } diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index a954d9b53e1..22fb5a1cdfb 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -55,14 +55,21 @@ import { setDoc, startsWith, subtract, - useFirestorePipelines + useFirestorePipelines, + setLogLevel, + cond, + eqAny, + logicalMaximum, + logicalMinimum, + notEqAny } from '../util/firebase_export'; import { apiDescribe, withTestCollection } from '../util/helpers'; use(chaiAsPromised); -useFirestorePipelines(); -apiDescribe.skip('Pipelines', persistence => { +setLogLevel('debug'); + +apiDescribe.only('Pipelines', persistence => { addEqualityMatcher(); let firestore: Firestore; let randomCol: CollectionReference; @@ -258,595 +265,689 @@ apiDescribe.skip('Pipelines', persistence => { await withTestCollectionPromise; }); - // setLogLevel('debug') + describe('fluent API', () => { + before(() => { + useFirestorePipelines(); + }); - it('empty results as expected', async () => { - const result = await firestore - .pipeline() - .collection(randomCol.path) - .limit(0) - .execute(); - expect(result.length).to.equal(0); - }); + it('empty results as expected', async () => { + const result = await firestore + .pipeline() + .collection(randomCol.path) + .limit(0) + .execute(); + expect(result.length).to.equal(0); + }); - it('full results as expected', async () => { - const result = await firestore - .pipeline() - .collection(randomCol.path) - .execute(); - expect(result.length).to.equal(10); - }); + it('full results as expected', async () => { + const result = await firestore + .pipeline() + .collection(randomCol.path) + .execute(); + expect(result.length).to.equal(10); + }); - it('returns aggregate results as expected', async () => { - let result = await firestore - .pipeline() - .collection(randomCol.path) - .aggregate(countAll().as('count')) - .execute(); - expectResults(result, { count: 10 }); - - result = await randomCol - .pipeline() - .where(eq('genre', 'Science Fiction')) - .aggregate( - countAll().as('count'), - avgFunction('rating').as('avgRating'), - Field.of('rating').max().as('maxRating') - ) - .execute(); - expectResults(result, { count: 2, avgRating: 4.4, maxRating: 4.6 }); - }); + it('returns aggregate results as expected', async () => { + let result = await firestore + .pipeline() + .collection(randomCol.path) + .aggregate(countAll().as('count')) + .execute(); + expectResults(result, { count: 10 }); + + result = await randomCol + .pipeline() + .where(eq('genre', 'Science Fiction')) + .aggregate( + countAll().as('count'), + avgFunction('rating').as('avgRating'), + Field.of('rating').maximum().as('maxRating') + ) + .execute(); + expectResults(result, { count: 2, avgRating: 4.4, maxRating: 4.6 }); + }); - it('rejects groups without accumulators', async () => { - await expect( - randomCol + it('rejects groups without accumulators', async () => { + await expect( + randomCol + .pipeline() + .where(lt('published', 1900)) + .aggregate({ + accumulators: [], + groups: ['genre'] + }) + .execute() + ).to.be.rejected; + }); + + // skip: toLower not supported + // it.skip('returns distinct values as expected', async () => { + // const results = await randomCol + // .pipeline() + // .where(lt('published', 1900)) + // .distinct(Field.of('genre').toLower().as('lowerGenre')) + // .execute(); + // expectResults( + // results, + // { lowerGenre: 'romance' }, + // { lowerGenre: 'psychological thriller' } + // ); + // }); + + it('returns group and accumulate results', async () => { + const results = await randomCol .pipeline() - .where(lt('published', 1900)) + .where(lt(Field.of('published'), 1984)) .aggregate({ - accumulators: [], + accumulators: [avgFunction('rating').as('avgRating')], groups: ['genre'] }) - .execute() - ).to.be.rejected; - }); - - // skip: toLower not supported - // it.skip('returns distinct values as expected', async () => { - // const results = await randomCol - // .pipeline() - // .where(lt('published', 1900)) - // .distinct(Field.of('genre').toLower().as('lowerGenre')) - // .execute(); - // expectResults( - // results, - // { lowerGenre: 'romance' }, - // { lowerGenre: 'psychological thriller' } - // ); - // }); - - it('returns group and accumulate results', async () => { - const results = await randomCol - .pipeline() - .where(lt(Field.of('published'), 1984)) - .aggregate({ - accumulators: [avgFunction('rating').as('avgRating')], - groups: ['genre'] - }) - .where(gt('avgRating', 4.3)) - .sort(Field.of('avgRating').descending()) - .execute(); - expectResults( - results, - { avgRating: 4.7, genre: 'Fantasy' }, - { avgRating: 4.5, genre: 'Romance' }, - { avgRating: 4.4, genre: 'Science Fiction' } - ); - }); + .where(gt('avgRating', 4.3)) + .sort(Field.of('avgRating').descending()) + .execute(); + expectResults( + results, + { avgRating: 4.7, genre: 'Fantasy' }, + { avgRating: 4.5, genre: 'Romance' }, + { avgRating: 4.4, genre: 'Science Fiction' } + ); + }); - it('returns min and max accumulations', async () => { - const results = await randomCol - .pipeline() - .aggregate( - countAll().as('count'), - Field.of('rating').max().as('maxRating'), - Field.of('published').min().as('minPublished') - ) - .execute(); - expectResults(results, { - count: 10, - maxRating: 4.7, - minPublished: 1813 + it('returns min and max accumulations', async () => { + const results = await randomCol + .pipeline() + .aggregate( + countAll().as('count'), + Field.of('rating').maximum().as('maxRating'), + Field.of('published').minimum().as('minPublished') + ) + .execute(); + expectResults(results, { + count: 10, + maxRating: 4.7, + minPublished: 1813 + }); }); - }); - it('can select fields', async () => { - const results = await firestore - .pipeline() - .collection(randomCol.path) - .select('title', 'author') - .sort(Field.of('author').ascending()) - .execute(); - expectResults( - results, - { - title: "The Hitchhiker's Guide to the Galaxy", - author: 'Douglas Adams' - }, - { title: 'The Great Gatsby', author: 'F. Scott Fitzgerald' }, - { title: 'Dune', author: 'Frank Herbert' }, - { title: 'Crime and Punishment', author: 'Fyodor Dostoevsky' }, - { - title: 'One Hundred Years of Solitude', - author: 'Gabriel García Márquez' - }, - { title: '1984', author: 'George Orwell' }, - { title: 'To Kill a Mockingbird', author: 'Harper Lee' }, - { title: 'The Lord of the Rings', author: 'J.R.R. Tolkien' }, - { title: 'Pride and Prejudice', author: 'Jane Austen' }, - { title: "The Handmaid's Tale", author: 'Margaret Atwood' } - ); - }); + it('can select fields', async () => { + const results = await firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'author') + .sort(Field.of('author').ascending()) + .execute(); + expectResults( + results, + { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams' + }, + { title: 'The Great Gatsby', author: 'F. Scott Fitzgerald' }, + { title: 'Dune', author: 'Frank Herbert' }, + { title: 'Crime and Punishment', author: 'Fyodor Dostoevsky' }, + { + title: 'One Hundred Years of Solitude', + author: 'Gabriel García Márquez' + }, + { title: '1984', author: 'George Orwell' }, + { title: 'To Kill a Mockingbird', author: 'Harper Lee' }, + { title: 'The Lord of the Rings', author: 'J.R.R. Tolkien' }, + { title: 'Pride and Prejudice', author: 'Jane Austen' }, + { title: "The Handmaid's Tale", author: 'Margaret Atwood' } + ); + }); - it('where with and', async () => { - const results = await randomCol - .pipeline() - .where(andFunction(gt('rating', 4.5), eq('genre', 'Science Fiction'))) - .execute(); - expectResults(results, 'book10'); - }); + it('where with and', async () => { + const results = await randomCol + .pipeline() + .where(andFunction(gt('rating', 4.5), eq('genre', 'Science Fiction'))) + .execute(); + expectResults(results, 'book10'); + }); - it('where with or', async () => { - const results = await randomCol - .pipeline() - .where(orFunction(eq('genre', 'Romance'), eq('genre', 'Dystopian'))) - .select('title') - .execute(); - expectResults( - results, - { title: 'Pride and Prejudice' }, - { title: "The Handmaid's Tale" }, - { title: '1984' } - ); - }); + it('where with or', async () => { + const results = await randomCol + .pipeline() + .where(orFunction(eq('genre', 'Romance'), eq('genre', 'Dystopian'))) + .select('title') + .execute(); + expectResults( + results, + { title: 'Pride and Prejudice' }, + { title: "The Handmaid's Tale" }, + { title: '1984' } + ); + }); - it('offset and limits', async () => { - const results = await firestore - .pipeline() - .collection(randomCol.path) - .sort(Field.of('author').ascending()) - .offset(5) - .limit(3) - .select('title', 'author') - .execute(); - expectResults( - results, - { title: '1984', author: 'George Orwell' }, - { title: 'To Kill a Mockingbird', author: 'Harper Lee' }, - { title: 'The Lord of the Rings', author: 'J.R.R. Tolkien' } - ); - }); + it('offset and limits', async () => { + const results = await firestore + .pipeline() + .collection(randomCol.path) + .sort(Field.of('author').ascending()) + .offset(5) + .limit(3) + .select('title', 'author') + .execute(); + expectResults( + results, + { title: '1984', author: 'George Orwell' }, + { title: 'To Kill a Mockingbird', author: 'Harper Lee' }, + { title: 'The Lord of the Rings', author: 'J.R.R. Tolkien' } + ); + }); - it('arrayContains works', async () => { - const results = await randomCol - .pipeline() - .where(arrayContains('tags', 'comedy')) - .select('title') - .execute(); - expectResults(results, { title: "The Hitchhiker's Guide to the Galaxy" }); - }); + it('logical min works', async () => { + const results = await randomCol + .pipeline() + .select( + 'title', + logicalMinimum(Constant.of(1960), Field.of('published')).as( + 'published-safe' + ) + ) + .sort(Field.of('title').ascending()) + .limit(3) + .execute(); + expectResults( + results, + { title: '1984', 'published-safe': 1949 }, + { title: 'Crime and Punishment', 'published-safe': 1866 }, + { title: 'Dune', 'published-safe': 1960 } + ); + }); - it('arrayContainsAny works', async () => { - const results = await randomCol - .pipeline() - .where(arrayContainsAny('tags', ['comedy', 'classic'])) - .select('title') - .execute(); - expectResults( - results, - { title: "The Hitchhiker's Guide to the Galaxy" }, - { title: 'Pride and Prejudice' } - ); - }); + it('logical max works', async () => { + const results = await randomCol + .pipeline() + .select( + 'title', + logicalMaximum(Constant.of(1960), Field.of('published')).as( + 'published-safe' + ) + ) + .sort(Field.of('title').ascending()) + .limit(3) + .execute(); + expectResults( + results, + { title: '1984', 'published-safe': 1960 }, + { title: 'Crime and Punishment', 'published-safe': 1960 }, + { title: 'Dune', 'published-safe': 1965 } + ); + }); - it('arrayContainsAll works', async () => { - const results = await randomCol - .pipeline() - .where(Field.of('tags').arrayContainsAll('adventure', 'magic')) - .select('title') - .execute(); - expectResults(results, { title: 'The Lord of the Rings' }); - }); + it('cond works', async () => { + const results = await randomCol + .pipeline() + .select( + 'title', + cond( + lt(Field.of('published'), 1960), + Constant.of(1960), + Field.of('published') + ).as('published-safe') + ) + .sort(Field.of('title').ascending()) + .limit(3) + .execute(); + expectResults( + results, + { title: '1984', 'published-safe': 1960 }, + { title: 'Crime and Punishment', 'published-safe': 1960 }, + { title: 'Dune', 'published-safe': 1965 } + ); + }); - it('arrayLength works', async () => { - const results = await randomCol - .pipeline() - .select(Field.of('tags').arrayLength().as('tagsCount')) - .where(eq('tagsCount', 3)) - .execute(); - expect(results.length).to.equal(10); - }); + it('eqAny works', async () => { + const results = await randomCol + .pipeline() + .where(eqAny('published', [1979, 1999, 1967])) + .select('title') + .execute(); + expectResults( + results, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'One Hundred Years of Solitude' } + ); + }); - // skip: arrayConcat not supported - // it.skip('arrayConcat works', async () => { - // const results = await randomCol - // .pipeline() - // .select( - // Field.of('tags').arrayConcat(['newTag1', 'newTag2']).as('modifiedTags') - // ) - // .limit(1) - // .execute(); - // expectResults(results, { - // modifiedTags: ['comedy', 'space', 'adventure', 'newTag1', 'newTag2'] - // }); - // }); - - it('testStrConcat', async () => { - const results = await randomCol - .pipeline() - .select( - Field.of('author').strConcat(' - ', Field.of('title')).as('bookInfo') - ) - .limit(1) - .execute(); - expectResults(results, { - bookInfo: "Douglas Adams - The Hitchhiker's Guide to the Galaxy" + it('notEqAny works', async () => { + const results = await randomCol + .pipeline() + .where( + notEqAny( + 'published', + [1965, 1925, 1949, 1960, 1866, 1985, 1954, 1967, 1979] + ) + ) + .select('title') + .execute(); + expectResults(results, { title: 'Pride and Prejudice' }); }); - }); - it('testStartsWith', async () => { - const results = await randomCol - .pipeline() - .where(startsWith('title', 'The')) - .select('title') - .sort(Field.of('title').ascending()) - .execute(); - expectResults( - results, - { title: 'The Great Gatsby' }, - { title: "The Handmaid's Tale" }, - { title: "The Hitchhiker's Guide to the Galaxy" }, - { title: 'The Lord of the Rings' } - ); - }); + it('arrayContains works', async () => { + const results = await randomCol + .pipeline() + .where(arrayContains('tags', 'comedy')) + .select('title') + .execute(); + expectResults(results, { title: "The Hitchhiker's Guide to the Galaxy" }); + }); - it('testEndsWith', async () => { - const results = await randomCol - .pipeline() - .where(endsWith('title', 'y')) - .select('title') - .sort(Field.of('title').descending()) - .execute(); - expectResults( - results, - { title: "The Hitchhiker's Guide to the Galaxy" }, - { title: 'The Great Gatsby' } - ); - }); + it('arrayContainsAny works', async () => { + const results = await randomCol + .pipeline() + .where(arrayContainsAny('tags', ['comedy', 'classic'])) + .select('title') + .execute(); + expectResults( + results, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'Pride and Prejudice' } + ); + }); - it('testLength', async () => { - const results = await randomCol - .pipeline() - .select( - Field.of('title').charLength().as('titleLength'), - Field.of('title') - ) - .where(gt('titleLength', 20)) - .sort(Field.of('title').ascending()) - .execute(); - - expectResults( - results, - - { - titleLength: 29, - title: 'One Hundred Years of Solitude' - }, - { - titleLength: 36, - title: "The Hitchhiker's Guide to the Galaxy" - }, - { - titleLength: 21, - title: 'The Lord of the Rings' - }, - { - titleLength: 21, - title: 'To Kill a Mockingbird' - } - ); - }); + it('arrayContainsAll works', async () => { + const results = await randomCol + .pipeline() + .where(Field.of('tags').arrayContainsAll('adventure', 'magic')) + .select('title') + .execute(); + expectResults(results, { title: 'The Lord of the Rings' }); + }); - // skip: toLower not supported - // it.skip('testToLowercase', async () => { - // const results = await randomCol - // .pipeline() - // .select(Field.of('title').toLower().as('lowercaseTitle')) - // .limit(1) - // .execute(); - // expectResults(results, { - // lowercaseTitle: "the hitchhiker's guide to the galaxy" - // }); - // }); - - // skip: toUpper not supported - // it.skip('testToUppercase', async () => { - // const results = await randomCol - // .pipeline() - // .select(Field.of('author').toUpper().as('uppercaseAuthor')) - // .limit(1) - // .execute(); - // expectResults(results, { uppercaseAuthor: 'DOUGLAS ADAMS' }); - // }); - - // skip: trim not supported - // it.skip('testTrim', async () => { - // const results = await randomCol - // .pipeline() - // .addFields(strConcat(' ', Field.of('title'), ' ').as('spacedTitle')) - // .select( - // Field.of('spacedTitle').trim().as('trimmedTitle'), - // Field.of('spacedTitle') - // ) - // .limit(1) - // .execute(); - // expectResults(results, { - // spacedTitle: " The Hitchhiker's Guide to the Galaxy ", - // trimmedTitle: "The Hitchhiker's Guide to the Galaxy" - // }); - // }); - - it('testLike', async () => { - const results = await randomCol - .pipeline() - .where(like('title', '%Guide%')) - .select('title') - .execute(); - expectResults(results, { title: "The Hitchhiker's Guide to the Galaxy" }); - }); + it('arrayLength works', async () => { + const results = await randomCol + .pipeline() + .select(Field.of('tags').arrayLength().as('tagsCount')) + .where(eq('tagsCount', 3)) + .execute(); + expect(results.length).to.equal(10); + }); - it('testRegexContains', async () => { - const results = await randomCol - .pipeline() - .where(regexContains('title', '(?i)(the|of)')) - .execute(); - expect(results.length).to.equal(5); - }); + // skip: arrayConcat not supported + // it.skip('arrayConcat works', async () => { + // const results = await randomCol + // .pipeline() + // .select( + // Field.of('tags').arrayConcat(['newTag1', 'newTag2']).as('modifiedTags') + // ) + // .limit(1) + // .execute(); + // expectResults(results, { + // modifiedTags: ['comedy', 'space', 'adventure', 'newTag1', 'newTag2'] + // }); + // }); + + it('testStrConcat', async () => { + const results = await randomCol + .pipeline() + .select( + Field.of('author').strConcat(' - ', Field.of('title')).as('bookInfo') + ) + .limit(1) + .execute(); + expectResults(results, { + bookInfo: "Douglas Adams - The Hitchhiker's Guide to the Galaxy" + }); + }); - it('testRegexMatches', async () => { - const results = await randomCol - .pipeline() - .where(regexMatch('title', '.*(?i)(the|of).*')) - .execute(); - expect(results.length).to.equal(5); - }); + it('testStartsWith', async () => { + const results = await randomCol + .pipeline() + .where(startsWith('title', 'The')) + .select('title') + .sort(Field.of('title').ascending()) + .execute(); + expectResults( + results, + { title: 'The Great Gatsby' }, + { title: "The Handmaid's Tale" }, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'The Lord of the Rings' } + ); + }); - it('testArithmeticOperations', async () => { - const results = await randomCol - .pipeline() - .select( - add(Field.of('rating'), 1).as('ratingPlusOne'), - subtract(Field.of('published'), 1900).as('yearsSince1900'), - Field.of('rating').multiply(10).as('ratingTimesTen'), - Field.of('rating').divide(2).as('ratingDividedByTwo') - ) - .limit(1) - .execute(); - expectResults(results, { - ratingPlusOne: 5.2, - yearsSince1900: 79, - ratingTimesTen: 42, - ratingDividedByTwo: 2.1 + it('testEndsWith', async () => { + const results = await randomCol + .pipeline() + .where(endsWith('title', 'y')) + .select('title') + .sort(Field.of('title').descending()) + .execute(); + expectResults( + results, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'The Great Gatsby' } + ); }); - }); - it('testComparisonOperators', async () => { - const results = await randomCol - .pipeline() - .where( - andFunction( - gt('rating', 4.2), - lte(Field.of('rating'), 4.5), - neq('genre', 'Science Fiction') + it('testLength', async () => { + const results = await randomCol + .pipeline() + .select( + Field.of('title').charLength().as('titleLength'), + Field.of('title') ) - ) - .select('rating', 'title') - .sort(Field.of('title').ascending()) - .execute(); - expectResults( - results, - { rating: 4.3, title: 'Crime and Punishment' }, - { - rating: 4.3, - title: 'One Hundred Years of Solitude' - }, - { rating: 4.5, title: 'Pride and Prejudice' } - ); - }); + .where(gt('titleLength', 20)) + .sort(Field.of('title').ascending()) + .execute(); + + expectResults( + results, + + { + titleLength: 29, + title: 'One Hundred Years of Solitude' + }, + { + titleLength: 36, + title: "The Hitchhiker's Guide to the Galaxy" + }, + { + titleLength: 21, + title: 'The Lord of the Rings' + }, + { + titleLength: 21, + title: 'To Kill a Mockingbird' + } + ); + }); - it('testLogicalOperators', async () => { - const results = await randomCol - .pipeline() - .where( - orFunction( - andFunction(gt('rating', 4.5), eq('genre', 'Science Fiction')), - lt('published', 1900) + // skip: toLower not supported + // it.skip('testToLowercase', async () => { + // const results = await randomCol + // .pipeline() + // .select(Field.of('title').toLower().as('lowercaseTitle')) + // .limit(1) + // .execute(); + // expectResults(results, { + // lowercaseTitle: "the hitchhiker's guide to the galaxy" + // }); + // }); + + // skip: toUpper not supported + // it.skip('testToUppercase', async () => { + // const results = await randomCol + // .pipeline() + // .select(Field.of('author').toUpper().as('uppercaseAuthor')) + // .limit(1) + // .execute(); + // expectResults(results, { uppercaseAuthor: 'DOUGLAS ADAMS' }); + // }); + + // skip: trim not supported + // it.skip('testTrim', async () => { + // const results = await randomCol + // .pipeline() + // .addFields(strConcat(' ', Field.of('title'), ' ').as('spacedTitle')) + // .select( + // Field.of('spacedTitle').trim().as('trimmedTitle'), + // Field.of('spacedTitle') + // ) + // .limit(1) + // .execute(); + // expectResults(results, { + // spacedTitle: " The Hitchhiker's Guide to the Galaxy ", + // trimmedTitle: "The Hitchhiker's Guide to the Galaxy" + // }); + // }); + + it('testLike', async () => { + const results = await randomCol + .pipeline() + .where(like('title', '%Guide%')) + .select('title') + .execute(); + expectResults(results, { title: "The Hitchhiker's Guide to the Galaxy" }); + }); + + it('testRegexContains', async () => { + const results = await randomCol + .pipeline() + .where(regexContains('title', '(?i)(the|of)')) + .execute(); + expect(results.length).to.equal(5); + }); + + it('testRegexMatches', async () => { + const results = await randomCol + .pipeline() + .where(regexMatch('title', '.*(?i)(the|of).*')) + .execute(); + expect(results.length).to.equal(5); + }); + + it('testArithmeticOperations', async () => { + const results = await randomCol + .pipeline() + .select( + add(Field.of('rating'), 1).as('ratingPlusOne'), + subtract(Field.of('published'), 1900).as('yearsSince1900'), + Field.of('rating').multiply(10).as('ratingTimesTen'), + Field.of('rating').divide(2).as('ratingDividedByTwo') ) - ) - .select('title') - .sort(Field.of('title').ascending()) - .execute(); - expectResults( - results, - { title: 'Crime and Punishment' }, - { title: 'Dune' }, - { title: 'Pride and Prejudice' } - ); - }); + .limit(1) + .execute(); + expectResults(results, { + ratingPlusOne: 5.2, + yearsSince1900: 79, + ratingTimesTen: 42, + ratingDividedByTwo: 2.1 + }); + }); - it('testChecks', async () => { - const results = await randomCol - .pipeline() - .where(not(Field.of('rating').isNaN())) - .select( - Field.of('rating').eq(null).as('ratingIsNull'), - not(Field.of('rating').isNaN()).as('ratingIsNotNaN') - ) - .limit(1) - .execute(); - expectResults(results, { ratingIsNull: false, ratingIsNotNaN: true }); - }); + it('testComparisonOperators', async () => { + const results = await randomCol + .pipeline() + .where( + andFunction( + gt('rating', 4.2), + lte(Field.of('rating'), 4.5), + neq('genre', 'Science Fiction') + ) + ) + .select('rating', 'title') + .sort(Field.of('title').ascending()) + .execute(); + expectResults( + results, + { rating: 4.3, title: 'Crime and Punishment' }, + { + rating: 4.3, + title: 'One Hundred Years of Solitude' + }, + { rating: 4.5, title: 'Pride and Prejudice' } + ); + }); - it('testMapGet', async () => { - const results = await randomCol - .pipeline() - .select( - Field.of('awards').mapGet('hugo').as('hugoAward'), - Field.of('awards').mapGet('others').as('others'), - Field.of('title') - ) - .where(eq('hugoAward', true)) - .execute(); - expectResults( - results, - { - hugoAward: true, - title: "The Hitchhiker's Guide to the Galaxy", - others: { unknown: { year: 1980 } } - }, - { hugoAward: true, title: 'Dune', others: null } - ); - }); + it('testLogicalOperators', async () => { + const results = await randomCol + .pipeline() + .where( + orFunction( + andFunction(gt('rating', 4.5), eq('genre', 'Science Fiction')), + lt('published', 1900) + ) + ) + .select('title') + .sort(Field.of('title').ascending()) + .execute(); + expectResults( + results, + { title: 'Crime and Punishment' }, + { title: 'Dune' }, + { title: 'Pride and Prejudice' } + ); + }); - // it('testParent', async () => { - // const results = await randomCol - // .pipeline() - // .select( - // parent(randomCol.doc('chile').collection('subCollection').path).as( - // 'parent' - // ) - // ) - // .limit(1) - // .execute(); - // expect(results[0].data().parent.endsWith('/books')).to.be.true; - // }); - // - // it('testCollectionId', async () => { - // const results = await randomCol - // .pipeline() - // .select(collectionId(randomCol.doc('chile')).as('collectionId')) - // .limit(1) - // .execute(); - // expectResults(results, {collectionId: 'books'}); - // }); - - it('testDistanceFunctions', async () => { - const sourceVector = [0.1, 0.1]; - const targetVector = [0.5, 0.8]; - const results = await randomCol - .pipeline() - .select( - cosineDistance(Constant.vector(sourceVector), targetVector).as( - 'cosineDistance' - ), - dotProduct(Constant.vector(sourceVector), targetVector).as( - 'dotProductDistance' - ), - euclideanDistance(Constant.vector(sourceVector), targetVector).as( - 'euclideanDistance' + it('testChecks', async () => { + const results = await randomCol + .pipeline() + .where(not(Field.of('rating').isNaN())) + .select( + Field.of('rating').eq(null).as('ratingIsNull'), + not(Field.of('rating').isNaN()).as('ratingIsNotNaN') ) - ) - .limit(1) - .execute(); + .limit(1) + .execute(); + expectResults(results, { ratingIsNull: false, ratingIsNotNaN: true }); + }); - expectResults(results, { - cosineDistance: 0.02560880430538015, - dotProductDistance: 0.13, - euclideanDistance: 0.806225774829855 + it('testMapGet', async () => { + const results = await randomCol + .pipeline() + .select( + Field.of('awards').mapGet('hugo').as('hugoAward'), + Field.of('awards').mapGet('others').as('others'), + Field.of('title') + ) + .where(eq('hugoAward', true)) + .execute(); + expectResults( + results, + { + hugoAward: true, + title: "The Hitchhiker's Guide to the Galaxy", + others: { unknown: { year: 1980 } } + }, + { hugoAward: true, title: 'Dune', others: null } + ); }); - }); - it('testNestedFields', async () => { - const results = await randomCol - .pipeline() - .where(eq('awards.hugo', true)) - .select('title', 'awards.hugo') - .execute(); - expectResults( - results, - { title: "The Hitchhiker's Guide to the Galaxy", 'awards.hugo': true }, - { title: 'Dune', 'awards.hugo': true } - ); - }); + // it('testParent', async () => { + // const results = await randomCol + // .pipeline() + // .select( + // parent(randomCol.doc('chile').collection('subCollection').path).as( + // 'parent' + // ) + // ) + // .limit(1) + // .execute(); + // expect(results[0].data().parent.endsWith('/books')).to.be.true; + // }); + // + // it('testCollectionId', async () => { + // const results = await randomCol + // .pipeline() + // .select(collectionId(randomCol.doc('chile')).as('collectionId')) + // .limit(1) + // .execute(); + // expectResults(results, {collectionId: 'books'}); + // }); + + it('testDistanceFunctions', async () => { + const sourceVector = [0.1, 0.1]; + const targetVector = [0.5, 0.8]; + const results = await randomCol + .pipeline() + .select( + cosineDistance(Constant.vector(sourceVector), targetVector).as( + 'cosineDistance' + ), + dotProduct(Constant.vector(sourceVector), targetVector).as( + 'dotProductDistance' + ), + euclideanDistance(Constant.vector(sourceVector), targetVector).as( + 'euclideanDistance' + ) + ) + .limit(1) + .execute(); + + expectResults(results, { + cosineDistance: 0.02560880430538015, + dotProductDistance: 0.13, + euclideanDistance: 0.806225774829855 + }); + }); - it('test mapGet with field name including . notation', async () => { - const results = await randomCol - .pipeline() - .where(eq('awards.hugo', true)) - .select( - 'title', - Field.of('nestedField.level.1'), - mapGet('nestedField', 'level.1').mapGet('level.2').as('nested') - ) - .execute(); - expectResults( - results, - { - title: "The Hitchhiker's Guide to the Galaxy", - 'nestedField.level.`1`': null, - nested: true - }, - { title: 'Dune', 'nestedField.level.`1`': null, nested: null } - ); - }); + it('testNestedFields', async () => { + const results = await randomCol + .pipeline() + .where(eq('awards.hugo', true)) + .select('title', 'awards.hugo') + .execute(); + expectResults( + results, + { title: "The Hitchhiker's Guide to the Galaxy", 'awards.hugo': true }, + { title: 'Dune', 'awards.hugo': true } + ); + }); - it('supports internal serialization to proto', async () => { - const pipeline = firestore - .pipeline() - .collection('books') - .where(eq('awards.hugo', true)) - .select( - 'title', - Field.of('nestedField.level.1'), - mapGet('nestedField', 'level.1').mapGet('level.2').as('nested') + it('test mapGet with field name including . notation', async () => { + const results = await randomCol + .pipeline() + .where(eq('awards.hugo', true)) + .select( + 'title', + Field.of('nestedField.level.1'), + mapGet('nestedField', 'level.1').mapGet('level.2').as('nested') + ) + .execute(); + expectResults( + results, + { + title: "The Hitchhiker's Guide to the Galaxy", + 'nestedField.level.`1`': null, + nested: true + }, + { title: 'Dune', 'nestedField.level.`1`': null, nested: null } ); + }); + + it('supports internal serialization to proto', async () => { + const pipeline = firestore + .pipeline() + .collection('books') + .where(eq('awards.hugo', true)) + .select( + 'title', + Field.of('nestedField.level.1'), + mapGet('nestedField', 'level.1').mapGet('level.2').as('nested') + ); + + const proto = _internalPipelineToExecutePipelineRequestProto(pipeline); + expect(proto).not.to.be.null; + }); - const proto = _internalPipelineToExecutePipelineRequestProto(pipeline); - expect(proto).not.to.be.null; + // TODO(pipeline) support converter + // it('pipeline converter works', async () => { + // interface AppModel {myTitle: string; myAuthor: string; myPublished: number} + // const converter: FirestorePipelineConverter = { + // fromFirestore(result: FirebaseFirestore.PipelineResult): AppModel { + // return { + // myTitle: result.data()!.title as string, + // myAuthor: result.data()!.author as string, + // myPublished: result.data()!.published as number, + // }; + // }, + // }; + // + // const results = await firestore + // .pipeline() + // .collection(randomCol.path) + // .sort(Field.of('published').ascending()) + // .limit(2) + // .withConverter(converter) + // .execute(); + // + // const objs = results.map(r => r.data()); + // expect(objs[0]).to.deep.equal({ + // myAuthor: 'Jane Austen', + // myPublished: 1813, + // myTitle: 'Pride and Prejudice', + // }); + // expect(objs[1]).to.deep.equal({ + // myAuthor: 'Fyodor Dostoevsky', + // myPublished: 1866, + // myTitle: 'Crime and Punishment', + // }); + // }); }); - // TODO(pipeline) support converter - // it('pipeline converter works', async () => { - // interface AppModel {myTitle: string; myAuthor: string; myPublished: number} - // const converter: FirestorePipelineConverter = { - // fromFirestore(result: FirebaseFirestore.PipelineResult): AppModel { - // return { - // myTitle: result.data()!.title as string, - // myAuthor: result.data()!.author as string, - // myPublished: result.data()!.published as number, - // }; - // }, - // }; - // - // const results = await firestore - // .pipeline() - // .collection(randomCol.path) - // .sort(Field.of('published').ascending()) - // .limit(2) - // .withConverter(converter) - // .execute(); - // - // const objs = results.map(r => r.data()); - // expect(objs[0]).to.deep.equal({ - // myAuthor: 'Jane Austen', - // myPublished: 1813, - // myTitle: 'Pride and Prejudice', - // }); - // expect(objs[1]).to.deep.equal({ - // myAuthor: 'Fyodor Dostoevsky', - // myPublished: 1866, - // myTitle: 'Crime and Punishment', - // }); - // }); describe('modular API', () => { it('works when creating a pipeline from a Firestore instance', async () => { const myPipeline = pipeline(firestore) diff --git a/repo-scripts/size-analysis/bundle-definitions/firestore.json b/repo-scripts/size-analysis/bundle-definitions/firestore.json index 6c1adcad52c..f265521b08b 100644 --- a/repo-scripts/size-analysis/bundle-definitions/firestore.json +++ b/repo-scripts/size-analysis/bundle-definitions/firestore.json @@ -129,7 +129,39 @@ ] }, { - "name": "Pipeline Query with lt filter", + "name": "Pipeline Query with lt filter (execute)", + "dependencies": [ + { + "packageName": "firebase", + "versionOrTag": "latest", + "imports": [ + { + "path": "app", + "imports": [ + "initializeApp" + ] + } + ] + }, + { + "packageName": "firebase", + "versionOrTag": "latest", + "imports": [ + { + "path": "firestore", + "imports": [ + "getFirestore", + "lt", + "Field", + "execute" + ] + } + ] + } + ] + }, + { + "name": "Pipeline Query with lt filter (useFirestorePipelines)", "dependencies": [ { "packageName": "firebase", From 63b88541dc00330e653cf794265df581e65f1858 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Mon, 25 Nov 2024 17:05:48 -0700 Subject: [PATCH 46/59] Fix build. Finish rename. Rename useFirestorePipelines to useFluentPipelines. --- common/api-review/firestore-lite.api.md | 268 ++++++++++-------- common/api-review/firestore.api.md | 234 ++++++++------- packages/firestore/lite/index.ts | 36 +-- packages/firestore/src/api.ts | 4 +- packages/firestore/src/api/database.ts | 2 +- .../src/api/database_augmentation.ts | 0 packages/firestore/src/api/pipeline-source.ts | 58 ++-- packages/firestore/src/api/pipeline.ts | 13 +- packages/firestore/src/api/pipeline_impl.ts | 7 +- packages/firestore/src/api_pipelines.ts | 2 +- packages/firestore/src/core/pipeline-util.ts | 4 +- packages/firestore/src/lite-api/database.ts | 4 +- .../firestore/src/lite-api/pipeline-source.ts | 64 +++-- packages/firestore/src/lite-api/pipeline.ts | 13 +- .../firestore/src/lite-api/pipeline_impl.ts | 2 +- packages/firestore/src/lite-api/reference.ts | 2 +- .../test/integration/api/pipeline.test.ts | 4 +- 17 files changed, 403 insertions(+), 314 deletions(-) delete mode 100644 packages/firestore/src/api/database_augmentation.ts diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index d3edaf71247..36d02015529 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -285,6 +285,16 @@ export class CollectionSource implements Stage { name: string; } +// @beta (undocumented) +export class Cond extends FirestoreFunction implements FilterCondition { + constructor(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function cond(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant): Cond; + // @public export function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: { mockUserToken?: EmulatorMockTokenOptions | string; @@ -323,6 +333,9 @@ export class Constant { endsWith(suffix: Constant): EndsWith; eq(other: Constant): Eq; eq(other: any): Eq; + eqAny(...others: Constant[]): EqAny; + // (undocumented) + eqAny(...others: any[]): EqAny; euclideanDistance(other: Constant): EuclideanDistance; euclideanDistance(other: VectorValue): EuclideanDistance; // (undocumented) @@ -334,30 +347,30 @@ export class Constant { gt(other: any): Gt; gte(other: Constant): Gte; gte(other: any): Gte; - in(...others: Constant[]): In; - // (undocumented) - in(...others: any[]): In; isNaN(): IsNan; like(pattern: string): Like; // (undocumented) like(pattern: Constant): Like; - logicalMax(other: Constant): LogicalMax; - logicalMax(other: any): LogicalMax; - logicalMin(other: Constant): LogicalMin; - logicalMin(other: any): LogicalMin; + logicalMaximum(other: Constant): LogicalMaximum; + logicalMaximum(other: any): LogicalMaximum; + logicalMinimum(other: Constant): LogicalMinimum; + logicalMinimum(other: any): LogicalMinimum; lt(other: Constant): Lt; lt(other: any): Lt; lte(other: Constant): Lte; lte(other: any): Lte; mapGet(subfield: string): MapGet; - max(): Max; - min(): Min; + maximum(): Maximum; + minimum(): Minimum; mod(other: Constant): Mod; mod(other: any): Mod; multiply(other: Constant): Multiply; multiply(other: any): Multiply; neq(other: Constant): Neq; neq(other: any): Neq; + notEqAny(...others: Constant[]): FirestoreFunction; + // (undocumented) + notEqAny(...others: any[]): FirestoreFunction; static of(value: number): Constant; static of(value: string): Constant; static of(value: boolean): Constant; @@ -603,6 +616,25 @@ export function eq(left: string, right: Constant): Eq; // @beta export function eq(left: string, right: any): Eq; +// @beta (undocumented) +export class EqAny extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, others: Constant[]); + // (undocumented) + filterable: true; + } + +// @beta +export function eqAny(element: Constant, others: Constant[]): EqAny; + +// @beta +export function eqAny(element: Constant, others: any[]): EqAny; + +// @beta +export function eqAny(element: string, others: Constant[]): EqAny; + +// @beta +export function eqAny(element: string, others: any[]): EqAny; + // @beta (undocumented) export class EuclideanDistance extends FirestoreFunction { constructor(vector1: Constant, vector2: Constant); @@ -681,6 +713,9 @@ export class ExprWithAlias implements Selectable { endsWith(suffix: Constant): EndsWith; eq(other: Constant): Eq; eq(other: any): Eq; + eqAny(...others: Constant[]): EqAny; + // (undocumented) + eqAny(...others: any[]): EqAny; euclideanDistance(other: Constant): EuclideanDistance; euclideanDistance(other: VectorValue): EuclideanDistance; // (undocumented) @@ -694,30 +729,30 @@ export class ExprWithAlias implements Selectable { gt(other: any): Gt; gte(other: Constant): Gte; gte(other: any): Gte; - in(...others: Constant[]): In; - // (undocumented) - in(...others: any[]): In; isNaN(): IsNan; like(pattern: string): Like; // (undocumented) like(pattern: Constant): Like; - logicalMax(other: Constant): LogicalMax; - logicalMax(other: any): LogicalMax; - logicalMin(other: Constant): LogicalMin; - logicalMin(other: any): LogicalMin; + logicalMaximum(other: Constant): LogicalMaximum; + logicalMaximum(other: any): LogicalMaximum; + logicalMinimum(other: Constant): LogicalMinimum; + logicalMinimum(other: any): LogicalMinimum; lt(other: Constant): Lt; lt(other: any): Lt; lte(other: Constant): Lte; lte(other: any): Lte; mapGet(subfield: string): MapGet; - max(): Max; - min(): Min; + maximum(): Maximum; + minimum(): Minimum; mod(other: Constant): Mod; mod(other: any): Mod; multiply(other: Constant): Multiply; multiply(other: any): Multiply; neq(other: Constant): Neq; neq(other: any): Neq; + notEqAny(...others: Constant[]): FirestoreFunction; + // (undocumented) + notEqAny(...others: any[]): FirestoreFunction; regexContains(pattern: string): RegexContains; regexContains(pattern: Constant): RegexContains; regexMatch(pattern: string): RegexMatch; @@ -786,6 +821,9 @@ export class Field implements Selectable { endsWith(suffix: Constant): EndsWith; eq(other: Constant): Eq; eq(other: any): Eq; + eqAny(...others: Constant[]): EqAny; + // (undocumented) + eqAny(...others: any[]): EqAny; euclideanDistance(other: Constant): EuclideanDistance; euclideanDistance(other: VectorValue): EuclideanDistance; // (undocumented) @@ -799,30 +837,30 @@ export class Field implements Selectable { gt(other: any): Gt; gte(other: Constant): Gte; gte(other: any): Gte; - in(...others: Constant[]): In; - // (undocumented) - in(...others: any[]): In; isNaN(): IsNan; like(pattern: string): Like; // (undocumented) like(pattern: Constant): Like; - logicalMax(other: Constant): LogicalMax; - logicalMax(other: any): LogicalMax; - logicalMin(other: Constant): LogicalMin; - logicalMin(other: any): LogicalMin; + logicalMaximum(other: Constant): LogicalMaximum; + logicalMaximum(other: any): LogicalMaximum; + logicalMinimum(other: Constant): LogicalMinimum; + logicalMinimum(other: any): LogicalMinimum; lt(other: Constant): Lt; lt(other: any): Lt; lte(other: Constant): Lte; lte(other: any): Lte; mapGet(subfield: string): MapGet; - max(): Max; - min(): Min; + maximum(): Maximum; + minimum(): Minimum; mod(other: Constant): Mod; mod(other: any): Mod; multiply(other: Constant): Multiply; multiply(other: any): Multiply; neq(other: Constant): Neq; neq(other: any): Neq; + notEqAny(...others: Constant[]): FirestoreFunction; + // (undocumented) + notEqAny(...others: any[]): FirestoreFunction; static of(name: string): Field; // (undocumented) static of(path: FieldPath): Field; @@ -902,6 +940,9 @@ export class Fields implements Selectable { endsWith(suffix: Constant): EndsWith; eq(other: Constant): Eq; eq(other: any): Eq; + eqAny(...others: Constant[]): EqAny; + // (undocumented) + eqAny(...others: any[]): EqAny; euclideanDistance(other: Constant): EuclideanDistance; euclideanDistance(other: VectorValue): EuclideanDistance; // (undocumented) @@ -915,30 +956,30 @@ export class Fields implements Selectable { gt(other: any): Gt; gte(other: Constant): Gte; gte(other: any): Gte; - in(...others: Constant[]): In; - // (undocumented) - in(...others: any[]): In; isNaN(): IsNan; like(pattern: string): Like; // (undocumented) like(pattern: Constant): Like; - logicalMax(other: Constant): LogicalMax; - logicalMax(other: any): LogicalMax; - logicalMin(other: Constant): LogicalMin; - logicalMin(other: any): LogicalMin; + logicalMaximum(other: Constant): LogicalMaximum; + logicalMaximum(other: any): LogicalMaximum; + logicalMinimum(other: Constant): LogicalMinimum; + logicalMinimum(other: any): LogicalMinimum; lt(other: Constant): Lt; lt(other: any): Lt; lte(other: Constant): Lte; lte(other: any): Lte; mapGet(subfield: string): MapGet; - max(): Max; - min(): Min; + maximum(): Maximum; + minimum(): Minimum; mod(other: Constant): Mod; mod(other: any): Mod; multiply(other: Constant): Multiply; multiply(other: any): Multiply; neq(other: Constant): Neq; neq(other: any): Neq; + notEqAny(...others: Constant[]): FirestoreFunction; + // (undocumented) + notEqAny(...others: any[]): FirestoreFunction; // (undocumented) static of(name: string, ...others: string[]): Fields; // (undocumented) @@ -1072,6 +1113,9 @@ export class FirestoreFunction { endsWith(suffix: Constant): EndsWith; eq(other: Constant): Eq; eq(other: any): Eq; + eqAny(...others: Constant[]): EqAny; + // (undocumented) + eqAny(...others: any[]): EqAny; euclideanDistance(other: Constant): EuclideanDistance; euclideanDistance(other: VectorValue): EuclideanDistance; // (undocumented) @@ -1083,30 +1127,30 @@ export class FirestoreFunction { gt(other: any): Gt; gte(other: Constant): Gte; gte(other: any): Gte; - in(...others: Constant[]): In; - // (undocumented) - in(...others: any[]): In; isNaN(): IsNan; like(pattern: string): Like; // (undocumented) like(pattern: Constant): Like; - logicalMax(other: Constant): LogicalMax; - logicalMax(other: any): LogicalMax; - logicalMin(other: Constant): LogicalMin; - logicalMin(other: any): LogicalMin; + logicalMaximum(other: Constant): LogicalMaximum; + logicalMaximum(other: any): LogicalMaximum; + logicalMinimum(other: Constant): LogicalMinimum; + logicalMinimum(other: any): LogicalMinimum; lt(other: Constant): Lt; lt(other: any): Lt; lte(other: Constant): Lte; lte(other: any): Lte; mapGet(subfield: string): MapGet; - max(): Max; - min(): Min; + maximum(): Maximum; + minimum(): Minimum; mod(other: Constant): Mod; mod(other: any): Mod; multiply(other: Constant): Multiply; multiply(other: any): Multiply; neq(other: Constant): Neq; neq(other: any): Neq; + notEqAny(...others: Constant[]): FirestoreFunction; + // (undocumented) + notEqAny(...others: any[]): FirestoreFunction; regexContains(pattern: string): RegexContains; regexContains(pattern: Constant): RegexContains; regexMatch(pattern: string): RegexMatch; @@ -1226,35 +1270,6 @@ export function gte(left: string, right: Constant): Gte; // @beta export function gte(left: string, right: any): Gte; -// @beta (undocumented) -export class If extends FirestoreFunction implements FilterCondition { - constructor(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function ifFunction(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant): If; - -// @beta (undocumented) -export class In extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, others: Constant[]); - // (undocumented) - filterable: true; - } - -// @beta -export function inAny(element: Constant, others: Constant[]): In; - -// @beta -export function inAny(element: Constant, others: any[]): In; - -// @beta -export function inAny(element: string, others: Constant[]): In; - -// @beta -export function inAny(element: string, others: any[]): In; - // @public export function increment(n: number): FieldValue; @@ -1310,38 +1325,38 @@ export function limit(limit: number): QueryLimitConstraint; export function limitToLast(limit: number): QueryLimitConstraint; // @beta (undocumented) -export class LogicalMax extends FirestoreFunction { +export class LogicalMaximum extends FirestoreFunction { constructor(left: Constant, right: Constant); } // @beta -export function logicalMax(left: Constant, right: Constant): LogicalMax; +export function logicalMaximum(left: Constant, right: Constant): LogicalMaximum; // @beta -export function logicalMax(left: Constant, right: any): LogicalMax; +export function logicalMaximum(left: Constant, right: any): LogicalMaximum; // @beta -export function logicalMax(left: string, right: Constant): LogicalMax; +export function logicalMaximum(left: string, right: Constant): LogicalMaximum; // @beta -export function logicalMax(left: string, right: any): LogicalMax; +export function logicalMaximum(left: string, right: any): LogicalMaximum; // @beta (undocumented) -export class LogicalMin extends FirestoreFunction { +export class LogicalMinimum extends FirestoreFunction { constructor(left: Constant, right: Constant); } // @beta -export function logicalMin(left: Constant, right: Constant): LogicalMin; +export function logicalMinimum(left: Constant, right: Constant): LogicalMinimum; // @beta -export function logicalMin(left: Constant, right: any): LogicalMin; +export function logicalMinimum(left: Constant, right: any): LogicalMinimum; // @beta -export function logicalMin(left: string, right: Constant): LogicalMin; +export function logicalMinimum(left: string, right: Constant): LogicalMinimum; // @beta -export function logicalMin(left: string, right: any): LogicalMin; +export function logicalMinimum(left: string, right: any): LogicalMinimum; export { LogLevel } @@ -1398,30 +1413,30 @@ export function mapGet(mapField: string, subField: string): MapGet; export function mapGet(mapExpr: Constant, subField: string): MapGet; // @beta (undocumented) -export class Max extends FirestoreFunction implements Accumulator { +export class Maximum extends FirestoreFunction implements Accumulator { constructor(value: Constant, distinct: boolean); // (undocumented) accumulator: true; } // @beta -export function max(value: Constant): Max; +export function maximum(value: Constant): Maximum; // @beta -export function max(value: string): Max; +export function maximum(value: string): Maximum; // @beta (undocumented) -export class Min extends FirestoreFunction implements Accumulator { +export class Minimum extends FirestoreFunction implements Accumulator { constructor(value: Constant, distinct: boolean); // (undocumented) accumulator: true; } // @beta -export function min(value: Constant): Min; +export function minimum(value: Constant): Minimum; // @beta -export function min(value: string): Min; +export function minimum(value: string): Minimum; // @beta (undocumented) export class Mod extends FirestoreFunction { @@ -1492,16 +1507,16 @@ export class Not extends FirestoreFunction implements FilterCondition { export function not(filter: FilterExpr): Not; // @beta -export function notInAny(element: Constant, others: Constant[]): Not; +export function notEqAny(element: Constant, others: Constant[]): FirestoreFunction; // @beta -export function notInAny(element: Constant, others: any[]): Not; +export function notEqAny(element: Constant, others: any[]): FirestoreFunction; // @beta -export function notInAny(element: string, others: Constant[]): Not; +export function notEqAny(element: string, others: Constant[]): FirestoreFunction; // @beta -export function notInAny(element: string, others: any[]): Not; +export function notEqAny(element: string, others: any[]): FirestoreFunction; // @beta (undocumented) export class Offset implements Stage { @@ -1541,55 +1556,55 @@ export class Pipeline { /* Excluded from this release type: _db */ // Warning: (ae-incompatible-release-tags) The symbol "addFields" is marked as @public, but its signature references "Selectable" which is marked as @beta addFields(...fields: Selectable[]): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ + /* Excluded from this release type: _userDataWriter */ + /* Excluded from this release type: _documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "aggregate" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta aggregate(...accumulators: AccumulatorTarget[]): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ + /* Excluded from this release type: _userDataWriter */ + /* Excluded from this release type: _documentReferenceFactory */ aggregate(options: { accumulators: AccumulatorTarget[]; groups?: Array; }): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ + /* Excluded from this release type: _userDataWriter */ + /* Excluded from this release type: _documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "distinct" is marked as @public, but its signature references "Selectable" which is marked as @beta distinct(...groups: Array): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ + /* Excluded from this release type: _userDataWriter */ + /* Excluded from this release type: _documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "execute" is marked as @public, but its signature references "PipelineResult" which is marked as @beta execute(): Promise>>; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ + /* Excluded from this release type: _userDataWriter */ + /* Excluded from this release type: _documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "findNearest" is marked as @public, but its signature references "FindNearestOptions" which is marked as @beta // // (undocumented) findNearest(options: FindNearestOptions): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ + /* Excluded from this release type: _userDataWriter */ + /* Excluded from this release type: _documentReferenceFactory */ genericStage(name: string, params: any[]): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ + /* Excluded from this release type: _userDataWriter */ + /* Excluded from this release type: _documentReferenceFactory */ limit(limit: number): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ + /* Excluded from this release type: _userDataWriter */ + /* Excluded from this release type: _documentReferenceFactory */ offset(offset: number): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ + /* Excluded from this release type: _userDataWriter */ + /* Excluded from this release type: _documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "select" is marked as @public, but its signature references "Selectable" which is marked as @beta select(...selections: Array): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ + /* Excluded from this release type: _userDataWriter */ + /* Excluded from this release type: _documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "sort" is marked as @public, but its signature references "Ordering" which is marked as @beta sort(...orderings: Ordering[]): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ + /* Excluded from this release type: _userDataWriter */ + /* Excluded from this release type: _documentReferenceFactory */ // (undocumented) sort(options: { orderings: Ordering[]; }): Pipeline; - /* Excluded from this release type: userDataWriter */ - /* Excluded from this release type: documentReferenceFactory */ + /* Excluded from this release type: _userDataWriter */ + /* Excluded from this release type: _documentReferenceFactory */ // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "FilterCondition" which is marked as @beta // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "Constant" which is marked as @beta where(condition: FilterCondition & Constant): Pipeline; @@ -1619,6 +1634,11 @@ export class PipelineResult { // @beta export class PipelineSource { + /* Excluded from this release type: _db */ + /* Excluded from this release type: _userDataReader */ + /* Excluded from this release type: _userDataWriter */ + /* Excluded from this release type: _documentReferenceFactory */ + /* Excluded from this release type: __constructor */ // (undocumented) collection(collectionPath: string): Pipeline; // (undocumented) @@ -1627,7 +1647,7 @@ export class PipelineSource { database(): Pipeline; // (undocumented) documents(docs: DocumentReference[]): Pipeline; - } +} // @public export type Primitive = string | number | boolean | undefined | null; @@ -2120,8 +2140,8 @@ export function updateDoc(refere // @public export function updateDoc(reference: DocumentReference, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise; -// @public -export function useFirestorePipelines(): void; +// @public (undocumented) +export function useFluentPipelines(): void; // @public export function vector(values?: number[]): VectorValue; @@ -2188,8 +2208,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9177:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9178:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9207:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9248:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9249:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9278:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index 212d93972b2..4b1e3bcc0b2 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -300,6 +300,16 @@ export class CollectionSource implements Stage { name: string; } +// @beta (undocumented) +export class Cond extends FirestoreFunction implements FilterCondition { + constructor(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant); + // (undocumented) + filterable: true; + } + +// @beta +export function cond(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant): Cond; + // @public export function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: { mockUserToken?: EmulatorMockTokenOptions | string; @@ -338,6 +348,9 @@ export class Constant { endsWith(suffix: Constant): EndsWith; eq(other: Constant): Eq; eq(other: any): Eq; + eqAny(...others: Constant[]): EqAny; + // (undocumented) + eqAny(...others: any[]): EqAny; euclideanDistance(other: Constant): EuclideanDistance; euclideanDistance(other: VectorValue): EuclideanDistance; // (undocumented) @@ -349,30 +362,30 @@ export class Constant { gt(other: any): Gt; gte(other: Constant): Gte; gte(other: any): Gte; - in(...others: Constant[]): In; - // (undocumented) - in(...others: any[]): In; isNaN(): IsNan; like(pattern: string): Like; // (undocumented) like(pattern: Constant): Like; - logicalMax(other: Constant): LogicalMax; - logicalMax(other: any): LogicalMax; - logicalMin(other: Constant): LogicalMin; - logicalMin(other: any): LogicalMin; + logicalMaximum(other: Constant): LogicalMaximum; + logicalMaximum(other: any): LogicalMaximum; + logicalMinimum(other: Constant): LogicalMinimum; + logicalMinimum(other: any): LogicalMinimum; lt(other: Constant): Lt; lt(other: any): Lt; lte(other: Constant): Lte; lte(other: any): Lte; mapGet(subfield: string): MapGet; - max(): Max; - min(): Min; + maximum(): Maximum; + minimum(): Minimum; mod(other: Constant): Mod; mod(other: any): Mod; multiply(other: Constant): Multiply; multiply(other: any): Multiply; neq(other: Constant): Neq; neq(other: any): Neq; + notEqAny(...others: Constant[]): NotEqAny; + // (undocumented) + notEqAny(...others: any[]): NotEqAny; static of(value: number): Constant; static of(value: string): Constant; static of(value: boolean): Constant; @@ -659,6 +672,25 @@ export function eq(left: string, right: Constant): Eq; // @beta export function eq(left: string, right: any): Eq; +// @beta (undocumented) +export class EqAny extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, others: Constant[]); + // (undocumented) + filterable: true; + } + +// @beta +export function eqAny(element: Constant, others: Constant[]): EqAny; + +// @beta +export function eqAny(element: Constant, others: any[]): EqAny; + +// @beta +export function eqAny(element: string, others: Constant[]): EqAny; + +// @beta +export function eqAny(element: string, others: any[]): EqAny; + // @beta (undocumented) export class EuclideanDistance extends FirestoreFunction { constructor(vector1: Constant, vector2: Constant); @@ -682,8 +714,10 @@ export function euclideanDistance(expr: Constant, other: VectorValue): Euclidean // @beta export function euclideanDistance(expr: Constant, other: Constant): EuclideanDistance; -// @beta -export function execute(pipeline: Pipeline): Promise>>; +// Warning: (ae-incompatible-release-tags) The symbol "execute" is marked as @public, but its signature references "PipelineResult" which is marked as @beta +// +// @public (undocumented) +export function execute(pipeline: Pipeline): Promise>>; // @beta (undocumented) export class Exists extends FirestoreFunction implements FilterCondition { @@ -742,6 +776,9 @@ export class ExprWithAlias implements Selectable { endsWith(suffix: Constant): EndsWith; eq(other: Constant): Eq; eq(other: any): Eq; + eqAny(...others: Constant[]): EqAny; + // (undocumented) + eqAny(...others: any[]): EqAny; euclideanDistance(other: Constant): EuclideanDistance; euclideanDistance(other: VectorValue): EuclideanDistance; // (undocumented) @@ -755,30 +792,30 @@ export class ExprWithAlias implements Selectable { gt(other: any): Gt; gte(other: Constant): Gte; gte(other: any): Gte; - in(...others: Constant[]): In; - // (undocumented) - in(...others: any[]): In; isNaN(): IsNan; like(pattern: string): Like; // (undocumented) like(pattern: Constant): Like; - logicalMax(other: Constant): LogicalMax; - logicalMax(other: any): LogicalMax; - logicalMin(other: Constant): LogicalMin; - logicalMin(other: any): LogicalMin; + logicalMaximum(other: Constant): LogicalMaximum; + logicalMaximum(other: any): LogicalMaximum; + logicalMinimum(other: Constant): LogicalMinimum; + logicalMinimum(other: any): LogicalMinimum; lt(other: Constant): Lt; lt(other: any): Lt; lte(other: Constant): Lte; lte(other: any): Lte; mapGet(subfield: string): MapGet; - max(): Max; - min(): Min; + maximum(): Maximum; + minimum(): Minimum; mod(other: Constant): Mod; mod(other: any): Mod; multiply(other: Constant): Multiply; multiply(other: any): Multiply; neq(other: Constant): Neq; neq(other: any): Neq; + notEqAny(...others: Constant[]): NotEqAny; + // (undocumented) + notEqAny(...others: any[]): NotEqAny; regexContains(pattern: string): RegexContains; regexContains(pattern: Constant): RegexContains; regexMatch(pattern: string): RegexMatch; @@ -847,6 +884,9 @@ export class Field implements Selectable { endsWith(suffix: Constant): EndsWith; eq(other: Constant): Eq; eq(other: any): Eq; + eqAny(...others: Constant[]): EqAny; + // (undocumented) + eqAny(...others: any[]): EqAny; euclideanDistance(other: Constant): EuclideanDistance; euclideanDistance(other: VectorValue): EuclideanDistance; // (undocumented) @@ -860,30 +900,30 @@ export class Field implements Selectable { gt(other: any): Gt; gte(other: Constant): Gte; gte(other: any): Gte; - in(...others: Constant[]): In; - // (undocumented) - in(...others: any[]): In; isNaN(): IsNan; like(pattern: string): Like; // (undocumented) like(pattern: Constant): Like; - logicalMax(other: Constant): LogicalMax; - logicalMax(other: any): LogicalMax; - logicalMin(other: Constant): LogicalMin; - logicalMin(other: any): LogicalMin; + logicalMaximum(other: Constant): LogicalMaximum; + logicalMaximum(other: any): LogicalMaximum; + logicalMinimum(other: Constant): LogicalMinimum; + logicalMinimum(other: any): LogicalMinimum; lt(other: Constant): Lt; lt(other: any): Lt; lte(other: Constant): Lte; lte(other: any): Lte; mapGet(subfield: string): MapGet; - max(): Max; - min(): Min; + maximum(): Maximum; + minimum(): Minimum; mod(other: Constant): Mod; mod(other: any): Mod; multiply(other: Constant): Multiply; multiply(other: any): Multiply; neq(other: Constant): Neq; neq(other: any): Neq; + notEqAny(...others: Constant[]): NotEqAny; + // (undocumented) + notEqAny(...others: any[]): NotEqAny; static of(name: string): Field; // (undocumented) static of(path: FieldPath): Field; @@ -963,6 +1003,9 @@ export class Fields implements Selectable { endsWith(suffix: Constant): EndsWith; eq(other: Constant): Eq; eq(other: any): Eq; + eqAny(...others: Constant[]): EqAny; + // (undocumented) + eqAny(...others: any[]): EqAny; euclideanDistance(other: Constant): EuclideanDistance; euclideanDistance(other: VectorValue): EuclideanDistance; // (undocumented) @@ -976,30 +1019,30 @@ export class Fields implements Selectable { gt(other: any): Gt; gte(other: Constant): Gte; gte(other: any): Gte; - in(...others: Constant[]): In; - // (undocumented) - in(...others: any[]): In; isNaN(): IsNan; like(pattern: string): Like; // (undocumented) like(pattern: Constant): Like; - logicalMax(other: Constant): LogicalMax; - logicalMax(other: any): LogicalMax; - logicalMin(other: Constant): LogicalMin; - logicalMin(other: any): LogicalMin; + logicalMaximum(other: Constant): LogicalMaximum; + logicalMaximum(other: any): LogicalMaximum; + logicalMinimum(other: Constant): LogicalMinimum; + logicalMinimum(other: any): LogicalMinimum; lt(other: Constant): Lt; lt(other: any): Lt; lte(other: Constant): Lte; lte(other: any): Lte; mapGet(subfield: string): MapGet; - max(): Max; - min(): Min; + maximum(): Maximum; + minimum(): Minimum; mod(other: Constant): Mod; mod(other: any): Mod; multiply(other: Constant): Multiply; multiply(other: any): Multiply; neq(other: Constant): Neq; neq(other: any): Neq; + notEqAny(...others: Constant[]): NotEqAny; + // (undocumented) + notEqAny(...others: any[]): NotEqAny; // (undocumented) static of(name: string, ...others: string[]): Fields; // (undocumented) @@ -1133,6 +1176,9 @@ export class FirestoreFunction { endsWith(suffix: Constant): EndsWith; eq(other: Constant): Eq; eq(other: any): Eq; + eqAny(...others: Constant[]): EqAny; + // (undocumented) + eqAny(...others: any[]): EqAny; euclideanDistance(other: Constant): EuclideanDistance; euclideanDistance(other: VectorValue): EuclideanDistance; // (undocumented) @@ -1144,30 +1190,30 @@ export class FirestoreFunction { gt(other: any): Gt; gte(other: Constant): Gte; gte(other: any): Gte; - in(...others: Constant[]): In; - // (undocumented) - in(...others: any[]): In; isNaN(): IsNan; like(pattern: string): Like; // (undocumented) like(pattern: Constant): Like; - logicalMax(other: Constant): LogicalMax; - logicalMax(other: any): LogicalMax; - logicalMin(other: Constant): LogicalMin; - logicalMin(other: any): LogicalMin; + logicalMaximum(other: Constant): LogicalMaximum; + logicalMaximum(other: any): LogicalMaximum; + logicalMinimum(other: Constant): LogicalMinimum; + logicalMinimum(other: any): LogicalMinimum; lt(other: Constant): Lt; lt(other: any): Lt; lte(other: Constant): Lte; lte(other: any): Lte; mapGet(subfield: string): MapGet; - max(): Max; - min(): Min; + maximum(): Maximum; + minimum(): Minimum; mod(other: Constant): Mod; mod(other: any): Mod; multiply(other: Constant): Multiply; multiply(other: any): Multiply; neq(other: Constant): Neq; neq(other: any): Neq; + notEqAny(...others: Constant[]): NotEqAny; + // (undocumented) + notEqAny(...others: any[]): NotEqAny; regexContains(pattern: string): RegexContains; regexContains(pattern: Constant): RegexContains; regexMatch(pattern: string): RegexMatch; @@ -1317,35 +1363,6 @@ export function gte(left: string, right: Constant): Gte; // @beta export function gte(left: string, right: any): Gte; -// @beta (undocumented) -export class If extends FirestoreFunction implements FilterCondition { - constructor(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant); - // (undocumented) - filterable: true; - } - -// @beta -export function ifFunction(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant): If; - -// @beta (undocumented) -export class In extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, others: Constant[]); - // (undocumented) - filterable: true; - } - -// @beta -export function inAny(element: Constant, others: Constant[]): In; - -// @beta -export function inAny(element: Constant, others: any[]): In; - -// @beta -export function inAny(element: string, others: Constant[]): In; - -// @beta -export function inAny(element: string, others: any[]): In; - // @public export function increment(n: number): FieldValue; @@ -1444,38 +1461,38 @@ export interface LoadBundleTaskProgress { } // @beta (undocumented) -export class LogicalMax extends FirestoreFunction { +export class LogicalMaximum extends FirestoreFunction { constructor(left: Constant, right: Constant); } // @beta -export function logicalMax(left: Constant, right: Constant): LogicalMax; +export function logicalMaximum(left: Constant, right: Constant): LogicalMaximum; // @beta -export function logicalMax(left: Constant, right: any): LogicalMax; +export function logicalMaximum(left: Constant, right: any): LogicalMaximum; // @beta -export function logicalMax(left: string, right: Constant): LogicalMax; +export function logicalMaximum(left: string, right: Constant): LogicalMaximum; // @beta -export function logicalMax(left: string, right: any): LogicalMax; +export function logicalMaximum(left: string, right: any): LogicalMaximum; // @beta (undocumented) -export class LogicalMin extends FirestoreFunction { +export class LogicalMinimum extends FirestoreFunction { constructor(left: Constant, right: Constant); } // @beta -export function logicalMin(left: Constant, right: Constant): LogicalMin; +export function logicalMinimum(left: Constant, right: Constant): LogicalMinimum; // @beta -export function logicalMin(left: Constant, right: any): LogicalMin; +export function logicalMinimum(left: Constant, right: any): LogicalMinimum; // @beta -export function logicalMin(left: string, right: Constant): LogicalMin; +export function logicalMinimum(left: string, right: Constant): LogicalMinimum; // @beta -export function logicalMin(left: string, right: any): LogicalMin; +export function logicalMinimum(left: string, right: any): LogicalMinimum; export { LogLevel } @@ -1532,17 +1549,17 @@ export function mapGet(mapField: string, subField: string): MapGet; export function mapGet(mapExpr: Constant, subField: string): MapGet; // @beta (undocumented) -export class Max extends FirestoreFunction implements Accumulator { +export class Maximum extends FirestoreFunction implements Accumulator { constructor(value: Constant, distinct: boolean); // (undocumented) accumulator: true; } // @beta -export function max(value: Constant): Max; +export function maximum(value: Constant): Maximum; // @beta -export function max(value: string): Max; +export function maximum(value: string): Maximum; // @public export interface MemoryCacheSettings { @@ -1582,17 +1599,17 @@ export function memoryLruGarbageCollector(settings?: { }): MemoryLruGarbageCollector; // @beta (undocumented) -export class Min extends FirestoreFunction implements Accumulator { +export class Minimum extends FirestoreFunction implements Accumulator { constructor(value: Constant, distinct: boolean); // (undocumented) accumulator: true; } // @beta -export function min(value: Constant): Min; +export function minimum(value: Constant): Minimum; // @beta -export function min(value: string): Min; +export function minimum(value: string): Minimum; // @beta (undocumented) export class Mod extends FirestoreFunction { @@ -1665,17 +1682,24 @@ export class Not extends FirestoreFunction implements FilterCondition { // @beta export function not(filter: FilterExpr): Not; +// @beta (undocumented) +export class NotEqAny extends FirestoreFunction implements FilterCondition { + constructor(left: Constant, others: Constant[]); + // (undocumented) + filterable: true; + } + // @beta -export function notInAny(element: Constant, others: Constant[]): Not; +export function notEqAny(element: Constant, others: Constant[]): NotEqAny; // @beta -export function notInAny(element: Constant, others: any[]): Not; +export function notEqAny(element: Constant, others: any[]): NotEqAny; // @beta -export function notInAny(element: string, others: Constant[]): Not; +export function notEqAny(element: string, others: Constant[]): NotEqAny; // @beta -export function notInAny(element: string, others: any[]): Not; +export function notEqAny(element: string, others: any[]): NotEqAny; // @beta (undocumented) export class Offset implements Stage { @@ -1817,6 +1841,7 @@ export type PersistentTabManager = PersistentSingleTabManager | PersistentMultip // @public (undocumented) export class Pipeline { /* Excluded from this release type: __constructor */ + /* Excluded from this release type: newPipeline */ // Warning: (ae-incompatible-release-tags) The symbol "addFields" is marked as @public, but its signature references "Selectable" which is marked as @beta addFields(...fields: Selectable[]): Pipeline; // Warning: (ae-incompatible-release-tags) The symbol "aggregate" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta @@ -1877,6 +1902,11 @@ export class PipelineResult { // @beta export class PipelineSource { + /* Excluded from this release type: _db */ + /* Excluded from this release type: _userDataReader */ + /* Excluded from this release type: _userDataWriter */ + /* Excluded from this release type: _documentReferenceFactory */ + /* Excluded from this release type: __constructor */ // (undocumented) collection(collectionPath: string): Pipeline; // (undocumented) @@ -1885,7 +1915,7 @@ export class PipelineSource { database(): Pipeline; // (undocumented) documents(docs: DocumentReference[]): Pipeline; - } +} // @public export type Primitive = string | number | boolean | undefined | null; @@ -2411,8 +2441,8 @@ export function updateDoc(refere // @public export function updateDoc(reference: DocumentReference, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise; -// @public -export function useFirestorePipelines(): void; +// @public (undocumented) +export function useFluentPipelines(): void; // @public export function vector(values?: number[]): VectorValue; @@ -2482,8 +2512,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10102:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10102:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10129:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10177:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10177:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10204:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/packages/firestore/lite/index.ts b/packages/firestore/lite/index.ts index 636eb4c6709..d001457ac50 100644 --- a/packages/firestore/lite/index.ts +++ b/packages/firestore/lite/index.ts @@ -31,11 +31,13 @@ export { PipelineSource } from '../src/lite-api/pipeline-source'; export { PipelineResult } from '../src/lite-api/pipeline-result'; -export { Pipeline, pipeline } from '../src/lite-api/pipeline'; +export { Pipeline } from '../src/lite-api/pipeline'; -export { useFirestorePipelines } from '../src/lite-api/database_augmentation'; - -export { execute } from '../src/lite-api/pipeline_impl'; +export { + useFluentPipelines, + pipeline, + execute +} from '../src/lite-api/pipeline_impl'; export { Stage, @@ -73,13 +75,13 @@ export { arrayContainsAny, arrayContainsAll, arrayLength, - inAny, - notInAny, + eqAny, + notEqAny, xor, - ifFunction, + cond, not, - logicalMax, - logicalMin, + logicalMaximum, + logicalMinimum, exists, isNan, reverse, @@ -99,8 +101,8 @@ export { strConcat, mapGet, countAll, - min, - max, + minimum, + maximum, cosineDistance, dotProduct, euclideanDistance, @@ -139,16 +141,16 @@ export { ArrayContainsAny, ArrayLength, ArrayElement, - In, + EqAny, IsNan, Exists, Not, And, Or, Xor, - If, - LogicalMax, - LogicalMin, + Cond, + LogicalMaximum, + LogicalMinimum, Reverse, ReplaceFirst, ReplaceAll, @@ -168,8 +170,8 @@ export { Count, Sum, Avg, - Min, - Max, + Minimum, + Maximum, CosineDistance, DotProduct, EuclideanDistance, diff --git a/packages/firestore/src/api.ts b/packages/firestore/src/api.ts index 4a35ed07760..7619312d2d5 100644 --- a/packages/firestore/src/api.ts +++ b/packages/firestore/src/api.ts @@ -21,9 +21,7 @@ export { PipelineResult } from './lite-api/pipeline-result'; export { Pipeline } from './api/pipeline'; -export { useFirestorePipelines, pipeline } from './api/pipeline_impl'; - -export { execute } from './lite-api/pipeline_impl'; +export { useFluentPipelines, pipeline, execute } from './api/pipeline_impl'; export { Stage, diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index cc1fab0c86a..bf36d469552 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -135,7 +135,7 @@ export class Firestore extends LiteFirestore { */ pipeline(): PipelineSource { throw new Error( - 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' + 'Pipelines not initialized. Your application must call `useFluentPipelines()` before using Firestore Pipeline features.' ); } } diff --git a/packages/firestore/src/api/database_augmentation.ts b/packages/firestore/src/api/database_augmentation.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/packages/firestore/src/api/pipeline-source.ts b/packages/firestore/src/api/pipeline-source.ts index 31a2d9d69a5..3ad66cab9e9 100644 --- a/packages/firestore/src/api/pipeline-source.ts +++ b/packages/firestore/src/api/pipeline-source.ts @@ -39,61 +39,61 @@ export class PipelineSource extends LitePipelineSoure { /** * @internal * @private - * @param db - * @param userDataReader - * @param userDataWriter - * @param documentReferenceFactory + * @param _db + * @param _userDataReader + * @param _userDataWriter + * @param _documentReferenceFactory */ // eslint-disable-next-line @typescript-eslint/no-useless-constructor constructor( - db: Firestore, - userDataReader: UserDataReader, - userDataWriter: AbstractUserDataWriter, - documentReferenceFactory: (id: DocumentKey) => DocumentReference + _db: Firestore, + _userDataReader: UserDataReader, + _userDataWriter: AbstractUserDataWriter, + _documentReferenceFactory: (id: DocumentKey) => DocumentReference ) { - super(db, userDataReader, userDataWriter, documentReferenceFactory); + super(_db, _userDataReader, _userDataWriter, _documentReferenceFactory); } collection(collectionPath: string): Pipeline { - const db = cast(this.db, Firestore); + const _db = cast(this._db, Firestore); return new Pipeline( - db, - this.userDataReader, - this.userDataWriter, - this.documentReferenceFactory, + _db, + this._userDataReader, + this._userDataWriter, + this._documentReferenceFactory, [new CollectionSource(collectionPath)] ); } collectionGroup(collectionId: string): Pipeline { - const db = cast(this.db, Firestore); + const _db = cast(this._db, Firestore); return new Pipeline( - db, - this.userDataReader, - this.userDataWriter, - this.documentReferenceFactory, + _db, + this._userDataReader, + this._userDataWriter, + this._documentReferenceFactory, [new CollectionGroupSource(collectionId)] ); } database(): Pipeline { - const db = cast(this.db, Firestore); + const _db = cast(this._db, Firestore); return new Pipeline( - db, - this.userDataReader, - this.userDataWriter, - this.documentReferenceFactory, + _db, + this._userDataReader, + this._userDataWriter, + this._documentReferenceFactory, [new DatabaseSource()] ); } documents(docs: DocumentReference[]): Pipeline { - const db = cast(this.db, Firestore); + const _db = cast(this._db, Firestore); return new Pipeline( - db, - this.userDataReader, - this.userDataWriter, - this.documentReferenceFactory, + _db, + this._userDataReader, + this._userDataWriter, + this._documentReferenceFactory, [DocumentsSource.of(docs)] ); } diff --git a/packages/firestore/src/api/pipeline.ts b/packages/firestore/src/api/pipeline.ts index 029e2d53eeb..de2cb16d9aa 100644 --- a/packages/firestore/src/api/pipeline.ts +++ b/packages/firestore/src/api/pipeline.ts @@ -58,6 +58,17 @@ export class Pipeline< ); } + /** + * @internal + * @private + * @param db + * @param userDataReader + * @param userDataWriter + * @param documentReferenceFactory + * @param stages + * @param converter + * @protected + */ protected newPipeline( db: Firestore, userDataReader: UserDataReader, @@ -109,7 +120,7 @@ export class Pipeline< */ execute(): Promise>> { throw new Error( - 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' + 'Pipelines not initialized. Your application must call `useFluentPipelines()` before using Firestore Pipeline features.' ); } } diff --git a/packages/firestore/src/api/pipeline_impl.ts b/packages/firestore/src/api/pipeline_impl.ts index 91163eff3c2..b28821dbfe2 100644 --- a/packages/firestore/src/api/pipeline_impl.ts +++ b/packages/firestore/src/api/pipeline_impl.ts @@ -17,8 +17,9 @@ import { Pipeline } from '../api/pipeline'; import { PipelineSource } from '../api/pipeline-source'; -import { PipelineResult } from '../api_pipelines'; import { firestoreClientExecutePipeline } from '../core/firestore_client'; +import { Pipeline as LitePipeline } from '../lite-api/pipeline'; +import { PipelineResult } from '../lite-api/pipeline-result'; import { newUserDataReader } from '../lite-api/user_data_reader'; import { DocumentKey } from '../model/document_key'; import { cast } from '../util/input_validation'; @@ -68,7 +69,7 @@ export function pipeline( return result; } } -export function useFirestorePipelines(): void { +export function useFluentPipelines(): void { Firestore.prototype.pipeline = function (): PipelineSource { return pipeline(this); }; @@ -83,7 +84,7 @@ export function useFirestorePipelines(): void { } export function execute( - pipeline: Pipeline + pipeline: LitePipeline ): Promise>> { const firestore = cast(pipeline._db, Firestore); const client = ensureFirestoreConfigured(firestore); diff --git a/packages/firestore/src/api_pipelines.ts b/packages/firestore/src/api_pipelines.ts index 658794098ea..bcd54dca314 100644 --- a/packages/firestore/src/api_pipelines.ts +++ b/packages/firestore/src/api_pipelines.ts @@ -20,7 +20,7 @@ export { PipelineResult } from './lite-api/pipeline-result'; export { Pipeline } from './lite-api/pipeline'; -export { useFirestorePipelines } from './api/database_augmentation'; +export { useFluentPipelines, execute, pipeline } from './api/pipeline_impl'; export { Stage, diff --git a/packages/firestore/src/core/pipeline-util.ts b/packages/firestore/src/core/pipeline-util.ts index 732d2963fcf..38c291a4710 100644 --- a/packages/firestore/src/core/pipeline-util.ts +++ b/packages/firestore/src/core/pipeline-util.ts @@ -211,7 +211,7 @@ export function toPipelineFilterCondition( const values = value?.arrayValue?.values?.map((val: any) => Constant.of(val) ); - return andFunction(field.exists(), field.in(...values!)); + return andFunction(field.exists(), field.eqAny(...values!)); } case Operator.ARRAY_CONTAINS_ANY: { const values = value?.arrayValue?.values?.map((val: any) => @@ -223,7 +223,7 @@ export function toPipelineFilterCondition( const values = value?.arrayValue?.values?.map((val: any) => Constant.of(val) ); - return andFunction(field.exists(), not(field.in(...values!))); + return andFunction(field.exists(), not(field.eqAny(...values!))); } default: fail('Unexpected operator'); diff --git a/packages/firestore/src/lite-api/database.ts b/packages/firestore/src/lite-api/database.ts index 6ef01bb5172..880ede2bed8 100644 --- a/packages/firestore/src/lite-api/database.ts +++ b/packages/firestore/src/lite-api/database.ts @@ -42,7 +42,7 @@ import { logWarn } from '../util/log'; import { FirestoreService, removeComponents } from './components'; // `import type` to avoid bundling the source for -// pipelines if `useFirestorePipelines()` is not called +// pipelines if `useFluentPipelines()` is not called import type { PipelineSource } from './pipeline-source'; import { DEFAULT_HOST, @@ -182,7 +182,7 @@ export class Firestore implements FirestoreService { */ pipeline(): PipelineSource { throw new Error( - 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' + 'Pipelines not initialized. Your application must call `useFluentPipelines()` before using Firestore Pipeline features.' ); } } diff --git a/packages/firestore/src/lite-api/pipeline-source.ts b/packages/firestore/src/lite-api/pipeline-source.ts index da62a229adc..99da8fee8c6 100644 --- a/packages/firestore/src/lite-api/pipeline-source.ts +++ b/packages/firestore/src/lite-api/pipeline-source.ts @@ -37,54 +37,70 @@ export class PipelineSource { /** * @internal * @private - * @param db - * @param userDataReader - * @param userDataWriter - * @param documentReferenceFactory + * @param _db + * @param _userDataReader + * @param _userDataWriter + * @param _documentReferenceFactory */ constructor( - protected db: Firestore, - protected userDataReader: UserDataReader, - protected userDataWriter: AbstractUserDataWriter, - protected documentReferenceFactory: (id: DocumentKey) => DocumentReference + /** + * @internal + * @private + */ + public _db: Firestore, + /** + * @internal + * @private + */ + public _userDataReader: UserDataReader, + /** + * @internal + * @private + */ + public _userDataWriter: AbstractUserDataWriter, + /** + * @internal + * @private + */ + public _documentReferenceFactory: (id: DocumentKey) => DocumentReference ) {} collection(collectionPath: string): Pipeline { return new Pipeline( - this.db, - this.userDataReader, - this.userDataWriter, - this.documentReferenceFactory, + this._db, + this._userDataReader, + this._userDataWriter, + this._documentReferenceFactory, [new CollectionSource(collectionPath)] ); } collectionGroup(collectionId: string): Pipeline { return new Pipeline( - this.db, - this.userDataReader, - this.userDataWriter, - this.documentReferenceFactory, + this._db, + this._userDataReader, + this._userDataWriter, + this._documentReferenceFactory, [new CollectionGroupSource(collectionId)] ); } database(): Pipeline { return new Pipeline( - this.db, - this.userDataReader, - this.userDataWriter, - this.documentReferenceFactory, + this._db, + this._userDataReader, + this._userDataWriter, + this._documentReferenceFactory, [new DatabaseSource()] ); } documents(docs: DocumentReference[]): Pipeline { return new Pipeline( - this.db, - this.userDataReader, - this.userDataWriter, - this.documentReferenceFactory, + this._db, + this._userDataReader, + this._userDataWriter, + this._documentReferenceFactory, [DocumentsSource.of(docs)] ); } diff --git a/packages/firestore/src/lite-api/pipeline.ts b/packages/firestore/src/lite-api/pipeline.ts index f835f709551..a1b9ad481e9 100644 --- a/packages/firestore/src/lite-api/pipeline.ts +++ b/packages/firestore/src/lite-api/pipeline.ts @@ -291,6 +291,17 @@ export class Pipeline return expressionMap; } + /** + * @internal + * @private + * @param db + * @param userDataReader + * @param userDataWriter + * @param documentReferenceFactory + * @param stages + * @param converter + * @protected + */ protected newPipeline( db: Firestore, userDataReader: UserDataReader, @@ -809,7 +820,7 @@ export class Pipeline */ execute(): Promise>> { throw new Error( - 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' + 'Pipelines not initialized. Your application must call `useFluentPipelines()` before using Firestore Pipeline features.' ); } diff --git a/packages/firestore/src/lite-api/pipeline_impl.ts b/packages/firestore/src/lite-api/pipeline_impl.ts index d049bbba05c..c9ebe8ac7f5 100644 --- a/packages/firestore/src/lite-api/pipeline_impl.ts +++ b/packages/firestore/src/lite-api/pipeline_impl.ts @@ -107,7 +107,7 @@ export function pipeline( } } -export function useFirestorePipelines(): void { +export function useFluentPipelines(): void { Firestore.prototype.pipeline = function (): PipelineSource { return pipeline(this); }; diff --git a/packages/firestore/src/lite-api/reference.ts b/packages/firestore/src/lite-api/reference.ts index 71b789227fc..db0949e9fbc 100644 --- a/packages/firestore/src/lite-api/reference.ts +++ b/packages/firestore/src/lite-api/reference.ts @@ -184,7 +184,7 @@ export class Query< */ pipeline(): Pipeline { throw new Error( - 'Pipelines not initialized. Your application must call `useFirestorePipelines()` before using Firestore Pipeline features.' + 'Pipelines not initialized. Your application must call `useFluentPipelines()` before using Firestore Pipeline features.' ); } } diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index 22fb5a1cdfb..6d499a2a4df 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -55,7 +55,7 @@ import { setDoc, startsWith, subtract, - useFirestorePipelines, + useFluentPipelines, setLogLevel, cond, eqAny, @@ -267,7 +267,7 @@ apiDescribe.only('Pipelines', persistence => { describe('fluent API', () => { before(() => { - useFirestorePipelines(); + useFluentPipelines(); }); it('empty results as expected', async () => { From a9a0b828322db7082a945f708a24be4d5a8021e6 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Tue, 10 Dec 2024 11:29:04 -0700 Subject: [PATCH 47/59] Remove type references from the core Firestore API surface. This will support multiple entrypoints work. --- common/api-review/firestore-lite.api.md | 9 +++------ common/api-review/firestore.api.md | 9 +++------ packages/firestore/src/api/database.ts | 10 ---------- packages/firestore/src/api/pipeline_impl.ts | 6 ++++++ packages/firestore/src/lite-api/database.ts | 10 ---------- packages/firestore/src/lite-api/pipeline_impl.ts | 12 ++++++++++++ packages/firestore/src/lite-api/reference.ts | 10 ---------- .../firestore/test/integration/api/pipeline.test.ts | 2 +- 8 files changed, 25 insertions(+), 43 deletions(-) diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 36d02015529..07af0bacd6e 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -1056,8 +1056,6 @@ export interface FindNearestOptions { // @public export class Firestore { get app(): FirebaseApp; - // Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta - pipeline(): PipelineSource; toJSON(): object; type: 'firestore-lite' | 'firestore'; } @@ -1657,7 +1655,6 @@ export class Query | null; readonly firestore: Firestore; - pipeline(): Pipeline; readonly type: 'query' | 'collection'; withConverter(converter: null): Query; withConverter(converter: FirestoreDataConverter): Query; @@ -2208,8 +2205,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9248:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9249:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9278:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9244:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9245:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9274:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index 4b1e3bcc0b2..270c71fe955 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -1119,8 +1119,6 @@ export interface FindNearestOptions { // @public export class Firestore { get app(): FirebaseApp; - // Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta - pipeline(): PipelineSource; toJSON(): object; type: 'firestore-lite' | 'firestore'; } @@ -1925,7 +1923,6 @@ export class Query | null; readonly firestore: Firestore; - pipeline(): Pipeline; readonly type: 'query' | 'collection'; withConverter(converter: null): Query; withConverter(converter: FirestoreDataConverter): Query; @@ -2512,8 +2509,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10177:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10177:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10204:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10173:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10173:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10200:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/packages/firestore/src/api/database.ts b/packages/firestore/src/api/database.ts index bf36d469552..0757378a74c 100644 --- a/packages/firestore/src/api/database.ts +++ b/packages/firestore/src/api/database.ts @@ -46,7 +46,6 @@ import { connectFirestoreEmulator, Firestore as LiteFirestore } from '../lite-api/database'; -import type { PipelineSource } from '../lite-api/pipeline-source'; import { Query } from '../lite-api/reference'; import { indexedDbClearPersistence, @@ -129,15 +128,6 @@ export class Firestore extends LiteFirestore { await terminate; } } - - /** - * Pipeline query. - */ - pipeline(): PipelineSource { - throw new Error( - 'Pipelines not initialized. Your application must call `useFluentPipelines()` before using Firestore Pipeline features.' - ); - } } /** diff --git a/packages/firestore/src/api/pipeline_impl.ts b/packages/firestore/src/api/pipeline_impl.ts index b28821dbfe2..5d58266b343 100644 --- a/packages/firestore/src/api/pipeline_impl.ts +++ b/packages/firestore/src/api/pipeline_impl.ts @@ -28,6 +28,12 @@ import { Firestore, ensureFirestoreConfigured } from './database'; import { DocumentReference, Query } from './reference'; import { ExpUserDataWriter } from './user_data_writer'; +declare module './database' { + interface Firestore { + pipeline(): PipelineSource; + } +} + /** * Experimental Modular API for console testing. * @param firestore diff --git a/packages/firestore/src/lite-api/database.ts b/packages/firestore/src/lite-api/database.ts index 880ede2bed8..33b6afa8092 100644 --- a/packages/firestore/src/lite-api/database.ts +++ b/packages/firestore/src/lite-api/database.ts @@ -43,7 +43,6 @@ import { logWarn } from '../util/log'; import { FirestoreService, removeComponents } from './components'; // `import type` to avoid bundling the source for // pipelines if `useFluentPipelines()` is not called -import type { PipelineSource } from './pipeline-source'; import { DEFAULT_HOST, FirestoreSettingsImpl, @@ -176,15 +175,6 @@ export class Firestore implements FirestoreService { removeComponents(this); return Promise.resolve(); } - - /** - * Pipeline query. - */ - pipeline(): PipelineSource { - throw new Error( - 'Pipelines not initialized. Your application must call `useFluentPipelines()` before using Firestore Pipeline features.' - ); - } } /** diff --git a/packages/firestore/src/lite-api/pipeline_impl.ts b/packages/firestore/src/lite-api/pipeline_impl.ts index c9ebe8ac7f5..f3556dc6f09 100644 --- a/packages/firestore/src/lite-api/pipeline_impl.ts +++ b/packages/firestore/src/lite-api/pipeline_impl.ts @@ -27,6 +27,18 @@ import { DocumentReference, Query } from './reference'; import { LiteUserDataWriter } from './reference_impl'; import { newUserDataReader } from './user_data_reader'; +declare module './database' { + interface Firestore { + pipeline(): PipelineSource; + } +} + +declare module './reference' { + interface Query { + pipeline(): Pipeline; + } +} + /** * Modular API for console experimentation. * @param pipeline Execute this pipeline. diff --git a/packages/firestore/src/lite-api/reference.ts b/packages/firestore/src/lite-api/reference.ts index db0949e9fbc..26ae2fbd433 100644 --- a/packages/firestore/src/lite-api/reference.ts +++ b/packages/firestore/src/lite-api/reference.ts @@ -37,7 +37,6 @@ import { AutoId } from '../util/misc'; import { Firestore } from './database'; import { FieldPath } from './field_path'; import { FieldValue } from './field_value'; -import type { Pipeline } from './pipeline'; import { FirestoreDataConverter } from './snapshot'; import { NestedUpdateFields, Primitive } from './types'; @@ -178,15 +177,6 @@ export class Query< this._query ); } - - /** - * Pipeline query. - */ - pipeline(): Pipeline { - throw new Error( - 'Pipelines not initialized. Your application must call `useFluentPipelines()` before using Firestore Pipeline features.' - ); - } } /** diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index 6d499a2a4df..ddedc966eb4 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -69,7 +69,7 @@ use(chaiAsPromised); setLogLevel('debug'); -apiDescribe.only('Pipelines', persistence => { +apiDescribe('Pipelines', persistence => { addEqualityMatcher(); let firestore: Firestore; let randomCol: CollectionReference; From df90a2e215d3e66dc93f621528f04d2516d207bf Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 18 Dec 2024 09:06:23 -0700 Subject: [PATCH 48/59] Fixes for Constant.of(...) (#8677) --- common/api-review/firestore-lite.api.md | 11 +- common/api-review/firestore.api.md | 11 +- .../firestore/src/lite-api/expressions.ts | 13 +- .../test/integration/api/pipeline.test.ts | 111 ++++++++++++++++++ 4 files changed, 129 insertions(+), 17 deletions(-) diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 07af0bacd6e..7435e2a250e 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -375,14 +375,13 @@ export class Constant { static of(value: string): Constant; static of(value: boolean): Constant; static of(value: null): Constant; - static of(value: undefined): Constant; static of(value: GeoPoint): Constant; static of(value: Timestamp): Constant; static of(value: Date): Constant; - static of(value: Uint8Array): Constant; + static of(value: Bytes): Constant; static of(value: DocumentReference): Constant; static of(value: any[]): Constant; - static of(value: Map): Constant; + static of(value: Record): Constant; static of(value: VectorValue): Constant; regexContains(pattern: string): RegexContains; regexContains(pattern: Constant): RegexContains; @@ -2205,8 +2204,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9244:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9245:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9274:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9238:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9239:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9268:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index 270c71fe955..37317520020 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -390,14 +390,13 @@ export class Constant { static of(value: string): Constant; static of(value: boolean): Constant; static of(value: null): Constant; - static of(value: undefined): Constant; static of(value: GeoPoint): Constant; static of(value: Timestamp): Constant; static of(value: Date): Constant; - static of(value: Uint8Array): Constant; + static of(value: Bytes): Constant; static of(value: DocumentReference): Constant; static of(value: any[]): Constant; - static of(value: Map): Constant; + static of(value: Record): Constant; static of(value: VectorValue): Constant; regexContains(pattern: string): RegexContains; regexContains(pattern: Constant): RegexContains; @@ -2509,8 +2508,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10173:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10173:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/index.d.ts:10200:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10167:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10167:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10194:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/packages/firestore/src/lite-api/expressions.ts b/packages/firestore/src/lite-api/expressions.ts index 3ec68601e9e..261f8112c4d 100644 --- a/packages/firestore/src/lite-api/expressions.ts +++ b/packages/firestore/src/lite-api/expressions.ts @@ -30,6 +30,7 @@ import { } from '../remote/serializer'; import { hardAssert } from '../util/assert'; +import { Bytes } from './bytes'; import { documentId, FieldPath } from './field_path'; import { GeoPoint } from './geo_point'; import { Pipeline } from './pipeline'; @@ -2084,6 +2085,8 @@ export class Constant extends Expr { /** * Creates a `Constant` instance for an undefined value. + * @private + * @internal * * @param value The undefined value. * @return A new `Constant` instance. @@ -2115,12 +2118,12 @@ export class Constant extends Expr { static of(value: Date): Constant; /** - * Creates a `Constant` instance for a Uint8Array value. + * Creates a `Constant` instance for a Bytes value. * - * @param value The Uint8Array value. + * @param value The Bytes value. * @return A new `Constant` instance. */ - static of(value: Uint8Array): Constant; + static of(value: Bytes): Constant; /** * Creates a `Constant` instance for a DocumentReference value. @@ -2130,9 +2133,9 @@ export class Constant extends Expr { */ static of(value: DocumentReference): Constant; - // TODO(pipeline) if we make this public, then the Proto types should also be documented /** * Creates a `Constant` instance for a Firestore proto value. + * For internal use only. * @private * @internal * @param value The Firestore proto value. @@ -2154,7 +2157,7 @@ export class Constant extends Expr { * @param value The map value. * @return A new `Constant` instance. */ - static of(value: Map): Constant; + static of(value: Record): Constant; /** * Creates a `Constant` instance for a VectorValue value. diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index ddedc966eb4..1376947f482 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -18,6 +18,9 @@ import { expect, use } from 'chai'; import chaiAsPromised from 'chai-as-promised'; +import { Bytes, vector } from '../../../src/api'; +import { GeoPoint } from '../../../src/lite-api/geo_point'; +import { Timestamp } from '../../../src/lite-api/timestamp'; import { addEqualityMatcher } from '../../util/equality_matcher'; import { Deferred } from '../../util/promise'; import { @@ -476,6 +479,114 @@ apiDescribe('Pipelines', persistence => { ); }); + it('accepts and returns all data types', async () => { + const refDate = new Date(); + const refTimestamp = Timestamp.now(); + const constants = [ + Constant.of(1).as('number'), + Constant.of('a string').as('string'), + Constant.of(true).as('boolean'), + Constant.of(null).as('null'), + Constant.of(new GeoPoint(0.1, 0.2)).as('geoPoint'), + Constant.of(refTimestamp).as('timestamp'), + Constant.of(refDate).as('date'), + Constant.of( + Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])) + ).as('bytes'), + Constant.of(doc(firestore, 'foo', 'bar')).as('documentReference'), + Constant.of(vector([1, 2, 3])).as('vectorValue'), + Constant.of({ + 'number': 1, + 'string': 'a string', + 'boolean': true, + 'null': null, + 'geoPoint': new GeoPoint(0.1, 0.2), + 'timestamp': refTimestamp, + 'date': refDate, + 'uint8Array': Bytes.fromUint8Array( + new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0]) + ), + 'documentReference': doc(firestore, 'foo', 'bar'), + 'vectorValue': vector([1, 2, 3]), + 'map': { + 'number': 2, + 'string': 'b string' + }, + 'array': [1, 'c string'] + }).as('map'), + Constant.of([ + 1, + 'a string', + true, + null, + new GeoPoint(0.1, 0.2), + refTimestamp, + refDate, + Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])), + doc(firestore, 'foo', 'bar'), + vector([1, 2, 3]), + { + 'number': 2, + 'string': 'b string' + } + ]).as('array') + ]; + + const results = await randomCol + .pipeline() + .limit(1) + .select(...constants) + .execute(); + + expectResults(results, { + 'number': 1, + 'string': 'a string', + 'boolean': true, + 'null': null, + 'geoPoint': new GeoPoint(0.1, 0.2), + 'timestamp': refTimestamp, + 'date': Timestamp.fromDate(refDate), + 'bytes': Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])), + 'documentReference': doc(firestore, 'foo', 'bar'), + 'vectorValue': vector([1, 2, 3]), + 'map': { + 'number': 1, + 'string': 'a string', + 'boolean': true, + 'null': null, + 'geoPoint': new GeoPoint(0.1, 0.2), + 'timestamp': refTimestamp, + 'date': Timestamp.fromDate(refDate), + 'uint8Array': Bytes.fromUint8Array( + new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0]) + ), + 'documentReference': doc(firestore, 'foo', 'bar'), + 'vectorValue': vector([1, 2, 3]), + 'map': { + 'number': 2, + 'string': 'b string' + }, + 'array': [1, 'c string'] + }, + 'array': [ + 1, + 'a string', + true, + null, + new GeoPoint(0.1, 0.2), + refTimestamp, + Timestamp.fromDate(refDate), + Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])), + doc(firestore, 'foo', 'bar'), + vector([1, 2, 3]), + { + 'number': 2, + 'string': 'b string' + } + ] + }); + }); + it('cond works', async () => { const results = await randomCol .pipeline() From fb5df426bdb9a9b22b1587528df49f7950b729d7 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Mon, 27 Jan 2025 13:12:14 -0700 Subject: [PATCH 49/59] PPL multiple entry points (#8717) * Multiple entry points for main package. * MEP for firestore lite building * Fix issue with external exports * Refactor to support multiple entry points for the lite SDK. Fixes import issues and makes code organization across /pipelines and /lite/pipeliens * Type and comment cleanup * Make PipelineSource generic and remove useFluentPipelines * Remove converter and placeholders for converter. * cleanup: remove documentReferenceFactory * Linting and formatting * Update the typings export for pipelines and lite pipelines so that it auguments the Firestore and Query classes. * Add missing Expr export * Lint fixes * TODOs cleanup * update api review * Query to Proto with integration tests * API tweaks from review. Selectable, FilterCondition, and Accumulator are abstract classes not interfaces. Removed extraneous Pipeline.sort overload * Remove console.log statements from prune-dts.ts * code cleanup in prune-dts * Add missing imports to pipelines.ts --- .../firestore-lite-pipelines.api.md | 2020 ++++++++++++++ common/api-review/firestore-lite.api.md | 12 +- common/api-review/firestore-pipelines.api.md | 1354 +++++++++ common/api-review/firestore.api.md | 978 ++----- .../firebase/firestore/pipelines/index.ts | 18 + .../firebase/firestore/pipelines/package.json | 7 + packages/firebase/package.json | 12 + packages/firestore/.eslintrc.js | 2 +- packages/firestore/externs.json | 2 + packages/firestore/lite/index.ts | 167 -- .../firestore/lite/pipelines/package.json | 14 + .../firestore/lite/pipelines/pipelines.d.ts | 28 + .../firestore/lite/pipelines/pipelines.ts | 210 ++ packages/firestore/package.json | 45 +- packages/firestore/pipelines/package.json | 14 + packages/firestore/pipelines/pipelines.d.ts | 31 + .../firestore/pipelines/pipelines.node.ts | 18 + packages/firestore/pipelines/pipelines.rn.ts | 18 + packages/firestore/pipelines/pipelines.ts | 51 + packages/firestore/rollup.config.js | 48 +- packages/firestore/rollup.config.lite.js | 54 +- packages/firestore/src/all_packages.ts | 25 + packages/firestore/src/api.ts | 169 -- packages/firestore/src/api/pipeline-source.ts | 100 - packages/firestore/src/api/pipeline.ts | 82 +- packages/firestore/src/api/pipeline_impl.ts | 92 +- packages/firestore/src/api_pipelines.ts | 13 +- .../firestore/src/core/firestore_client.ts | 2 +- packages/firestore/src/core/pipeline-util.ts | 281 +- packages/firestore/src/lite-api/database.ts | 2 - .../firestore/src/lite-api/expressions.ts | 172 +- .../firestore/src/lite-api/pipeline-result.ts | 25 +- .../firestore/src/lite-api/pipeline-source.ts | 73 +- packages/firestore/src/lite-api/pipeline.ts | 204 +- .../firestore/src/lite-api/pipeline_impl.ts | 66 +- packages/firestore/src/lite-api/stage.ts | 13 +- packages/firestore/src/remote/datastore.ts | 2 +- packages/firestore/src/util/proto.ts | 155 ++ .../test/integration/api/pipeline.test.ts | 2455 +++++++++++------ .../test/integration/util/firebase_export.ts | 1 + repo-scripts/prune-dts/extract-public-api.ts | 19 +- repo-scripts/prune-dts/prune-dts.ts | 127 +- 42 files changed, 6472 insertions(+), 2709 deletions(-) create mode 100644 common/api-review/firestore-lite-pipelines.api.md create mode 100644 common/api-review/firestore-pipelines.api.md create mode 100644 packages/firebase/firestore/pipelines/index.ts create mode 100644 packages/firebase/firestore/pipelines/package.json create mode 100644 packages/firestore/lite/pipelines/package.json create mode 100644 packages/firestore/lite/pipelines/pipelines.d.ts create mode 100644 packages/firestore/lite/pipelines/pipelines.ts create mode 100644 packages/firestore/pipelines/package.json create mode 100644 packages/firestore/pipelines/pipelines.d.ts create mode 100644 packages/firestore/pipelines/pipelines.node.ts create mode 100644 packages/firestore/pipelines/pipelines.rn.ts create mode 100644 packages/firestore/pipelines/pipelines.ts create mode 100644 packages/firestore/src/all_packages.ts delete mode 100644 packages/firestore/src/api/pipeline-source.ts create mode 100644 packages/firestore/src/util/proto.ts diff --git a/common/api-review/firestore-lite-pipelines.api.md b/common/api-review/firestore-lite-pipelines.api.md new file mode 100644 index 00000000000..d1536c8a626 --- /dev/null +++ b/common/api-review/firestore-lite-pipelines.api.md @@ -0,0 +1,2020 @@ +## API Report File for "@firebase/firestore-lite-pipelines" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import { FirebaseApp } from '@firebase/app'; + +// @beta +export interface Accumulator { + // (undocumented) + accumulator: true; + add(other: Accumulator): Add; + add(other: any): Add; + arrayConcat(...arrays: Accumulator[]): ArrayConcat; + arrayConcat(...arrays: any[][]): ArrayConcat; + arrayContains(element: Accumulator): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Accumulator[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Accumulator[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Accumulator): CosineDistance; + // Warning: (ae-forgotten-export) The symbol "VectorValue" needs to be exported by the entry point pipelines.d.ts + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Accumulator): Divide; + divide(other: any): Divide; + dotProduct(other: Accumulator): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Accumulator): EndsWith; + eq(other: Accumulator): Eq; + eq(other: any): Eq; + eqAny(...others: Accumulator[]): EqAny; + // (undocumented) + eqAny(...others: any[]): EqAny; + euclideanDistance(other: Accumulator): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + gt(other: Accumulator): Gt; + gt(other: any): Gt; + gte(other: Accumulator): Gte; + gte(other: any): Gte; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Accumulator): Like; + logicalMaximum(other: Accumulator): LogicalMaximum; + logicalMaximum(other: any): LogicalMaximum; + logicalMinimum(other: Accumulator): LogicalMinimum; + logicalMinimum(other: any): LogicalMinimum; + lt(other: Accumulator): Lt; + lt(other: any): Lt; + lte(other: Accumulator): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + maximum(): Maximum; + minimum(): Minimum; + mod(other: Accumulator): Mod; + mod(other: any): Mod; + multiply(other: Accumulator): Multiply; + multiply(other: any): Multiply; + neq(other: Accumulator): Neq; + neq(other: any): Neq; + notEqAny(...others: Accumulator[]): FirestoreFunction; + // (undocumented) + notEqAny(...others: any[]): FirestoreFunction; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Accumulator): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Accumulator): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Accumulator, replace: Accumulator): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Accumulator, replace: Accumulator): ReplaceFirst; + reverse(): Reverse; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Accumulator): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Accumulator): StrContains; + subtract(other: Accumulator): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Accumulator, amount: Accumulator): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Accumulator, amount: Accumulator): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + +// @beta +export type AccumulatorTarget = ExprWithAlias; + +// @beta (undocumented) +export class Add extends FirestoreFunction { + constructor(left: Accumulator, right: Accumulator); + } + +// @beta +export function add(left: Accumulator, right: Accumulator): Add; + +// @beta +export function add(left: Accumulator, right: any): Add; + +// @beta +export function add(left: string, right: Accumulator): Add; + +// @beta +export function add(left: string, right: any): Add; + +// @beta (undocumented) +export class AddFields implements Stage { + constructor(fields: Map); + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class Aggregate implements Stage { + constructor(accumulators: Map, groups: Map); + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class And extends FirestoreFunction implements FilterCondition { + constructor(conditions: FilterCondition[]); + // (undocumented) + filterable: true; +} + +// @beta (undocumented) +export class ArrayConcat extends FirestoreFunction { + constructor(array: Accumulator, elements: Accumulator[]); + } + +// @beta +export function arrayConcat(array: Accumulator, elements: Accumulator[]): ArrayConcat; + +// @beta +export function arrayConcat(array: Accumulator, elements: any[]): ArrayConcat; + +// @beta +export function arrayConcat(array: string, elements: Accumulator[]): ArrayConcat; + +// @beta +export function arrayConcat(array: string, elements: any[]): ArrayConcat; + +// @beta (undocumented) +export class ArrayContains extends FirestoreFunction implements FilterCondition { + constructor(array: Accumulator, element: Accumulator); + // (undocumented) + filterable: true; +} + +// @beta +export function arrayContains(array: Accumulator, element: Accumulator): ArrayContains; + +// @beta +export function arrayContains(array: Accumulator, element: any): ArrayContains; + +// @beta +export function arrayContains(array: string, element: Accumulator): ArrayContains; + +// @beta +export function arrayContains(array: string, element: any): ArrayContains; + +// @beta (undocumented) +export class ArrayContainsAll extends FirestoreFunction implements FilterCondition { + constructor(array: Accumulator, values: Accumulator[]); + // (undocumented) + filterable: true; + } + +// @beta +export function arrayContainsAll(array: Accumulator, values: Accumulator[]): ArrayContainsAll; + +// @beta +export function arrayContainsAll(array: Accumulator, values: any[]): ArrayContainsAll; + +// @beta +export function arrayContainsAll(array: string, values: Accumulator[]): ArrayContainsAll; + +// @beta +export function arrayContainsAll(array: string, values: any[]): ArrayContainsAll; + +// @beta (undocumented) +export class ArrayContainsAny extends FirestoreFunction implements FilterCondition { + constructor(array: Accumulator, values: Accumulator[]); + // (undocumented) + filterable: true; + } + +// @beta +export function arrayContainsAny(array: Accumulator, values: Accumulator[]): ArrayContainsAny; + +// @beta +export function arrayContainsAny(array: Accumulator, values: any[]): ArrayContainsAny; + +// @beta +export function arrayContainsAny(array: string, values: Accumulator[]): ArrayContainsAny; + +// @beta +export function arrayContainsAny(array: string, values: any[]): ArrayContainsAny; + +// @beta (undocumented) +export class ArrayElement extends FirestoreFunction { + constructor(); +} + +// @beta (undocumented) +export class ArrayLength extends FirestoreFunction { + constructor(array: Accumulator); + } + +// @beta +export function arrayLength(array: Accumulator): ArrayLength; + +// @beta (undocumented) +export class ArrayReverse extends FirestoreFunction { + constructor(array: Accumulator); + } + +// @beta +export function ascending(expr: Accumulator): Ordering; + +// @beta (undocumented) +export class Avg extends FirestoreFunction implements Accumulator { + constructor(value: Accumulator, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta (undocumented) +export class ByteLength extends FirestoreFunction { + constructor(value: Accumulator); + } + +// @beta +export function byteLength(expr: Accumulator): ByteLength; + +// @beta +export function byteLength(field: string): ByteLength; + +// @beta (undocumented) +export class CharLength extends FirestoreFunction { + constructor(value: Accumulator); + } + +// @beta +export function charLength(field: string): CharLength; + +// @beta +export function charLength(expr: Accumulator): CharLength; + +// @beta (undocumented) +export class CollectionGroupSource implements Stage { + constructor(collectionId: string); + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class CollectionSource implements Stage { + constructor(collectionPath: string); + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class Cond extends FirestoreFunction { + constructor(condition: FilterCondition, thenExpr: Accumulator, elseExpr: Accumulator); + // (undocumented) + filterable: true; + } + +// @beta +export function cond(condition: FilterCondition, thenExpr: Accumulator, elseExpr: Accumulator): Cond; + +// @beta +export class Constant { + add(other: Accumulator): Add; + add(other: any): Add; + arrayConcat(...arrays: Accumulator[]): ArrayConcat; + arrayConcat(...arrays: any[][]): ArrayConcat; + arrayContains(element: Accumulator): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Accumulator[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Accumulator[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Accumulator): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Accumulator): Divide; + divide(other: any): Divide; + dotProduct(other: Accumulator): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Accumulator): EndsWith; + eq(other: Accumulator): Eq; + eq(other: any): Eq; + eqAny(...others: Accumulator[]): EqAny; + // (undocumented) + eqAny(...others: any[]): EqAny; + euclideanDistance(other: Accumulator): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + gt(other: Accumulator): Gt; + gt(other: any): Gt; + gte(other: Accumulator): Gte; + gte(other: any): Gte; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Accumulator): Like; + logicalMaximum(other: Accumulator): LogicalMaximum; + logicalMaximum(other: any): LogicalMaximum; + logicalMinimum(other: Accumulator): LogicalMinimum; + logicalMinimum(other: any): LogicalMinimum; + lt(other: Accumulator): Lt; + lt(other: any): Lt; + lte(other: Accumulator): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + maximum(): Maximum; + minimum(): Minimum; + mod(other: Accumulator): Mod; + mod(other: any): Mod; + multiply(other: Accumulator): Multiply; + multiply(other: any): Multiply; + neq(other: Accumulator): Neq; + neq(other: any): Neq; + notEqAny(...others: Accumulator[]): FirestoreFunction; + // (undocumented) + notEqAny(...others: any[]): FirestoreFunction; + static of(value: number): Constant; + static of(value: string): Constant; + static of(value: boolean): Constant; + static of(value: null): Constant; + static of(value: undefined): Constant; + // Warning: (ae-forgotten-export) The symbol "GeoPoint" needs to be exported by the entry point pipelines.d.ts + static of(value: GeoPoint): Constant; + // Warning: (ae-forgotten-export) The symbol "Timestamp" needs to be exported by the entry point pipelines.d.ts + static of(value: Timestamp): Constant; + static of(value: Date): Constant; + static of(value: Uint8Array): Constant; + // Warning: (ae-forgotten-export) The symbol "DocumentReference" needs to be exported by the entry point pipelines.d.ts + static of(value: DocumentReference): Constant; + static of(value: any[]): Constant; + static of(value: Map): Constant; + static of(value: VectorValue): Constant; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Accumulator): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Accumulator): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Accumulator, replace: Accumulator): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Accumulator, replace: Accumulator): ReplaceFirst; + reverse(): Reverse; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Accumulator): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Accumulator): StrContains; + subtract(other: Accumulator): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Accumulator, amount: Accumulator): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Accumulator, amount: Accumulator): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + static vector(value: number[] | VectorValue): Constant; + vectorLength(): VectorLength; +} + +// @beta (undocumented) +export class CosineDistance extends FirestoreFunction { + constructor(vector1: Accumulator, vector2: Accumulator); + } + +// @beta +export function cosineDistance(expr: string, other: number[]): CosineDistance; + +// @beta +export function cosineDistance(expr: string, other: VectorValue): CosineDistance; + +// @beta +export function cosineDistance(expr: string, other: Accumulator): CosineDistance; + +// @beta +export function cosineDistance(expr: Accumulator, other: number[]): CosineDistance; + +// @beta +export function cosineDistance(expr: Accumulator, other: VectorValue): CosineDistance; + +// @beta +export function cosineDistance(expr: Accumulator, other: Accumulator): CosineDistance; + +// @beta (undocumented) +export class Count extends FirestoreFunction implements Accumulator { + constructor(value: Accumulator | undefined, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta +export function countAll(): Count; + +// @beta (undocumented) +export class DatabaseSource implements Stage { + // (undocumented) + name: string; +} + +// @beta +export function descending(expr: Accumulator): Ordering; + +// @beta (undocumented) +export class Distinct implements Stage { + constructor(groups: Map); + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class Divide extends FirestoreFunction { + constructor(left: Accumulator, right: Accumulator); + } + +// @beta +export function divide(left: Accumulator, right: Accumulator): Divide; + +// @beta +export function divide(left: Accumulator, right: any): Divide; + +// @beta +export function divide(left: string, right: Accumulator): Divide; + +// @beta +export function divide(left: string, right: any): Divide; + +// @beta (undocumented) +export class DocumentsSource implements Stage { + constructor(docPaths: string[]); + // (undocumented) + name: string; + // (undocumented) + static of(refs: DocumentReference[]): DocumentsSource; +} + +// @beta (undocumented) +export class DotProduct extends FirestoreFunction { + constructor(vector1: Accumulator, vector2: Accumulator); + } + +// @beta +export function dotProduct(expr: string, other: number[]): DotProduct; + +// @beta +export function dotProduct(expr: string, other: VectorValue): DotProduct; + +// @beta +export function dotProduct(expr: string, other: Accumulator): DotProduct; + +// @beta +export function dotProduct(expr: Accumulator, other: number[]): DotProduct; + +// @beta +export function dotProduct(expr: Accumulator, other: VectorValue): DotProduct; + +// @beta +export function dotProduct(expr: Accumulator, other: Accumulator): DotProduct; + +// @beta (undocumented) +export class EndsWith extends FirestoreFunction implements FilterCondition { + constructor(expr: Accumulator, suffix: Accumulator); + // (undocumented) + filterable: true; + } + +// @beta +export function endsWith(expr: string, suffix: string): EndsWith; + +// @beta +export function endsWith(expr: string, suffix: Accumulator): EndsWith; + +// @beta +export function endsWith(expr: Accumulator, suffix: string): EndsWith; + +// @beta +export function endsWith(expr: Accumulator, suffix: Accumulator): EndsWith; + +// @beta (undocumented) +export class Eq extends FirestoreFunction implements FilterCondition { + constructor(left: Accumulator, right: Accumulator); + // (undocumented) + filterable: true; + } + +// @beta +export function eq(left: Accumulator, right: Accumulator): Eq; + +// @beta +export function eq(left: Accumulator, right: any): Eq; + +// @beta +export function eq(left: string, right: Accumulator): Eq; + +// @beta +export function eq(left: string, right: any): Eq; + +// @beta (undocumented) +export class EqAny extends FirestoreFunction implements FilterCondition { + constructor(left: Accumulator, others: Accumulator[]); + // (undocumented) + filterable: true; + } + +// @beta +export function eqAny(element: Accumulator, others: Accumulator[]): EqAny; + +// @beta +export function eqAny(element: Accumulator, others: any[]): EqAny; + +// @beta +export function eqAny(element: string, others: Accumulator[]): EqAny; + +// @beta +export function eqAny(element: string, others: any[]): EqAny; + +// @beta (undocumented) +export class EuclideanDistance extends FirestoreFunction { + constructor(vector1: Accumulator, vector2: Accumulator); + } + +// @beta +export function euclideanDistance(expr: string, other: number[]): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: string, other: VectorValue): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: string, other: Accumulator): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: Accumulator, other: number[]): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: Accumulator, other: VectorValue): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: Accumulator, other: Accumulator): EuclideanDistance; + +// @beta +export function execute(pipeline: Pipeline): Promise; + +// @beta (undocumented) +export class Exists extends FirestoreFunction implements FilterCondition { + constructor(expr: Accumulator); + // (undocumented) + filterable: true; +} + +// @beta +export function exists(value: Accumulator): Exists; + +// @beta +export function exists(field: string): Exists; + +// @beta +export type ExprType = 'Field' | 'Constant' | 'Function' | 'ListOfExprs' | 'ExprWithAlias'; + +// @beta (undocumented) +export class ExprWithAlias implements Selectable { + constructor(expr: T, alias: string); + add(other: Accumulator): Add; + add(other: any): Add; + // (undocumented) + readonly alias: string; + arrayConcat(...arrays: Accumulator[]): ArrayConcat; + arrayConcat(...arrays: any[][]): ArrayConcat; + arrayContains(element: Accumulator): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Accumulator[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Accumulator[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Accumulator): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Accumulator): Divide; + divide(other: any): Divide; + dotProduct(other: Accumulator): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Accumulator): EndsWith; + eq(other: Accumulator): Eq; + eq(other: any): Eq; + eqAny(...others: Accumulator[]): EqAny; + // (undocumented) + eqAny(...others: any[]): EqAny; + euclideanDistance(other: Accumulator): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + readonly expr: T; + // (undocumented) + exprType: ExprType; + gt(other: Accumulator): Gt; + gt(other: any): Gt; + gte(other: Accumulator): Gte; + gte(other: any): Gte; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Accumulator): Like; + logicalMaximum(other: Accumulator): LogicalMaximum; + logicalMaximum(other: any): LogicalMaximum; + logicalMinimum(other: Accumulator): LogicalMinimum; + logicalMinimum(other: any): LogicalMinimum; + lt(other: Accumulator): Lt; + lt(other: any): Lt; + lte(other: Accumulator): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + maximum(): Maximum; + minimum(): Minimum; + mod(other: Accumulator): Mod; + mod(other: any): Mod; + multiply(other: Accumulator): Multiply; + multiply(other: any): Multiply; + neq(other: Accumulator): Neq; + neq(other: any): Neq; + notEqAny(...others: Accumulator[]): FirestoreFunction; + // (undocumented) + notEqAny(...others: any[]): FirestoreFunction; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Accumulator): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Accumulator): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Accumulator, replace: Accumulator): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Accumulator, replace: Accumulator): ReplaceFirst; + reverse(): Reverse; + // (undocumented) + selectable: true; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Accumulator): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Accumulator): StrContains; + subtract(other: Accumulator): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Accumulator, amount: Accumulator): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Accumulator, amount: Accumulator): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + +// @beta +export class Field implements Selectable { + add(other: Accumulator): Add; + add(other: any): Add; + arrayConcat(...arrays: Accumulator[]): ArrayConcat; + arrayConcat(...arrays: any[][]): ArrayConcat; + arrayContains(element: Accumulator): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Accumulator[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Accumulator[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Accumulator): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Accumulator): Divide; + divide(other: any): Divide; + dotProduct(other: Accumulator): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Accumulator): EndsWith; + eq(other: Accumulator): Eq; + eq(other: any): Eq; + eqAny(...others: Accumulator[]): EqAny; + // (undocumented) + eqAny(...others: any[]): EqAny; + euclideanDistance(other: Accumulator): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + // (undocumented) + fieldName(): string; + gt(other: Accumulator): Gt; + gt(other: any): Gt; + gte(other: Accumulator): Gte; + gte(other: any): Gte; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Accumulator): Like; + logicalMaximum(other: Accumulator): LogicalMaximum; + logicalMaximum(other: any): LogicalMaximum; + logicalMinimum(other: Accumulator): LogicalMinimum; + logicalMinimum(other: any): LogicalMinimum; + lt(other: Accumulator): Lt; + lt(other: any): Lt; + lte(other: Accumulator): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + maximum(): Maximum; + minimum(): Minimum; + mod(other: Accumulator): Mod; + mod(other: any): Mod; + multiply(other: Accumulator): Multiply; + multiply(other: any): Multiply; + neq(other: Accumulator): Neq; + neq(other: any): Neq; + notEqAny(...others: Accumulator[]): FirestoreFunction; + // (undocumented) + notEqAny(...others: any[]): FirestoreFunction; + static of(name: string): Field; + // Warning: (ae-forgotten-export) The symbol "FieldPath" needs to be exported by the entry point pipelines.d.ts + // + // (undocumented) + static of(path: FieldPath): Field; + // (undocumented) + static of(pipeline: Pipeline, name: string): Field; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Accumulator): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Accumulator): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Accumulator, replace: Accumulator): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Accumulator, replace: Accumulator): ReplaceFirst; + reverse(): Reverse; + // (undocumented) + selectable: true; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Accumulator): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Accumulator): StrContains; + subtract(other: Accumulator): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Accumulator, amount: Accumulator): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Accumulator, amount: Accumulator): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + +// @beta (undocumented) +export class Fields implements Selectable { + add(other: Accumulator): Add; + add(other: any): Add; + arrayConcat(...arrays: Accumulator[]): ArrayConcat; + arrayConcat(...arrays: any[][]): ArrayConcat; + arrayContains(element: Accumulator): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Accumulator[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Accumulator[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Accumulator): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Accumulator): Divide; + divide(other: any): Divide; + dotProduct(other: Accumulator): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Accumulator): EndsWith; + eq(other: Accumulator): Eq; + eq(other: any): Eq; + eqAny(...others: Accumulator[]): EqAny; + // (undocumented) + eqAny(...others: any[]): EqAny; + euclideanDistance(other: Accumulator): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + // (undocumented) + fieldList(): Field[]; + gt(other: Accumulator): Gt; + gt(other: any): Gt; + gte(other: Accumulator): Gte; + gte(other: any): Gte; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Accumulator): Like; + logicalMaximum(other: Accumulator): LogicalMaximum; + logicalMaximum(other: any): LogicalMaximum; + logicalMinimum(other: Accumulator): LogicalMinimum; + logicalMinimum(other: any): LogicalMinimum; + lt(other: Accumulator): Lt; + lt(other: any): Lt; + lte(other: Accumulator): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + maximum(): Maximum; + minimum(): Minimum; + mod(other: Accumulator): Mod; + mod(other: any): Mod; + multiply(other: Accumulator): Multiply; + multiply(other: any): Multiply; + neq(other: Accumulator): Neq; + neq(other: any): Neq; + notEqAny(...others: Accumulator[]): FirestoreFunction; + // (undocumented) + notEqAny(...others: any[]): FirestoreFunction; + // (undocumented) + static of(name: string, ...others: string[]): Fields; + // (undocumented) + static ofAll(): Fields; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Accumulator): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Accumulator): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Accumulator, replace: Accumulator): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Accumulator, replace: Accumulator): ReplaceFirst; + reverse(): Reverse; + // (undocumented) + selectable: true; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Accumulator): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Accumulator): StrContains; + subtract(other: Accumulator): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Accumulator, amount: Accumulator): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Accumulator, amount: Accumulator): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + +// @beta +export interface FilterCondition { + add(other: Accumulator): Add; + add(other: any): Add; + arrayConcat(...arrays: Accumulator[]): ArrayConcat; + arrayConcat(...arrays: any[][]): ArrayConcat; + arrayContains(element: Accumulator): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Accumulator[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Accumulator[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Accumulator): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Accumulator): Divide; + divide(other: any): Divide; + dotProduct(other: Accumulator): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Accumulator): EndsWith; + eq(other: Accumulator): Eq; + eq(other: any): Eq; + eqAny(...others: Accumulator[]): EqAny; + // (undocumented) + eqAny(...others: any[]): EqAny; + euclideanDistance(other: Accumulator): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + // (undocumented) + filterable: true; + gt(other: Accumulator): Gt; + gt(other: any): Gt; + gte(other: Accumulator): Gte; + gte(other: any): Gte; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Accumulator): Like; + logicalMaximum(other: Accumulator): LogicalMaximum; + logicalMaximum(other: any): LogicalMaximum; + logicalMinimum(other: Accumulator): LogicalMinimum; + logicalMinimum(other: any): LogicalMinimum; + lt(other: Accumulator): Lt; + lt(other: any): Lt; + lte(other: Accumulator): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + maximum(): Maximum; + minimum(): Minimum; + mod(other: Accumulator): Mod; + mod(other: any): Mod; + multiply(other: Accumulator): Multiply; + multiply(other: any): Multiply; + neq(other: Accumulator): Neq; + neq(other: any): Neq; + notEqAny(...others: Accumulator[]): FirestoreFunction; + // (undocumented) + notEqAny(...others: any[]): FirestoreFunction; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Accumulator): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Accumulator): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Accumulator, replace: Accumulator): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Accumulator, replace: Accumulator): ReplaceFirst; + reverse(): Reverse; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Accumulator): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Accumulator): StrContains; + subtract(other: Accumulator): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Accumulator, amount: Accumulator): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Accumulator, amount: Accumulator): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + +// @beta (undocumented) +export class FindNearest implements Stage { + // (undocumented) + name: string; +} + +// @beta (undocumented) +export interface FindNearestOptions { + // (undocumented) + distanceField?: string; + // (undocumented) + distanceMeasure: 'euclidean' | 'cosine' | 'dot_product'; + // (undocumented) + field: Field; + // (undocumented) + limit?: number; + // (undocumented) + vectorValue: VectorValue | number[]; +} + +// @beta +export class FirestoreFunction { + constructor(name: string, params: Accumulator[]); + add(other: Accumulator): Add; + add(other: any): Add; + arrayConcat(...arrays: Accumulator[]): ArrayConcat; + arrayConcat(...arrays: any[][]): ArrayConcat; + arrayContains(element: Accumulator): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Accumulator[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Accumulator[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Accumulator): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Accumulator): Divide; + divide(other: any): Divide; + dotProduct(other: Accumulator): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Accumulator): EndsWith; + eq(other: Accumulator): Eq; + eq(other: any): Eq; + eqAny(...others: Accumulator[]): EqAny; + // (undocumented) + eqAny(...others: any[]): EqAny; + euclideanDistance(other: Accumulator): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + gt(other: Accumulator): Gt; + gt(other: any): Gt; + gte(other: Accumulator): Gte; + gte(other: any): Gte; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Accumulator): Like; + logicalMaximum(other: Accumulator): LogicalMaximum; + logicalMaximum(other: any): LogicalMaximum; + logicalMinimum(other: Accumulator): LogicalMinimum; + logicalMinimum(other: any): LogicalMinimum; + lt(other: Accumulator): Lt; + lt(other: any): Lt; + lte(other: Accumulator): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + maximum(): Maximum; + minimum(): Minimum; + mod(other: Accumulator): Mod; + mod(other: any): Mod; + multiply(other: Accumulator): Multiply; + multiply(other: any): Multiply; + neq(other: Accumulator): Neq; + neq(other: any): Neq; + notEqAny(...others: Accumulator[]): FirestoreFunction; + // (undocumented) + notEqAny(...others: any[]): FirestoreFunction; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Accumulator): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Accumulator): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Accumulator, replace: Accumulator): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Accumulator, replace: Accumulator): ReplaceFirst; + reverse(): Reverse; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Accumulator): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Accumulator): StrContains; + subtract(other: Accumulator): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Accumulator, amount: Accumulator): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Accumulator, amount: Accumulator): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + +// @beta +export function genericFunction(name: string, params: Accumulator[]): FirestoreFunction; + +// @beta (undocumented) +export class GenericStage implements Stage { + constructor(name: string, params: unknown[]); + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class Gt extends FirestoreFunction implements FilterCondition { + constructor(left: Accumulator, right: Accumulator); + // (undocumented) + filterable: true; + } + +// @beta +export function gt(left: Accumulator, right: Accumulator): Gt; + +// @beta +export function gt(left: Accumulator, right: any): Gt; + +// @beta +export function gt(left: string, right: Accumulator): Gt; + +// @beta +export function gt(left: string, right: any): Gt; + +// @beta (undocumented) +export class Gte extends FirestoreFunction implements FilterCondition { + constructor(left: Accumulator, right: Accumulator); + // (undocumented) + filterable: true; + } + +// @beta +export function gte(left: Accumulator, right: Accumulator): Gte; + +// @beta +export function gte(left: Accumulator, right: any): Gte; + +// @beta +export function gte(left: string, right: Accumulator): Gte; + +// @beta +export function gte(left: string, right: any): Gte; + +// @beta (undocumented) +export class IsNan extends FirestoreFunction implements FilterCondition { + constructor(expr: Accumulator); + // (undocumented) + filterable: true; +} + +// @beta +export function isNan(value: Accumulator): IsNan; + +// @beta +export function isNan(value: string): IsNan; + +// @beta (undocumented) +export class Like extends FirestoreFunction implements FilterCondition { + constructor(expr: Accumulator, pattern: Accumulator); + // (undocumented) + filterable: true; + } + +// @beta +export function like(left: string, pattern: string): Like; + +// @beta +export function like(left: string, pattern: Accumulator): Like; + +// @beta +export function like(left: Accumulator, pattern: string): Like; + +// @beta +export function like(left: Accumulator, pattern: Accumulator): Like; + +// @beta (undocumented) +export class Limit implements Stage { + constructor(limit: number, convertedFromLimitTolast?: boolean); + // (undocumented) + readonly convertedFromLimitTolast: boolean; + // (undocumented) + readonly limit: number; + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class LogicalMaximum extends FirestoreFunction { + constructor(left: Accumulator, right: Accumulator); + } + +// @beta +export function logicalMaximum(left: Accumulator, right: Accumulator): LogicalMaximum; + +// @beta +export function logicalMaximum(left: Accumulator, right: any): LogicalMaximum; + +// @beta +export function logicalMaximum(left: string, right: Accumulator): LogicalMaximum; + +// @beta +export function logicalMaximum(left: string, right: any): LogicalMaximum; + +// @beta (undocumented) +export class LogicalMinimum extends FirestoreFunction { + constructor(left: Accumulator, right: Accumulator); + } + +// @beta +export function logicalMinimum(left: Accumulator, right: Accumulator): LogicalMinimum; + +// @beta +export function logicalMinimum(left: Accumulator, right: any): LogicalMinimum; + +// @beta +export function logicalMinimum(left: string, right: Accumulator): LogicalMinimum; + +// @beta +export function logicalMinimum(left: string, right: any): LogicalMinimum; + +// @beta (undocumented) +export class Lt extends FirestoreFunction implements FilterCondition { + constructor(left: Accumulator, right: Accumulator); + // (undocumented) + filterable: true; + } + +// @beta +export function lt(left: Accumulator, right: Accumulator): Lt; + +// @beta +export function lt(left: Accumulator, right: any): Lt; + +// @beta +export function lt(left: string, right: Accumulator): Lt; + +// @beta +export function lt(left: string, right: any): Lt; + +// @beta (undocumented) +export class Lte extends FirestoreFunction implements FilterCondition { + constructor(left: Accumulator, right: Accumulator); + // (undocumented) + filterable: true; + } + +// @beta +export function lte(left: Accumulator, right: Accumulator): Lte; + +// @beta +export function lte(left: Accumulator, right: any): Lte; + +// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Accumulator" which is marked as @beta +// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Lte" which is marked as @beta +// +// @public +export function lte(left: string, right: Accumulator): Lte; + +// @beta +export function lte(left: string, right: any): Lte; + +// @beta (undocumented) +export class MapGet extends FirestoreFunction { + constructor(map: Accumulator, name: string); +} + +// @beta +export function mapGet(mapField: string, subField: string): MapGet; + +// @beta +export function mapGet(mapExpr: Accumulator, subField: string): MapGet; + +// @beta (undocumented) +export class Maximum extends FirestoreFunction implements Accumulator { + constructor(value: Accumulator, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta +export function maximum(value: Accumulator): Maximum; + +// @beta +export function maximum(value: string): Maximum; + +// @beta (undocumented) +export class Minimum extends FirestoreFunction implements Accumulator { + constructor(value: Accumulator, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta +export function minimum(value: Accumulator): Minimum; + +// @beta +export function minimum(value: string): Minimum; + +// @beta (undocumented) +export class Mod extends FirestoreFunction { + constructor(left: Accumulator, right: Accumulator); + } + +// @beta +export function mod(left: Accumulator, right: Accumulator): Mod; + +// @beta +export function mod(left: Accumulator, right: any): Mod; + +// @beta +export function mod(left: string, right: Accumulator): Mod; + +// @beta +export function mod(left: string, right: any): Mod; + +// @beta (undocumented) +export class Multiply extends FirestoreFunction { + constructor(left: Accumulator, right: Accumulator); + } + +// @beta +export function multiply(left: Accumulator, right: Accumulator): Multiply; + +// @beta +export function multiply(left: Accumulator, right: any): Multiply; + +// @beta +export function multiply(left: string, right: Accumulator): Multiply; + +// @beta +export function multiply(left: string, right: any): Multiply; + +// @beta (undocumented) +export class Neq extends FirestoreFunction implements FilterCondition { + constructor(left: Accumulator, right: Accumulator); + // (undocumented) + filterable: true; + } + +// @beta +export function neq(left: Accumulator, right: Accumulator): Neq; + +// @beta +export function neq(left: Accumulator, right: any): Neq; + +// @beta +export function neq(left: string, right: Accumulator): Neq; + +// @beta +export function neq(left: string, right: any): Neq; + +// @beta (undocumented) +export class Not extends FirestoreFunction implements FilterCondition { + constructor(expr: Accumulator); + // (undocumented) + filterable: true; +} + +// @beta +export function not(filter: FilterCondition): Not; + +// @beta +export function notEqAny(element: Accumulator, others: Accumulator[]): FirestoreFunction; + +// @beta +export function notEqAny(element: Accumulator, others: any[]): FirestoreFunction; + +// @beta +export function notEqAny(element: string, others: Accumulator[]): FirestoreFunction; + +// @beta +export function notEqAny(element: string, others: any[]): FirestoreFunction; + +// @beta (undocumented) +export class Offset implements Stage { + constructor(offset: number); + // (undocumented) + name: string; + } + +// @beta (undocumented) +export class Or extends FirestoreFunction implements FilterCondition { + constructor(conditions: FilterCondition[]); + // (undocumented) + filterable: true; +} + +// @beta +export class Ordering { + constructor(expr: Accumulator, direction: 'ascending' | 'descending'); + // (undocumented) + readonly direction: 'ascending' | 'descending'; + // (undocumented) + readonly expr: Accumulator; +} + +// @public +export class Pipeline { + /* Excluded from this release type: _db */ + // Warning: (ae-incompatible-release-tags) The symbol "addFields" is marked as @public, but its signature references "Selectable" which is marked as @beta + addFields(...fields: Selectable[]): Pipeline; + /* Excluded from this release type: _userDataWriter */ + // Warning: (ae-incompatible-release-tags) The symbol "aggregate" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta + aggregate(...accumulators: AccumulatorTarget[]): Pipeline; + /* Excluded from this release type: _userDataWriter */ + aggregate(options: { + accumulators: AccumulatorTarget[]; + groups?: Array; + }): Pipeline; + /* Excluded from this release type: _userDataWriter */ + // Warning: (ae-incompatible-release-tags) The symbol "distinct" is marked as @public, but its signature references "Selectable" which is marked as @beta + distinct(...groups: Array): Pipeline; + /* Excluded from this release type: _userDataWriter */ + // Warning: (ae-incompatible-release-tags) The symbol "execute" is marked as @public, but its signature references "PipelineResult" which is marked as @beta + execute(): Promise; + /* Excluded from this release type: _userDataWriter */ + // Warning: (ae-incompatible-release-tags) The symbol "findNearest" is marked as @public, but its signature references "FindNearestOptions" which is marked as @beta + // + // (undocumented) + findNearest(options: FindNearestOptions): Pipeline; + /* Excluded from this release type: _userDataWriter */ + genericStage(name: string, params: any[]): Pipeline; + /* Excluded from this release type: _userDataWriter */ + limit(limit: number): Pipeline; + /* Excluded from this release type: _userDataWriter */ + offset(offset: number): Pipeline; + /* Excluded from this release type: _userDataWriter */ + // Warning: (ae-incompatible-release-tags) The symbol "select" is marked as @public, but its signature references "Selectable" which is marked as @beta + select(...selections: Array): Pipeline; + /* Excluded from this release type: _userDataWriter */ + // Warning: (ae-incompatible-release-tags) The symbol "sort" is marked as @public, but its signature references "Ordering" which is marked as @beta + sort(...orderings: Ordering[]): Pipeline; + /* Excluded from this release type: _userDataWriter */ + // (undocumented) + sort(options: { + orderings: Ordering[]; + }): Pipeline; + /* Excluded from this release type: _userDataWriter */ + // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "FilterCondition" which is marked as @beta + where(condition: FilterCondition): Pipeline; +} + +// Warning: (ae-forgotten-export) The symbol "Firestore" needs to be exported by the entry point pipelines.d.ts +// Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta +// +// @public +export function pipeline(firestore: Firestore): PipelineSource; + +// Warning: (ae-forgotten-export) The symbol "Query" needs to be exported by the entry point pipelines.d.ts +// +// @public +export function pipeline(query: Query): Pipeline; + +// Warning: (ae-forgotten-export) The symbol "DocumentData" needs to be exported by the entry point pipelines.d.ts +// +// @beta +export class PipelineResult { + /* Excluded from this release type: _ref */ + /* Excluded from this release type: _fields */ + /* Excluded from this release type: __constructor */ + get createTime(): Timestamp | undefined; + data(): AppModelType | undefined; + get executionTime(): Timestamp; + get(fieldPath: string | FieldPath): any; + get id(): string | undefined; + get ref(): DocumentReference | undefined; + get updateTime(): Timestamp | undefined; +} + +// @beta +export class PipelineSource { + /* Excluded from this release type: _createPipeline */ + /* Excluded from this release type: __constructor */ + // (undocumented) + collection(collectionPath: string): PipelineType; + // (undocumented) + collectionGroup(collectionId: string): PipelineType; + // (undocumented) + database(): PipelineType; + // (undocumented) + documents(docs: DocumentReference[]): PipelineType; +} + +// @beta (undocumented) +export class RegexContains extends FirestoreFunction implements FilterCondition { + constructor(expr: Accumulator, pattern: Accumulator); + // (undocumented) + filterable: true; + } + +// @beta +export function regexContains(left: string, pattern: string): RegexContains; + +// @beta +export function regexContains(left: string, pattern: Accumulator): RegexContains; + +// @beta +export function regexContains(left: Accumulator, pattern: string): RegexContains; + +// @beta +export function regexContains(left: Accumulator, pattern: Accumulator): RegexContains; + +// @beta (undocumented) +export class RegexMatch extends FirestoreFunction implements FilterCondition { + constructor(expr: Accumulator, pattern: Accumulator); + // (undocumented) + filterable: true; + } + +// @beta +export function regexMatch(left: string, pattern: string): RegexMatch; + +// @beta +export function regexMatch(left: string, pattern: Accumulator): RegexMatch; + +// @beta +export function regexMatch(left: Accumulator, pattern: string): RegexMatch; + +// @beta +export function regexMatch(left: Accumulator, pattern: Accumulator): RegexMatch; + +// @beta (undocumented) +export class ReplaceAll extends FirestoreFunction { + constructor(value: Accumulator, find: Accumulator, replace: Accumulator); + } + +// @beta +export function replaceAll(value: Accumulator, find: string, replace: string): ReplaceAll; + +// @beta +export function replaceAll(value: Accumulator, find: Accumulator, replace: Accumulator): ReplaceAll; + +// @beta +export function replaceAll(field: string, find: string, replace: string): ReplaceAll; + +// @beta (undocumented) +export class ReplaceFirst extends FirestoreFunction { + constructor(value: Accumulator, find: Accumulator, replace: Accumulator); + } + +// @beta +export function replaceFirst(value: Accumulator, find: string, replace: string): ReplaceFirst; + +// @beta +export function replaceFirst(value: Accumulator, find: Accumulator, replace: Accumulator): ReplaceFirst; + +// @beta +export function replaceFirst(field: string, find: string, replace: string): ReplaceFirst; + +// @beta (undocumented) +export class Reverse extends FirestoreFunction { + constructor(value: Accumulator); + } + +// @beta +export function reverse(expr: Accumulator): Reverse; + +// @beta +export function reverse(field: string): Reverse; + +// @beta (undocumented) +export class Select implements Stage { + constructor(projections: Map); + // (undocumented) + name: string; + } + +// @beta +export interface Selectable { + add(other: Accumulator): Add; + add(other: any): Add; + arrayConcat(...arrays: Accumulator[]): ArrayConcat; + arrayConcat(...arrays: any[][]): ArrayConcat; + arrayContains(element: Accumulator): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Accumulator[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Accumulator[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Accumulator): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Accumulator): Divide; + divide(other: any): Divide; + dotProduct(other: Accumulator): DotProduct; + dotProduct(other: VectorValue): DotProduct; + // (undocumented) + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Accumulator): EndsWith; + eq(other: Accumulator): Eq; + eq(other: any): Eq; + eqAny(...others: Accumulator[]): EqAny; + // (undocumented) + eqAny(...others: any[]): EqAny; + euclideanDistance(other: Accumulator): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + // (undocumented) + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + exprType: ExprType; + gt(other: Accumulator): Gt; + gt(other: any): Gt; + gte(other: Accumulator): Gte; + gte(other: any): Gte; + isNaN(): IsNan; + like(pattern: string): Like; + // (undocumented) + like(pattern: Accumulator): Like; + logicalMaximum(other: Accumulator): LogicalMaximum; + logicalMaximum(other: any): LogicalMaximum; + logicalMinimum(other: Accumulator): LogicalMinimum; + logicalMinimum(other: any): LogicalMinimum; + lt(other: Accumulator): Lt; + lt(other: any): Lt; + lte(other: Accumulator): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + maximum(): Maximum; + minimum(): Minimum; + mod(other: Accumulator): Mod; + mod(other: any): Mod; + multiply(other: Accumulator): Multiply; + multiply(other: any): Multiply; + neq(other: Accumulator): Neq; + neq(other: any): Neq; + notEqAny(...others: Accumulator[]): FirestoreFunction; + // (undocumented) + notEqAny(...others: any[]): FirestoreFunction; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Accumulator): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Accumulator): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Accumulator, replace: Accumulator): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Accumulator, replace: Accumulator): ReplaceFirst; + reverse(): Reverse; + // (undocumented) + selectable: true; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Accumulator): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Accumulator): StrContains; + subtract(other: Accumulator): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Accumulator, amount: Accumulator): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Accumulator, amount: Accumulator): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + +// @beta (undocumented) +export class Sort implements Stage { + constructor(orders: Ordering[]); + // (undocumented) + name: string; + } + +// @beta (undocumented) +export interface Stage { + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class StartsWith extends FirestoreFunction implements FilterCondition { + constructor(expr: Accumulator, prefix: Accumulator); + // (undocumented) + filterable: true; + } + +// @beta +export function startsWith(expr: string, prefix: string): StartsWith; + +// @beta +export function startsWith(expr: string, prefix: Accumulator): StartsWith; + +// @beta +export function startsWith(expr: Accumulator, prefix: string): StartsWith; + +// @beta +export function startsWith(expr: Accumulator, prefix: Accumulator): StartsWith; + +// @beta (undocumented) +export class StrConcat extends FirestoreFunction { + constructor(first: Accumulator, rest: Accumulator[]); + } + +// @beta +export function strConcat(first: string, ...elements: Array): StrConcat; + +// @beta +export function strConcat(first: Accumulator, ...elements: Array): StrConcat; + +// @beta (undocumented) +export class StrContains extends FirestoreFunction implements FilterCondition { + constructor(expr: Accumulator, substring: Accumulator); + // (undocumented) + filterable: true; + } + +// @beta +export function strContains(left: string, substring: string): StrContains; + +// @beta +export function strContains(left: string, substring: Accumulator): StrContains; + +// @beta +export function strContains(left: Accumulator, substring: string): StrContains; + +// @beta +export function strContains(left: Accumulator, substring: Accumulator): StrContains; + +// @beta (undocumented) +export class Subtract extends FirestoreFunction { + constructor(left: Accumulator, right: Accumulator); + } + +// @beta +export function subtract(left: Accumulator, right: Accumulator): Subtract; + +// @beta +export function subtract(left: Accumulator, right: any): Subtract; + +// @beta +export function subtract(left: string, right: Accumulator): Subtract; + +// @beta +export function subtract(left: string, right: any): Subtract; + +// @beta (undocumented) +export class Sum extends FirestoreFunction implements Accumulator { + constructor(value: Accumulator, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta (undocumented) +export class TimestampAdd extends FirestoreFunction { + constructor(timestamp: Accumulator, unit: Accumulator, amount: Accumulator); + } + +// @beta +export function timestampAdd(timestamp: Accumulator, unit: Accumulator, amount: Accumulator): TimestampAdd; + +// @beta +export function timestampAdd(timestamp: Accumulator, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + +// @beta +export function timestampAdd(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + +// @beta (undocumented) +export class TimestampSub extends FirestoreFunction { + constructor(timestamp: Accumulator, unit: Accumulator, amount: Accumulator); + } + +// @beta +export function timestampSub(timestamp: Accumulator, unit: Accumulator, amount: Accumulator): TimestampSub; + +// @beta +export function timestampSub(timestamp: Accumulator, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + +// @beta +export function timestampSub(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + +// @beta (undocumented) +export class TimestampToUnixMicros extends FirestoreFunction { + constructor(input: Accumulator); + } + +// @beta +export function timestampToUnixMicros(expr: Accumulator): TimestampToUnixMicros; + +// @beta +export function timestampToUnixMicros(field: string): TimestampToUnixMicros; + +// @beta (undocumented) +export class TimestampToUnixMillis extends FirestoreFunction { + constructor(input: Accumulator); + } + +// @beta +export function timestampToUnixMillis(expr: Accumulator): TimestampToUnixMillis; + +// @beta +export function timestampToUnixMillis(field: string): TimestampToUnixMillis; + +// @beta (undocumented) +export class TimestampToUnixSeconds extends FirestoreFunction { + constructor(input: Accumulator); + } + +// @beta +export function timestampToUnixSeconds(expr: Accumulator): TimestampToUnixSeconds; + +// @beta +export function timestampToUnixSeconds(field: string): TimestampToUnixSeconds; + +// @beta (undocumented) +export class ToLower extends FirestoreFunction { + constructor(expr: Accumulator); + } + +// @beta +export function toLower(expr: string): ToLower; + +// @beta +export function toLower(expr: Accumulator): ToLower; + +// @beta (undocumented) +export class ToUpper extends FirestoreFunction { + constructor(expr: Accumulator); + } + +// @beta +export function toUpper(expr: string): ToUpper; + +// @beta +export function toUpper(expr: Accumulator): ToUpper; + +// @beta (undocumented) +export class Trim extends FirestoreFunction { + constructor(expr: Accumulator); + } + +// @beta +export function trim(expr: string): Trim; + +// @beta +export function trim(expr: Accumulator): Trim; + +// @beta (undocumented) +export class UnixMicrosToTimestamp extends FirestoreFunction { + constructor(input: Accumulator); + } + +// @beta +export function unixMicrosToTimestamp(expr: Accumulator): UnixMicrosToTimestamp; + +// @beta +export function unixMicrosToTimestamp(field: string): UnixMicrosToTimestamp; + +// @beta (undocumented) +export class UnixMillisToTimestamp extends FirestoreFunction { + constructor(input: Accumulator); + } + +// @beta +export function unixMillisToTimestamp(expr: Accumulator): UnixMillisToTimestamp; + +// @beta +export function unixMillisToTimestamp(field: string): UnixMillisToTimestamp; + +// @beta (undocumented) +export class UnixSecondsToTimestamp extends FirestoreFunction { + constructor(input: Accumulator); + } + +// @beta +export function unixSecondsToTimestamp(expr: Accumulator): UnixSecondsToTimestamp; + +// @beta +export function unixSecondsToTimestamp(field: string): UnixSecondsToTimestamp; + +// @beta (undocumented) +export class VectorLength extends FirestoreFunction { + constructor(value: Accumulator); + } + +// @beta +export function vectorLength(expr: Accumulator): VectorLength; + +// @beta +export function vectorLength(field: string): VectorLength; + +// @beta (undocumented) +export class Where implements Stage { + constructor(condition: FilterCondition); + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class Xor extends FirestoreFunction implements FilterCondition { + constructor(conditions: FilterCondition[]); + // (undocumented) + filterable: true; +} + +// @beta +export function xor(left: FilterCondition, ...right: FilterCondition[]): Xor; + + +// Warnings were encountered during analysis: +// +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/pipelines.d.ts:10253:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/pipelines.d.ts:10254:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/pipelines.d.ts:10283:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta + +// (No @packageDocumentation comment for this package) + +``` diff --git a/common/api-review/firestore-lite.api.md b/common/api-review/firestore-lite.api.md index 7435e2a250e..29c373ff3c1 100644 --- a/common/api-review/firestore-lite.api.md +++ b/common/api-review/firestore-lite.api.md @@ -1310,7 +1310,11 @@ export function like(left: Constant, pattern: Constant): Like; // @beta (undocumented) export class Limit implements Stage { - constructor(limit: number); + constructor(limit: number, convertedFromLimitTolast?: boolean); + // (undocumented) + readonly convertedFromLimitTolast: boolean; + // (undocumented) + readonly limit: number; // (undocumented) name: string; } @@ -2204,8 +2208,8 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; // Warnings were encountered during analysis: // -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9238:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9239:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9268:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9239:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9240:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/index.d.ts:9269:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/common/api-review/firestore-pipelines.api.md b/common/api-review/firestore-pipelines.api.md new file mode 100644 index 00000000000..375f5dfd976 --- /dev/null +++ b/common/api-review/firestore-pipelines.api.md @@ -0,0 +1,1354 @@ +## API Report File for "@firebase/firestore-pipelines" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import { FirebaseApp } from '@firebase/app'; + +// @beta +export interface Accumulator extends Expr { + // (undocumented) + accumulator: true; +} + +// @beta +export type AccumulatorTarget = ExprWithAlias; + +// @beta (undocumented) +export class Add extends FirestoreFunction { + constructor(left: Expr, right: Expr); + } + +// @beta +export function add(left: Expr, right: Expr): Add; + +// @beta +export function add(left: Expr, right: any): Add; + +// @beta +export function add(left: string, right: Expr): Add; + +// @beta +export function add(left: string, right: any): Add; + +// @beta (undocumented) +export class AddFields implements Stage { + constructor(fields: Map); + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class Aggregate implements Stage { + constructor(accumulators: Map, groups: Map); + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class And extends FirestoreFunction implements FilterCondition { + constructor(conditions: FilterCondition[]); + // (undocumented) + filterable: true; +} + +// @beta +export function andFunction(left: FilterCondition, ...right: FilterCondition[]): And; + +// @beta (undocumented) +export class ArrayConcat extends FirestoreFunction { + constructor(array: Expr, elements: Expr[]); + } + +// @beta +export function arrayConcat(array: Expr, elements: Expr[]): ArrayConcat; + +// @beta +export function arrayConcat(array: Expr, elements: any[]): ArrayConcat; + +// @beta +export function arrayConcat(array: string, elements: Expr[]): ArrayConcat; + +// @beta +export function arrayConcat(array: string, elements: any[]): ArrayConcat; + +// @beta (undocumented) +export class ArrayContains extends FirestoreFunction implements FilterCondition { + constructor(array: Expr, element: Expr); + // (undocumented) + filterable: true; +} + +// @beta +export function arrayContains(array: Expr, element: Expr): ArrayContains; + +// @beta +export function arrayContains(array: Expr, element: any): ArrayContains; + +// @beta +export function arrayContains(array: string, element: Expr): ArrayContains; + +// @beta +export function arrayContains(array: string, element: any): ArrayContains; + +// @beta (undocumented) +export class ArrayContainsAll extends FirestoreFunction implements FilterCondition { + constructor(array: Expr, values: Expr[]); + // (undocumented) + filterable: true; + } + +// @beta +export function arrayContainsAll(array: Expr, values: Expr[]): ArrayContainsAll; + +// @beta +export function arrayContainsAll(array: Expr, values: any[]): ArrayContainsAll; + +// @beta +export function arrayContainsAll(array: string, values: Expr[]): ArrayContainsAll; + +// @beta +export function arrayContainsAll(array: string, values: any[]): ArrayContainsAll; + +// @beta (undocumented) +export class ArrayContainsAny extends FirestoreFunction implements FilterCondition { + constructor(array: Expr, values: Expr[]); + // (undocumented) + filterable: true; + } + +// @beta +export function arrayContainsAny(array: Expr, values: Expr[]): ArrayContainsAny; + +// @beta +export function arrayContainsAny(array: Expr, values: any[]): ArrayContainsAny; + +// @beta +export function arrayContainsAny(array: string, values: Expr[]): ArrayContainsAny; + +// @beta +export function arrayContainsAny(array: string, values: any[]): ArrayContainsAny; + +// @beta (undocumented) +export class ArrayElement extends FirestoreFunction { + constructor(); +} + +// @beta (undocumented) +export class ArrayLength extends FirestoreFunction { + constructor(array: Expr); + } + +// @beta +export function arrayLength(array: Expr): ArrayLength; + +// @beta (undocumented) +export class ArrayReverse extends FirestoreFunction { + constructor(array: Expr); + } + +// @beta +export function ascending(expr: Expr): Ordering; + +// @beta (undocumented) +export class Avg extends FirestoreFunction implements Accumulator { + constructor(value: Expr, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta +export function avgFunction(value: Expr): Avg; + +// @beta +export function avgFunction(value: string): Avg; + +// @beta (undocumented) +export class ByteLength extends FirestoreFunction { + constructor(value: Expr); + } + +// @beta +export function byteLength(expr: Expr): ByteLength; + +// @beta +export function byteLength(field: string): ByteLength; + +// @beta (undocumented) +export class CharLength extends FirestoreFunction { + constructor(value: Expr); + } + +// @beta +export function charLength(field: string): CharLength; + +// @beta +export function charLength(expr: Expr): CharLength; + +// @beta (undocumented) +export class CollectionGroupSource implements Stage { + constructor(collectionId: string); + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class CollectionSource implements Stage { + constructor(collectionPath: string); + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class Cond extends FirestoreFunction { + constructor(condition: FilterCondition, thenExpr: Expr, elseExpr: Expr); + // (undocumented) + filterable: true; + } + +// @beta +export function cond(condition: FilterCondition, thenExpr: Expr, elseExpr: Expr): Cond; + +// @beta +export class Constant extends Expr { + // (undocumented) + exprType: ExprType; + static of(value: number): Constant; + static of(value: string): Constant; + static of(value: boolean): Constant; + static of(value: null): Constant; + static of(value: undefined): Constant; + // Warning: (ae-forgotten-export) The symbol "GeoPoint" needs to be exported by the entry point pipelines.d.ts + static of(value: GeoPoint): Constant; + // Warning: (ae-forgotten-export) The symbol "Timestamp" needs to be exported by the entry point pipelines.d.ts + static of(value: Timestamp): Constant; + static of(value: Date): Constant; + static of(value: Uint8Array): Constant; + // Warning: (ae-forgotten-export) The symbol "DocumentReference" needs to be exported by the entry point pipelines.d.ts + static of(value: DocumentReference): Constant; + static of(value: any[]): Constant; + static of(value: Map): Constant; + // Warning: (ae-forgotten-export) The symbol "VectorValue" needs to be exported by the entry point pipelines.d.ts + static of(value: VectorValue): Constant; + static vector(value: number[] | VectorValue): Constant; +} + +// @beta (undocumented) +export class CosineDistance extends FirestoreFunction { + constructor(vector1: Expr, vector2: Expr); + } + +// @beta +export function cosineDistance(expr: string, other: number[]): CosineDistance; + +// @beta +export function cosineDistance(expr: string, other: VectorValue): CosineDistance; + +// @beta +export function cosineDistance(expr: string, other: Expr): CosineDistance; + +// @beta +export function cosineDistance(expr: Expr, other: number[]): CosineDistance; + +// @beta +export function cosineDistance(expr: Expr, other: VectorValue): CosineDistance; + +// @beta +export function cosineDistance(expr: Expr, other: Expr): CosineDistance; + +// @beta (undocumented) +export class Count extends FirestoreFunction implements Accumulator { + constructor(value: Expr | undefined, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta +export function countAll(): Count; + +// @beta +export function countFunction(value: Expr): Count; + +// Warning: (ae-incompatible-release-tags) The symbol "countFunction" is marked as @public, but its signature references "Count" which is marked as @beta +// +// @public +export function countFunction(value: string): Count; + +// @beta (undocumented) +export class DatabaseSource implements Stage { + // (undocumented) + name: string; +} + +// @beta +export function descending(expr: Expr): Ordering; + +// @beta (undocumented) +export class Distinct implements Stage { + constructor(groups: Map); + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class Divide extends FirestoreFunction { + constructor(left: Expr, right: Expr); + } + +// @beta +export function divide(left: Expr, right: Expr): Divide; + +// @beta +export function divide(left: Expr, right: any): Divide; + +// @beta +export function divide(left: string, right: Expr): Divide; + +// @beta +export function divide(left: string, right: any): Divide; + +// @beta (undocumented) +export class DocumentsSource implements Stage { + constructor(docPaths: string[]); + // (undocumented) + name: string; + // (undocumented) + static of(refs: DocumentReference[]): DocumentsSource; +} + +// @beta (undocumented) +export class DotProduct extends FirestoreFunction { + constructor(vector1: Expr, vector2: Expr); + } + +// @beta +export function dotProduct(expr: string, other: number[]): DotProduct; + +// @beta +export function dotProduct(expr: string, other: VectorValue): DotProduct; + +// @beta +export function dotProduct(expr: string, other: Expr): DotProduct; + +// @beta +export function dotProduct(expr: Expr, other: number[]): DotProduct; + +// @beta +export function dotProduct(expr: Expr, other: VectorValue): DotProduct; + +// @beta +export function dotProduct(expr: Expr, other: Expr): DotProduct; + +// @beta (undocumented) +export class EndsWith extends FirestoreFunction implements FilterCondition { + constructor(expr: Expr, suffix: Expr); + // (undocumented) + filterable: true; + } + +// @beta +export function endsWith(expr: string, suffix: string): EndsWith; + +// @beta +export function endsWith(expr: string, suffix: Expr): EndsWith; + +// @beta +export function endsWith(expr: Expr, suffix: string): EndsWith; + +// @beta +export function endsWith(expr: Expr, suffix: Expr): EndsWith; + +// @beta (undocumented) +export class Eq extends FirestoreFunction implements FilterCondition { + constructor(left: Expr, right: Expr); + // (undocumented) + filterable: true; + } + +// @beta +export function eq(left: Expr, right: Expr): Eq; + +// @beta +export function eq(left: Expr, right: any): Eq; + +// @beta +export function eq(left: string, right: Expr): Eq; + +// @beta +export function eq(left: string, right: any): Eq; + +// @beta (undocumented) +export class EqAny extends FirestoreFunction implements FilterCondition { + constructor(left: Expr, others: Expr[]); + // (undocumented) + filterable: true; + } + +// @beta +export function eqAny(element: Expr, others: Expr[]): EqAny; + +// @beta +export function eqAny(element: Expr, others: any[]): EqAny; + +// @beta +export function eqAny(element: string, others: Expr[]): EqAny; + +// @beta +export function eqAny(element: string, others: any[]): EqAny; + +// @beta (undocumented) +export class EuclideanDistance extends FirestoreFunction { + constructor(vector1: Expr, vector2: Expr); + } + +// @beta +export function euclideanDistance(expr: string, other: number[]): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: string, other: VectorValue): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: string, other: Expr): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: Expr, other: number[]): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: Expr, other: VectorValue): EuclideanDistance; + +// @beta +export function euclideanDistance(expr: Expr, other: Expr): EuclideanDistance; + +// Warning: (ae-incompatible-release-tags) The symbol "execute" is marked as @public, but its signature references "PipelineResult" which is marked as @beta +// +// @public (undocumented) +export function execute(pipeline: Pipeline): Promise; + +// @beta (undocumented) +export class Exists extends FirestoreFunction implements FilterCondition { + constructor(expr: Expr); + // (undocumented) + filterable: true; +} + +// @beta +export function exists(value: Expr): Exists; + +// @beta +export function exists(field: string): Exists; + +// @beta +export abstract class Expr { + add(other: Expr): Add; + add(other: any): Add; + arrayConcat(...arrays: Expr[]): ArrayConcat; + arrayConcat(...arrays: any[][]): ArrayConcat; + arrayContains(element: Expr): ArrayContains; + arrayContains(element: any): ArrayContains; + arrayContainsAll(...values: Expr[]): ArrayContainsAll; + arrayContainsAll(...values: any[]): ArrayContainsAll; + arrayContainsAny(...values: Expr[]): ArrayContainsAny; + arrayContainsAny(...values: any[]): ArrayContainsAny; + arrayLength(): ArrayLength; + as(name: string): ExprWithAlias; + ascending(): Ordering; + avg(): Avg; + byteLength(): ByteLength; + charLength(): CharLength; + cosineDistance(other: Expr): CosineDistance; + cosineDistance(other: VectorValue): CosineDistance; + cosineDistance(other: number[]): CosineDistance; + count(): Count; + descending(): Ordering; + divide(other: Expr): Divide; + divide(other: any): Divide; + dotProduct(other: Expr): DotProduct; + dotProduct(other: VectorValue): DotProduct; + dotProduct(other: number[]): DotProduct; + endsWith(suffix: string): EndsWith; + endsWith(suffix: Expr): EndsWith; + eq(other: Expr): Eq; + eq(other: any): Eq; + eqAny(...others: Expr[]): EqAny; + eqAny(...others: any[]): EqAny; + euclideanDistance(other: Expr): EuclideanDistance; + euclideanDistance(other: VectorValue): EuclideanDistance; + euclideanDistance(other: number[]): EuclideanDistance; + exists(): Exists; + // (undocumented) + abstract exprType: ExprType; + gt(other: Expr): Gt; + gt(other: any): Gt; + gte(other: Expr): Gte; + gte(other: any): Gte; + isNaN(): IsNan; + like(pattern: string): Like; + like(pattern: Expr): Like; + logicalMaximum(other: Expr): LogicalMaximum; + logicalMaximum(other: any): LogicalMaximum; + logicalMinimum(other: Expr): LogicalMinimum; + logicalMinimum(other: any): LogicalMinimum; + lt(other: Expr): Lt; + lt(other: any): Lt; + lte(other: Expr): Lte; + lte(other: any): Lte; + mapGet(subfield: string): MapGet; + maximum(): Maximum; + minimum(): Minimum; + mod(other: Expr): Mod; + mod(other: any): Mod; + multiply(other: Expr): Multiply; + multiply(other: any): Multiply; + neq(other: Expr): Neq; + neq(other: any): Neq; + notEqAny(...others: Expr[]): NotEqAny; + notEqAny(...others: any[]): NotEqAny; + regexContains(pattern: string): RegexContains; + regexContains(pattern: Expr): RegexContains; + regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: Expr): RegexMatch; + replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: Expr, replace: Expr): ReplaceAll; + replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: Expr, replace: Expr): ReplaceFirst; + reverse(): Reverse; + startsWith(prefix: string): StartsWith; + startsWith(prefix: Expr): StartsWith; + strConcat(...elements: Array): StrConcat; + strContains(substring: string): StrContains; + strContains(expr: Expr): StrContains; + subtract(other: Expr): Subtract; + subtract(other: any): Subtract; + sum(): Sum; + timestampAdd(unit: Expr, amount: Expr): TimestampAdd; + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + timestampSub(unit: Expr, amount: Expr): TimestampSub; + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + timestampToUnixMicros(): TimestampToUnixMicros; + timestampToUnixMillis(): TimestampToUnixMillis; + timestampToUnixSeconds(): TimestampToUnixSeconds; + toLower(): ToLower; + toUpper(): ToUpper; + trim(): Trim; + unixMicrosToTimestamp(): UnixMicrosToTimestamp; + unixMillisToTimestamp(): UnixMillisToTimestamp; + unixSecondsToTimestamp(): UnixSecondsToTimestamp; + vectorLength(): VectorLength; +} + +// @beta +export type ExprType = 'Field' | 'Constant' | 'Function' | 'ListOfExprs' | 'ExprWithAlias'; + +// @beta (undocumented) +export class ExprWithAlias extends Expr implements Selectable { + constructor(expr: T, alias: string); + // (undocumented) + readonly alias: string; + // (undocumented) + readonly expr: T; + // (undocumented) + exprType: ExprType; + // (undocumented) + selectable: true; +} + +// @beta +export class Field extends Expr implements Selectable { + // (undocumented) + exprType: ExprType; + // (undocumented) + fieldName(): string; + static of(name: string): Field; + // Warning: (ae-forgotten-export) The symbol "FieldPath" needs to be exported by the entry point pipelines.d.ts + // + // (undocumented) + static of(path: FieldPath): Field; + // (undocumented) + static of(pipeline: Pipeline, name: string): Field; + // (undocumented) + selectable: true; +} + +// @beta (undocumented) +export class Fields extends Expr implements Selectable { + // (undocumented) + exprType: ExprType; + // (undocumented) + fieldList(): Field[]; + // (undocumented) + static of(name: string, ...others: string[]): Fields; + // (undocumented) + static ofAll(): Fields; + // (undocumented) + selectable: true; +} + +// @beta +export interface FilterCondition extends Expr { + // (undocumented) + filterable: true; +} + +// @beta (undocumented) +export class FindNearest implements Stage { + // (undocumented) + name: string; +} + +// @beta (undocumented) +export interface FindNearestOptions { + // (undocumented) + distanceField?: string; + // (undocumented) + distanceMeasure: 'euclidean' | 'cosine' | 'dot_product'; + // (undocumented) + field: Field; + // (undocumented) + limit?: number; + // (undocumented) + vectorValue: VectorValue | number[]; +} + +// @beta +export class FirestoreFunction extends Expr { + constructor(name: string, params: Expr[]); + // (undocumented) + exprType: ExprType; + } + +// @beta +export function genericFunction(name: string, params: Expr[]): FirestoreFunction; + +// @beta (undocumented) +export class GenericStage implements Stage { + constructor(name: string, params: unknown[]); + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class Gt extends FirestoreFunction implements FilterCondition { + constructor(left: Expr, right: Expr); + // (undocumented) + filterable: true; + } + +// @beta +export function gt(left: Expr, right: Expr): Gt; + +// @beta +export function gt(left: Expr, right: any): Gt; + +// @beta +export function gt(left: string, right: Expr): Gt; + +// @beta +export function gt(left: string, right: any): Gt; + +// @beta (undocumented) +export class Gte extends FirestoreFunction implements FilterCondition { + constructor(left: Expr, right: Expr); + // (undocumented) + filterable: true; + } + +// @beta +export function gte(left: Expr, right: Expr): Gte; + +// @beta +export function gte(left: Expr, right: any): Gte; + +// @beta +export function gte(left: string, right: Expr): Gte; + +// @beta +export function gte(left: string, right: any): Gte; + +// @beta (undocumented) +export class IsNan extends FirestoreFunction implements FilterCondition { + constructor(expr: Expr); + // (undocumented) + filterable: true; +} + +// @beta +export function isNan(value: Expr): IsNan; + +// @beta +export function isNan(value: string): IsNan; + +// @beta (undocumented) +export class Like extends FirestoreFunction implements FilterCondition { + constructor(expr: Expr, pattern: Expr); + // (undocumented) + filterable: true; + } + +// @beta +export function like(left: string, pattern: string): Like; + +// @beta +export function like(left: string, pattern: Expr): Like; + +// @beta +export function like(left: Expr, pattern: string): Like; + +// @beta +export function like(left: Expr, pattern: Expr): Like; + +// @beta (undocumented) +export class Limit implements Stage { + constructor(limit: number, convertedFromLimitTolast?: boolean); + // (undocumented) + readonly convertedFromLimitTolast: boolean; + // (undocumented) + readonly limit: number; + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class LogicalMaximum extends FirestoreFunction { + constructor(left: Expr, right: Expr); + } + +// @beta +export function logicalMaximum(left: Expr, right: Expr): LogicalMaximum; + +// @beta +export function logicalMaximum(left: Expr, right: any): LogicalMaximum; + +// @beta +export function logicalMaximum(left: string, right: Expr): LogicalMaximum; + +// @beta +export function logicalMaximum(left: string, right: any): LogicalMaximum; + +// @beta (undocumented) +export class LogicalMinimum extends FirestoreFunction { + constructor(left: Expr, right: Expr); + } + +// @beta +export function logicalMinimum(left: Expr, right: Expr): LogicalMinimum; + +// @beta +export function logicalMinimum(left: Expr, right: any): LogicalMinimum; + +// @beta +export function logicalMinimum(left: string, right: Expr): LogicalMinimum; + +// @beta +export function logicalMinimum(left: string, right: any): LogicalMinimum; + +// @beta (undocumented) +export class Lt extends FirestoreFunction implements FilterCondition { + constructor(left: Expr, right: Expr); + // (undocumented) + filterable: true; + } + +// @beta +export function lt(left: Expr, right: Expr): Lt; + +// @beta +export function lt(left: Expr, right: any): Lt; + +// @beta +export function lt(left: string, right: Expr): Lt; + +// @beta +export function lt(left: string, right: any): Lt; + +// @beta (undocumented) +export class Lte extends FirestoreFunction implements FilterCondition { + constructor(left: Expr, right: Expr); + // (undocumented) + filterable: true; + } + +// @beta +export function lte(left: Expr, right: Expr): Lte; + +// @beta +export function lte(left: Expr, right: any): Lte; + +// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Expr" which is marked as @beta +// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Lte" which is marked as @beta +// +// @public +export function lte(left: string, right: Expr): Lte; + +// @beta +export function lte(left: string, right: any): Lte; + +// @beta (undocumented) +export class MapGet extends FirestoreFunction { + constructor(map: Expr, name: string); +} + +// @beta +export function mapGet(mapField: string, subField: string): MapGet; + +// @beta +export function mapGet(mapExpr: Expr, subField: string): MapGet; + +// @beta (undocumented) +export class Maximum extends FirestoreFunction implements Accumulator { + constructor(value: Expr, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta +export function maximum(value: Expr): Maximum; + +// @beta +export function maximum(value: string): Maximum; + +// @beta (undocumented) +export class Minimum extends FirestoreFunction implements Accumulator { + constructor(value: Expr, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta +export function minimum(value: Expr): Minimum; + +// @beta +export function minimum(value: string): Minimum; + +// @beta (undocumented) +export class Mod extends FirestoreFunction { + constructor(left: Expr, right: Expr); + } + +// @beta +export function mod(left: Expr, right: Expr): Mod; + +// @beta +export function mod(left: Expr, right: any): Mod; + +// @beta +export function mod(left: string, right: Expr): Mod; + +// @beta +export function mod(left: string, right: any): Mod; + +// @beta (undocumented) +export class Multiply extends FirestoreFunction { + constructor(left: Expr, right: Expr); + } + +// @beta +export function multiply(left: Expr, right: Expr): Multiply; + +// @beta +export function multiply(left: Expr, right: any): Multiply; + +// @beta +export function multiply(left: string, right: Expr): Multiply; + +// @beta +export function multiply(left: string, right: any): Multiply; + +// @beta (undocumented) +export class Neq extends FirestoreFunction implements FilterCondition { + constructor(left: Expr, right: Expr); + // (undocumented) + filterable: true; + } + +// @beta +export function neq(left: Expr, right: Expr): Neq; + +// @beta +export function neq(left: Expr, right: any): Neq; + +// @beta +export function neq(left: string, right: Expr): Neq; + +// @beta +export function neq(left: string, right: any): Neq; + +// @beta (undocumented) +export class Not extends FirestoreFunction implements FilterCondition { + constructor(expr: Expr); + // (undocumented) + filterable: true; +} + +// @beta +export function not(filter: FilterCondition): Not; + +// @beta (undocumented) +export class NotEqAny extends FirestoreFunction implements FilterCondition { + constructor(left: Expr, others: Expr[]); + // (undocumented) + filterable: true; + } + +// @beta +export function notEqAny(element: Expr, others: Expr[]): NotEqAny; + +// @beta +export function notEqAny(element: Expr, others: any[]): NotEqAny; + +// @beta +export function notEqAny(element: string, others: Expr[]): NotEqAny; + +// @beta +export function notEqAny(element: string, others: any[]): NotEqAny; + +// @beta (undocumented) +export class Offset implements Stage { + constructor(offset: number); + // (undocumented) + name: string; + } + +// @beta (undocumented) +export class Or extends FirestoreFunction implements FilterCondition { + constructor(conditions: FilterCondition[]); + // (undocumented) + filterable: true; +} + +// @beta +export class Ordering { + constructor(expr: Expr, direction: 'ascending' | 'descending'); + // (undocumented) + readonly direction: 'ascending' | 'descending'; + // (undocumented) + readonly expr: Expr; +} + +// @beta +export function orFunction(left: FilterCondition, ...right: FilterCondition[]): Or; + +// @public (undocumented) +export class Pipeline { + /* Excluded from this release type: newPipeline */ + // Warning: (ae-incompatible-release-tags) The symbol "addFields" is marked as @public, but its signature references "Selectable" which is marked as @beta + addFields(...fields: Selectable[]): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "aggregate" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta + aggregate(...accumulators: AccumulatorTarget[]): Pipeline; + aggregate(options: { accumulators: AccumulatorTarget[]; groups?: Array; }): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "distinct" is marked as @public, but its signature references "Selectable" which is marked as @beta + distinct(...groups: Array): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "execute" is marked as @public, but its signature references "PipelineResult" which is marked as @beta + execute(): Promise; + // Warning: (ae-incompatible-release-tags) The symbol "findNearest" is marked as @public, but its signature references "FindNearestOptions" which is marked as @beta + // + // (undocumented) + findNearest(options: FindNearestOptions): Pipeline; + genericStage(name: string, params: any[]): Pipeline; + limit(limit: number): Pipeline; + offset(offset: number): Pipeline; + readUserData: any; + // Warning: (ae-incompatible-release-tags) The symbol "select" is marked as @public, but its signature references "Selectable" which is marked as @beta + select(...selections: Array): Pipeline; + // (undocumented) + selectablesToMap: any; + // Warning: (ae-incompatible-release-tags) The symbol "sort" is marked as @public, but its signature references "Ordering" which is marked as @beta + sort(...orderings: Ordering[]): Pipeline; + // (undocumented) + sort(options: { orderings: Ordering[]; }): Pipeline; + // (undocumented) + stages: any; + // (undocumented) + userDataReader: any; + // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "FilterCondition" which is marked as @beta + where(condition: FilterCondition): Pipeline; +} + +// Warning: (ae-forgotten-export) The symbol "Firestore" needs to be exported by the entry point pipelines.d.ts +// Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta +// +// @public +export function pipeline(firestore: Firestore): PipelineSource; + +// Warning: (ae-forgotten-export) The symbol "Query" needs to be exported by the entry point pipelines.d.ts +// +// @public +export function pipeline(query: Query): Pipeline; + +// Warning: (ae-forgotten-export) The symbol "DocumentData" needs to be exported by the entry point pipelines.d.ts +// +// @beta +export class PipelineResult { + /* Excluded from this release type: _ref */ + /* Excluded from this release type: _fields */ + /* Excluded from this release type: __constructor */ + get createTime(): Timestamp | undefined; + data(): AppModelType | undefined; + get executionTime(): Timestamp; + get(fieldPath: string | FieldPath): any; + get id(): string | undefined; + get ref(): DocumentReference | undefined; + get updateTime(): Timestamp | undefined; +} + +// @beta +export class PipelineSource { + /* Excluded from this release type: _createPipeline */ + /* Excluded from this release type: __constructor */ + // (undocumented) + collection(collectionPath: string): PipelineType; + // (undocumented) + collectionGroup(collectionId: string): PipelineType; + // (undocumented) + database(): PipelineType; + // (undocumented) + documents(docs: DocumentReference[]): PipelineType; +} + +// @beta (undocumented) +export class RegexContains extends FirestoreFunction implements FilterCondition { + constructor(expr: Expr, pattern: Expr); + // (undocumented) + filterable: true; + } + +// @beta +export function regexContains(left: string, pattern: string): RegexContains; + +// @beta +export function regexContains(left: string, pattern: Expr): RegexContains; + +// @beta +export function regexContains(left: Expr, pattern: string): RegexContains; + +// @beta +export function regexContains(left: Expr, pattern: Expr): RegexContains; + +// @beta (undocumented) +export class RegexMatch extends FirestoreFunction implements FilterCondition { + constructor(expr: Expr, pattern: Expr); + // (undocumented) + filterable: true; + } + +// @beta +export function regexMatch(left: string, pattern: string): RegexMatch; + +// @beta +export function regexMatch(left: string, pattern: Expr): RegexMatch; + +// @beta +export function regexMatch(left: Expr, pattern: string): RegexMatch; + +// @beta +export function regexMatch(left: Expr, pattern: Expr): RegexMatch; + +// @beta (undocumented) +export class ReplaceAll extends FirestoreFunction { + constructor(value: Expr, find: Expr, replace: Expr); + } + +// @beta +export function replaceAll(value: Expr, find: string, replace: string): ReplaceAll; + +// @beta +export function replaceAll(value: Expr, find: Expr, replace: Expr): ReplaceAll; + +// @beta +export function replaceAll(field: string, find: string, replace: string): ReplaceAll; + +// @beta (undocumented) +export class ReplaceFirst extends FirestoreFunction { + constructor(value: Expr, find: Expr, replace: Expr); + } + +// @beta +export function replaceFirst(value: Expr, find: string, replace: string): ReplaceFirst; + +// @beta +export function replaceFirst(value: Expr, find: Expr, replace: Expr): ReplaceFirst; + +// @beta +export function replaceFirst(field: string, find: string, replace: string): ReplaceFirst; + +// @beta (undocumented) +export class Reverse extends FirestoreFunction { + constructor(value: Expr); + } + +// @beta +export function reverse(expr: Expr): Reverse; + +// @beta +export function reverse(field: string): Reverse; + +// @beta (undocumented) +export class Select implements Stage { + constructor(projections: Map); + // (undocumented) + name: string; + } + +// @beta +export interface Selectable extends Expr { + // (undocumented) + selectable: true; +} + +// @beta (undocumented) +export class Sort implements Stage { + constructor(orders: Ordering[]); + // (undocumented) + name: string; + } + +// @beta (undocumented) +export interface Stage { + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class StartsWith extends FirestoreFunction implements FilterCondition { + constructor(expr: Expr, prefix: Expr); + // (undocumented) + filterable: true; + } + +// @beta +export function startsWith(expr: string, prefix: string): StartsWith; + +// @beta +export function startsWith(expr: string, prefix: Expr): StartsWith; + +// @beta +export function startsWith(expr: Expr, prefix: string): StartsWith; + +// @beta +export function startsWith(expr: Expr, prefix: Expr): StartsWith; + +// @beta (undocumented) +export class StrConcat extends FirestoreFunction { + constructor(first: Expr, rest: Expr[]); + } + +// @beta +export function strConcat(first: string, ...elements: Array): StrConcat; + +// @beta +export function strConcat(first: Expr, ...elements: Array): StrConcat; + +// @beta (undocumented) +export class StrContains extends FirestoreFunction implements FilterCondition { + constructor(expr: Expr, substring: Expr); + // (undocumented) + filterable: true; + } + +// @beta +export function strContains(left: string, substring: string): StrContains; + +// @beta +export function strContains(left: string, substring: Expr): StrContains; + +// @beta +export function strContains(left: Expr, substring: string): StrContains; + +// @beta +export function strContains(left: Expr, substring: Expr): StrContains; + +// @beta (undocumented) +export class Subtract extends FirestoreFunction { + constructor(left: Expr, right: Expr); + } + +// @beta +export function subtract(left: Expr, right: Expr): Subtract; + +// @beta +export function subtract(left: Expr, right: any): Subtract; + +// @beta +export function subtract(left: string, right: Expr): Subtract; + +// @beta +export function subtract(left: string, right: any): Subtract; + +// @beta (undocumented) +export class Sum extends FirestoreFunction implements Accumulator { + constructor(value: Expr, distinct: boolean); + // (undocumented) + accumulator: true; + } + +// @beta +export function sumFunction(value: Expr): Sum; + +// @beta +export function sumFunction(value: string): Sum; + +// @beta (undocumented) +export class TimestampAdd extends FirestoreFunction { + constructor(timestamp: Expr, unit: Expr, amount: Expr); + } + +// @beta +export function timestampAdd(timestamp: Expr, unit: Expr, amount: Expr): TimestampAdd; + +// @beta +export function timestampAdd(timestamp: Expr, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + +// @beta +export function timestampAdd(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; + +// @beta (undocumented) +export class TimestampSub extends FirestoreFunction { + constructor(timestamp: Expr, unit: Expr, amount: Expr); + } + +// @beta +export function timestampSub(timestamp: Expr, unit: Expr, amount: Expr): TimestampSub; + +// @beta +export function timestampSub(timestamp: Expr, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + +// @beta +export function timestampSub(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; + +// @beta (undocumented) +export class TimestampToUnixMicros extends FirestoreFunction { + constructor(input: Expr); + } + +// @beta +export function timestampToUnixMicros(expr: Expr): TimestampToUnixMicros; + +// @beta +export function timestampToUnixMicros(field: string): TimestampToUnixMicros; + +// @beta (undocumented) +export class TimestampToUnixMillis extends FirestoreFunction { + constructor(input: Expr); + } + +// @beta +export function timestampToUnixMillis(expr: Expr): TimestampToUnixMillis; + +// @beta +export function timestampToUnixMillis(field: string): TimestampToUnixMillis; + +// @beta (undocumented) +export class TimestampToUnixSeconds extends FirestoreFunction { + constructor(input: Expr); + } + +// @beta +export function timestampToUnixSeconds(expr: Expr): TimestampToUnixSeconds; + +// @beta +export function timestampToUnixSeconds(field: string): TimestampToUnixSeconds; + +// @beta (undocumented) +export class ToLower extends FirestoreFunction { + constructor(expr: Expr); + } + +// @beta +export function toLower(expr: string): ToLower; + +// @beta +export function toLower(expr: Expr): ToLower; + +// @beta (undocumented) +export class ToUpper extends FirestoreFunction { + constructor(expr: Expr); + } + +// @beta +export function toUpper(expr: string): ToUpper; + +// @beta +export function toUpper(expr: Expr): ToUpper; + +// @beta (undocumented) +export class Trim extends FirestoreFunction { + constructor(expr: Expr); + } + +// @beta +export function trim(expr: string): Trim; + +// @beta +export function trim(expr: Expr): Trim; + +// @beta (undocumented) +export class UnixMicrosToTimestamp extends FirestoreFunction { + constructor(input: Expr); + } + +// @beta +export function unixMicrosToTimestamp(expr: Expr): UnixMicrosToTimestamp; + +// @beta +export function unixMicrosToTimestamp(field: string): UnixMicrosToTimestamp; + +// @beta (undocumented) +export class UnixMillisToTimestamp extends FirestoreFunction { + constructor(input: Expr); + } + +// @beta +export function unixMillisToTimestamp(expr: Expr): UnixMillisToTimestamp; + +// @beta +export function unixMillisToTimestamp(field: string): UnixMillisToTimestamp; + +// @beta (undocumented) +export class UnixSecondsToTimestamp extends FirestoreFunction { + constructor(input: Expr); + } + +// @beta +export function unixSecondsToTimestamp(expr: Expr): UnixSecondsToTimestamp; + +// @beta +export function unixSecondsToTimestamp(field: string): UnixSecondsToTimestamp; + +// @beta (undocumented) +export class VectorLength extends FirestoreFunction { + constructor(value: Expr); + } + +// @beta +export function vectorLength(expr: Expr): VectorLength; + +// @beta +export function vectorLength(field: string): VectorLength; + +// @beta (undocumented) +export class Where implements Stage { + constructor(condition: FilterCondition); + // (undocumented) + name: string; +} + +// @beta (undocumented) +export class Xor extends FirestoreFunction implements FilterCondition { + constructor(conditions: FilterCondition[]); + // (undocumented) + filterable: true; +} + +// @beta +export function xor(left: FilterCondition, ...right: FilterCondition[]): Xor; + + +// Warnings were encountered during analysis: +// +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/pipelines.d.ts:3983:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/pipelines.d.ts:3983:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/pipelines.d.ts:4010:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta + +// (No @packageDocumentation comment for this package) + +``` diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index 37317520020..6f0e14206c2 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -10,27 +10,27 @@ import { FirebaseError } from '@firebase/util'; import { LogLevelString as LogLevel } from '@firebase/logger'; // @beta -export interface Accumulator { +export interface Accumulator extends Expr { // (undocumented) accumulator: true; } // @beta -export type AccumulatorTarget = ExprWithAlias; +export type AccumulatorTarget = ExprWithAlias; // @beta (undocumented) export class Add extends FirestoreFunction { - constructor(left: Constant, right: Constant); + constructor(left: Expr, right: Expr); } // @beta -export function add(left: Constant, right: Constant): Add; +export function add(left: Expr, right: Expr): Add; // @beta -export function add(left: Constant, right: any): Add; +export function add(left: Expr, right: any): Add; // @beta -export function add(left: string, right: Constant): Add; +export function add(left: string, right: Expr): Add; // @beta export function add(left: string, right: any): Add; @@ -40,7 +40,7 @@ export function addDoc(reference // @beta (undocumented) export class AddFields implements Stage { - constructor(fields: Map); + constructor(fields: Map); // (undocumented) name: string; } @@ -52,7 +52,7 @@ export type AddPrefixToKeys, groups: Map); + constructor(accumulators: Map, groups: Map); // (undocumented) name: string; } @@ -95,7 +95,7 @@ export type AggregateType = 'count' | 'avg' | 'sum'; // @beta (undocumented) export class And extends FirestoreFunction implements FilterCondition { - constructor(conditions: FilterExpr[]); + constructor(conditions: (FilterCondition)[]); // (undocumented) filterable: true; } @@ -104,78 +104,78 @@ export class And extends FirestoreFunction implements FilterCondition { export function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; // @beta -export function andFunction(left: FilterExpr, ...right: FilterExpr[]): And; +export function andFunction(left: FilterCondition, ...right: (FilterCondition)[]): And; // @beta (undocumented) export class ArrayConcat extends FirestoreFunction { - constructor(array: Constant, elements: Constant[]); + constructor(array: Expr, elements: Expr[]); } // @beta -export function arrayConcat(array: Constant, elements: Constant[]): ArrayConcat; +export function arrayConcat(array: Expr, elements: Expr[]): ArrayConcat; // @beta -export function arrayConcat(array: Constant, elements: any[]): ArrayConcat; +export function arrayConcat(array: Expr, elements: any[]): ArrayConcat; // @beta -export function arrayConcat(array: string, elements: Constant[]): ArrayConcat; +export function arrayConcat(array: string, elements: Expr[]): ArrayConcat; // @beta export function arrayConcat(array: string, elements: any[]): ArrayConcat; // @beta (undocumented) export class ArrayContains extends FirestoreFunction implements FilterCondition { - constructor(array: Constant, element: Constant); + constructor(array: Expr, element: Expr); // (undocumented) filterable: true; } // @beta -export function arrayContains(array: Constant, element: Constant): ArrayContains; +export function arrayContains(array: Expr, element: Expr): ArrayContains; // @beta -export function arrayContains(array: Constant, element: any): ArrayContains; +export function arrayContains(array: Expr, element: any): ArrayContains; // @beta -export function arrayContains(array: string, element: Constant): ArrayContains; +export function arrayContains(array: string, element: Expr): ArrayContains; // @beta export function arrayContains(array: string, element: any): ArrayContains; // @beta (undocumented) export class ArrayContainsAll extends FirestoreFunction implements FilterCondition { - constructor(array: Constant, values: Constant[]); + constructor(array: Expr, values: Expr[]); // (undocumented) filterable: true; } // @beta -export function arrayContainsAll(array: Constant, values: Constant[]): ArrayContainsAll; +export function arrayContainsAll(array: Expr, values: Expr[]): ArrayContainsAll; // @beta -export function arrayContainsAll(array: Constant, values: any[]): ArrayContainsAll; +export function arrayContainsAll(array: Expr, values: any[]): ArrayContainsAll; // @beta -export function arrayContainsAll(array: string, values: Constant[]): ArrayContainsAll; +export function arrayContainsAll(array: string, values: Expr[]): ArrayContainsAll; // @beta export function arrayContainsAll(array: string, values: any[]): ArrayContainsAll; // @beta (undocumented) export class ArrayContainsAny extends FirestoreFunction implements FilterCondition { - constructor(array: Constant, values: Constant[]); + constructor(array: Expr, values: Expr[]); // (undocumented) filterable: true; } // @beta -export function arrayContainsAny(array: Constant, values: Constant[]): ArrayContainsAny; +export function arrayContainsAny(array: Expr, values: Expr[]): ArrayContainsAny; // @beta -export function arrayContainsAny(array: Constant, values: any[]): ArrayContainsAny; +export function arrayContainsAny(array: Expr, values: any[]): ArrayContainsAny; // @beta -export function arrayContainsAny(array: string, values: Constant[]): ArrayContainsAny; +export function arrayContainsAny(array: string, values: Expr[]): ArrayContainsAny; // @beta export function arrayContainsAny(array: string, values: any[]): ArrayContainsAny; @@ -187,49 +187,49 @@ export class ArrayElement extends FirestoreFunction { // @beta (undocumented) export class ArrayLength extends FirestoreFunction { - constructor(array: Constant); + constructor(array: Expr); } // @beta -export function arrayLength(array: Constant): ArrayLength; +export function arrayLength(array: Expr): ArrayLength; // @public export function arrayRemove(...elements: unknown[]): FieldValue; // @beta (undocumented) export class ArrayReverse extends FirestoreFunction { - constructor(array: Constant); + constructor(array: Expr); } // @public export function arrayUnion(...elements: unknown[]): FieldValue; // @beta -export function ascending(expr: Constant): Ordering; +export function ascending(expr: Expr): Ordering; // @public export function average(field: string | FieldPath): AggregateField; // @beta (undocumented) export class Avg extends FirestoreFunction implements Accumulator { - constructor(value: Constant, distinct: boolean); + constructor(value: Expr, distinct: boolean); // (undocumented) accumulator: true; } // @beta -export function avgFunction(value: Constant): Avg; +export function avgFunction(value: Expr): Avg; // @beta export function avgFunction(value: string): Avg; // @beta (undocumented) export class ByteLength extends FirestoreFunction { - constructor(value: Constant); + constructor(value: Expr); } // @beta -export function byteLength(expr: Constant): ByteLength; +export function byteLength(expr: Expr): ByteLength; // @beta export function byteLength(field: string): ByteLength; @@ -249,14 +249,14 @@ export const CACHE_SIZE_UNLIMITED = -1; // @beta (undocumented) export class CharLength extends FirestoreFunction { - constructor(value: Constant); + constructor(value: Expr); } // @beta export function charLength(field: string): CharLength; // @beta -export function charLength(expr: Constant): CharLength; +export function charLength(expr: Expr): CharLength; // @public export type ChildUpdateFields = V extends Record ? AddPrefixToKeys> : never; @@ -301,14 +301,14 @@ export class CollectionSource implements Stage { } // @beta (undocumented) -export class Cond extends FirestoreFunction implements FilterCondition { - constructor(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant); +export class Cond extends FirestoreFunction { + constructor(condition: FilterCondition, thenExpr: Expr, elseExpr: Expr); // (undocumented) filterable: true; } // @beta -export function cond(condition: FilterExpr, thenExpr: Constant, elseExpr: Constant): Cond; +export function cond(condition: FilterCondition, thenExpr: Expr, elseExpr: Expr): Cond; // @public export function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: { @@ -316,125 +316,28 @@ export function connectFirestoreEmulator(firestore: Firestore, host: string, por }): void; // @beta -export class Constant { - add(other: Constant): Add; - add(other: any): Add; - arrayConcat(arrays: Constant[]): ArrayConcat; - arrayConcat(arrays: any[]): ArrayConcat; - arrayContains(element: Constant): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Constant[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Constant[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Constant): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Constant): Divide; - divide(other: any): Divide; - dotProduct(other: Constant): DotProduct; - dotProduct(other: VectorValue): DotProduct; - // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Constant): EndsWith; - eq(other: Constant): Eq; - eq(other: any): Eq; - eqAny(...others: Constant[]): EqAny; - // (undocumented) - eqAny(...others: any[]): EqAny; - euclideanDistance(other: Constant): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; - // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; +export class Constant extends Expr { // (undocumented) exprType: ExprType; - gt(other: Constant): Gt; - gt(other: any): Gt; - gte(other: Constant): Gte; - gte(other: any): Gte; - isNaN(): IsNan; - like(pattern: string): Like; - // (undocumented) - like(pattern: Constant): Like; - logicalMaximum(other: Constant): LogicalMaximum; - logicalMaximum(other: any): LogicalMaximum; - logicalMinimum(other: Constant): LogicalMinimum; - logicalMinimum(other: any): LogicalMinimum; - lt(other: Constant): Lt; - lt(other: any): Lt; - lte(other: Constant): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - maximum(): Maximum; - minimum(): Minimum; - mod(other: Constant): Mod; - mod(other: any): Mod; - multiply(other: Constant): Multiply; - multiply(other: any): Multiply; - neq(other: Constant): Neq; - neq(other: any): Neq; - notEqAny(...others: Constant[]): NotEqAny; - // (undocumented) - notEqAny(...others: any[]): NotEqAny; static of(value: number): Constant; static of(value: string): Constant; static of(value: boolean): Constant; static of(value: null): Constant; + static of(value: undefined): Constant; static of(value: GeoPoint): Constant; static of(value: Timestamp): Constant; static of(value: Date): Constant; - static of(value: Bytes): Constant; + static of(value: Uint8Array): Constant; static of(value: DocumentReference): Constant; static of(value: any[]): Constant; - static of(value: Record): Constant; + static of(value: Map): Constant; static of(value: VectorValue): Constant; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Constant): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Constant): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Constant, replace: Constant): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Constant, replace: Constant): ReplaceFirst; - reverse(): Reverse; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Constant): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Constant): StrContains; - subtract(other: Constant): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Constant, amount: Constant): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Constant, amount: Constant): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; static vector(value: number[] | VectorValue): Constant; - vectorLength(): VectorLength; } // @beta (undocumented) export class CosineDistance extends FirestoreFunction { - constructor(vector1: Constant, vector2: Constant); + constructor(vector1: Expr, vector2: Expr); } // @beta @@ -444,20 +347,20 @@ export function cosineDistance(expr: string, other: number[]): CosineDistance; export function cosineDistance(expr: string, other: VectorValue): CosineDistance; // @beta -export function cosineDistance(expr: string, other: Constant): CosineDistance; +export function cosineDistance(expr: string, other: Expr): CosineDistance; // @beta -export function cosineDistance(expr: Constant, other: number[]): CosineDistance; +export function cosineDistance(expr: Expr, other: number[]): CosineDistance; // @beta -export function cosineDistance(expr: Constant, other: VectorValue): CosineDistance; +export function cosineDistance(expr: Expr, other: VectorValue): CosineDistance; // @beta -export function cosineDistance(expr: Constant, other: Constant): CosineDistance; +export function cosineDistance(expr: Expr, other: Expr): CosineDistance; // @beta (undocumented) export class Count extends FirestoreFunction implements Accumulator { - constructor(value: Constant | undefined, distinct: boolean); + constructor(value: Expr | undefined, distinct: boolean); // (undocumented) accumulator: true; } @@ -469,7 +372,7 @@ export function count(): AggregateField; export function countAll(): Count; // @beta -export function countFunction(value: Constant): Count; +export function countFunction(value: Expr): Count; // Warning: (ae-incompatible-release-tags) The symbol "countFunction" is marked as @public, but its signature references "Count" which is marked as @beta // @@ -492,7 +395,7 @@ export function deleteDoc(refere export function deleteField(): FieldValue; // @beta -export function descending(expr: Constant): Ordering; +export function descending(expr: Expr): Ordering; // @public export function disableNetwork(firestore: Firestore): Promise; @@ -502,24 +405,24 @@ export function disablePersistentCacheIndexAutoCreation(indexManager: Persistent // @beta (undocumented) export class Distinct implements Stage { - constructor(groups: Map); + constructor(groups: Map); // (undocumented) name: string; } // @beta (undocumented) export class Divide extends FirestoreFunction { - constructor(left: Constant, right: Constant); + constructor(left: Expr, right: Expr); } // @beta -export function divide(left: Constant, right: Constant): Divide; +export function divide(left: Expr, right: Expr): Divide; // @beta -export function divide(left: Constant, right: any): Divide; +export function divide(left: Expr, right: any): Divide; // @beta -export function divide(left: string, right: Constant): Divide; +export function divide(left: string, right: Expr): Divide; // @beta export function divide(left: string, right: any): Divide; @@ -586,7 +489,7 @@ export class DocumentsSource implements Stage { // @beta (undocumented) export class DotProduct extends FirestoreFunction { - constructor(vector1: Constant, vector2: Constant); + constructor(vector1: Expr, vector2: Expr); } // @beta @@ -596,16 +499,16 @@ export function dotProduct(expr: string, other: number[]): DotProduct; export function dotProduct(expr: string, other: VectorValue): DotProduct; // @beta -export function dotProduct(expr: string, other: Constant): DotProduct; +export function dotProduct(expr: string, other: Expr): DotProduct; // @beta -export function dotProduct(expr: Constant, other: number[]): DotProduct; +export function dotProduct(expr: Expr, other: number[]): DotProduct; // @beta -export function dotProduct(expr: Constant, other: VectorValue): DotProduct; +export function dotProduct(expr: Expr, other: VectorValue): DotProduct; // @beta -export function dotProduct(expr: Constant, other: Constant): DotProduct; +export function dotProduct(expr: Expr, other: Expr): DotProduct; export { EmulatorMockTokenOptions } @@ -635,7 +538,7 @@ export function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint; // @beta (undocumented) export class EndsWith extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant, suffix: Constant); + constructor(expr: Expr, suffix: Expr); // (undocumented) filterable: true; } @@ -644,55 +547,55 @@ export class EndsWith extends FirestoreFunction implements FilterCondition { export function endsWith(expr: string, suffix: string): EndsWith; // @beta -export function endsWith(expr: string, suffix: Constant): EndsWith; +export function endsWith(expr: string, suffix: Expr): EndsWith; // @beta -export function endsWith(expr: Constant, suffix: string): EndsWith; +export function endsWith(expr: Expr, suffix: string): EndsWith; // @beta -export function endsWith(expr: Constant, suffix: Constant): EndsWith; +export function endsWith(expr: Expr, suffix: Expr): EndsWith; // @beta (undocumented) export class Eq extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, right: Constant); + constructor(left: Expr, right: Expr); // (undocumented) filterable: true; } // @beta -export function eq(left: Constant, right: Constant): Eq; +export function eq(left: Expr, right: Expr): Eq; // @beta -export function eq(left: Constant, right: any): Eq; +export function eq(left: Expr, right: any): Eq; // @beta -export function eq(left: string, right: Constant): Eq; +export function eq(left: string, right: Expr): Eq; // @beta export function eq(left: string, right: any): Eq; // @beta (undocumented) export class EqAny extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, others: Constant[]); + constructor(left: Expr, others: Expr[]); // (undocumented) filterable: true; } // @beta -export function eqAny(element: Constant, others: Constant[]): EqAny; +export function eqAny(element: Expr, others: Expr[]): EqAny; // @beta -export function eqAny(element: Constant, others: any[]): EqAny; +export function eqAny(element: Expr, others: any[]): EqAny; // @beta -export function eqAny(element: string, others: Constant[]): EqAny; +export function eqAny(element: string, others: Expr[]): EqAny; // @beta export function eqAny(element: string, others: any[]): EqAny; // @beta (undocumented) export class EuclideanDistance extends FirestoreFunction { - constructor(vector1: Constant, vector2: Constant); + constructor(vector1: Expr, vector2: Expr); } // @beta @@ -702,31 +605,31 @@ export function euclideanDistance(expr: string, other: number[]): EuclideanDista export function euclideanDistance(expr: string, other: VectorValue): EuclideanDistance; // @beta -export function euclideanDistance(expr: string, other: Constant): EuclideanDistance; +export function euclideanDistance(expr: string, other: Expr): EuclideanDistance; // @beta -export function euclideanDistance(expr: Constant, other: number[]): EuclideanDistance; +export function euclideanDistance(expr: Expr, other: number[]): EuclideanDistance; // @beta -export function euclideanDistance(expr: Constant, other: VectorValue): EuclideanDistance; +export function euclideanDistance(expr: Expr, other: VectorValue): EuclideanDistance; // @beta -export function euclideanDistance(expr: Constant, other: Constant): EuclideanDistance; +export function euclideanDistance(expr: Expr, other: Expr): EuclideanDistance; // Warning: (ae-incompatible-release-tags) The symbol "execute" is marked as @public, but its signature references "PipelineResult" which is marked as @beta // // @public (undocumented) -export function execute(pipeline: Pipeline): Promise>>; +export function execute(pipeline: Pipeline): Promise; // @beta (undocumented) export class Exists extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant); + constructor(expr: Expr); // (undocumented) filterable: true; } // @beta -export function exists(value: Constant): Exists; +export function exists(value: Expr): Exists; // @beta export function exists(field: string): Exists; @@ -737,22 +640,16 @@ export interface ExperimentalLongPollingOptions { } // @beta -export type ExprType = 'Field' | 'Constant' | 'Function' | 'ListOfExprs' | 'ExprWithAlias'; - -// @beta (undocumented) -export class ExprWithAlias implements Selectable { - constructor(expr: T, alias: string); - add(other: Constant): Add; +export abstract class Expr { + add(other: Expr): Add; add(other: any): Add; - // (undocumented) - alias: string; - arrayConcat(arrays: Constant[]): ArrayConcat; - arrayConcat(arrays: any[]): ArrayConcat; - arrayContains(element: Constant): ArrayContains; + arrayConcat(...arrays: Expr[]): ArrayConcat; + arrayConcat(...arrays: any[][]): ArrayConcat; + arrayContains(element: Expr): ArrayContains; arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Constant[]): ArrayContainsAll; + arrayContainsAll(...values: Expr[]): ArrayContainsAll; arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Constant[]): ArrayContainsAny; + arrayContainsAny(...values: Expr[]): ArrayContainsAny; arrayContainsAny(...values: any[]): ArrayContainsAny; arrayLength(): ArrayLength; as(name: string): ExprWithAlias; @@ -760,83 +657,74 @@ export class ExprWithAlias implements Selectable { avg(): Avg; byteLength(): ByteLength; charLength(): CharLength; - cosineDistance(other: Constant): CosineDistance; + cosineDistance(other: Expr): CosineDistance; cosineDistance(other: VectorValue): CosineDistance; cosineDistance(other: number[]): CosineDistance; count(): Count; descending(): Ordering; - divide(other: Constant): Divide; + divide(other: Expr): Divide; divide(other: any): Divide; - dotProduct(other: Constant): DotProduct; + dotProduct(other: Expr): DotProduct; dotProduct(other: VectorValue): DotProduct; - // (undocumented) dotProduct(other: number[]): DotProduct; endsWith(suffix: string): EndsWith; - endsWith(suffix: Constant): EndsWith; - eq(other: Constant): Eq; + endsWith(suffix: Expr): EndsWith; + eq(other: Expr): Eq; eq(other: any): Eq; - eqAny(...others: Constant[]): EqAny; - // (undocumented) + eqAny(...others: Expr[]): EqAny; eqAny(...others: any[]): EqAny; - euclideanDistance(other: Constant): EuclideanDistance; + euclideanDistance(other: Expr): EuclideanDistance; euclideanDistance(other: VectorValue): EuclideanDistance; - // (undocumented) euclideanDistance(other: number[]): EuclideanDistance; exists(): Exists; // (undocumented) - expr: T; - // (undocumented) - exprType: ExprType; - gt(other: Constant): Gt; + abstract exprType: ExprType; + gt(other: Expr): Gt; gt(other: any): Gt; - gte(other: Constant): Gte; + gte(other: Expr): Gte; gte(other: any): Gte; isNaN(): IsNan; like(pattern: string): Like; - // (undocumented) - like(pattern: Constant): Like; - logicalMaximum(other: Constant): LogicalMaximum; + like(pattern: Expr): Like; + logicalMaximum(other: Expr): LogicalMaximum; logicalMaximum(other: any): LogicalMaximum; - logicalMinimum(other: Constant): LogicalMinimum; + logicalMinimum(other: Expr): LogicalMinimum; logicalMinimum(other: any): LogicalMinimum; - lt(other: Constant): Lt; + lt(other: Expr): Lt; lt(other: any): Lt; - lte(other: Constant): Lte; + lte(other: Expr): Lte; lte(other: any): Lte; mapGet(subfield: string): MapGet; maximum(): Maximum; minimum(): Minimum; - mod(other: Constant): Mod; + mod(other: Expr): Mod; mod(other: any): Mod; - multiply(other: Constant): Multiply; + multiply(other: Expr): Multiply; multiply(other: any): Multiply; - neq(other: Constant): Neq; + neq(other: Expr): Neq; neq(other: any): Neq; - notEqAny(...others: Constant[]): NotEqAny; - // (undocumented) + notEqAny(...others: Expr[]): NotEqAny; notEqAny(...others: any[]): NotEqAny; regexContains(pattern: string): RegexContains; - regexContains(pattern: Constant): RegexContains; + regexContains(pattern: Expr): RegexContains; regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Constant): RegexMatch; + regexMatch(pattern: Expr): RegexMatch; replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Constant, replace: Constant): ReplaceAll; + replaceAll(find: Expr, replace: Expr): ReplaceAll; replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Constant, replace: Constant): ReplaceFirst; + replaceFirst(find: Expr, replace: Expr): ReplaceFirst; reverse(): Reverse; - // (undocumented) - selectable: true; startsWith(prefix: string): StartsWith; - startsWith(prefix: Constant): StartsWith; - strConcat(...elements: Array): StrConcat; + startsWith(prefix: Expr): StartsWith; + strConcat(...elements: Array): StrConcat; strContains(substring: string): StrContains; - strContains(expr: Constant): StrContains; - subtract(other: Constant): Subtract; + strContains(expr: Expr): StrContains; + subtract(other: Expr): Subtract; subtract(other: any): Subtract; sum(): Sum; - timestampAdd(unit: Constant, amount: Constant): TimestampAdd; + timestampAdd(unit: Expr, amount: Expr): TimestampAdd; timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Constant, amount: Constant): TimestampSub; + timestampSub(unit: Expr, amount: Expr): TimestampSub; timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; timestampToUnixMicros(): TimestampToUnixMicros; timestampToUnixMillis(): TimestampToUnixMillis; @@ -851,116 +739,34 @@ export class ExprWithAlias implements Selectable { } // @beta -export class Field implements Selectable { - add(other: Constant): Add; - add(other: any): Add; - arrayConcat(arrays: Constant[]): ArrayConcat; - arrayConcat(arrays: any[]): ArrayConcat; - arrayContains(element: Constant): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Constant[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Constant[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Constant): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Constant): Divide; - divide(other: any): Divide; - dotProduct(other: Constant): DotProduct; - dotProduct(other: VectorValue): DotProduct; - // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Constant): EndsWith; - eq(other: Constant): Eq; - eq(other: any): Eq; - eqAny(...others: Constant[]): EqAny; +export type ExprType = 'Field' | 'Constant' | 'Function' | 'ListOfExprs' | 'ExprWithAlias'; + +// @beta (undocumented) +export class ExprWithAlias extends Expr implements Selectable { + constructor(expr: T, alias: string); // (undocumented) - eqAny(...others: any[]): EqAny; - euclideanDistance(other: Constant): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; + readonly alias: string; // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; + readonly expr: T; // (undocumented) exprType: ExprType; // (undocumented) - fieldName(): string; - gt(other: Constant): Gt; - gt(other: any): Gt; - gte(other: Constant): Gte; - gte(other: any): Gte; - isNaN(): IsNan; - like(pattern: string): Like; + selectable: true; +} + +// @beta +export class Field extends Expr implements Selectable { // (undocumented) - like(pattern: Constant): Like; - logicalMaximum(other: Constant): LogicalMaximum; - logicalMaximum(other: any): LogicalMaximum; - logicalMinimum(other: Constant): LogicalMinimum; - logicalMinimum(other: any): LogicalMinimum; - lt(other: Constant): Lt; - lt(other: any): Lt; - lte(other: Constant): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - maximum(): Maximum; - minimum(): Minimum; - mod(other: Constant): Mod; - mod(other: any): Mod; - multiply(other: Constant): Multiply; - multiply(other: any): Multiply; - neq(other: Constant): Neq; - neq(other: any): Neq; - notEqAny(...others: Constant[]): NotEqAny; + exprType: ExprType; // (undocumented) - notEqAny(...others: any[]): NotEqAny; + fieldName(): string; static of(name: string): Field; // (undocumented) static of(path: FieldPath): Field; // (undocumented) static of(pipeline: Pipeline, name: string): Field; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Constant): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Constant): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Constant, replace: Constant): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Constant, replace: Constant): ReplaceFirst; - reverse(): Reverse; // (undocumented) selectable: true; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Constant): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Constant): StrContains; - subtract(other: Constant): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Constant, amount: Constant): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Constant, amount: Constant): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - vectorLength(): VectorLength; } // @public @@ -970,115 +776,17 @@ export class FieldPath { } // @beta (undocumented) -export class Fields implements Selectable { - add(other: Constant): Add; - add(other: any): Add; - arrayConcat(arrays: Constant[]): ArrayConcat; - arrayConcat(arrays: any[]): ArrayConcat; - arrayContains(element: Constant): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Constant[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Constant[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Constant): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Constant): Divide; - divide(other: any): Divide; - dotProduct(other: Constant): DotProduct; - dotProduct(other: VectorValue): DotProduct; - // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Constant): EndsWith; - eq(other: Constant): Eq; - eq(other: any): Eq; - eqAny(...others: Constant[]): EqAny; - // (undocumented) - eqAny(...others: any[]): EqAny; - euclideanDistance(other: Constant): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; - // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; +export class Fields extends Expr implements Selectable { // (undocumented) exprType: ExprType; // (undocumented) fieldList(): Field[]; - gt(other: Constant): Gt; - gt(other: any): Gt; - gte(other: Constant): Gte; - gte(other: any): Gte; - isNaN(): IsNan; - like(pattern: string): Like; - // (undocumented) - like(pattern: Constant): Like; - logicalMaximum(other: Constant): LogicalMaximum; - logicalMaximum(other: any): LogicalMaximum; - logicalMinimum(other: Constant): LogicalMinimum; - logicalMinimum(other: any): LogicalMinimum; - lt(other: Constant): Lt; - lt(other: any): Lt; - lte(other: Constant): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - maximum(): Maximum; - minimum(): Minimum; - mod(other: Constant): Mod; - mod(other: any): Mod; - multiply(other: Constant): Multiply; - multiply(other: any): Multiply; - neq(other: Constant): Neq; - neq(other: any): Neq; - notEqAny(...others: Constant[]): NotEqAny; - // (undocumented) - notEqAny(...others: any[]): NotEqAny; // (undocumented) static of(name: string, ...others: string[]): Fields; // (undocumented) static ofAll(): Fields; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Constant): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Constant): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Constant, replace: Constant): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Constant, replace: Constant): ReplaceFirst; - reverse(): Reverse; // (undocumented) selectable: true; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Constant): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Constant): StrContains; - subtract(other: Constant): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Constant, amount: Constant): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Constant, amount: Constant): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - vectorLength(): VectorLength; } // @public @@ -1087,14 +795,11 @@ export abstract class FieldValue { } // @beta -export interface FilterCondition { +export interface FilterCondition extends Expr { // (undocumented) filterable: true; } -// @beta -export type FilterExpr = Constant & FilterCondition; - // @beta (undocumented) export class FindNearest implements Stage { // (undocumented) @@ -1140,109 +845,11 @@ export class FirestoreError extends FirebaseError { export type FirestoreErrorCode = 'cancelled' | 'unknown' | 'invalid-argument' | 'deadline-exceeded' | 'not-found' | 'already-exists' | 'permission-denied' | 'resource-exhausted' | 'failed-precondition' | 'aborted' | 'out-of-range' | 'unimplemented' | 'internal' | 'unavailable' | 'data-loss' | 'unauthenticated'; // @beta -export class FirestoreFunction { - constructor(name: string, params: Constant[]); - add(other: Constant): Add; - add(other: any): Add; - arrayConcat(arrays: Constant[]): ArrayConcat; - arrayConcat(arrays: any[]): ArrayConcat; - arrayContains(element: Constant): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Constant[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Constant[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Constant): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Constant): Divide; - divide(other: any): Divide; - dotProduct(other: Constant): DotProduct; - dotProduct(other: VectorValue): DotProduct; - // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Constant): EndsWith; - eq(other: Constant): Eq; - eq(other: any): Eq; - eqAny(...others: Constant[]): EqAny; - // (undocumented) - eqAny(...others: any[]): EqAny; - euclideanDistance(other: Constant): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; - // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; +export class FirestoreFunction extends Expr { + constructor(name: string, params: Expr[]); // (undocumented) exprType: ExprType; - gt(other: Constant): Gt; - gt(other: any): Gt; - gte(other: Constant): Gte; - gte(other: any): Gte; - isNaN(): IsNan; - like(pattern: string): Like; - // (undocumented) - like(pattern: Constant): Like; - logicalMaximum(other: Constant): LogicalMaximum; - logicalMaximum(other: any): LogicalMaximum; - logicalMinimum(other: Constant): LogicalMinimum; - logicalMinimum(other: any): LogicalMinimum; - lt(other: Constant): Lt; - lt(other: any): Lt; - lte(other: Constant): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - maximum(): Maximum; - minimum(): Minimum; - mod(other: Constant): Mod; - mod(other: any): Mod; - multiply(other: Constant): Multiply; - multiply(other: any): Multiply; - neq(other: Constant): Neq; - neq(other: any): Neq; - notEqAny(...others: Constant[]): NotEqAny; - // (undocumented) - notEqAny(...others: any[]): NotEqAny; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Constant): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Constant): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Constant, replace: Constant): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Constant, replace: Constant): ReplaceFirst; - reverse(): Reverse; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Constant): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Constant): StrContains; - subtract(other: Constant): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Constant, amount: Constant): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Constant, amount: Constant): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - vectorLength(): VectorLength; -} + } // @public export type FirestoreLocalCache = MemoryLocalCache | PersistentLocalCache; @@ -1260,7 +867,7 @@ export interface FirestoreSettings { } // @beta -export function genericFunction(name: string, params: Constant[]): FirestoreFunction; +export function genericFunction(name: string, params: Expr[]): FirestoreFunction; // @beta (undocumented) export class GenericStage implements Stage { @@ -1324,38 +931,38 @@ export function getPersistentCacheIndexManager(firestore: Firestore): Persistent // @beta (undocumented) export class Gt extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, right: Constant); + constructor(left: Expr, right: Expr); // (undocumented) filterable: true; } // @beta -export function gt(left: Constant, right: Constant): Gt; +export function gt(left: Expr, right: Expr): Gt; // @beta -export function gt(left: Constant, right: any): Gt; +export function gt(left: Expr, right: any): Gt; // @beta -export function gt(left: string, right: Constant): Gt; +export function gt(left: string, right: Expr): Gt; // @beta export function gt(left: string, right: any): Gt; // @beta (undocumented) export class Gte extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, right: Constant); + constructor(left: Expr, right: Expr); // (undocumented) filterable: true; } // @beta -export function gte(left: Constant, right: Constant): Gte; +export function gte(left: Expr, right: Expr): Gte; // @beta -export function gte(left: Constant, right: any): Gte; +export function gte(left: Expr, right: any): Gte; // @beta -export function gte(left: string, right: Constant): Gte; +export function gte(left: string, right: Expr): Gte; // @beta export function gte(left: string, right: any): Gte; @@ -1392,20 +999,20 @@ export function initializeFirestore(app: FirebaseApp, settings: FirestoreSetting // @beta (undocumented) export class IsNan extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant); + constructor(expr: Expr); // (undocumented) filterable: true; } // @beta -export function isNan(value: Constant): IsNan; +export function isNan(value: Expr): IsNan; // @beta export function isNan(value: string): IsNan; // @beta (undocumented) export class Like extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant, pattern: Constant); + constructor(expr: Expr, pattern: Expr); // (undocumented) filterable: true; } @@ -1414,13 +1021,13 @@ export class Like extends FirestoreFunction implements FilterCondition { export function like(left: string, pattern: string): Like; // @beta -export function like(left: string, pattern: Constant): Like; +export function like(left: string, pattern: Expr): Like; // @beta -export function like(left: Constant, pattern: string): Like; +export function like(left: Expr, pattern: string): Like; // @beta -export function like(left: Constant, pattern: Constant): Like; +export function like(left: Expr, pattern: Expr): Like; // @beta (undocumented) export class Limit implements Stage { @@ -1459,34 +1066,34 @@ export interface LoadBundleTaskProgress { // @beta (undocumented) export class LogicalMaximum extends FirestoreFunction { - constructor(left: Constant, right: Constant); + constructor(left: Expr, right: Expr); } // @beta -export function logicalMaximum(left: Constant, right: Constant): LogicalMaximum; +export function logicalMaximum(left: Expr, right: Expr): LogicalMaximum; // @beta -export function logicalMaximum(left: Constant, right: any): LogicalMaximum; +export function logicalMaximum(left: Expr, right: any): LogicalMaximum; // @beta -export function logicalMaximum(left: string, right: Constant): LogicalMaximum; +export function logicalMaximum(left: string, right: Expr): LogicalMaximum; // @beta export function logicalMaximum(left: string, right: any): LogicalMaximum; // @beta (undocumented) export class LogicalMinimum extends FirestoreFunction { - constructor(left: Constant, right: Constant); + constructor(left: Expr, right: Expr); } // @beta -export function logicalMinimum(left: Constant, right: Constant): LogicalMinimum; +export function logicalMinimum(left: Expr, right: Expr): LogicalMinimum; // @beta -export function logicalMinimum(left: Constant, right: any): LogicalMinimum; +export function logicalMinimum(left: Expr, right: any): LogicalMinimum; // @beta -export function logicalMinimum(left: string, right: Constant): LogicalMinimum; +export function logicalMinimum(left: string, right: Expr): LogicalMinimum; // @beta export function logicalMinimum(left: string, right: any): LogicalMinimum; @@ -1495,65 +1102,65 @@ export { LogLevel } // @beta (undocumented) export class Lt extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, right: Constant); + constructor(left: Expr, right: Expr); // (undocumented) filterable: true; } // @beta -export function lt(left: Constant, right: Constant): Lt; +export function lt(left: Expr, right: Expr): Lt; // @beta -export function lt(left: Constant, right: any): Lt; +export function lt(left: Expr, right: any): Lt; // @beta -export function lt(left: string, right: Constant): Lt; +export function lt(left: string, right: Expr): Lt; // @beta export function lt(left: string, right: any): Lt; // @beta (undocumented) export class Lte extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, right: Constant); + constructor(left: Expr, right: Expr); // (undocumented) filterable: true; } // @beta -export function lte(left: Constant, right: Constant): Lte; +export function lte(left: Expr, right: Expr): Lte; // @beta -export function lte(left: Constant, right: any): Lte; +export function lte(left: Expr, right: any): Lte; -// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Constant" which is marked as @beta +// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Expr" which is marked as @beta // Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Lte" which is marked as @beta // // @public -export function lte(left: string, right: Constant): Lte; +export function lte(left: string, right: Expr): Lte; // @beta export function lte(left: string, right: any): Lte; // @beta (undocumented) export class MapGet extends FirestoreFunction { - constructor(map: Constant, name: string); + constructor(map: Expr, name: string); } // @beta export function mapGet(mapField: string, subField: string): MapGet; // @beta -export function mapGet(mapExpr: Constant, subField: string): MapGet; +export function mapGet(mapExpr: Expr, subField: string): MapGet; // @beta (undocumented) export class Maximum extends FirestoreFunction implements Accumulator { - constructor(value: Constant, distinct: boolean); + constructor(value: Expr, distinct: boolean); // (undocumented) accumulator: true; } // @beta -export function maximum(value: Constant): Maximum; +export function maximum(value: Expr): Maximum; // @beta export function maximum(value: string): Maximum; @@ -1597,47 +1204,47 @@ export function memoryLruGarbageCollector(settings?: { // @beta (undocumented) export class Minimum extends FirestoreFunction implements Accumulator { - constructor(value: Constant, distinct: boolean); + constructor(value: Expr, distinct: boolean); // (undocumented) accumulator: true; } // @beta -export function minimum(value: Constant): Minimum; +export function minimum(value: Expr): Minimum; // @beta export function minimum(value: string): Minimum; // @beta (undocumented) export class Mod extends FirestoreFunction { - constructor(left: Constant, right: Constant); + constructor(left: Expr, right: Expr); } // @beta -export function mod(left: Constant, right: Constant): Mod; +export function mod(left: Expr, right: Expr): Mod; // @beta -export function mod(left: Constant, right: any): Mod; +export function mod(left: Expr, right: any): Mod; // @beta -export function mod(left: string, right: Constant): Mod; +export function mod(left: string, right: Expr): Mod; // @beta export function mod(left: string, right: any): Mod; // @beta (undocumented) export class Multiply extends FirestoreFunction { - constructor(left: Constant, right: Constant); + constructor(left: Expr, right: Expr); } // @beta -export function multiply(left: Constant, right: Constant): Multiply; +export function multiply(left: Expr, right: Expr): Multiply; // @beta -export function multiply(left: Constant, right: any): Multiply; +export function multiply(left: Expr, right: any): Multiply; // @beta -export function multiply(left: string, right: Constant): Multiply; +export function multiply(left: string, right: Expr): Multiply; // @beta export function multiply(left: string, right: any): Multiply; @@ -1647,19 +1254,19 @@ export function namedQuery(firestore: Firestore, name: string): Promise> = UnionToInter // @beta (undocumented) export class Not extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant); + constructor(expr: Expr); // (undocumented) filterable: true; } // @beta -export function not(filter: FilterExpr): Not; +export function not(filter: FilterCondition): Not; // @beta (undocumented) export class NotEqAny extends FirestoreFunction implements FilterCondition { - constructor(left: Constant, others: Constant[]); + constructor(left: Expr, others: Expr[]); // (undocumented) filterable: true; } // @beta -export function notEqAny(element: Constant, others: Constant[]): NotEqAny; +export function notEqAny(element: Expr, others: Expr[]): NotEqAny; // @beta -export function notEqAny(element: Constant, others: any[]): NotEqAny; +export function notEqAny(element: Expr, others: any[]): NotEqAny; // @beta -export function notEqAny(element: string, others: Constant[]): NotEqAny; +export function notEqAny(element: string, others: Expr[]): NotEqAny; // @beta export function notEqAny(element: string, others: any[]): NotEqAny; @@ -1757,7 +1364,7 @@ export function onSnapshotsInSync(firestore: Firestore, onSync: () => void): Uns // @beta (undocumented) export class Or extends FirestoreFunction implements FilterCondition { - constructor(conditions: FilterExpr[]); + constructor(conditions: (FilterCondition)[]); // (undocumented) filterable: true; } @@ -1773,11 +1380,15 @@ export type OrderByDirection = 'desc' | 'asc'; // @beta export class Ordering { - constructor(expr: Constant, direction: 'ascending' | 'descending'); - } + constructor(expr: Expr, direction: 'ascending' | 'descending'); + // (undocumented) + readonly direction: 'ascending' | 'descending'; + // (undocumented) + readonly expr: Expr; +} // @beta -export function orFunction(left: FilterExpr, ...right: FilterExpr[]): Or; +export function orFunction(left: FilterCondition, ...right: (FilterCondition)[]): Or; // @public export type PartialWithFieldValue = Partial | (T extends Primitive ? T : T extends {} ? { @@ -1836,49 +1447,45 @@ export interface PersistentSingleTabManagerSettings { export type PersistentTabManager = PersistentSingleTabManager | PersistentMultipleTabManager; // @public (undocumented) -export class Pipeline { - /* Excluded from this release type: __constructor */ +export class Pipeline { /* Excluded from this release type: newPipeline */ // Warning: (ae-incompatible-release-tags) The symbol "addFields" is marked as @public, but its signature references "Selectable" which is marked as @beta - addFields(...fields: Selectable[]): Pipeline; + addFields(...fields: Selectable[]): Pipeline; // Warning: (ae-incompatible-release-tags) The symbol "aggregate" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta - aggregate(...accumulators: AccumulatorTarget[]): Pipeline; - aggregate(options: { accumulators: AccumulatorTarget[]; groups?: Array; }): Pipeline; - // (undocumented) - converter: any; + aggregate(...accumulators: AccumulatorTarget[]): Pipeline; + aggregate(options: { accumulators: AccumulatorTarget[]; groups?: Array; }): Pipeline; // Warning: (ae-incompatible-release-tags) The symbol "distinct" is marked as @public, but its signature references "Selectable" which is marked as @beta - distinct(...groups: Array): Pipeline; + distinct(...groups: Array): Pipeline; // Warning: (ae-incompatible-release-tags) The symbol "execute" is marked as @public, but its signature references "PipelineResult" which is marked as @beta - execute(): Promise>>; + execute(): Promise; // Warning: (ae-incompatible-release-tags) The symbol "findNearest" is marked as @public, but its signature references "FindNearestOptions" which is marked as @beta // // (undocumented) - findNearest(options: FindNearestOptions): Pipeline; - genericStage(name: string, params: any[]): Pipeline; - limit(limit: number): Pipeline; - offset(offset: number): Pipeline; + findNearest(options: FindNearestOptions): Pipeline; + genericStage(name: string, params: any[]): Pipeline; + limit(limit: number): Pipeline; + offset(offset: number): Pipeline; readUserData: any; // Warning: (ae-incompatible-release-tags) The symbol "select" is marked as @public, but its signature references "Selectable" which is marked as @beta - select(...selections: Array): Pipeline; + select(...selections: Array): Pipeline; // (undocumented) selectablesToMap: any; // Warning: (ae-incompatible-release-tags) The symbol "sort" is marked as @public, but its signature references "Ordering" which is marked as @beta - sort(...orderings: Ordering[]): Pipeline; + sort(...orderings: Ordering[]): Pipeline; // (undocumented) - sort(options: { orderings: Ordering[]; }): Pipeline; + sort(options: { orderings: Ordering[]; }): Pipeline; // (undocumented) stages: any; // (undocumented) userDataReader: any; // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "FilterCondition" which is marked as @beta - // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "Constant" which is marked as @beta - where(condition: FilterCondition & Constant): Pipeline; + where(condition: FilterCondition): Pipeline; } // Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta // // @public -export function pipeline(firestore: Firestore): PipelineSource; +export function pipeline(firestore: Firestore): PipelineSource; // @public export function pipeline(query: Query): Pipeline; @@ -1898,20 +1505,17 @@ export class PipelineResult { } // @beta -export class PipelineSource { - /* Excluded from this release type: _db */ - /* Excluded from this release type: _userDataReader */ - /* Excluded from this release type: _userDataWriter */ - /* Excluded from this release type: _documentReferenceFactory */ +export class PipelineSource { + /* Excluded from this release type: _createPipeline */ /* Excluded from this release type: __constructor */ // (undocumented) - collection(collectionPath: string): Pipeline; + collection(collectionPath: string): PipelineType; // (undocumented) - collectionGroup(collectionId: string): Pipeline; + collectionGroup(collectionId: string): PipelineType; // (undocumented) - database(): Pipeline; + database(): PipelineType; // (undocumented) - documents(docs: DocumentReference[]): Pipeline; + documents(docs: DocumentReference[]): PipelineType; } // @public @@ -2002,7 +1606,7 @@ export function refEqual(left: D // @beta (undocumented) export class RegexContains extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant, pattern: Constant); + constructor(expr: Expr, pattern: Expr); // (undocumented) filterable: true; } @@ -2011,17 +1615,17 @@ export class RegexContains extends FirestoreFunction implements FilterCondition export function regexContains(left: string, pattern: string): RegexContains; // @beta -export function regexContains(left: string, pattern: Constant): RegexContains; +export function regexContains(left: string, pattern: Expr): RegexContains; // @beta -export function regexContains(left: Constant, pattern: string): RegexContains; +export function regexContains(left: Expr, pattern: string): RegexContains; // @beta -export function regexContains(left: Constant, pattern: Constant): RegexContains; +export function regexContains(left: Expr, pattern: Expr): RegexContains; // @beta (undocumented) export class RegexMatch extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant, pattern: Constant); + constructor(expr: Expr, pattern: Expr); // (undocumented) filterable: true; } @@ -2030,49 +1634,49 @@ export class RegexMatch extends FirestoreFunction implements FilterCondition { export function regexMatch(left: string, pattern: string): RegexMatch; // @beta -export function regexMatch(left: string, pattern: Constant): RegexMatch; +export function regexMatch(left: string, pattern: Expr): RegexMatch; // @beta -export function regexMatch(left: Constant, pattern: string): RegexMatch; +export function regexMatch(left: Expr, pattern: string): RegexMatch; // @beta -export function regexMatch(left: Constant, pattern: Constant): RegexMatch; +export function regexMatch(left: Expr, pattern: Expr): RegexMatch; // @beta (undocumented) export class ReplaceAll extends FirestoreFunction { - constructor(value: Constant, find: Constant, replace: Constant); + constructor(value: Expr, find: Expr, replace: Expr); } // @beta -export function replaceAll(value: Constant, find: string, replace: string): ReplaceAll; +export function replaceAll(value: Expr, find: string, replace: string): ReplaceAll; // @beta -export function replaceAll(value: Constant, find: Constant, replace: Constant): ReplaceAll; +export function replaceAll(value: Expr, find: Expr, replace: Expr): ReplaceAll; // @beta export function replaceAll(field: string, find: string, replace: string): ReplaceAll; // @beta (undocumented) export class ReplaceFirst extends FirestoreFunction { - constructor(value: Constant, find: Constant, replace: Constant); + constructor(value: Expr, find: Expr, replace: Expr); } // @beta -export function replaceFirst(value: Constant, find: string, replace: string): ReplaceFirst; +export function replaceFirst(value: Expr, find: string, replace: string): ReplaceFirst; // @beta -export function replaceFirst(value: Constant, find: Constant, replace: Constant): ReplaceFirst; +export function replaceFirst(value: Expr, find: Expr, replace: Expr): ReplaceFirst; // @beta export function replaceFirst(field: string, find: string, replace: string): ReplaceFirst; // @beta (undocumented) export class Reverse extends FirestoreFunction { - constructor(value: Constant); + constructor(value: Expr); } // @beta -export function reverse(expr: Constant): Reverse; +export function reverse(expr: Expr): Reverse; // @beta export function reverse(field: string): Reverse; @@ -2082,20 +1686,17 @@ export function runTransaction(firestore: Firestore, updateFunction: (transac // @beta (undocumented) export class Select implements Stage { - constructor(projections: Map); + constructor(projections: Map); // (undocumented) name: string; } // @beta -export interface Selectable { +export interface Selectable extends Expr { // (undocumented) selectable: true; } -// @beta -export type SelectableExpr = Constant & Selectable; - // @public export function serverTimestamp(): FieldValue; @@ -2169,7 +1770,7 @@ export function startAt(...fieldValues: unknown[]): QueryStartAtConstraint; // @beta (undocumented) export class StartsWith extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant, prefix: Constant); + constructor(expr: Expr, prefix: Expr); // (undocumented) filterable: true; } @@ -2178,28 +1779,28 @@ export class StartsWith extends FirestoreFunction implements FilterCondition { export function startsWith(expr: string, prefix: string): StartsWith; // @beta -export function startsWith(expr: string, prefix: Constant): StartsWith; +export function startsWith(expr: string, prefix: Expr): StartsWith; // @beta -export function startsWith(expr: Constant, prefix: string): StartsWith; +export function startsWith(expr: Expr, prefix: string): StartsWith; // @beta -export function startsWith(expr: Constant, prefix: Constant): StartsWith; +export function startsWith(expr: Expr, prefix: Expr): StartsWith; // @beta (undocumented) export class StrConcat extends FirestoreFunction { - constructor(first: Constant, rest: Constant[]); + constructor(first: Expr, rest: Expr[]); } // @beta -export function strConcat(first: string, ...elements: Array): StrConcat; +export function strConcat(first: string, ...elements: Array): StrConcat; // @beta -export function strConcat(first: Constant, ...elements: Array): StrConcat; +export function strConcat(first: Expr, ...elements: Array): StrConcat; // @beta (undocumented) export class StrContains extends FirestoreFunction implements FilterCondition { - constructor(expr: Constant, substring: Constant); + constructor(expr: Expr, substring: Expr); // (undocumented) filterable: true; } @@ -2208,34 +1809,34 @@ export class StrContains extends FirestoreFunction implements FilterCondition { export function strContains(left: string, substring: string): StrContains; // @beta -export function strContains(left: string, substring: Constant): StrContains; +export function strContains(left: string, substring: Expr): StrContains; // @beta -export function strContains(left: Constant, substring: string): StrContains; +export function strContains(left: Expr, substring: string): StrContains; // @beta -export function strContains(left: Constant, substring: Constant): StrContains; +export function strContains(left: Expr, substring: Expr): StrContains; // @beta (undocumented) export class Subtract extends FirestoreFunction { - constructor(left: Constant, right: Constant); + constructor(left: Expr, right: Expr); } // @beta -export function subtract(left: Constant, right: Constant): Subtract; +export function subtract(left: Expr, right: Expr): Subtract; // @beta -export function subtract(left: Constant, right: any): Subtract; +export function subtract(left: Expr, right: any): Subtract; // @beta -export function subtract(left: string, right: Constant): Subtract; +export function subtract(left: string, right: Expr): Subtract; // @beta export function subtract(left: string, right: any): Subtract; // @beta (undocumented) export class Sum extends FirestoreFunction implements Accumulator { - constructor(value: Constant, distinct: boolean); + constructor(value: Expr, distinct: boolean); // (undocumented) accumulator: true; } @@ -2244,7 +1845,7 @@ export class Sum extends FirestoreFunction implements Accumulator { export function sum(field: string | FieldPath): AggregateField; // @beta -export function sumFunction(value: Constant): Sum; +export function sumFunction(value: Expr): Sum; // @beta export function sumFunction(value: string): Sum; @@ -2278,86 +1879,86 @@ export class Timestamp { // @beta (undocumented) export class TimestampAdd extends FirestoreFunction { - constructor(timestamp: Constant, unit: Constant, amount: Constant); + constructor(timestamp: Expr, unit: Expr, amount: Expr); } // @beta -export function timestampAdd(timestamp: Constant, unit: Constant, amount: Constant): TimestampAdd; +export function timestampAdd(timestamp: Expr, unit: Expr, amount: Expr): TimestampAdd; // @beta -export function timestampAdd(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; +export function timestampAdd(timestamp: Expr, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; // @beta export function timestampAdd(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; // @beta (undocumented) export class TimestampSub extends FirestoreFunction { - constructor(timestamp: Constant, unit: Constant, amount: Constant); + constructor(timestamp: Expr, unit: Expr, amount: Expr); } // @beta -export function timestampSub(timestamp: Constant, unit: Constant, amount: Constant): TimestampSub; +export function timestampSub(timestamp: Expr, unit: Expr, amount: Expr): TimestampSub; // @beta -export function timestampSub(timestamp: Constant, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; +export function timestampSub(timestamp: Expr, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; // @beta export function timestampSub(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; // @beta (undocumented) export class TimestampToUnixMicros extends FirestoreFunction { - constructor(input: Constant); + constructor(input: Expr); } // @beta -export function timestampToUnixMicros(expr: Constant): TimestampToUnixMicros; +export function timestampToUnixMicros(expr: Expr): TimestampToUnixMicros; // @beta export function timestampToUnixMicros(field: string): TimestampToUnixMicros; // @beta (undocumented) export class TimestampToUnixMillis extends FirestoreFunction { - constructor(input: Constant); + constructor(input: Expr); } // @beta -export function timestampToUnixMillis(expr: Constant): TimestampToUnixMillis; +export function timestampToUnixMillis(expr: Expr): TimestampToUnixMillis; // @beta export function timestampToUnixMillis(field: string): TimestampToUnixMillis; // @beta (undocumented) export class TimestampToUnixSeconds extends FirestoreFunction { - constructor(input: Constant); + constructor(input: Expr); } // @beta -export function timestampToUnixSeconds(expr: Constant): TimestampToUnixSeconds; +export function timestampToUnixSeconds(expr: Expr): TimestampToUnixSeconds; // @beta export function timestampToUnixSeconds(field: string): TimestampToUnixSeconds; // @beta (undocumented) export class ToLower extends FirestoreFunction { - constructor(expr: Constant); + constructor(expr: Expr); } // @beta export function toLower(expr: string): ToLower; // @beta -export function toLower(expr: Constant): ToLower; +export function toLower(expr: Expr): ToLower; // @beta (undocumented) export class ToUpper extends FirestoreFunction { - constructor(expr: Constant); + constructor(expr: Expr); } // @beta export function toUpper(expr: string): ToUpper; // @beta -export function toUpper(expr: Constant): ToUpper; +export function toUpper(expr: Expr): ToUpper; // @public export class Transaction { @@ -2376,47 +1977,47 @@ export interface TransactionOptions { // @beta (undocumented) export class Trim extends FirestoreFunction { - constructor(expr: Constant); + constructor(expr: Expr); } // @beta export function trim(expr: string): Trim; // @beta -export function trim(expr: Constant): Trim; +export function trim(expr: Expr): Trim; // @public export type UnionToIntersection = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never; // @beta (undocumented) export class UnixMicrosToTimestamp extends FirestoreFunction { - constructor(input: Constant); + constructor(input: Expr); } // @beta -export function unixMicrosToTimestamp(expr: Constant): UnixMicrosToTimestamp; +export function unixMicrosToTimestamp(expr: Expr): UnixMicrosToTimestamp; // @beta export function unixMicrosToTimestamp(field: string): UnixMicrosToTimestamp; // @beta (undocumented) export class UnixMillisToTimestamp extends FirestoreFunction { - constructor(input: Constant); + constructor(input: Expr); } // @beta -export function unixMillisToTimestamp(expr: Constant): UnixMillisToTimestamp; +export function unixMillisToTimestamp(expr: Expr): UnixMillisToTimestamp; // @beta export function unixMillisToTimestamp(field: string): UnixMillisToTimestamp; // @beta (undocumented) export class UnixSecondsToTimestamp extends FirestoreFunction { - constructor(input: Constant); + constructor(input: Expr); } // @beta -export function unixSecondsToTimestamp(expr: Constant): UnixSecondsToTimestamp; +export function unixSecondsToTimestamp(expr: Expr): UnixSecondsToTimestamp; // @beta export function unixSecondsToTimestamp(field: string): UnixSecondsToTimestamp; @@ -2437,19 +2038,16 @@ export function updateDoc(refere // @public export function updateDoc(reference: DocumentReference, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise; -// @public (undocumented) -export function useFluentPipelines(): void; - // @public export function vector(values?: number[]): VectorValue; // @beta (undocumented) export class VectorLength extends FirestoreFunction { - constructor(value: Constant); + constructor(value: Expr); } // @beta -export function vectorLength(expr: Constant): VectorLength; +export function vectorLength(expr: Expr): VectorLength; // @beta export function vectorLength(field: string): VectorLength; @@ -2466,7 +2064,7 @@ export function waitForPendingWrites(firestore: Firestore): Promise; // @beta (undocumented) export class Where implements Stage { - constructor(condition: FilterCondition & Constant); + constructor(condition: FilterCondition); // (undocumented) name: string; } @@ -2497,19 +2095,19 @@ export function writeBatch(firestore: Firestore): WriteBatch; // @beta (undocumented) export class Xor extends FirestoreFunction implements FilterCondition { - constructor(conditions: FilterExpr[]); + constructor(conditions: (FilterCondition)[]); // (undocumented) filterable: true; } // @beta -export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor; +export function xor(left: FilterCondition, ...right: (FilterCondition)[]): Xor; // Warnings were encountered during analysis: // -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10167:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10167:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /home/runner/work/firebase-js-sdk/firebase-js-sdk/packages/firestore/dist/index.d.ts:10194:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/all_packages.d.ts:5962:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/all_packages.d.ts:5962:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/all_packages.d.ts:5989:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/packages/firebase/firestore/pipelines/index.ts b/packages/firebase/firestore/pipelines/index.ts new file mode 100644 index 00000000000..be062f16e96 --- /dev/null +++ b/packages/firebase/firestore/pipelines/index.ts @@ -0,0 +1,18 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from '@firebase/firestore/pipelines'; diff --git a/packages/firebase/firestore/pipelines/package.json b/packages/firebase/firestore/pipelines/package.json new file mode 100644 index 00000000000..e63cb928b0f --- /dev/null +++ b/packages/firebase/firestore/pipelines/package.json @@ -0,0 +1,7 @@ +{ + "name": "firebase/firestore/pipelines", + "main": "dist/pipelines.cjs.js", + "browser": "dist/esm/pipelines.esm.js", + "module": "dist/esm/pipelines.esm.js", + "typings": "dist/firestore/lite/pipelines.d.ts" +} diff --git a/packages/firebase/package.json b/packages/firebase/package.json index f716238f483..ee9fe733892 100644 --- a/packages/firebase/package.json +++ b/packages/firebase/package.json @@ -131,6 +131,18 @@ }, "default": "./firestore/dist/esm/index.esm.js" }, + "./firestore/pipelines": { + "types": "./firestore/dist/firestore/pipelines.d.ts", + "node": { + "require": "./firestore/dist/pipelines.cjs.js", + "import": "./firestore/dist/pipelines.mjs" + }, + "browser": { + "require": "./firestore/dist/pipelines.cjs.js", + "import": "./firestore/dist/esm/pipelines.esm.js" + }, + "default": "./firestore/dist/esm/pipelines.esm.js" + }, "./firestore/lite": { "types": "./firestore/lite/dist/firestore/lite/index.d.ts", "node": { diff --git a/packages/firestore/.eslintrc.js b/packages/firestore/.eslintrc.js index 5dd443333d9..9ffb1d0279b 100644 --- a/packages/firestore/.eslintrc.js +++ b/packages/firestore/.eslintrc.js @@ -24,7 +24,7 @@ module.exports = { tsconfigRootDir: __dirname }, plugins: ['import'], - ignorePatterns: ['compat/*'], + ignorePatterns: ['compat/*', 'pipelines.d.ts'], rules: { 'no-console': ['error', { allow: ['warn', 'error'] }], '@typescript-eslint/no-unused-vars': [ diff --git a/packages/firestore/externs.json b/packages/firestore/externs.json index f7fbbabeb14..22da710fe3a 100644 --- a/packages/firestore/externs.json +++ b/packages/firestore/externs.json @@ -17,7 +17,9 @@ "packages/app-check-interop-types/index.d.ts", "packages/auth-interop-types/index.d.ts", "packages/firestore/dist/lite/internal.d.ts", + "packages/firestore/dist/lite/internal.pipelines.d.ts", "packages/firestore/dist/internal.d.ts", + "packages/firestore/dist/internal.pipelines.d.ts", "packages/firestore-types/index.d.ts", "packages/firebase/compat/index.d.ts", "packages/component/dist/src/component.d.ts", diff --git a/packages/firestore/lite/index.ts b/packages/firestore/lite/index.ts index d001457ac50..b751f0a8254 100644 --- a/packages/firestore/lite/index.ts +++ b/packages/firestore/lite/index.ts @@ -27,173 +27,6 @@ import { registerFirestore } from './register'; registerFirestore(); -export { PipelineSource } from '../src/lite-api/pipeline-source'; - -export { PipelineResult } from '../src/lite-api/pipeline-result'; - -export { Pipeline } from '../src/lite-api/pipeline'; - -export { - useFluentPipelines, - pipeline, - execute -} from '../src/lite-api/pipeline_impl'; - -export { - Stage, - FindNearestOptions, - AddFields, - Aggregate, - Distinct, - CollectionSource, - CollectionGroupSource, - DatabaseSource, - DocumentsSource, - Where, - FindNearest, - Limit, - Offset, - Select, - Sort, - GenericStage -} from '../src/lite-api/stage'; - -export { - add, - subtract, - multiply, - divide, - mod, - eq, - neq, - lt, - lte, - gt, - gte, - arrayConcat, - arrayContains, - arrayContainsAny, - arrayContainsAll, - arrayLength, - eqAny, - notEqAny, - xor, - cond, - not, - logicalMaximum, - logicalMinimum, - exists, - isNan, - reverse, - replaceFirst, - replaceAll, - byteLength, - charLength, - like, - regexContains, - regexMatch, - strContains, - startsWith, - endsWith, - toLower, - toUpper, - trim, - strConcat, - mapGet, - countAll, - minimum, - maximum, - cosineDistance, - dotProduct, - euclideanDistance, - vectorLength, - unixMicrosToTimestamp, - timestampToUnixMicros, - unixMillisToTimestamp, - timestampToUnixMillis, - unixSecondsToTimestamp, - timestampToUnixSeconds, - timestampAdd, - timestampSub, - genericFunction, - ascending, - descending, - ExprWithAlias, - Field, - Fields, - Constant, - FirestoreFunction, - Add, - Subtract, - Multiply, - Divide, - Mod, - Eq, - Neq, - Lt, - Lte, - Gt, - Gte, - ArrayConcat, - ArrayReverse, - ArrayContains, - ArrayContainsAll, - ArrayContainsAny, - ArrayLength, - ArrayElement, - EqAny, - IsNan, - Exists, - Not, - And, - Or, - Xor, - Cond, - LogicalMaximum, - LogicalMinimum, - Reverse, - ReplaceFirst, - ReplaceAll, - CharLength, - ByteLength, - Like, - RegexContains, - RegexMatch, - StrContains, - StartsWith, - EndsWith, - ToLower, - ToUpper, - Trim, - StrConcat, - MapGet, - Count, - Sum, - Avg, - Minimum, - Maximum, - CosineDistance, - DotProduct, - EuclideanDistance, - VectorLength, - UnixMicrosToTimestamp, - TimestampToUnixMicros, - UnixMillisToTimestamp, - TimestampToUnixMillis, - UnixSecondsToTimestamp, - TimestampToUnixSeconds, - TimestampAdd, - TimestampSub, - Ordering, - ExprType, - AccumulatorTarget, - FilterExpr, - SelectableExpr, - Selectable, - FilterCondition, - Accumulator -} from '../src/lite-api/expressions'; - export { aggregateQuerySnapshotEqual, getCount, diff --git a/packages/firestore/lite/pipelines/package.json b/packages/firestore/lite/pipelines/package.json new file mode 100644 index 00000000000..349e25e3ac3 --- /dev/null +++ b/packages/firestore/lite/pipelines/package.json @@ -0,0 +1,14 @@ +{ + "name": "@firebase/firestore-lite-pipelines", + "description": "Pipelines for the lite Firestore SDK", + "main": "../../dist/lite/pipelines.node.cjs.js", + "main-esm": "../../dist/lite/pipelines.node.mjs", + "module": "../../dist/lite/pipelines.browser.esm2017.js", + "browser": "../../dist/lite/pipelines.browser.esm2017.js", + "react-native": "../../dist/lite/pipelines.rn.esm2017.js", + "typings": "../../dist/lite/pipelines.d.ts", + "private": true, + "engines": { + "node": ">=18.0.0" + } +} diff --git a/packages/firestore/lite/pipelines/pipelines.d.ts b/packages/firestore/lite/pipelines/pipelines.d.ts new file mode 100644 index 00000000000..e1243ebe907 --- /dev/null +++ b/packages/firestore/lite/pipelines/pipelines.d.ts @@ -0,0 +1,28 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { PipelineSource, Pipeline } from '../../dist/lite/pipelines'; + +// Augument the Firestore class with the pipeline() method. +// This is stripped from dist/lite/pipelines.d.ts during the build +// so it needs to be re-added here. +declare module '@firebase/firestore' { + interface Firestore { + pipeline(): PipelineSource; + } +} + +export * from '../../dist/lite/pipelines'; diff --git a/packages/firestore/lite/pipelines/pipelines.ts b/packages/firestore/lite/pipelines/pipelines.ts new file mode 100644 index 00000000000..d3e31f5e52b --- /dev/null +++ b/packages/firestore/lite/pipelines/pipelines.ts @@ -0,0 +1,210 @@ +/** + * Firestore Lite Pipelines + * + * @remarks Firestore Lite is a small online-only SDK that allows read + * and write access to your Firestore database. All operations connect + * directly to the backend, and `onSnapshot()` APIs are not supported. + * @packageDocumentation + */ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// External exports: ./index +// These external exports will be stripped from the dist/pipelines.d.ts file +// by the prune-dts script, in order to reduce type duplication. However, these +// types need to be exported here to ensure that api-extractor behaves +// correctly. If a type from api.ts is missing from this export, then +// api-extractor may rename it with a suffix `_#`, e.g. `YourType_2`. +export type { + Timestamp, + DocumentReference, + VectorValue, + GeoPoint, + FieldPath, + DocumentData, + Query, + Firestore, + FirestoreDataConverter, + WithFieldValue, + PartialWithFieldValue, + SetOptions, + QueryDocumentSnapshot, + Primitive, + FieldValue, + Bytes +} from '../index'; + +export { PipelineSource } from '../../src/lite-api/pipeline-source'; + +export { PipelineResult } from '../../src/lite-api/pipeline-result'; + +export { Pipeline } from '../../src/lite-api/pipeline'; + +export { pipeline, execute } from '../../src/lite-api/pipeline_impl'; + +export { + Stage, + FindNearestOptions, + AddFields, + Aggregate, + Distinct, + CollectionSource, + CollectionGroupSource, + DatabaseSource, + DocumentsSource, + Where, + FindNearest, + Limit, + Offset, + Select, + Sort, + GenericStage +} from '../../src/lite-api/stage'; + +export { + add, + subtract, + multiply, + divide, + mod, + eq, + neq, + lt, + lte, + gt, + gte, + arrayConcat, + arrayContains, + arrayContainsAny, + arrayContainsAll, + arrayLength, + eqAny, + notEqAny, + xor, + cond, + not, + logicalMaximum, + logicalMinimum, + exists, + isNan, + reverse, + replaceFirst, + replaceAll, + byteLength, + charLength, + like, + regexContains, + regexMatch, + strContains, + startsWith, + endsWith, + toLower, + toUpper, + trim, + strConcat, + mapGet, + countAll, + minimum, + maximum, + cosineDistance, + dotProduct, + euclideanDistance, + vectorLength, + unixMicrosToTimestamp, + timestampToUnixMicros, + unixMillisToTimestamp, + timestampToUnixMillis, + unixSecondsToTimestamp, + timestampToUnixSeconds, + timestampAdd, + timestampSub, + genericFunction, + ascending, + descending, + ExprWithAlias, + Field, + Fields, + Constant, + FirestoreFunction, + Add, + Subtract, + Multiply, + Divide, + Mod, + Eq, + Neq, + Lt, + Lte, + Gt, + Gte, + ArrayConcat, + ArrayReverse, + ArrayContains, + ArrayContainsAll, + ArrayContainsAny, + ArrayLength, + ArrayElement, + EqAny, + IsNan, + Exists, + Not, + And, + Or, + Xor, + Cond, + LogicalMaximum, + LogicalMinimum, + Reverse, + ReplaceFirst, + ReplaceAll, + CharLength, + ByteLength, + Like, + RegexContains, + RegexMatch, + StrContains, + StartsWith, + EndsWith, + ToLower, + ToUpper, + Trim, + StrConcat, + MapGet, + Count, + Sum, + Avg, + Minimum, + Maximum, + CosineDistance, + DotProduct, + EuclideanDistance, + VectorLength, + UnixMicrosToTimestamp, + TimestampToUnixMicros, + UnixMillisToTimestamp, + TimestampToUnixMillis, + UnixSecondsToTimestamp, + TimestampToUnixSeconds, + TimestampAdd, + TimestampSub, + Ordering, + ExprType, + AccumulatorTarget, + Selectable, + FilterCondition, + Accumulator +} from '../../src/lite-api/expressions'; diff --git a/packages/firestore/package.json b/packages/firestore/package.json index 896aaa55d6e..a615a5559a5 100644 --- a/packages/firestore/package.json +++ b/packages/firestore/package.json @@ -48,11 +48,14 @@ "test:minified": "(cd ../../integration/firestore ; yarn test)", "trusted-type-check": "tsec -p tsconfig.json --noEmit", "api-report:main": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node ../../repo-scripts/prune-dts/extract-public-api.ts --package firestore --packageRoot . --typescriptDts ./dist/firestore/src/index.d.ts --rollupDts ./dist/private.d.ts --untrimmedRollupDts ./dist/internal.d.ts --publicDts ./dist/index.d.ts", + "api-report:all-packages": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node ../../repo-scripts/prune-dts/extract-public-api.ts --package firestore --packageRoot . --typescriptDts ./dist/firestore/src/all_packages.d.ts --rollupDts ./dist/private.all_packages.d.ts --untrimmedRollupDts ./dist/internal.all_packages.d.ts --publicDts ./dist/all_packages.d.ts", + "api-report:pipelines": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node ../../repo-scripts/prune-dts/extract-public-api.ts --package firestore-pipelines --packageRoot . --typescriptDts ./dist/firestore/pipelines/pipelines.d.ts --rollupDts ./dist/private.pipelines.d.ts --untrimmedRollupDts ./dist/internal.pipelines.d.ts --publicDts ./dist/pipelines.d.ts --otherExportsPublicDtsFiles ./dist/index.d.ts", "api-report:lite": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node ../../repo-scripts/prune-dts/extract-public-api.ts --package firestore-lite --packageRoot . --typescriptDts ./dist/firestore/lite/index.d.ts --rollupDts ./dist/lite/private.d.ts --untrimmedRollupDts ./dist/lite/internal.d.ts --publicDts ./dist/lite/index.d.ts", + "api-report:lite:pipelines": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node ../../repo-scripts/prune-dts/extract-public-api.ts --package firestore-lite-pipelines --packageRoot . --typescriptDts ./dist/firestore/lite/pipelines/pipelines.d.ts --rollupDts ./dist/lite/private.pipelines.d.ts --untrimmedRollupDts ./dist/lite/internal.pipelines.d.ts --publicDts ./dist/lite/pipelines.d.ts --otherExportsPublicDtsFiles ./dist/index.d.ts", "api-report:api-json": "rm -rf temp && api-extractor run --local --verbose", - "api-report": "run-s --npm-path npm api-report:main api-report:lite && yarn api-report:api-json", + "api-report": "run-s --npm-path npm api-report:main api-report:pipelines api-report:all-packages api-report:lite api-report:lite:pipelines && yarn api-report:api-json", "doc": "api-documenter markdown --input temp --output docs", - "typings:public": "node ../../scripts/build/use_typings.js ./dist/index.d.ts" + "typings:public": "node ../../scripts/build/use_typings.js ./dist/all-packages.d.ts" }, "exports": { ".": { @@ -76,18 +79,44 @@ }, "react-native": "./dist/lite/index.rn.esm2017.js", "browser": { - "require": "./dist/lite/index.cjs.js", + "require": "./dist/lite/index.browser.cjs.js", "import": "./dist/lite/index.browser.esm2017.js" }, "default": "./dist/lite/index.browser.esm2017.js" }, + "./lite/pipelines": { + "types": "./dist/lite/pipelines.d.ts", + "node": { + "require": "./dist/lite/pipelines.node.cjs.js", + "import": "./dist/lite/pipelines.node.mjs" + }, + "react-native": "./dist/lite/pipelines.rn.esm2017.js", + "browser": { + "require": "./dist/lite/pipelines.browser.cjs.js", + "import": "./dist/lite/pipelines.browser.esm2017.js" + }, + "default": "./dist/lite/pipelines.browser.esm2017.js" + }, + "./pipelines": { + "types": "./pipelines/pipelines.d.ts", + "node": { + "require": "./dist/pipelines.node.cjs.js", + "import": "./dist/pipelines.node.mjs" + }, + "react-native": "./dist/index.rn.esm2017.js", + "browser": { + "require": "./dist/pipelines.cjs.js", + "import": "./dist/pipelines.esm2017.js" + }, + "default": "./dist/pipelines.esm2017.js" + }, "./package.json": "./package.json" }, - "main": "dist/index.node.cjs.js", - "main-esm": "dist/index.node.mjs", + "main": "dist/node-cjs/index.node.cjs.js", + "main-esm": "dist/node-esm/index.node.mjs", "react-native": "dist/index.rn.js", - "browser": "dist/index.esm2017.js", - "module": "dist/index.esm2017.js", + "browser": "dist/browser-esm2017/index.esm2017.js", + "module": "dist/browser-esm2017/index.esm2017.js", "license": "Apache-2.0", "files": [ "dist", @@ -135,7 +164,7 @@ "bugs": { "url": "https://github.com/firebase/firebase-js-sdk/issues" }, - "typings": "dist/firestore/src/index.d.ts", + "types": "dist/index.d.ts", "nyc": { "extension": [ ".ts" diff --git a/packages/firestore/pipelines/package.json b/packages/firestore/pipelines/package.json new file mode 100644 index 00000000000..aab036bfdb0 --- /dev/null +++ b/packages/firestore/pipelines/package.json @@ -0,0 +1,14 @@ +{ + "name": "@firebase/firestore/pipelines", + "description": "pipelines", + "main": "../dist/pipelines.node.cjs.js", + "main-esm": "../dist/pipelines.node.mjs", + "module": "../dist/pipelines.browser.esm2017.js", + "browser": "../dist/pipelines.browser.esm2017.js", + "react-native": "../dist/pipelines.rn.esm2017.js", + "typings": "./pipelines.d.ts", + "private": true, + "engines": { + "node": ">=18.0.0" + } +} diff --git a/packages/firestore/pipelines/pipelines.d.ts b/packages/firestore/pipelines/pipelines.d.ts new file mode 100644 index 00000000000..5e7944e5731 --- /dev/null +++ b/packages/firestore/pipelines/pipelines.d.ts @@ -0,0 +1,31 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {PipelineSource, Pipeline} from "../dist/pipelines"; + +// Augument the Firestore and Query classes with the pipeline() method. +// This is stripped from dist/lite/pipelines.d.ts during the build +// so it needs to be re-added here. +declare module '@firebase/firestore' { + interface Firestore { + pipeline(): PipelineSource; + } + interface Query { + pipeline(): Pipeline; + } +} + +export * from "../dist/pipelines"; diff --git a/packages/firestore/pipelines/pipelines.node.ts b/packages/firestore/pipelines/pipelines.node.ts new file mode 100644 index 00000000000..fc0e91de0fc --- /dev/null +++ b/packages/firestore/pipelines/pipelines.node.ts @@ -0,0 +1,18 @@ +/** + * @license + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from '../src/api_pipelines'; diff --git a/packages/firestore/pipelines/pipelines.rn.ts b/packages/firestore/pipelines/pipelines.rn.ts new file mode 100644 index 00000000000..d5d4597190d --- /dev/null +++ b/packages/firestore/pipelines/pipelines.rn.ts @@ -0,0 +1,18 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from '../src/api_pipelines'; diff --git a/packages/firestore/pipelines/pipelines.ts b/packages/firestore/pipelines/pipelines.ts new file mode 100644 index 00000000000..b056059adf4 --- /dev/null +++ b/packages/firestore/pipelines/pipelines.ts @@ -0,0 +1,51 @@ +/** + * Cloud Firestore + * + * @packageDocumentation + */ + +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// External exports: ./api +// These external exports will be stripped from the dist/pipelines.d.ts file +// by the prune-dts script, in order to reduce type duplication. However, these +// types need to be exported here to ensure that api-extractor behaves +// correctly. If a type from api.ts is missing from this export, then +// api-extractor may rename it with a suffix `_#`, e.g. `YourType_2`. +export type { + Timestamp, + DocumentReference, + VectorValue, + GeoPoint, + FieldPath, + DocumentData, + Query, + Firestore, + FirestoreDataConverter, + WithFieldValue, + PartialWithFieldValue, + SetOptions, + QueryDocumentSnapshot, + SnapshotOptions, + Primitive, + FieldValue, + SnapshotMetadata, + Bytes +} from '../src/api'; + +export * from '../src/api_pipelines'; diff --git a/packages/firestore/rollup.config.js b/packages/firestore/rollup.config.js index c9604fee55d..cac0a9c741b 100644 --- a/packages/firestore/rollup.config.js +++ b/packages/firestore/rollup.config.js @@ -61,9 +61,11 @@ const allBuilds = [ // this is an intermediate build used to generate the actual esm and cjs builds // which add build target reporting { - input: './src/index.node.ts', + input: ['./src/index.node.ts', './pipelines/pipelines.node.ts'], output: { - file: pkg['main-esm'], + dir: 'dist/intermediate', + entryFileNames: '[name].mjs', + chunkFileNames: 'common-[hash].node.mjs', format: 'es', sourcemap: true }, @@ -76,9 +78,14 @@ const allBuilds = [ }, // Node CJS build { - input: pkg['main-esm'], + input: [ + 'dist/intermediate/index.node.mjs', + 'dist/intermediate/pipelines.node.mjs' + ], output: { - file: pkg.main, + dir: 'dist/', + entryFileNames: '[name].cjs.js', + chunkFileNames: 'common-[hash].node.cjs.js', format: 'cjs', sourcemap: true }, @@ -103,9 +110,14 @@ const allBuilds = [ }, // Node ESM build with build target reporting { - input: pkg['main-esm'], + input: [ + 'dist/intermediate/index.node.mjs', + 'dist/intermediate/pipelines.node.mjs' + ], output: { - file: pkg['main-esm'], + dir: 'dist/', + entryFileNames: '[name].mjs', + chunkFileNames: 'common-[hash].node.mjs', format: 'es', sourcemap: true }, @@ -122,9 +134,11 @@ const allBuilds = [ // this is an intermediate build used to generate the actual esm and cjs builds // which add build target reporting { - input: './src/index.ts', + input: ['./src/index.ts', './pipelines/pipelines.ts'], output: { - file: pkg.browser, + dir: 'dist/intermediate', + entryFileNames: '[name].js', + chunkFileNames: 'common-[hash].js', format: 'es', sourcemap: true }, @@ -136,10 +150,12 @@ const allBuilds = [ }, // Convert es2017 build to cjs { - input: pkg['browser'], + input: ['dist/intermediate/index.js', 'dist/intermediate/pipelines.js'], output: [ { - file: './dist/index.cjs.js', + dir: 'dist/', + entryFileNames: '[name].cjs.js', + chunkFileNames: 'common-[hash].cjs.js', format: 'cjs', sourcemap: true } @@ -155,10 +171,12 @@ const allBuilds = [ }, // es2017 build with build target reporting { - input: pkg['browser'], + input: ['dist/intermediate/index.js', 'dist/intermediate/pipelines.js'], output: [ { - file: pkg['browser'], + dir: 'dist/', + entryFileNames: '[name].esm2017.js', + chunkFileNames: 'common-[hash].esm2017.js', format: 'es', sourcemap: true } @@ -174,9 +192,11 @@ const allBuilds = [ }, // RN build { - input: './src/index.rn.ts', + input: ['./src/index.rn.ts', './pipelines/pipelines.rn.ts'], output: { - file: pkg['react-native'], + dir: 'dist/', + entryFileNames: '[name].js', + chunkFileNames: 'common-[hash].rn.js', format: 'es', sourcemap: true }, diff --git a/packages/firestore/rollup.config.lite.js b/packages/firestore/rollup.config.lite.js index 25209966fe8..2c7707c3ba0 100644 --- a/packages/firestore/rollup.config.lite.js +++ b/packages/firestore/rollup.config.lite.js @@ -56,9 +56,11 @@ const allBuilds = [ // this is an intermediate build used to generate the actual esm and cjs builds // which add build target reporting { - input: './lite/index.ts', + input: ['./lite/index.ts', './lite/pipelines/pipelines.ts'], output: { - file: path.resolve('./lite', pkg['main-esm']), + dir: 'dist/intermediate/lite/', + entryFileNames: '[name].node.mjs', + chunkFileNames: 'common-[hash].node.mjs', format: 'es', sourcemap: true }, @@ -77,9 +79,14 @@ const allBuilds = [ }, // Node CJS build { - input: path.resolve('./lite', pkg['main-esm']), + input: [ + 'dist/intermediate/lite/index.node.mjs', + 'dist/intermediate/lite/pipelines.node.mjs' + ], output: { - file: path.resolve('./lite', pkg.main), + dir: 'dist/lite/', + entryFileNames: '[name].cjs.js', + chunkFileNames: 'common-[hash].node.cjs.js', format: 'cjs', sourcemap: true }, @@ -102,9 +109,14 @@ const allBuilds = [ }, // Node ESM build { - input: path.resolve('./lite', pkg['main-esm']), + input: [ + 'dist/intermediate/lite/index.node.mjs', + 'dist/intermediate/lite/pipelines.node.mjs' + ], output: { - file: path.resolve('./lite', pkg['main-esm']), + dir: 'dist/lite/', + entryFileNames: '[name].mjs', + chunkFileNames: 'common-[hash].node.mjs', format: 'es', sourcemap: true }, @@ -121,9 +133,11 @@ const allBuilds = [ // this is an intermediate build used to generate the actual esm and cjs builds // which add build target reporting { - input: './lite/index.ts', + input: ['./lite/index.ts', './lite/pipelines/pipelines.ts'], output: { - file: path.resolve('./lite', pkg.browser), + dir: 'dist/intermediate/lite/', + entryFileNames: '[name].browser.js', + chunkFileNames: 'common-[hash].browser.js', format: 'es', sourcemap: true }, @@ -142,10 +156,15 @@ const allBuilds = [ }, // Convert es2017 build to CJS { - input: path.resolve('./lite', pkg.browser), + input: [ + 'dist/intermediate/lite/index.browser.js', + 'dist/intermediate/lite/pipelines.browser.js' + ], output: [ { - file: './dist/lite/index.cjs.js', + dir: 'dist/lite/', + entryFileNames: '[name].cjs.js', + chunkFileNames: 'common-[hash].cjs.js', format: 'es', sourcemap: true } @@ -161,10 +180,15 @@ const allBuilds = [ }, // Browser es2017 build { - input: path.resolve('./lite', pkg.browser), + input: [ + 'dist/intermediate/lite/index.browser.js', + 'dist/intermediate/lite/pipelines.browser.js' + ], output: [ { - file: path.resolve('./lite', pkg.browser), + dir: 'dist/lite/', + entryFileNames: '[name].esm2017.js', + chunkFileNames: 'common-[hash].esm2017.js', format: 'es', sourcemap: true } @@ -180,9 +204,11 @@ const allBuilds = [ }, // RN build { - input: './lite/index.ts', + input: ['./lite/index.ts', './lite/pipelines/pipelines.ts'], output: { - file: path.resolve('./lite', pkg['react-native']), + dir: 'dist/lite/', + entryFileNames: '[name].rn.esm2017.js', + chunkFileNames: 'common-[hash].rn.esm2017.js', format: 'es', sourcemap: true }, diff --git a/packages/firestore/src/all_packages.ts b/packages/firestore/src/all_packages.ts new file mode 100644 index 00000000000..82babeea706 --- /dev/null +++ b/packages/firestore/src/all_packages.ts @@ -0,0 +1,25 @@ +/** + * Cloud Firestore + * + * @packageDocumentation + */ + +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from './api'; +export * from './api_pipelines'; diff --git a/packages/firestore/src/api.ts b/packages/firestore/src/api.ts index 7619312d2d5..14390d57b49 100644 --- a/packages/firestore/src/api.ts +++ b/packages/firestore/src/api.ts @@ -15,175 +15,6 @@ * limitations under the License. */ -export { PipelineSource } from './lite-api/pipeline-source'; - -export { PipelineResult } from './lite-api/pipeline-result'; - -export { Pipeline } from './api/pipeline'; - -export { useFluentPipelines, pipeline, execute } from './api/pipeline_impl'; - -export { - Stage, - FindNearestOptions, - AddFields, - Aggregate, - Distinct, - CollectionSource, - CollectionGroupSource, - DatabaseSource, - DocumentsSource, - Where, - FindNearest, - Limit, - Offset, - Select, - Sort, - GenericStage -} from './lite-api/stage'; - -export { - add, - subtract, - multiply, - divide, - mod, - eq, - neq, - lt, - lte, - gt, - gte, - arrayConcat, - arrayContains, - arrayContainsAny, - arrayContainsAll, - arrayLength, - eqAny, - notEqAny, - xor, - cond, - not, - logicalMaximum, - logicalMinimum, - exists, - isNan, - reverse, - replaceFirst, - replaceAll, - byteLength, - charLength, - like, - regexContains, - regexMatch, - strContains, - startsWith, - endsWith, - toLower, - toUpper, - trim, - strConcat, - mapGet, - countAll, - countFunction, - sumFunction, - avgFunction, - andFunction, - orFunction, - minimum, - maximum, - cosineDistance, - dotProduct, - euclideanDistance, - vectorLength, - unixMicrosToTimestamp, - timestampToUnixMicros, - unixMillisToTimestamp, - timestampToUnixMillis, - unixSecondsToTimestamp, - timestampToUnixSeconds, - timestampAdd, - timestampSub, - genericFunction, - ascending, - descending, - ExprWithAlias, - Field, - Fields, - Constant, - FirestoreFunction, - Add, - Subtract, - Multiply, - Divide, - Mod, - Eq, - Neq, - Lt, - Lte, - Gt, - Gte, - ArrayConcat, - ArrayReverse, - ArrayContains, - ArrayContainsAll, - ArrayContainsAny, - ArrayLength, - ArrayElement, - EqAny, - NotEqAny, - IsNan, - Exists, - Not, - And, - Or, - Xor, - Cond, - LogicalMaximum, - LogicalMinimum, - Reverse, - ReplaceFirst, - ReplaceAll, - CharLength, - ByteLength, - Like, - RegexContains, - RegexMatch, - StrContains, - StartsWith, - EndsWith, - ToLower, - ToUpper, - Trim, - StrConcat, - MapGet, - Count, - Sum, - Avg, - Minimum, - Maximum, - CosineDistance, - DotProduct, - EuclideanDistance, - VectorLength, - UnixMicrosToTimestamp, - TimestampToUnixMicros, - UnixMillisToTimestamp, - TimestampToUnixMillis, - UnixSecondsToTimestamp, - TimestampToUnixSeconds, - TimestampAdd, - TimestampSub, - Ordering, - ExprType, - AccumulatorTarget, - FilterExpr, - SelectableExpr, - Selectable, - FilterCondition, - Accumulator -} from './lite-api/expressions'; - export { aggregateFieldEqual, aggregateQuerySnapshotEqual, diff --git a/packages/firestore/src/api/pipeline-source.ts b/packages/firestore/src/api/pipeline-source.ts deleted file mode 100644 index 3ad66cab9e9..00000000000 --- a/packages/firestore/src/api/pipeline-source.ts +++ /dev/null @@ -1,100 +0,0 @@ -/** - * @license - * Copyright 2024 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { PipelineSource as LitePipelineSoure } from '../lite-api/pipeline-source'; -import { - CollectionGroupSource, - CollectionSource, - DatabaseSource, - DocumentsSource -} from '../lite-api/stage'; -import { UserDataReader } from '../lite-api/user_data_reader'; -import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; -import { DocumentKey } from '../model/document_key'; -import { cast } from '../util/input_validation'; - -import { Firestore } from './database'; -import { Pipeline } from './pipeline'; -import { DocumentReference } from './reference'; - -/** - * Represents the source of a Firestore {@link Pipeline}. - * @beta - */ -export class PipelineSource extends LitePipelineSoure { - /** - * @internal - * @private - * @param _db - * @param _userDataReader - * @param _userDataWriter - * @param _documentReferenceFactory - */ - // eslint-disable-next-line @typescript-eslint/no-useless-constructor - constructor( - _db: Firestore, - _userDataReader: UserDataReader, - _userDataWriter: AbstractUserDataWriter, - _documentReferenceFactory: (id: DocumentKey) => DocumentReference - ) { - super(_db, _userDataReader, _userDataWriter, _documentReferenceFactory); - } - - collection(collectionPath: string): Pipeline { - const _db = cast(this._db, Firestore); - return new Pipeline( - _db, - this._userDataReader, - this._userDataWriter, - this._documentReferenceFactory, - [new CollectionSource(collectionPath)] - ); - } - - collectionGroup(collectionId: string): Pipeline { - const _db = cast(this._db, Firestore); - return new Pipeline( - _db, - this._userDataReader, - this._userDataWriter, - this._documentReferenceFactory, - [new CollectionGroupSource(collectionId)] - ); - } - - database(): Pipeline { - const _db = cast(this._db, Firestore); - return new Pipeline( - _db, - this._userDataReader, - this._userDataWriter, - this._documentReferenceFactory, - [new DatabaseSource()] - ); - } - - documents(docs: DocumentReference[]): Pipeline { - const _db = cast(this._db, Firestore); - return new Pipeline( - _db, - this._userDataReader, - this._userDataWriter, - this._documentReferenceFactory, - [DocumentsSource.of(docs)] - ); - } -} diff --git a/packages/firestore/src/api/pipeline.ts b/packages/firestore/src/api/pipeline.ts index de2cb16d9aa..aaddf00274b 100644 --- a/packages/firestore/src/api/pipeline.ts +++ b/packages/firestore/src/api/pipeline.ts @@ -15,56 +15,24 @@ * limitations under the License. */ +import { firestoreClientExecutePipeline } from '../core/firestore_client'; import { Pipeline as LitePipeline } from '../lite-api/pipeline'; import { PipelineResult } from '../lite-api/pipeline-result'; -import { DocumentData, DocumentReference } from '../lite-api/reference'; +import { DocumentReference } from '../lite-api/reference'; import { Stage } from '../lite-api/stage'; import { UserDataReader } from '../lite-api/user_data_reader'; import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; -import { DocumentKey } from '../model/document_key'; +import { cast } from '../util/input_validation'; -import { Firestore } from './database'; +import { ensureFirestoreConfigured, Firestore } from './database'; -export class Pipeline< - AppModelType = DocumentData -> extends LitePipeline { +export class Pipeline extends LitePipeline { /** * @internal * @private * @param db * @param userDataReader * @param userDataWriter - * @param documentReferenceFactory - * @param stages - * @param converter - */ - constructor( - db: Firestore, - userDataReader: UserDataReader, - userDataWriter: AbstractUserDataWriter, - documentReferenceFactory: (id: DocumentKey) => DocumentReference, - stages: Stage[], - // TODO(pipeline) support converter - //private converter: FirestorePipelineConverter = defaultPipelineConverter() - converter: unknown = {} - ) { - super( - db, - userDataReader, - userDataWriter, - documentReferenceFactory, - stages, - converter - ); - } - - /** - * @internal - * @private - * @param db - * @param userDataReader - * @param userDataWriter - * @param documentReferenceFactory * @param stages * @param converter * @protected @@ -73,18 +41,10 @@ export class Pipeline< db: Firestore, userDataReader: UserDataReader, userDataWriter: AbstractUserDataWriter, - documentReferenceFactory: (id: DocumentKey) => DocumentReference, stages: Stage[], converter: unknown = {} - ): Pipeline { - return new Pipeline( - db, - userDataReader, - userDataWriter, - documentReferenceFactory, - stages, - converter - ); + ): Pipeline { + return new Pipeline(db, userDataReader, userDataWriter, stages); } /** @@ -118,9 +78,29 @@ export class Pipeline< * * @return A Promise representing the asynchronous pipeline execution. */ - execute(): Promise>> { - throw new Error( - 'Pipelines not initialized. Your application must call `useFluentPipelines()` before using Firestore Pipeline features.' - ); + execute(): Promise { + const firestore = cast(this._db, Firestore); + const client = ensureFirestoreConfigured(firestore); + return firestoreClientExecutePipeline(client, this).then(result => { + const docs = result + // Currently ignore any response from ExecutePipeline that does + // not contain any document data in the `fields` property. + .filter(element => !!element.fields) + .map( + element => + new PipelineResult( + this._userDataWriter, + element.key?.path + ? new DocumentReference(firestore, null, element.key) + : undefined, + element.fields, + element.executionTime?.toTimestamp(), + element.createTime?.toTimestamp(), + element.updateTime?.toTimestamp() + ) + ); + + return docs; + }); } } diff --git a/packages/firestore/src/api/pipeline_impl.ts b/packages/firestore/src/api/pipeline_impl.ts index 5d58266b343..9e7c25e69ab 100644 --- a/packages/firestore/src/api/pipeline_impl.ts +++ b/packages/firestore/src/api/pipeline_impl.ts @@ -16,21 +16,21 @@ */ import { Pipeline } from '../api/pipeline'; -import { PipelineSource } from '../api/pipeline-source'; -import { firestoreClientExecutePipeline } from '../core/firestore_client'; +import { toPipeline } from '../core/pipeline-util'; import { Pipeline as LitePipeline } from '../lite-api/pipeline'; import { PipelineResult } from '../lite-api/pipeline-result'; +import { PipelineSource } from '../lite-api/pipeline-source'; +import { Stage } from '../lite-api/stage'; import { newUserDataReader } from '../lite-api/user_data_reader'; -import { DocumentKey } from '../model/document_key'; import { cast } from '../util/input_validation'; -import { Firestore, ensureFirestoreConfigured } from './database'; -import { DocumentReference, Query } from './reference'; +import { Firestore } from './database'; +import { Query } from './reference'; import { ExpUserDataWriter } from './user_data_writer'; declare module './database' { interface Firestore { - pipeline(): PipelineSource; + pipeline(): PipelineSource; } } @@ -38,7 +38,7 @@ declare module './database' { * Experimental Modular API for console testing. * @param firestore */ -export function pipeline(firestore: Firestore): PipelineSource; +export function pipeline(firestore: Firestore): PipelineSource; /** * Experimental Modular API for console testing. @@ -48,72 +48,36 @@ export function pipeline(query: Query): Pipeline; export function pipeline( firestoreOrQuery: Firestore | Query -): PipelineSource | Pipeline { +): PipelineSource | Pipeline { if (firestoreOrQuery instanceof Firestore) { const firestore = firestoreOrQuery; - return new PipelineSource( - firestore, - newUserDataReader(firestore), - new ExpUserDataWriter(firestore), - (key: DocumentKey) => { - return new DocumentReference(firestore, null, key); - } - ); + return new PipelineSource((stages: Stage[]) => { + return new Pipeline( + firestore, + newUserDataReader(firestore), + new ExpUserDataWriter(firestore), + stages + ); + }); } else { - let result; const query = firestoreOrQuery; const db = cast(query.firestore, Firestore); - if (query._query.collectionGroup) { - result = pipeline(db).collectionGroup(query._query.collectionGroup); - } else { - result = pipeline(db).collection(query._query.path.canonicalString()); - } - - // TODO(pipeline) convert existing query filters, limits, etc into - // pipeline stages - return result; + const litePipeline: LitePipeline = toPipeline(query._query, db); + return cast(litePipeline, Pipeline); } } -export function useFluentPipelines(): void { - Firestore.prototype.pipeline = function (): PipelineSource { - return pipeline(this); - }; - - Query.prototype.pipeline = function (): Pipeline { - return pipeline(this); - }; - Pipeline.prototype.execute = function (): Promise { - return execute(this); - }; +export function execute(pipeline: LitePipeline): Promise { + return pipeline.execute(); } -export function execute( - pipeline: LitePipeline -): Promise>> { - const firestore = cast(pipeline._db, Firestore); - const client = ensureFirestoreConfigured(firestore); - return firestoreClientExecutePipeline(client, pipeline).then(result => { - const docs = result - // Currently ignore any response from ExecutePipeline that does - // not contain any document data in the `fields` property. - .filter(element => !!element.fields) - .map( - element => - new PipelineResult( - pipeline._userDataWriter, - element.key?.path - ? pipeline._documentReferenceFactory(element.key) - : undefined, - element.fields, - element.executionTime?.toTimestamp(), - element.createTime?.toTimestamp(), - element.updateTime?.toTimestamp() - //this.converter - ) - ); +// Augment the Firestore class with the pipeline() factory method +Firestore.prototype.pipeline = function (): PipelineSource { + return pipeline(this); +}; - return docs; - }); -} +// Augment the Query class with the pipeline() factory method +Query.prototype.pipeline = function (): Pipeline { + return pipeline(this); +}; diff --git a/packages/firestore/src/api_pipelines.ts b/packages/firestore/src/api_pipelines.ts index bcd54dca314..90fe836932f 100644 --- a/packages/firestore/src/api_pipelines.ts +++ b/packages/firestore/src/api_pipelines.ts @@ -14,13 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + export { PipelineSource } from './lite-api/pipeline-source'; export { PipelineResult } from './lite-api/pipeline-result'; -export { Pipeline } from './lite-api/pipeline'; +export { Pipeline } from './api/pipeline'; -export { useFluentPipelines, execute, pipeline } from './api/pipeline_impl'; +export { pipeline, execute } from './api/pipeline_impl'; export { Stage, @@ -106,6 +107,7 @@ export { genericFunction, ascending, descending, + Expr, ExprWithAlias, Field, Fields, @@ -173,11 +175,12 @@ export { TimestampToUnixSeconds, TimestampAdd, TimestampSub, - Ordering, + Ordering +} from './lite-api/expressions'; + +export type { ExprType, AccumulatorTarget, - FilterExpr, - SelectableExpr, Selectable, FilterCondition, Accumulator diff --git a/packages/firestore/src/core/firestore_client.ts b/packages/firestore/src/core/firestore_client.ts index ad485c7f77a..bb0771d2335 100644 --- a/packages/firestore/src/core/firestore_client.ts +++ b/packages/firestore/src/core/firestore_client.ts @@ -557,7 +557,7 @@ export function firestoreClientRunAggregateQuery( export function firestoreClientExecutePipeline( client: FirestoreClient, - pipeline: Pipeline + pipeline: Pipeline ): Promise { const deferred = new Deferred(); diff --git a/packages/firestore/src/core/pipeline-util.ts b/packages/firestore/src/core/pipeline-util.ts index 38c291a4710..0800eba85ea 100644 --- a/packages/firestore/src/core/pipeline-util.ts +++ b/packages/firestore/src/core/pipeline-util.ts @@ -15,28 +15,29 @@ * limitations under the License. */ +import { Firestore } from '../api/database'; import { Constant, - Expr, Field, FilterCondition, not, andFunction, - orFunction + orFunction, + Ordering, + And, + lt, + gt, + lte, + gte, + eq, + Or } from '../lite-api/expressions'; +import { Pipeline } from '../lite-api/pipeline'; +import { doc } from '../lite-api/reference'; import { isNanValue, isNullValue } from '../model/values'; -import { - ArrayValue as ProtoArrayValue, - Function as ProtoFunction, - LatLng as ProtoLatLng, - MapValue as ProtoMapValue, - Pipeline as ProtoPipeline, - Timestamp as ProtoTimestamp, - Value as ProtoValue -} from '../protos/firestore_proto_api'; import { fail } from '../util/assert'; -import { isPlainObject } from '../util/input_validation'; +import { Bound } from './bound'; import { CompositeFilter as CompositeFilterInternal, CompositeOperator, @@ -44,137 +45,18 @@ import { Filter as FilterInternal, Operator } from './filter'; +import { Direction } from './order_by'; +import { + isCollectionGroupQuery, + isDocumentQuery, + LimitType, + Query, + queryNormalizedOrderBy +} from './query'; /* eslint @typescript-eslint/no-explicit-any: 0 */ -function isITimestamp(obj: any): obj is ProtoTimestamp { - if (typeof obj !== 'object' || obj === null) { - return false; // Must be a non-null object - } - if ( - 'seconds' in obj && - (obj.seconds === null || - typeof obj.seconds === 'number' || - typeof obj.seconds === 'string') && - 'nanos' in obj && - (obj.nanos === null || typeof obj.nanos === 'number') - ) { - return true; - } - - return false; -} -function isILatLng(obj: any): obj is ProtoLatLng { - if (typeof obj !== 'object' || obj === null) { - return false; // Must be a non-null object - } - if ( - 'latitude' in obj && - (obj.latitude === null || typeof obj.latitude === 'number') && - 'longitude' in obj && - (obj.longitude === null || typeof obj.longitude === 'number') - ) { - return true; - } - - return false; -} -function isIArrayValue(obj: any): obj is ProtoArrayValue { - if (typeof obj !== 'object' || obj === null) { - return false; // Must be a non-null object - } - if ('values' in obj && (obj.values === null || Array.isArray(obj.values))) { - return true; - } - - return false; -} -function isIMapValue(obj: any): obj is ProtoMapValue { - if (typeof obj !== 'object' || obj === null) { - return false; // Must be a non-null object - } - if ('fields' in obj && (obj.fields === null || isPlainObject(obj.fields))) { - return true; - } - - return false; -} -function isIFunction(obj: any): obj is ProtoFunction { - if (typeof obj !== 'object' || obj === null) { - return false; // Must be a non-null object - } - if ( - 'name' in obj && - (obj.name === null || typeof obj.name === 'string') && - 'args' in obj && - (obj.args === null || Array.isArray(obj.args)) - ) { - return true; - } - - return false; -} - -function isIPipeline(obj: any): obj is ProtoPipeline { - if (typeof obj !== 'object' || obj === null) { - return false; // Must be a non-null object - } - if ('stages' in obj && (obj.stages === null || Array.isArray(obj.stages))) { - return true; - } - - return false; -} - -export function isFirestoreValue(obj: any): obj is ProtoValue { - if (typeof obj !== 'object' || obj === null) { - return false; // Must be a non-null object - } - - // Check optional properties and their types - if ( - ('nullValue' in obj && - (obj.nullValue === null || obj.nullValue === 'NULL_VALUE')) || - ('booleanValue' in obj && - (obj.booleanValue === null || typeof obj.booleanValue === 'boolean')) || - ('integerValue' in obj && - (obj.integerValue === null || - typeof obj.integerValue === 'number' || - typeof obj.integerValue === 'string')) || - ('doubleValue' in obj && - (obj.doubleValue === null || typeof obj.doubleValue === 'number')) || - ('timestampValue' in obj && - (obj.timestampValue === null || isITimestamp(obj.timestampValue))) || - ('stringValue' in obj && - (obj.stringValue === null || typeof obj.stringValue === 'string')) || - ('bytesValue' in obj && - (obj.bytesValue === null || obj.bytesValue instanceof Uint8Array)) || - ('referenceValue' in obj && - (obj.referenceValue === null || - typeof obj.referenceValue === 'string')) || - ('geoPointValue' in obj && - (obj.geoPointValue === null || isILatLng(obj.geoPointValue))) || - ('arrayValue' in obj && - (obj.arrayValue === null || isIArrayValue(obj.arrayValue))) || - ('mapValue' in obj && - (obj.mapValue === null || isIMapValue(obj.mapValue))) || - ('fieldReferenceValue' in obj && - (obj.fieldReferenceValue === null || - typeof obj.fieldReferenceValue === 'string')) || - ('functionValue' in obj && - (obj.functionValue === null || isIFunction(obj.functionValue))) || - ('pipelineValue' in obj && - (obj.pipelineValue === null || isIPipeline(obj.pipelineValue))) - ) { - return true; - } - - return false; -} - -export function toPipelineFilterCondition( - f: FilterInternal -): FilterCondition & Expr { +export function toPipelineFilterCondition(f: FilterInternal): FilterCondition { if (f instanceof FieldFilterInternal) { const field = Field.of(f.field.toString()); if (isNanValue(f.value)) { @@ -250,3 +132,122 @@ export function toPipelineFilterCondition( throw new Error(`Failed to convert filter to pipeline conditions: ${f}`); } + +function reverseOrderings(orderings: Ordering[]): Ordering[] { + return orderings.map( + o => + new Ordering( + o.expr, + o.direction === 'ascending' ? 'descending' : 'ascending' + ) + ); +} + +export function toPipeline(query: Query, db: Firestore): Pipeline { + let pipeline: Pipeline; + if (isCollectionGroupQuery(query)) { + pipeline = db.pipeline().collectionGroup(query.collectionGroup!); + } else if (isDocumentQuery(query)) { + pipeline = db.pipeline().documents([doc(db, query.path.canonicalString())]); + } else { + pipeline = db.pipeline().collection(query.path.canonicalString()); + } + + // filters + for (const filter of query.filters) { + pipeline = pipeline.where(toPipelineFilterCondition(filter)); + } + + // orders + const orders = queryNormalizedOrderBy(query); + const existsConditions = orders.map(order => + Field.of(order.field.canonicalString()).exists() + ); + if (existsConditions.length > 1) { + pipeline = pipeline.where( + andFunction(existsConditions[0], ...existsConditions.slice(1)) + ); + } else { + pipeline = pipeline.where(existsConditions[0]); + } + + const orderings = orders.map(order => + order.dir === Direction.ASCENDING + ? Field.of(order.field.canonicalString()).ascending() + : Field.of(order.field.canonicalString()).descending() + ); + + if (query.limitType === LimitType.Last) { + pipeline = pipeline.sort(...reverseOrderings(orderings)); + // cursors + if (query.startAt !== null) { + pipeline = pipeline.where( + whereConditionsFromCursor(query.startAt, orderings, 'before') + ); + } + + if (query.endAt !== null) { + pipeline = pipeline.where( + whereConditionsFromCursor(query.endAt, orderings, 'after') + ); + } + + pipeline = pipeline._limit(query.limit!, true); + pipeline = pipeline.sort(...orderings); + } else { + pipeline = pipeline.sort(...orderings); + if (query.startAt !== null) { + pipeline = pipeline.where( + whereConditionsFromCursor(query.startAt, orderings, 'after') + ); + } + if (query.endAt !== null) { + pipeline = pipeline.where( + whereConditionsFromCursor(query.endAt, orderings, 'before') + ); + } + + if (query.limit !== null) { + pipeline = pipeline.limit(query.limit); + } + } + + return pipeline; +} + +function whereConditionsFromCursor( + bound: Bound, + orderings: Ordering[], + position: 'before' | 'after' +): FilterCondition { + const cursors = bound.position.map(value => Constant._fromProto(value)); + const filterFunc = position === 'before' ? lt : gt; + const filterInclusiveFunc = position === 'before' ? lte : gte; + + const orConditions = []; + for (let i = 1; i <= orderings.length; i++) { + const cursorSubset = cursors.slice(0, i); + + const conditions = cursorSubset.map((cursor, index) => { + if (index < cursorSubset.length - 1) { + return eq(orderings[index].expr as Field, cursor); + } else if (!!bound.inclusive && i === orderings.length) { + return filterInclusiveFunc(orderings[index].expr as Field, cursor); + } else { + return filterFunc(orderings[index].expr as Field, cursor); + } + }); + + if (conditions.length === 1) { + orConditions.push(conditions[0]); + } else { + orConditions.push(new And(conditions)); + } + } + + if (orConditions.length === 1) { + return orConditions[0]; + } else { + return new Or(orConditions); + } +} diff --git a/packages/firestore/src/lite-api/database.ts b/packages/firestore/src/lite-api/database.ts index 33b6afa8092..9ea4d4ec52e 100644 --- a/packages/firestore/src/lite-api/database.ts +++ b/packages/firestore/src/lite-api/database.ts @@ -41,8 +41,6 @@ import { cast } from '../util/input_validation'; import { logWarn } from '../util/log'; import { FirestoreService, removeComponents } from './components'; -// `import type` to avoid bundling the source for -// pipelines if `useFluentPipelines()` is not called import { DEFAULT_HOST, FirestoreSettingsImpl, diff --git a/packages/firestore/src/lite-api/expressions.ts b/packages/firestore/src/lite-api/expressions.ts index 261f8112c4d..03e5c5e747e 100644 --- a/packages/firestore/src/lite-api/expressions.ts +++ b/packages/firestore/src/lite-api/expressions.ts @@ -29,6 +29,7 @@ import { UserData } from '../remote/serializer'; import { hardAssert } from '../util/assert'; +import { isFirestoreValue } from '../util/proto'; import { Bytes } from './bytes'; import { documentId, FieldPath } from './field_path'; @@ -44,59 +45,6 @@ import { } from './user_data_reader'; import { VectorValue } from './vector_value'; -/** - * @beta - * - * An interface that represents a selectable expression. - */ -export interface Selectable { - selectable: true; -} - -/** - * @beta - * - * An interface that represents a filter condition. - */ -export interface FilterCondition { - filterable: true; -} - -/** - * @beta - * - * An interface that represents an accumulator. - */ -export interface Accumulator { - accumulator: true; - /** - * @private - * @internal - */ - _toProto(serializer: JsonProtoSerializer): ProtoValue; -} - -/** - * @beta - * - * An accumulator target, which is an expression with an alias that also implements the Accumulator interface. - */ -export type AccumulatorTarget = ExprWithAlias; - -/** - * @beta - * - * A filter expression, which is an expression that also implements the FilterCondition interface. - */ -export type FilterExpr = Expr & FilterCondition; - -/** - * @beta - * - * A selectable expression, which is an expression that also implements the Selectable interface. - */ -export type SelectableExpr = Expr & Selectable; - /** * @beta * @@ -127,6 +75,8 @@ export type ExprType = * method calls to create complex expressions. */ export abstract class Expr implements ProtoSerializable, UserData { + abstract exprType: ExprType; + /** * Creates an expression that adds this expression to another expression. * @@ -667,21 +617,21 @@ export abstract class Expr implements ProtoSerializable, UserData { * @param arrays The array expressions to concatenate. * @return A new `Expr` representing the concatenated array. */ - arrayConcat(arrays: Expr[]): ArrayConcat; + arrayConcat(...arrays: Expr[]): ArrayConcat; /** - * Creates an expression that concatenates an array expression with one or more other arrays. + * Creates an expression that concatenates an array with one or more other arrays. * * ```typescript * // Combine the 'tags' array with a new array and an array field * Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); * ``` * - * @param arrays The array expressions or values to concatenate. - * @return A new `Expr` representing the concatenated array. + * @param arrays The arrays to concatenate. + * @return A new `Expr` representing the concatenated arrays. */ - arrayConcat(arrays: any[]): ArrayConcat; - arrayConcat(arrays: any[]): ArrayConcat { + arrayConcat(...arrays: any[][]): ArrayConcat; + arrayConcat(...arrays: any[]): ArrayConcat { const exprValues = arrays.map(value => value instanceof Expr ? value : Constant.of(value) ); @@ -1835,12 +1785,52 @@ export abstract class Expr implements ProtoSerializable, UserData { /** * @beta + * + * An interface that represents a selectable expression. + */ +export abstract class Selectable extends Expr { + selectable: true = true; +} + +/** + * @beta + * + * An interface that represents a filter condition. + */ +export abstract class FilterCondition extends Expr { + filterable: true = true; +} + +/** + * @beta + * + * An interface that represents an accumulator. + */ +export abstract class Accumulator extends Expr { + accumulator: true = true; + + /** + * @private + * @internal + */ + abstract _toProto(serializer: JsonProtoSerializer): ProtoValue; +} + +/** + * @beta + * + * An accumulator target, which is an expression with an alias that also implements the Accumulator interface. */ -export class ExprWithAlias extends Expr implements Selectable { +export type AccumulatorTarget = ExprWithAlias; + +/** + * @beta + */ +export class ExprWithAlias extends Selectable { exprType: ExprType = 'ExprWithAlias'; selectable = true as const; - constructor(public expr: T, public alias: string) { + constructor(readonly expr: T, readonly alias: string) { super(); } @@ -1909,7 +1899,7 @@ class ListOfExprs extends Expr { * const cityField = Field.of("address.city"); * ``` */ -export class Field extends Expr implements Selectable { +export class Field extends Selectable { exprType: ExprType = 'Field'; selectable = true as const; @@ -1939,7 +1929,6 @@ export class Field extends Expr implements Selectable { */ static of(name: string): Field; static of(path: FieldPath): Field; - static of(pipeline: Pipeline, name: string): Field; static of( pipelineOrName: Pipeline | string | FieldPath, name?: string @@ -1986,7 +1975,7 @@ export class Field extends Expr implements Selectable { /** * @beta */ -export class Fields extends Expr implements Selectable { +export class Fields extends Selectable { exprType: ExprType = 'Field'; selectable = true as const; @@ -2190,6 +2179,16 @@ export class Constant extends Expr { } } + /** + * @private + * @internal + */ + static _fromProto(value: ProtoValue): Constant { + const result = new Constant(value); + result._protoValue = value; + return result; + } + /** * @private * @internal @@ -2211,8 +2210,13 @@ export class Constant extends Expr { UserDataSource.Argument, 'Constant.of' ); - if (this.value === undefined) { - // TODO how should we treat the value of `undefined`? + + if (isFirestoreValue(this.value)) { + // Special case where value is a proto value. + // This can occur when converting a Query to Pipeline. + this._protoValue = this.value; + } else if (this.value === undefined) { + // TODO(pipeline) how should we treat the value of `undefined`? this._protoValue = parseData(null, context)!; } else { this._protoValue = parseData(this.value, context)!; @@ -2560,7 +2564,7 @@ export class Not extends FirestoreFunction implements FilterCondition { * @beta */ export class And extends FirestoreFunction implements FilterCondition { - constructor(private conditions: FilterExpr[]) { + constructor(private conditions: FilterCondition[]) { super('and', conditions); } @@ -2571,7 +2575,7 @@ export class And extends FirestoreFunction implements FilterCondition { * @beta */ export class Or extends FirestoreFunction implements FilterCondition { - constructor(private conditions: FilterExpr[]) { + constructor(private conditions: FilterCondition[]) { super('or', conditions); } filterable = true as const; @@ -2581,7 +2585,7 @@ export class Or extends FirestoreFunction implements FilterCondition { * @beta */ export class Xor extends FirestoreFunction implements FilterCondition { - constructor(private conditions: FilterExpr[]) { + constructor(private conditions: FilterCondition[]) { super('xor', conditions); } filterable = true as const; @@ -2590,9 +2594,9 @@ export class Xor extends FirestoreFunction implements FilterCondition { /** * @beta */ -export class Cond extends FirestoreFunction implements FilterCondition { +export class Cond extends FirestoreFunction { constructor( - private condition: FilterExpr, + private condition: FilterCondition, private thenExpr: Expr, private elseExpr: Expr ) { @@ -4324,8 +4328,8 @@ export function arrayContainsAny( * Creates an expression that checks if an array expression contains all the specified elements. * * ```typescript - * // Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" - * arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); + * // Check if the "tags" array contains all of the values: "SciFi", "Adventure", and the value from field "tag1" + * arrayContainsAll(Field.of("tags"), [Field.of("tag1"), Constant.of("SciFi"), Constant.of("Adventure")]); * ``` * * @param array The array expression to check. @@ -4340,7 +4344,7 @@ export function arrayContainsAll(array: Expr, values: Expr[]): ArrayContainsAll; * Creates an expression that checks if an array expression contains all the specified elements. * * ```typescript - * // Check if the 'tags' array contains both of the values from field 'tag1', 'tag2' and "tag3" + * // Check if the "tags" array contains all of the values: "SciFi", "Adventure", and the value from field "tag1" * arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); * ``` * @@ -4586,7 +4590,7 @@ export function notEqAny(element: Expr | string, others: any[]): NotEqAny { * @param right Additional filter conditions to 'XOR' together. * @return A new {@code Expr} representing the logical 'XOR' operation. */ -export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor { +export function xor(left: FilterCondition, ...right: FilterCondition[]): Xor { return new Xor([left, ...right]); } @@ -4608,7 +4612,7 @@ export function xor(left: FilterExpr, ...right: FilterExpr[]): Xor { * @return A new {@code Expr} representing the conditional expression. */ export function cond( - condition: FilterExpr, + condition: FilterCondition, thenExpr: Expr, elseExpr: Expr ): Cond { @@ -4628,7 +4632,7 @@ export function cond( * @param filter The filter condition to negate. * @return A new {@code Expr} representing the negated filter condition. */ -export function not(filter: FilterExpr): Not { +export function not(filter: FilterCondition): Not { return new Not(filter); } @@ -6694,7 +6698,10 @@ export function genericFunction( * @param right Additional filter conditions to 'AND' together. * @return A new {@code Expr} representing the logical 'AND' operation. */ -export function andFunction(left: FilterExpr, ...right: FilterExpr[]): And { +export function andFunction( + left: FilterCondition, + ...right: FilterCondition[] +): And { return new And([left, ...right]); } @@ -6713,7 +6720,10 @@ export function andFunction(left: FilterExpr, ...right: FilterExpr[]): And { * @param right Additional filter conditions to 'OR' together. * @return A new {@code Expr} representing the logical 'OR' operation. */ -export function orFunction(left: FilterExpr, ...right: FilterExpr[]): Or { +export function orFunction( + left: FilterCondition, + ...right: FilterCondition[] +): Or { return new Or([left, ...right]); } @@ -6762,8 +6772,8 @@ export function descending(expr: Expr): Ordering { */ export class Ordering { constructor( - private expr: Expr, - private direction: 'ascending' | 'descending' + readonly expr: Expr, + readonly direction: 'ascending' | 'descending' ) {} /** diff --git a/packages/firestore/src/lite-api/pipeline-result.ts b/packages/firestore/src/lite-api/pipeline-result.ts index f3951099ba2..dc0a6412481 100644 --- a/packages/firestore/src/lite-api/pipeline-result.ts +++ b/packages/firestore/src/lite-api/pipeline-result.ts @@ -72,8 +72,6 @@ export class PipelineResult { executionTime?: Timestamp, createTime?: Timestamp, updateTime?: Timestamp - // TODO converter - //readonly converter: FirestorePipelineConverter = defaultPipelineConverter() ) { this._ref = ref; this._userDataWriter = userDataWriter; @@ -160,26 +158,9 @@ export class PipelineResult { return undefined; } - // TODO(pipelines) - // We only want to use the converter and create a new QueryDocumentSnapshot - // if a converter has been provided. - // if (!!this.converter && this.converter !== defaultPipelineConverter()) { - // return this.converter.fromFirestore( - // new PipelineResult< DocumentData>( - // this._serializer, - // this.ref, - // this._fieldsProto, - // this._executionTime, - // this.createTime, - // this.updateTime, - // defaultPipelineConverter() - // ) - // ); - // } else {{ return this._userDataWriter.convertValue( this._fields.value ) as AppModelType; - //} } /** @@ -217,9 +198,9 @@ export class PipelineResult { } } -export function pipelineResultEqual( - left: PipelineResult, - right: PipelineResult +export function pipelineResultEqual( + left: PipelineResult, + right: PipelineResult ): boolean { if (left === right) { return true; diff --git a/packages/firestore/src/lite-api/pipeline-source.ts b/packages/firestore/src/lite-api/pipeline-source.ts index 99da8fee8c6..856096037f8 100644 --- a/packages/firestore/src/lite-api/pipeline-source.ts +++ b/packages/firestore/src/lite-api/pipeline-source.ts @@ -15,93 +15,46 @@ * limitations under the License. */ -import { DocumentKey } from '../model/document_key'; - -import { Firestore } from './database'; -import { Pipeline } from './pipeline'; import { DocumentReference } from './reference'; import { CollectionGroupSource, CollectionSource, DatabaseSource, - DocumentsSource + DocumentsSource, + Stage } from './stage'; -import { UserDataReader } from './user_data_reader'; -import { AbstractUserDataWriter } from './user_data_writer'; /** * Represents the source of a Firestore {@link Pipeline}. * @beta */ -export class PipelineSource { +export class PipelineSource { /** * @internal * @private - * @param _db - * @param _userDataReader - * @param _userDataWriter - * @param _documentReferenceFactory + * @param _createPipeline */ constructor( /** * @internal * @private */ - public _db: Firestore, - /** - * @internal - * @private - */ - public _userDataReader: UserDataReader, - /** - * @internal - * @private - */ - public _userDataWriter: AbstractUserDataWriter, - /** - * @internal - * @private - */ - public _documentReferenceFactory: (id: DocumentKey) => DocumentReference + public _createPipeline: (stages: Stage[]) => PipelineType ) {} - collection(collectionPath: string): Pipeline { - return new Pipeline( - this._db, - this._userDataReader, - this._userDataWriter, - this._documentReferenceFactory, - [new CollectionSource(collectionPath)] - ); + collection(collectionPath: string): PipelineType { + return this._createPipeline([new CollectionSource(collectionPath)]); } - collectionGroup(collectionId: string): Pipeline { - return new Pipeline( - this._db, - this._userDataReader, - this._userDataWriter, - this._documentReferenceFactory, - [new CollectionGroupSource(collectionId)] - ); + collectionGroup(collectionId: string): PipelineType { + return this._createPipeline([new CollectionGroupSource(collectionId)]); } - database(): Pipeline { - return new Pipeline( - this._db, - this._userDataReader, - this._userDataWriter, - this._documentReferenceFactory, - [new DatabaseSource()] - ); + database(): PipelineType { + return this._createPipeline([new DatabaseSource()]); } - documents(docs: DocumentReference[]): Pipeline { - return new Pipeline( - this._db, - this._userDataReader, - this._userDataWriter, - this._documentReferenceFactory, - [DocumentsSource.of(docs)] - ); + documents(docs: DocumentReference[]): PipelineType { + return this._createPipeline([DocumentsSource.of(docs)]); } } diff --git a/packages/firestore/src/lite-api/pipeline.ts b/packages/firestore/src/lite-api/pipeline.ts index a1b9ad481e9..2145952c004 100644 --- a/packages/firestore/src/lite-api/pipeline.ts +++ b/packages/firestore/src/lite-api/pipeline.ts @@ -17,19 +17,20 @@ /* eslint @typescript-eslint/no-explicit-any: 0 */ -import { DocumentKey } from '../model/document_key'; import { ObjectValue } from '../model/object_value'; import { ExecutePipelineRequest, StructuredPipeline, Stage as ProtoStage } from '../protos/firestore_proto_api'; +import { invokeExecutePipeline } from '../remote/datastore'; import { getEncodedDatabaseId, JsonProtoSerializer, ProtoSerializable } from '../remote/serializer'; +import { getDatastore } from './components'; import { Firestore } from './database'; import { Accumulator, @@ -43,7 +44,7 @@ import { Selectable } from './expressions'; import { PipelineResult } from './pipeline-result'; -import { DocumentData, DocumentReference } from './reference'; +import { DocumentReference } from './reference'; import { AddFields, Aggregate, @@ -119,18 +120,14 @@ function isReadableUserData(value: any): value is ReadableUserData { /** * Base-class implementation */ -export class Pipeline - implements ProtoSerializable -{ +export class Pipeline implements ProtoSerializable { /** * @internal * @private * @param _db * @param userDataReader * @param _userDataWriter - * @param _documentReferenceFactory * @param stages - * @param converter */ constructor( /** @@ -144,15 +141,7 @@ export class Pipeline * @private */ public _userDataWriter: AbstractUserDataWriter, - /** - * @internal - * @private - */ - public _documentReferenceFactory: (id: DocumentKey) => DocumentReference, - private stages: Stage[], - // TODO(pipeline) support converter - //private converter: FirestorePipelineConverter = defaultPipelineConverter() - private converter: unknown = {} + private stages: Stage[] ) {} /** @@ -181,7 +170,7 @@ export class Pipeline * @param fields The fields to add to the documents, specified as {@link Selectable}s. * @return A new Pipeline object with this stage appended to the stage list. */ - addFields(...fields: Selectable[]): Pipeline { + addFields(...fields: Selectable[]): Pipeline { const copy = this.stages.map(s => s); copy.push( new AddFields( @@ -192,9 +181,7 @@ export class Pipeline this._db, this.userDataReader, this._userDataWriter, - this._documentReferenceFactory, - copy, - this.converter + copy ); } @@ -229,7 +216,7 @@ export class Pipeline * Selectable} expressions or {@code string} values representing field names. * @return A new Pipeline object with this stage appended to the stage list. */ - select(...selections: Array): Pipeline { + select(...selections: Array): Pipeline { const copy = this.stages.map(s => s); let projections: Map = this.selectablesToMap(selections); projections = this.readUserData('select', projections); @@ -238,9 +225,7 @@ export class Pipeline this._db, this.userDataReader, this._userDataWriter, - this._documentReferenceFactory, - copy, - this.converter + copy ); } @@ -297,27 +282,17 @@ export class Pipeline * @param db * @param userDataReader * @param userDataWriter - * @param documentReferenceFactory * @param stages - * @param converter * @protected */ protected newPipeline( db: Firestore, userDataReader: UserDataReader, userDataWriter: AbstractUserDataWriter, - documentReferenceFactory: (id: DocumentKey) => DocumentReference, stages: Stage[], converter: unknown = {} - ): Pipeline { - return new Pipeline( - db, - userDataReader, - userDataWriter, - documentReferenceFactory, - stages, - converter - ); + ): Pipeline { + return new Pipeline(db, userDataReader, userDataWriter, stages); } /** @@ -351,7 +326,7 @@ export class Pipeline * @param condition The {@link FilterCondition} to apply. * @return A new Pipeline object with this stage appended to the stage list. */ - where(condition: FilterCondition & Expr): Pipeline { + where(condition: FilterCondition): Pipeline { const copy = this.stages.map(s => s); this.readUserData('where', condition); copy.push(new Where(condition)); @@ -359,9 +334,7 @@ export class Pipeline this._db, this.userDataReader, this._userDataWriter, - this._documentReferenceFactory, - copy, - this.converter + copy ); } @@ -385,16 +358,14 @@ export class Pipeline * @param offset The number of documents to skip. * @return A new Pipeline object with this stage appended to the stage list. */ - offset(offset: number): Pipeline { + offset(offset: number): Pipeline { const copy = this.stages.map(s => s); copy.push(new Offset(offset)); return this.newPipeline( this._db, this.userDataReader, this._userDataWriter, - this._documentReferenceFactory, - copy, - this.converter + copy ); } @@ -423,16 +394,25 @@ export class Pipeline * @param limit The maximum number of documents to return. * @return A new Pipeline object with this stage appended to the stage list. */ - limit(limit: number): Pipeline { + limit(limit: number): Pipeline { const copy = this.stages.map(s => s); copy.push(new Limit(limit)); return this.newPipeline( this._db, this.userDataReader, this._userDataWriter, - this._documentReferenceFactory, - copy, - this.converter + copy + ); + } + + _limit(limit: number, convertedFromLimitTolast: boolean): Pipeline { + const copy = this.stages.map(s => s); + copy.push(new Limit(limit, convertedFromLimitTolast)); + return this.newPipeline( + this._db, + this.userDataReader, + this._userDataWriter, + copy ); } @@ -464,7 +444,7 @@ export class Pipeline * value combinations or {@code string}s representing field names. * @return A new {@code Pipeline} object with this stage appended to the stage list. */ - distinct(...groups: Array): Pipeline { + distinct(...groups: Array): Pipeline { const copy = this.stages.map(s => s); copy.push( new Distinct( @@ -475,9 +455,7 @@ export class Pipeline this._db, this.userDataReader, this._userDataWriter, - this._documentReferenceFactory, - copy, - this.converter + copy ); } @@ -503,7 +481,7 @@ export class Pipeline * and provide a name for the accumulated results. * @return A new Pipeline object with this stage appended to the stage list. */ - aggregate(...accumulators: AccumulatorTarget[]): Pipeline; + aggregate(...accumulators: AccumulatorTarget[]): Pipeline; /** * Performs optionally grouped aggregation operations on the documents from previous stages. * @@ -539,7 +517,7 @@ export class Pipeline aggregate(options: { accumulators: AccumulatorTarget[]; groups?: Array; - }): Pipeline; + }): Pipeline; aggregate( optionsOrTarget: | AccumulatorTarget @@ -548,7 +526,7 @@ export class Pipeline groups?: Array; }, ...rest: AccumulatorTarget[] - ): Pipeline { + ): Pipeline { const copy = this.stages.map(s => s); if ('accumulators' in optionsOrTarget) { copy.push( @@ -588,14 +566,11 @@ export class Pipeline this._db, this.userDataReader, this._userDataWriter, - this._documentReferenceFactory, - copy, - this.converter + copy ); } - findNearest(options: FindNearestOptions): Pipeline; - findNearest(options: FindNearestOptions): Pipeline { + findNearest(options: FindNearestOptions): Pipeline { const copy = this.stages.map(s => s); const parseContext = this.userDataReader.createContext( UserDataSource.Argument, @@ -616,7 +591,6 @@ export class Pipeline this._db, this.userDataReader, this._userDataWriter, - this._documentReferenceFactory, copy ); } @@ -645,8 +619,7 @@ export class Pipeline * @param orders One or more {@link Ordering} instances specifying the sorting criteria. * @return A new {@code Pipeline} object with this stage appended to the stage list. */ - sort(...orderings: Ordering[]): Pipeline; - sort(options: { orderings: Ordering[] }): Pipeline; + sort(...orderings: Ordering[]): Pipeline; sort( optionsOrOrderings: | Ordering @@ -654,7 +627,7 @@ export class Pipeline orderings: Ordering[]; }, ...rest: Ordering[] - ): Pipeline { + ): Pipeline { const copy = this.stages.map(s => s); // Option object if ('orderings' in optionsOrOrderings) { @@ -677,9 +650,7 @@ export class Pipeline this._db, this.userDataReader, this._userDataWriter, - this._documentReferenceFactory, - copy, - this.converter + copy ); } @@ -703,7 +674,7 @@ export class Pipeline * @param params A list of parameters to configure the generic stage's behavior. * @return A new {@code Pipeline} object with this stage appended to the stage list. */ - genericStage(name: string, params: any[]): Pipeline { + genericStage(name: string, params: any[]): Pipeline { const copy = this.stages.map(s => s); params.forEach(param => { if (isReadableUserData(param)) { @@ -715,78 +686,10 @@ export class Pipeline this._db, this.userDataReader, this._userDataWriter, - this._documentReferenceFactory, - copy, - this.converter + copy ); } - // TODO(pipeline) support converter - // withConverter(converter: null): Pipeline; - // withConverter( - // converter: FirestorePipelineConverter - // ): Pipeline; - // /** - // * Applies a custom data converter to this Query, allowing you to use your - // * own custom model objects with Firestore. When you call get() on the - // * returned Query, the provided converter will convert between Firestore - // * data of type `NewDbModelType` and your custom type `NewAppModelType`. - // * - // * Using the converter allows you to specify generic type arguments when - // * storing and retrieving objects from Firestore. - // * - // * Passing in `null` as the converter parameter removes the current - // * converter. - // * - // * @example - // * ``` - // * class Post { - // * constructor(readonly title: string, readonly author: string) {} - // * - // * toString(): string { - // * return this.title + ', by ' + this.author; - // * } - // * } - // * - // * const postConverter = { - // * toFirestore(post: Post): FirebaseFirestore.DocumentData { - // * return {title: post.title, author: post.author}; - // * }, - // * fromFirestore( - // * snapshot: FirebaseFirestore.QueryDocumentSnapshot - // * ): Post { - // * const data = snapshot.data(); - // * return new Post(data.title, data.author); - // * } - // * }; - // * - // * const postSnap = await Firestore() - // * .collection('posts') - // * .withConverter(postConverter) - // * .doc().get(); - // * const post = postSnap.data(); - // * if (post !== undefined) { - // * post.title; // string - // * post.toString(); // Should be defined - // * post.someNonExistentProperty; // TS error - // * } - // * - // * ``` - // * @param {FirestoreDataConverter | null} converter Converts objects to and - // * from Firestore. Passing in `null` removes the current converter. - // * @return A Query that uses the provided converter. - // */ - // withConverter( - // converter: FirestorePipelineConverter | null - // ): Pipeline { - // const copy = this.stages.map(s => s); - // return this.newPipeline( - // this.db, - // copy, - // converter ?? defaultPipelineConverter() - // ); - // } - /** * Executes this pipeline and returns a Promise to represent the asynchronous operation. * @@ -818,10 +721,29 @@ export class Pipeline * * @return A Promise representing the asynchronous pipeline execution. */ - execute(): Promise>> { - throw new Error( - 'Pipelines not initialized. Your application must call `useFluentPipelines()` before using Firestore Pipeline features.' - ); + execute(): Promise { + const datastore = getDatastore(this._db); + return invokeExecutePipeline(datastore, this).then(result => { + const docs = result + // Currently ignore any response from ExecutePipeline that does + // not contain any document data in the `fields` property. + .filter(element => !!element.fields) + .map( + element => + new PipelineResult( + this._userDataWriter, + element.key?.path + ? new DocumentReference(this._db, null, element.key) + : undefined, + element.fields, + element.executionTime?.toTimestamp(), + element.createTime?.toTimestamp(), + element.updateTime?.toTimestamp() + ) + ); + + return docs; + }); } /** diff --git a/packages/firestore/src/lite-api/pipeline_impl.ts b/packages/firestore/src/lite-api/pipeline_impl.ts index f3556dc6f09..98b121ad485 100644 --- a/packages/firestore/src/lite-api/pipeline_impl.ts +++ b/packages/firestore/src/lite-api/pipeline_impl.ts @@ -15,21 +15,18 @@ * limitations under the License. */ -import { DocumentKey } from '../model/document_key'; -import { invokeExecutePipeline } from '../remote/datastore'; - -import { getDatastore } from './components'; import { Firestore } from './database'; import { Pipeline } from './pipeline'; import { PipelineResult } from './pipeline-result'; import { PipelineSource } from './pipeline-source'; -import { DocumentReference, Query } from './reference'; +import { Query } from './reference'; import { LiteUserDataWriter } from './reference_impl'; +import { Stage } from './stage'; import { newUserDataReader } from './user_data_reader'; declare module './database' { interface Firestore { - pipeline(): PipelineSource; + pipeline(): PipelineSource; } } @@ -44,39 +41,15 @@ declare module './reference' { * @param pipeline Execute this pipeline. * @beta */ -export function execute( - pipeline: Pipeline -): Promise>> { - const datastore = getDatastore(pipeline._db); - return invokeExecutePipeline(datastore, pipeline).then(result => { - const docs = result - // Currently ignore any response from ExecutePipeline that does - // not contain any document data in the `fields` property. - .filter(element => !!element.fields) - .map( - element => - new PipelineResult( - pipeline._userDataWriter, - element.key?.path - ? pipeline._documentReferenceFactory(element.key) - : undefined, - element.fields, - element.executionTime?.toTimestamp(), - element.createTime?.toTimestamp(), - element.updateTime?.toTimestamp() - //this.converter - ) - ); - - return docs; - }); +export function execute(pipeline: Pipeline): Promise { + return pipeline.execute(); } /** * Experimental Modular API for console testing. * @param firestore */ -export function pipeline(firestore: Firestore): PipelineSource; +export function pipeline(firestore: Firestore): PipelineSource; /** * Experimental Modular API for console testing. @@ -86,19 +59,14 @@ export function pipeline(query: Query): Pipeline; export function pipeline( firestoreOrQuery: Firestore | Query -): PipelineSource | Pipeline { +): PipelineSource | Pipeline { if (firestoreOrQuery instanceof Firestore) { const db = firestoreOrQuery; const userDataWriter = new LiteUserDataWriter(db); const userDataReader = newUserDataReader(db); - return new PipelineSource( - db, - userDataReader, - userDataWriter, - (key: DocumentKey) => { - return new DocumentReference(db, null, key); - } - ); + return new PipelineSource((stages: Stage[]) => { + return new Pipeline(db, userDataReader, userDataWriter, stages); + }); } else { let pipeline; const query = firestoreOrQuery; @@ -119,12 +87,10 @@ export function pipeline( } } -export function useFluentPipelines(): void { - Firestore.prototype.pipeline = function (): PipelineSource { - return pipeline(this); - }; +Firestore.prototype.pipeline = function (): PipelineSource { + return pipeline(this); +}; - Query.prototype.pipeline = function (): Pipeline { - return pipeline(this); - }; -} +Query.prototype.pipeline = function (): Pipeline { + return pipeline(this); +}; diff --git a/packages/firestore/src/lite-api/stage.ts b/packages/firestore/src/lite-api/stage.ts index b4fe237f79c..46f8fe60654 100644 --- a/packages/firestore/src/lite-api/stage.ts +++ b/packages/firestore/src/lite-api/stage.ts @@ -27,6 +27,7 @@ import { toMapValue, toStringValue } from '../remote/serializer'; +import { hardAssert } from '../util/assert'; import { Accumulator, @@ -204,7 +205,7 @@ export class DocumentsSource implements Stage { export class Where implements Stage { name = 'where'; - constructor(private condition: FilterCondition & Expr) {} + constructor(private condition: FilterCondition) {} /** * @internal @@ -289,7 +290,15 @@ export class FindNearest implements Stage { export class Limit implements Stage { name = 'limit'; - constructor(private limit: number) {} + constructor( + readonly limit: number, + readonly convertedFromLimitTolast: boolean = false + ) { + hardAssert( + !isNaN(limit) && limit !== Infinity && limit !== -Infinity, + 'Invalid limit value' + ); + } /** * @internal diff --git a/packages/firestore/src/remote/datastore.ts b/packages/firestore/src/remote/datastore.ts index 5fbff4392ac..00c1e7fca9e 100644 --- a/packages/firestore/src/remote/datastore.ts +++ b/packages/firestore/src/remote/datastore.ts @@ -241,7 +241,7 @@ export async function invokeBatchGetDocumentsRpc( export async function invokeExecutePipeline( datastore: Datastore, - pipeline: Pipeline + pipeline: Pipeline ): Promise { const datastoreImpl = debugCast(datastore, DatastoreImpl); const executePipelineRequest = pipeline._toProto(datastoreImpl.serializer); diff --git a/packages/firestore/src/util/proto.ts b/packages/firestore/src/util/proto.ts new file mode 100644 index 00000000000..a99f73cfa9c --- /dev/null +++ b/packages/firestore/src/util/proto.ts @@ -0,0 +1,155 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + ArrayValue as ProtoArrayValue, + Function as ProtoFunction, + LatLng as ProtoLatLng, + MapValue as ProtoMapValue, + Pipeline as ProtoPipeline, + Timestamp as ProtoTimestamp, + Value as ProtoValue +} from '../protos/firestore_proto_api'; + +import { isPlainObject } from './input_validation'; + +/* eslint @typescript-eslint/no-explicit-any: 0 */ + +function isITimestamp(obj: any): obj is ProtoTimestamp { + if (typeof obj !== 'object' || obj === null) { + return false; // Must be a non-null object + } + if ( + 'seconds' in obj && + (obj.seconds === null || + typeof obj.seconds === 'number' || + typeof obj.seconds === 'string') && + 'nanos' in obj && + (obj.nanos === null || typeof obj.nanos === 'number') + ) { + return true; + } + + return false; +} +function isILatLng(obj: any): obj is ProtoLatLng { + if (typeof obj !== 'object' || obj === null) { + return false; // Must be a non-null object + } + if ( + 'latitude' in obj && + (obj.latitude === null || typeof obj.latitude === 'number') && + 'longitude' in obj && + (obj.longitude === null || typeof obj.longitude === 'number') + ) { + return true; + } + + return false; +} +function isIArrayValue(obj: any): obj is ProtoArrayValue { + if (typeof obj !== 'object' || obj === null) { + return false; // Must be a non-null object + } + if ('values' in obj && (obj.values === null || Array.isArray(obj.values))) { + return true; + } + + return false; +} +function isIMapValue(obj: any): obj is ProtoMapValue { + if (typeof obj !== 'object' || obj === null) { + return false; // Must be a non-null object + } + if ('fields' in obj && (obj.fields === null || isPlainObject(obj.fields))) { + return true; + } + + return false; +} +function isIFunction(obj: any): obj is ProtoFunction { + if (typeof obj !== 'object' || obj === null) { + return false; // Must be a non-null object + } + if ( + 'name' in obj && + (obj.name === null || typeof obj.name === 'string') && + 'args' in obj && + (obj.args === null || Array.isArray(obj.args)) + ) { + return true; + } + + return false; +} + +function isIPipeline(obj: any): obj is ProtoPipeline { + if (typeof obj !== 'object' || obj === null) { + return false; // Must be a non-null object + } + if ('stages' in obj && (obj.stages === null || Array.isArray(obj.stages))) { + return true; + } + + return false; +} + +export function isFirestoreValue(obj: any): obj is ProtoValue { + if (typeof obj !== 'object' || obj === null) { + return false; // Must be a non-null object + } + + // Check optional properties and their types + if ( + ('nullValue' in obj && + (obj.nullValue === null || obj.nullValue === 'NULL_VALUE')) || + ('booleanValue' in obj && + (obj.booleanValue === null || typeof obj.booleanValue === 'boolean')) || + ('integerValue' in obj && + (obj.integerValue === null || + typeof obj.integerValue === 'number' || + typeof obj.integerValue === 'string')) || + ('doubleValue' in obj && + (obj.doubleValue === null || typeof obj.doubleValue === 'number')) || + ('timestampValue' in obj && + (obj.timestampValue === null || isITimestamp(obj.timestampValue))) || + ('stringValue' in obj && + (obj.stringValue === null || typeof obj.stringValue === 'string')) || + ('bytesValue' in obj && + (obj.bytesValue === null || obj.bytesValue instanceof Uint8Array)) || + ('referenceValue' in obj && + (obj.referenceValue === null || + typeof obj.referenceValue === 'string')) || + ('geoPointValue' in obj && + (obj.geoPointValue === null || isILatLng(obj.geoPointValue))) || + ('arrayValue' in obj && + (obj.arrayValue === null || isIArrayValue(obj.arrayValue))) || + ('mapValue' in obj && + (obj.mapValue === null || isIMapValue(obj.mapValue))) || + ('fieldReferenceValue' in obj && + (obj.fieldReferenceValue === null || + typeof obj.fieldReferenceValue === 'string')) || + ('functionValue' in obj && + (obj.functionValue === null || isIFunction(obj.functionValue))) || + ('pipelineValue' in obj && + (obj.pipelineValue === null || isIPipeline(obj.pipelineValue))) + ) { + return true; + } + + return false; +} diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index 1376947f482..48441c26065 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -58,1046 +58,1671 @@ import { setDoc, startsWith, subtract, - useFluentPipelines, setLogLevel, cond, eqAny, logicalMaximum, logicalMinimum, - notEqAny + notEqAny, + query, + where, + FieldPath, + orderBy, + limit, + limitToLast, + startAt, + startAfter, + endAt, + endBefore, + collectionGroup, + collection, + and, + documentId, + addDoc, + getDoc } from '../util/firebase_export'; -import { apiDescribe, withTestCollection } from '../util/helpers'; +import { + apiDescribe, + PERSISTENCE_MODE_UNSPECIFIED, + withTestCollection +} from '../util/helpers'; use(chaiAsPromised); setLogLevel('debug'); -apiDescribe('Pipelines', persistence => { +apiDescribe.only('Pipelines', persistence => { addEqualityMatcher(); - let firestore: Firestore; - let randomCol: CollectionReference; - - // async function addDocs( - // ...docs: DocumentData[] - // ): Promise { - // let id = 0; // Guarantees consistent ordering for the first documents - // const refs: DocumentReference[] = []; - // for (const data of docs) { - // const ref = doc(randomCol, 'doc' + id++); - // await setDoc(ref, data); - // refs.push(ref); - // } - // return refs; - // } - - async function testCollectionWithDocs(docs: { - [id: string]: DocumentData; - }): Promise> { - for (const id in docs) { - if (docs.hasOwnProperty(id)) { - const ref = doc(randomCol, id); - await setDoc(ref, docs[id]); + + describe('books tests', () => { + let firestore: Firestore; + let randomCol: CollectionReference; + + async function testCollectionWithDocs(docs: { + [id: string]: DocumentData; + }): Promise> { + for (const id in docs) { + if (docs.hasOwnProperty(id)) { + const ref = doc(randomCol, id); + await setDoc(ref, docs[id]); + } } + return randomCol; } - return randomCol; - } - - function expectResults( - result: Array>, - ...docs: string[] - ): void; - function expectResults( - result: Array>, - ...data: DocumentData[] - ): void; - - function expectResults( - result: Array>, - ...data: DocumentData[] | string[] - ): void { - expect(result.length).to.equal(data.length); - - if (data.length > 0) { - if (typeof data[0] === 'string') { - const actualIds = result.map(result => result.ref?.id); - expect(actualIds).to.deep.equal(data); - } else { - result.forEach(r => { - expect(r.data()).to.deep.equal(data.shift()); - }); + + function expectResults( + result: Array>, + ...docs: string[] + ): void; + function expectResults( + result: Array>, + ...data: DocumentData[] + ): void; + + function expectResults( + result: Array>, + ...data: DocumentData[] | string[] + ): void { + expect(result.length).to.equal(data.length); + + if (data.length > 0) { + if (typeof data[0] === 'string') { + const actualIds = result.map(result => result.ref?.id); + expect(actualIds).to.deep.equal(data); + } else { + result.forEach(r => { + expect(r.data()).to.deep.equal(data.shift()); + }); + } } } - } - - // async function compareQueryAndPipeline(query: Query): Promise { - // const queryResults = await getDocs(query); - // const pipeline = query.pipeline(); - // const pipelineResults = await pipeline.execute(); - // - // expect(queryResults.docs.map(s => s._fieldsProto)).to.deep.equal( - // pipelineResults.map(r => r._fieldsProto) - // ); - // return queryResults; - // } - - async function setupBookDocs(): Promise> { - const bookDocs: { [id: string]: DocumentData } = { - book1: { - title: "The Hitchhiker's Guide to the Galaxy", - author: 'Douglas Adams', - genre: 'Science Fiction', - published: 1979, - rating: 4.2, - tags: ['comedy', 'space', 'adventure'], - awards: { - hugo: true, - nebula: false, - others: { unknown: { year: 1980 } } - }, - nestedField: { 'level.1': { 'level.2': true } } - }, - book2: { - title: 'Pride and Prejudice', - author: 'Jane Austen', - genre: 'Romance', - published: 1813, - rating: 4.5, - tags: ['classic', 'social commentary', 'love'], - awards: { none: true } - }, - book3: { - title: 'One Hundred Years of Solitude', - author: 'Gabriel García Márquez', - genre: 'Magical Realism', - published: 1967, - rating: 4.3, - tags: ['family', 'history', 'fantasy'], - awards: { nobel: true, nebula: false } - }, - book4: { - title: 'The Lord of the Rings', - author: 'J.R.R. Tolkien', - genre: 'Fantasy', - published: 1954, - rating: 4.7, - tags: ['adventure', 'magic', 'epic'], - awards: { hugo: false, nebula: false } - }, - book5: { - title: "The Handmaid's Tale", - author: 'Margaret Atwood', - genre: 'Dystopian', - published: 1985, - rating: 4.1, - tags: ['feminism', 'totalitarianism', 'resistance'], - awards: { 'arthur c. clarke': true, 'booker prize': false } - }, - book6: { - title: 'Crime and Punishment', - author: 'Fyodor Dostoevsky', - genre: 'Psychological Thriller', - published: 1866, - rating: 4.3, - tags: ['philosophy', 'crime', 'redemption'], - awards: { none: true } - }, - book7: { - title: 'To Kill a Mockingbird', - author: 'Harper Lee', - genre: 'Southern Gothic', - published: 1960, - rating: 4.2, - tags: ['racism', 'injustice', 'coming-of-age'], - awards: { pulitzer: true } - }, - book8: { - title: '1984', - author: 'George Orwell', - genre: 'Dystopian', - published: 1949, - rating: 4.2, - tags: ['surveillance', 'totalitarianism', 'propaganda'], - awards: { prometheus: true } - }, - book9: { - title: 'The Great Gatsby', - author: 'F. Scott Fitzgerald', - genre: 'Modernist', - published: 1925, - rating: 4.0, - tags: ['wealth', 'american dream', 'love'], - awards: { none: true } - }, - book10: { - title: 'Dune', - author: 'Frank Herbert', - genre: 'Science Fiction', - published: 1965, - rating: 4.6, - tags: ['politics', 'desert', 'ecology'], - awards: { hugo: true, nebula: true } - } - }; - return testCollectionWithDocs(bookDocs); - } - - let testDeferred: Deferred | undefined; - let withTestCollectionPromise: Promise | undefined; - - beforeEach(async () => { - const setupDeferred = new Deferred(); - testDeferred = new Deferred(); - withTestCollectionPromise = withTestCollection( - persistence, - {}, - async (collectionRef, firestoreInstance) => { - randomCol = collectionRef; - firestore = firestoreInstance; - await setupBookDocs(); - setupDeferred.resolve(); - - return testDeferred?.promise; - } - ); - await setupDeferred.promise; - }); + async function setupBookDocs(): Promise> { + const bookDocs: { [id: string]: DocumentData } = { + book1: { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams', + genre: 'Science Fiction', + published: 1979, + rating: 4.2, + tags: ['comedy', 'space', 'adventure'], + awards: { + hugo: true, + nebula: false, + others: { unknown: { year: 1980 } } + }, + nestedField: { 'level.1': { 'level.2': true } } + }, + book2: { + title: 'Pride and Prejudice', + author: 'Jane Austen', + genre: 'Romance', + published: 1813, + rating: 4.5, + tags: ['classic', 'social commentary', 'love'], + awards: { none: true } + }, + book3: { + title: 'One Hundred Years of Solitude', + author: 'Gabriel García Márquez', + genre: 'Magical Realism', + published: 1967, + rating: 4.3, + tags: ['family', 'history', 'fantasy'], + awards: { nobel: true, nebula: false } + }, + book4: { + title: 'The Lord of the Rings', + author: 'J.R.R. Tolkien', + genre: 'Fantasy', + published: 1954, + rating: 4.7, + tags: ['adventure', 'magic', 'epic'], + awards: { hugo: false, nebula: false } + }, + book5: { + title: "The Handmaid's Tale", + author: 'Margaret Atwood', + genre: 'Dystopian', + published: 1985, + rating: 4.1, + tags: ['feminism', 'totalitarianism', 'resistance'], + awards: { 'arthur c. clarke': true, 'booker prize': false } + }, + book6: { + title: 'Crime and Punishment', + author: 'Fyodor Dostoevsky', + genre: 'Psychological Thriller', + published: 1866, + rating: 4.3, + tags: ['philosophy', 'crime', 'redemption'], + awards: { none: true } + }, + book7: { + title: 'To Kill a Mockingbird', + author: 'Harper Lee', + genre: 'Southern Gothic', + published: 1960, + rating: 4.2, + tags: ['racism', 'injustice', 'coming-of-age'], + awards: { pulitzer: true } + }, + book8: { + title: '1984', + author: 'George Orwell', + genre: 'Dystopian', + published: 1949, + rating: 4.2, + tags: ['surveillance', 'totalitarianism', 'propaganda'], + awards: { prometheus: true } + }, + book9: { + title: 'The Great Gatsby', + author: 'F. Scott Fitzgerald', + genre: 'Modernist', + published: 1925, + rating: 4.0, + tags: ['wealth', 'american dream', 'love'], + awards: { none: true } + }, + book10: { + title: 'Dune', + author: 'Frank Herbert', + genre: 'Science Fiction', + published: 1965, + rating: 4.6, + tags: ['politics', 'desert', 'ecology'], + awards: { hugo: true, nebula: true } + } + }; + return testCollectionWithDocs(bookDocs); + } - afterEach(async () => { - testDeferred?.resolve(); - await withTestCollectionPromise; - }); + let testDeferred: Deferred | undefined; + let withTestCollectionPromise: Promise | undefined; + + beforeEach(async () => { + const setupDeferred = new Deferred(); + testDeferred = new Deferred(); + withTestCollectionPromise = withTestCollection( + persistence, + {}, + async (collectionRef, firestoreInstance) => { + randomCol = collectionRef; + firestore = firestoreInstance; + await setupBookDocs(); + setupDeferred.resolve(); + + return testDeferred?.promise; + } + ); - describe('fluent API', () => { - before(() => { - useFluentPipelines(); + await setupDeferred.promise; }); - it('empty results as expected', async () => { - const result = await firestore - .pipeline() - .collection(randomCol.path) - .limit(0) - .execute(); - expect(result.length).to.equal(0); + afterEach(async () => { + testDeferred?.resolve(); + await withTestCollectionPromise; }); - it('full results as expected', async () => { - const result = await firestore - .pipeline() - .collection(randomCol.path) - .execute(); - expect(result.length).to.equal(10); - }); + describe('fluent API', () => { + it('empty results as expected', async () => { + const result = await firestore + .pipeline() + .collection(randomCol.path) + .limit(0) + .execute(); + expect(result.length).to.equal(0); + }); - it('returns aggregate results as expected', async () => { - let result = await firestore - .pipeline() - .collection(randomCol.path) - .aggregate(countAll().as('count')) - .execute(); - expectResults(result, { count: 10 }); - - result = await randomCol - .pipeline() - .where(eq('genre', 'Science Fiction')) - .aggregate( - countAll().as('count'), - avgFunction('rating').as('avgRating'), - Field.of('rating').maximum().as('maxRating') - ) - .execute(); - expectResults(result, { count: 2, avgRating: 4.4, maxRating: 4.6 }); - }); + it('full results as expected', async () => { + const result = await firestore + .pipeline() + .collection(randomCol.path) + .execute(); + expect(result.length).to.equal(10); + }); + + it('returns aggregate results as expected', async () => { + let result = await firestore + .pipeline() + .collection(randomCol.path) + .aggregate(countAll().as('count')) + .execute(); + expectResults(result, { count: 10 }); + + result = await randomCol + .pipeline() + .where(eq('genre', 'Science Fiction')) + .aggregate( + countAll().as('count'), + avgFunction('rating').as('avgRating'), + Field.of('rating').maximum().as('maxRating') + ) + .execute(); + expectResults(result, { count: 2, avgRating: 4.4, maxRating: 4.6 }); + }); - it('rejects groups without accumulators', async () => { - await expect( - randomCol + it('rejects groups without accumulators', async () => { + await expect( + randomCol + .pipeline() + .where(lt('published', 1900)) + .aggregate({ + accumulators: [], + groups: ['genre'] + }) + .execute() + ).to.be.rejected; + }); + + it('returns distinct values as expected', async () => { + const results = await randomCol + .pipeline() + .distinct('genre', 'author') + .sort(Field.of('genre').ascending(), Field.of('author').ascending()) + .execute(); + expectResults( + results, + { genre: 'Dystopian', author: 'George Orwell' }, + { genre: 'Dystopian', author: 'Margaret Atwood' }, + { genre: 'Fantasy', author: 'J.R.R. Tolkien' }, + { genre: 'Magical Realism', author: 'Gabriel García Márquez' }, + { genre: 'Modernist', author: 'F. Scott Fitzgerald' }, + { genre: 'Psychological Thriller', author: 'Fyodor Dostoevsky' }, + { genre: 'Romance', author: 'Jane Austen' }, + { genre: 'Science Fiction', author: 'Douglas Adams' }, + { genre: 'Science Fiction', author: 'Frank Herbert' }, + { genre: 'Southern Gothic', author: 'Harper Lee' } + ); + }); + + it('returns group and accumulate results', async () => { + const results = await randomCol .pipeline() - .where(lt('published', 1900)) + .where(lt(Field.of('published'), 1984)) .aggregate({ - accumulators: [], + accumulators: [avgFunction('rating').as('avgRating')], groups: ['genre'] }) - .execute() - ).to.be.rejected; - }); - - // skip: toLower not supported - // it.skip('returns distinct values as expected', async () => { - // const results = await randomCol - // .pipeline() - // .where(lt('published', 1900)) - // .distinct(Field.of('genre').toLower().as('lowerGenre')) - // .execute(); - // expectResults( - // results, - // { lowerGenre: 'romance' }, - // { lowerGenre: 'psychological thriller' } - // ); - // }); - - it('returns group and accumulate results', async () => { - const results = await randomCol - .pipeline() - .where(lt(Field.of('published'), 1984)) - .aggregate({ - accumulators: [avgFunction('rating').as('avgRating')], - groups: ['genre'] - }) - .where(gt('avgRating', 4.3)) - .sort(Field.of('avgRating').descending()) - .execute(); - expectResults( - results, - { avgRating: 4.7, genre: 'Fantasy' }, - { avgRating: 4.5, genre: 'Romance' }, - { avgRating: 4.4, genre: 'Science Fiction' } - ); - }); + .where(gt('avgRating', 4.3)) + .sort(Field.of('avgRating').descending()) + .execute(); + expectResults( + results, + { avgRating: 4.7, genre: 'Fantasy' }, + { avgRating: 4.5, genre: 'Romance' }, + { avgRating: 4.4, genre: 'Science Fiction' } + ); + }); - it('returns min and max accumulations', async () => { - const results = await randomCol - .pipeline() - .aggregate( - countAll().as('count'), - Field.of('rating').maximum().as('maxRating'), - Field.of('published').minimum().as('minPublished') - ) - .execute(); - expectResults(results, { - count: 10, - maxRating: 4.7, - minPublished: 1813 + it('returns min and max accumulations', async () => { + const results = await randomCol + .pipeline() + .aggregate( + countAll().as('count'), + Field.of('rating').maximum().as('maxRating'), + Field.of('published').minimum().as('minPublished') + ) + .execute(); + expectResults(results, { + count: 10, + maxRating: 4.7, + minPublished: 1813 + }); }); - }); - it('can select fields', async () => { - const results = await firestore - .pipeline() - .collection(randomCol.path) - .select('title', 'author') - .sort(Field.of('author').ascending()) - .execute(); - expectResults( - results, - { - title: "The Hitchhiker's Guide to the Galaxy", - author: 'Douglas Adams' - }, - { title: 'The Great Gatsby', author: 'F. Scott Fitzgerald' }, - { title: 'Dune', author: 'Frank Herbert' }, - { title: 'Crime and Punishment', author: 'Fyodor Dostoevsky' }, - { - title: 'One Hundred Years of Solitude', - author: 'Gabriel García Márquez' - }, - { title: '1984', author: 'George Orwell' }, - { title: 'To Kill a Mockingbird', author: 'Harper Lee' }, - { title: 'The Lord of the Rings', author: 'J.R.R. Tolkien' }, - { title: 'Pride and Prejudice', author: 'Jane Austen' }, - { title: "The Handmaid's Tale", author: 'Margaret Atwood' } - ); - }); + it('can select fields', async () => { + const results = await firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'author') + .sort(Field.of('author').ascending()) + .execute(); + expectResults( + results, + { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams' + }, + { title: 'The Great Gatsby', author: 'F. Scott Fitzgerald' }, + { title: 'Dune', author: 'Frank Herbert' }, + { title: 'Crime and Punishment', author: 'Fyodor Dostoevsky' }, + { + title: 'One Hundred Years of Solitude', + author: 'Gabriel García Márquez' + }, + { title: '1984', author: 'George Orwell' }, + { title: 'To Kill a Mockingbird', author: 'Harper Lee' }, + { title: 'The Lord of the Rings', author: 'J.R.R. Tolkien' }, + { title: 'Pride and Prejudice', author: 'Jane Austen' }, + { title: "The Handmaid's Tale", author: 'Margaret Atwood' } + ); + }); - it('where with and', async () => { - const results = await randomCol - .pipeline() - .where(andFunction(gt('rating', 4.5), eq('genre', 'Science Fiction'))) - .execute(); - expectResults(results, 'book10'); - }); + it('where with and', async () => { + const results = await randomCol + .pipeline() + .where(andFunction(gt('rating', 4.5), eq('genre', 'Science Fiction'))) + .execute(); + expectResults(results, 'book10'); + }); - it('where with or', async () => { - const results = await randomCol - .pipeline() - .where(orFunction(eq('genre', 'Romance'), eq('genre', 'Dystopian'))) - .select('title') - .execute(); - expectResults( - results, - { title: 'Pride and Prejudice' }, - { title: "The Handmaid's Tale" }, - { title: '1984' } - ); - }); + it('where with or', async () => { + const results = await randomCol + .pipeline() + .where(orFunction(eq('genre', 'Romance'), eq('genre', 'Dystopian'))) + .select('title') + .execute(); + expectResults( + results, + { title: 'Pride and Prejudice' }, + { title: "The Handmaid's Tale" }, + { title: '1984' } + ); + }); - it('offset and limits', async () => { - const results = await firestore - .pipeline() - .collection(randomCol.path) - .sort(Field.of('author').ascending()) - .offset(5) - .limit(3) - .select('title', 'author') - .execute(); - expectResults( - results, - { title: '1984', author: 'George Orwell' }, - { title: 'To Kill a Mockingbird', author: 'Harper Lee' }, - { title: 'The Lord of the Rings', author: 'J.R.R. Tolkien' } - ); - }); + it('offset and limits', async () => { + const results = await firestore + .pipeline() + .collection(randomCol.path) + .sort(Field.of('author').ascending()) + .offset(5) + .limit(3) + .select('title', 'author') + .execute(); + expectResults( + results, + { title: '1984', author: 'George Orwell' }, + { title: 'To Kill a Mockingbird', author: 'Harper Lee' }, + { title: 'The Lord of the Rings', author: 'J.R.R. Tolkien' } + ); + }); - it('logical min works', async () => { - const results = await randomCol - .pipeline() - .select( - 'title', - logicalMinimum(Constant.of(1960), Field.of('published')).as( - 'published-safe' + it('logical min works', async () => { + const results = await randomCol + .pipeline() + .select( + 'title', + logicalMinimum(Constant.of(1960), Field.of('published')).as( + 'published-safe' + ) ) - ) - .sort(Field.of('title').ascending()) - .limit(3) - .execute(); - expectResults( - results, - { title: '1984', 'published-safe': 1949 }, - { title: 'Crime and Punishment', 'published-safe': 1866 }, - { title: 'Dune', 'published-safe': 1960 } - ); - }); + .sort(Field.of('title').ascending()) + .limit(3) + .execute(); + expectResults( + results, + { title: '1984', 'published-safe': 1949 }, + { title: 'Crime and Punishment', 'published-safe': 1866 }, + { title: 'Dune', 'published-safe': 1960 } + ); + }); - it('logical max works', async () => { - const results = await randomCol - .pipeline() - .select( - 'title', - logicalMaximum(Constant.of(1960), Field.of('published')).as( - 'published-safe' + it('logical max works', async () => { + const results = await randomCol + .pipeline() + .select( + 'title', + logicalMaximum(Constant.of(1960), Field.of('published')).as( + 'published-safe' + ) ) - ) - .sort(Field.of('title').ascending()) - .limit(3) - .execute(); - expectResults( - results, - { title: '1984', 'published-safe': 1960 }, - { title: 'Crime and Punishment', 'published-safe': 1960 }, - { title: 'Dune', 'published-safe': 1965 } - ); - }); + .sort(Field.of('title').ascending()) + .limit(3) + .execute(); + expectResults( + results, + { title: '1984', 'published-safe': 1960 }, + { title: 'Crime and Punishment', 'published-safe': 1960 }, + { title: 'Dune', 'published-safe': 1965 } + ); + }); - it('accepts and returns all data types', async () => { - const refDate = new Date(); - const refTimestamp = Timestamp.now(); - const constants = [ - Constant.of(1).as('number'), - Constant.of('a string').as('string'), - Constant.of(true).as('boolean'), - Constant.of(null).as('null'), - Constant.of(new GeoPoint(0.1, 0.2)).as('geoPoint'), - Constant.of(refTimestamp).as('timestamp'), - Constant.of(refDate).as('date'), - Constant.of( - Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])) - ).as('bytes'), - Constant.of(doc(firestore, 'foo', 'bar')).as('documentReference'), - Constant.of(vector([1, 2, 3])).as('vectorValue'), - Constant.of({ + it('accepts and returns all data types', async () => { + const refDate = new Date(); + const refTimestamp = Timestamp.now(); + const constants = [ + Constant.of(1).as('number'), + Constant.of('a string').as('string'), + Constant.of(true).as('boolean'), + Constant.of(null).as('null'), + Constant.of(new GeoPoint(0.1, 0.2)).as('geoPoint'), + Constant.of(refTimestamp).as('timestamp'), + Constant.of(refDate).as('date'), + Constant.of( + Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])) + ).as('bytes'), + Constant.of(doc(firestore, 'foo', 'bar')).as('documentReference'), + Constant.of(vector([1, 2, 3])).as('vectorValue'), + Constant.of({ + 'number': 1, + 'string': 'a string', + 'boolean': true, + 'null': null, + 'geoPoint': new GeoPoint(0.1, 0.2), + 'timestamp': refTimestamp, + 'date': refDate, + 'uint8Array': Bytes.fromUint8Array( + new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0]) + ), + 'documentReference': doc(firestore, 'foo', 'bar'), + 'vectorValue': vector([1, 2, 3]), + 'map': { + 'number': 2, + 'string': 'b string' + }, + 'array': [1, 'c string'] + }).as('map'), + Constant.of([ + 1, + 'a string', + true, + null, + new GeoPoint(0.1, 0.2), + refTimestamp, + refDate, + Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])), + doc(firestore, 'foo', 'bar'), + vector([1, 2, 3]), + { + 'number': 2, + 'string': 'b string' + } + ]).as('array') + ]; + + const results = await randomCol + .pipeline() + .limit(1) + .select(...constants) + .execute(); + + expectResults(results, { 'number': 1, 'string': 'a string', 'boolean': true, 'null': null, 'geoPoint': new GeoPoint(0.1, 0.2), 'timestamp': refTimestamp, - 'date': refDate, - 'uint8Array': Bytes.fromUint8Array( + 'date': Timestamp.fromDate(refDate), + 'bytes': Bytes.fromUint8Array( new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0]) ), 'documentReference': doc(firestore, 'foo', 'bar'), 'vectorValue': vector([1, 2, 3]), 'map': { - 'number': 2, - 'string': 'b string' + 'number': 1, + 'string': 'a string', + 'boolean': true, + 'null': null, + 'geoPoint': new GeoPoint(0.1, 0.2), + 'timestamp': refTimestamp, + 'date': Timestamp.fromDate(refDate), + 'uint8Array': Bytes.fromUint8Array( + new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0]) + ), + 'documentReference': doc(firestore, 'foo', 'bar'), + 'vectorValue': vector([1, 2, 3]), + 'map': { + 'number': 2, + 'string': 'b string' + }, + 'array': [1, 'c string'] + }, + 'array': [ + 1, + 'a string', + true, + null, + new GeoPoint(0.1, 0.2), + refTimestamp, + Timestamp.fromDate(refDate), + Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])), + doc(firestore, 'foo', 'bar'), + vector([1, 2, 3]), + { + 'number': 2, + 'string': 'b string' + } + ] + }); + }); + + it('cond works', async () => { + const results = await randomCol + .pipeline() + .select( + 'title', + cond( + lt(Field.of('published'), 1960), + Constant.of(1960), + Field.of('published') + ).as('published-safe') + ) + .sort(Field.of('title').ascending()) + .limit(3) + .execute(); + expectResults( + results, + { title: '1984', 'published-safe': 1960 }, + { title: 'Crime and Punishment', 'published-safe': 1960 }, + { title: 'Dune', 'published-safe': 1965 } + ); + }); + + it('eqAny works', async () => { + const results = await randomCol + .pipeline() + .where(eqAny('published', [1979, 1999, 1967])) + .select('title') + .execute(); + expectResults( + results, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'One Hundred Years of Solitude' } + ); + }); + + it('notEqAny works', async () => { + const results = await randomCol + .pipeline() + .where( + notEqAny( + 'published', + [1965, 1925, 1949, 1960, 1866, 1985, 1954, 1967, 1979] + ) + ) + .select('title') + .execute(); + expectResults(results, { title: 'Pride and Prejudice' }); + }); + + it('arrayContains works', async () => { + const results = await randomCol + .pipeline() + .where(arrayContains('tags', 'comedy')) + .select('title') + .execute(); + expectResults(results, { + title: "The Hitchhiker's Guide to the Galaxy" + }); + }); + + it('arrayContainsAny works', async () => { + const results = await randomCol + .pipeline() + .where(arrayContainsAny('tags', ['comedy', 'classic'])) + .select('title') + .execute(); + expectResults( + results, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'Pride and Prejudice' } + ); + }); + + it('arrayContainsAll works', async () => { + const results = await randomCol + .pipeline() + .where(Field.of('tags').arrayContainsAll('adventure', 'magic')) + .select('title') + .execute(); + expectResults(results, { title: 'The Lord of the Rings' }); + }); + + it('arrayLength works', async () => { + const results = await randomCol + .pipeline() + .select(Field.of('tags').arrayLength().as('tagsCount')) + .where(eq('tagsCount', 3)) + .execute(); + expect(results.length).to.equal(10); + }); + + // skip: arrayConcat not supported + // it.skip('arrayConcat works', async () => { + // const results = await randomCol + // .pipeline() + // .select( + // Field.of('tags').arrayConcat(['newTag1', 'newTag2']).as('modifiedTags') + // ) + // .limit(1) + // .execute(); + // expectResults(results, { + // modifiedTags: ['comedy', 'space', 'adventure', 'newTag1', 'newTag2'] + // }); + // }); + + it('testStrConcat', async () => { + const results = await randomCol + .pipeline() + .select( + Field.of('author') + .strConcat(' - ', Field.of('title')) + .as('bookInfo') + ) + .limit(1) + .execute(); + expectResults(results, { + bookInfo: "Douglas Adams - The Hitchhiker's Guide to the Galaxy" + }); + }); + + it('testStartsWith', async () => { + const results = await randomCol + .pipeline() + .where(startsWith('title', 'The')) + .select('title') + .sort(Field.of('title').ascending()) + .execute(); + expectResults( + results, + { title: 'The Great Gatsby' }, + { title: "The Handmaid's Tale" }, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'The Lord of the Rings' } + ); + }); + + it('testEndsWith', async () => { + const results = await randomCol + .pipeline() + .where(endsWith('title', 'y')) + .select('title') + .sort(Field.of('title').descending()) + .execute(); + expectResults( + results, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'The Great Gatsby' } + ); + }); + + it('testLength', async () => { + const results = await randomCol + .pipeline() + .select( + Field.of('title').charLength().as('titleLength'), + Field.of('title') + ) + .where(gt('titleLength', 20)) + .sort(Field.of('title').ascending()) + .execute(); + + expectResults( + results, + + { + titleLength: 29, + title: 'One Hundred Years of Solitude' }, - 'array': [1, 'c string'] - }).as('map'), - Constant.of([ - 1, - 'a string', - true, - null, - new GeoPoint(0.1, 0.2), - refTimestamp, - refDate, - Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])), - doc(firestore, 'foo', 'bar'), - vector([1, 2, 3]), { - 'number': 2, - 'string': 'b string' - } - ]).as('array') - ]; - - const results = await randomCol - .pipeline() - .limit(1) - .select(...constants) - .execute(); - - expectResults(results, { - 'number': 1, - 'string': 'a string', - 'boolean': true, - 'null': null, - 'geoPoint': new GeoPoint(0.1, 0.2), - 'timestamp': refTimestamp, - 'date': Timestamp.fromDate(refDate), - 'bytes': Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])), - 'documentReference': doc(firestore, 'foo', 'bar'), - 'vectorValue': vector([1, 2, 3]), - 'map': { - 'number': 1, - 'string': 'a string', - 'boolean': true, - 'null': null, - 'geoPoint': new GeoPoint(0.1, 0.2), - 'timestamp': refTimestamp, - 'date': Timestamp.fromDate(refDate), - 'uint8Array': Bytes.fromUint8Array( - new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0]) - ), - 'documentReference': doc(firestore, 'foo', 'bar'), - 'vectorValue': vector([1, 2, 3]), - 'map': { - 'number': 2, - 'string': 'b string' + titleLength: 36, + title: "The Hitchhiker's Guide to the Galaxy" + }, + { + titleLength: 21, + title: 'The Lord of the Rings' }, - 'array': [1, 'c string'] - }, - 'array': [ - 1, - 'a string', - true, - null, - new GeoPoint(0.1, 0.2), - refTimestamp, - Timestamp.fromDate(refDate), - Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])), - doc(firestore, 'foo', 'bar'), - vector([1, 2, 3]), { - 'number': 2, - 'string': 'b string' + titleLength: 21, + title: 'To Kill a Mockingbird' } - ] + ); }); - }); - it('cond works', async () => { - const results = await randomCol - .pipeline() - .select( - 'title', - cond( - lt(Field.of('published'), 1960), - Constant.of(1960), - Field.of('published') - ).as('published-safe') - ) - .sort(Field.of('title').ascending()) - .limit(3) - .execute(); - expectResults( - results, - { title: '1984', 'published-safe': 1960 }, - { title: 'Crime and Punishment', 'published-safe': 1960 }, - { title: 'Dune', 'published-safe': 1965 } - ); - }); + // skip: toLower not supported + // it.skip('testToLowercase', async () => { + // const results = await randomCol + // .pipeline() + // .select(Field.of('title').toLower().as('lowercaseTitle')) + // .limit(1) + // .execute(); + // expectResults(results, { + // lowercaseTitle: "the hitchhiker's guide to the galaxy" + // }); + // }); + + // skip: toUpper not supported + // it.skip('testToUppercase', async () => { + // const results = await randomCol + // .pipeline() + // .select(Field.of('author').toUpper().as('uppercaseAuthor')) + // .limit(1) + // .execute(); + // expectResults(results, { uppercaseAuthor: 'DOUGLAS ADAMS' }); + // }); + + // skip: trim not supported + // it.skip('testTrim', async () => { + // const results = await randomCol + // .pipeline() + // .addFields(strConcat(' ', Field.of('title'), ' ').as('spacedTitle')) + // .select( + // Field.of('spacedTitle').trim().as('trimmedTitle'), + // Field.of('spacedTitle') + // ) + // .limit(1) + // .execute(); + // expectResults(results, { + // spacedTitle: " The Hitchhiker's Guide to the Galaxy ", + // trimmedTitle: "The Hitchhiker's Guide to the Galaxy" + // }); + // }); + + it('testLike', async () => { + const results = await randomCol + .pipeline() + .where(like('title', '%Guide%')) + .select('title') + .execute(); + expectResults(results, { + title: "The Hitchhiker's Guide to the Galaxy" + }); + }); - it('eqAny works', async () => { - const results = await randomCol - .pipeline() - .where(eqAny('published', [1979, 1999, 1967])) - .select('title') - .execute(); - expectResults( - results, - { title: "The Hitchhiker's Guide to the Galaxy" }, - { title: 'One Hundred Years of Solitude' } - ); - }); + it('testRegexContains', async () => { + const results = await randomCol + .pipeline() + .where(regexContains('title', '(?i)(the|of)')) + .execute(); + expect(results.length).to.equal(5); + }); - it('notEqAny works', async () => { - const results = await randomCol - .pipeline() - .where( - notEqAny( - 'published', - [1965, 1925, 1949, 1960, 1866, 1985, 1954, 1967, 1979] + it('testRegexMatches', async () => { + const results = await randomCol + .pipeline() + .where(regexMatch('title', '.*(?i)(the|of).*')) + .execute(); + expect(results.length).to.equal(5); + }); + + it('testArithmeticOperations', async () => { + const results = await randomCol + .pipeline() + .select( + add(Field.of('rating'), 1).as('ratingPlusOne'), + subtract(Field.of('published'), 1900).as('yearsSince1900'), + Field.of('rating').multiply(10).as('ratingTimesTen'), + Field.of('rating').divide(2).as('ratingDividedByTwo') ) - ) - .select('title') - .execute(); - expectResults(results, { title: 'Pride and Prejudice' }); - }); + .limit(1) + .execute(); + expectResults(results, { + ratingPlusOne: 5.2, + yearsSince1900: 79, + ratingTimesTen: 42, + ratingDividedByTwo: 2.1 + }); + }); - it('arrayContains works', async () => { - const results = await randomCol - .pipeline() - .where(arrayContains('tags', 'comedy')) - .select('title') - .execute(); - expectResults(results, { title: "The Hitchhiker's Guide to the Galaxy" }); - }); + it('testComparisonOperators', async () => { + const results = await randomCol + .pipeline() + .where( + andFunction( + gt('rating', 4.2), + lte(Field.of('rating'), 4.5), + neq('genre', 'Science Fiction') + ) + ) + .select('rating', 'title') + .sort(Field.of('title').ascending()) + .execute(); + expectResults( + results, + { rating: 4.3, title: 'Crime and Punishment' }, + { + rating: 4.3, + title: 'One Hundred Years of Solitude' + }, + { rating: 4.5, title: 'Pride and Prejudice' } + ); + }); - it('arrayContainsAny works', async () => { - const results = await randomCol - .pipeline() - .where(arrayContainsAny('tags', ['comedy', 'classic'])) - .select('title') - .execute(); - expectResults( - results, - { title: "The Hitchhiker's Guide to the Galaxy" }, - { title: 'Pride and Prejudice' } - ); - }); + it('testLogicalOperators', async () => { + const results = await randomCol + .pipeline() + .where( + orFunction( + andFunction(gt('rating', 4.5), eq('genre', 'Science Fiction')), + lt('published', 1900) + ) + ) + .select('title') + .sort(Field.of('title').ascending()) + .execute(); + expectResults( + results, + { title: 'Crime and Punishment' }, + { title: 'Dune' }, + { title: 'Pride and Prejudice' } + ); + }); - it('arrayContainsAll works', async () => { - const results = await randomCol - .pipeline() - .where(Field.of('tags').arrayContainsAll('adventure', 'magic')) - .select('title') - .execute(); - expectResults(results, { title: 'The Lord of the Rings' }); - }); + it('testChecks', async () => { + const results = await randomCol + .pipeline() + .where(not(Field.of('rating').isNaN())) + .select( + Field.of('rating').eq(null).as('ratingIsNull'), + not(Field.of('rating').isNaN()).as('ratingIsNotNaN') + ) + .limit(1) + .execute(); + expectResults(results, { ratingIsNull: false, ratingIsNotNaN: true }); + }); + + it('testMapGet', async () => { + const results = await randomCol + .pipeline() + .select( + Field.of('awards').mapGet('hugo').as('hugoAward'), + Field.of('awards').mapGet('others').as('others'), + Field.of('title') + ) + .where(eq('hugoAward', true)) + .execute(); + expectResults( + results, + { + hugoAward: true, + title: "The Hitchhiker's Guide to the Galaxy", + others: { unknown: { year: 1980 } } + }, + { hugoAward: true, title: 'Dune', others: null } + ); + }); + + // it('testParent', async () => { + // const results = await randomCol + // .pipeline() + // .select( + // parent(randomCol.doc('chile').collection('subCollection').path).as( + // 'parent' + // ) + // ) + // .limit(1) + // .execute(); + // expect(results[0].data().parent.endsWith('/books')).to.be.true; + // }); + // + // it('testCollectionId', async () => { + // const results = await randomCol + // .pipeline() + // .select(collectionId(randomCol.doc('chile')).as('collectionId')) + // .limit(1) + // .execute(); + // expectResults(results, {collectionId: 'books'}); + // }); + + it('testDistanceFunctions', async () => { + const sourceVector = [0.1, 0.1]; + const targetVector = [0.5, 0.8]; + const results = await randomCol + .pipeline() + .select( + cosineDistance(Constant.vector(sourceVector), targetVector).as( + 'cosineDistance' + ), + dotProduct(Constant.vector(sourceVector), targetVector).as( + 'dotProductDistance' + ), + euclideanDistance(Constant.vector(sourceVector), targetVector).as( + 'euclideanDistance' + ) + ) + .limit(1) + .execute(); + + expectResults(results, { + cosineDistance: 0.02560880430538015, + dotProductDistance: 0.13, + euclideanDistance: 0.806225774829855 + }); + }); + + it('testNestedFields', async () => { + const results = await randomCol + .pipeline() + .where(eq('awards.hugo', true)) + .select('title', 'awards.hugo') + .execute(); + expectResults( + results, + { + title: "The Hitchhiker's Guide to the Galaxy", + 'awards.hugo': true + }, + { title: 'Dune', 'awards.hugo': true } + ); + }); + + it('test mapGet with field name including . notation', async () => { + const results = await randomCol + .pipeline() + .where(eq('awards.hugo', true)) + .select( + 'title', + Field.of('nestedField.level.1'), + mapGet('nestedField', 'level.1').mapGet('level.2').as('nested') + ) + .execute(); + expectResults( + results, + { + title: "The Hitchhiker's Guide to the Galaxy", + 'nestedField.level.`1`': null, + nested: true + }, + { title: 'Dune', 'nestedField.level.`1`': null, nested: null } + ); + }); - it('arrayLength works', async () => { - const results = await randomCol - .pipeline() - .select(Field.of('tags').arrayLength().as('tagsCount')) - .where(eq('tagsCount', 3)) - .execute(); - expect(results.length).to.equal(10); + it('supports internal serialization to proto', async () => { + const pipeline = firestore + .pipeline() + .collection('books') + .where(eq('awards.hugo', true)) + .select( + 'title', + Field.of('nestedField.level.1'), + mapGet('nestedField', 'level.1').mapGet('level.2').as('nested') + ); + + const proto = _internalPipelineToExecutePipelineRequestProto(pipeline); + expect(proto).not.to.be.null; + }); + + describe('pagination', () => { + async function addBooks( + collection: CollectionReference + ): Promise { + await setDoc(doc(randomCol, 'book11'), { + title: 'Jonathan Strange & Mr Norrell', + author: 'Susanna Clarke', + genre: 'Fantasy', + published: 2004, + rating: 4.6, + tags: [ + 'historical fantasy', + 'magic', + 'alternate history', + 'england' + ], + awards: { hugo: false, nebula: false } + }); + await setDoc(doc(randomCol, 'book12'), { + title: 'The Master and Margarita', + author: 'Mikhail Bulgakov', + genre: 'Satire', + published: 1967, // Though written much earlier + rating: 4.6, + tags: [ + 'russian literature', + 'supernatural', + 'philosophy', + 'dark comedy' + ], + awards: {} + }); + await setDoc(doc(randomCol, 'book13'), { + title: 'A Long Way to a Small, Angry Planet', + author: 'Becky Chambers', + genre: 'Science Fiction', + published: 2014, + rating: 4.6, + tags: [ + 'space opera', + 'found family', + 'character-driven', + 'optimistic' + ], + awards: { hugo: false, nebula: false, kitschies: true } + }); + } + + it('supports pagination with filters', async () => { + await addBooks(randomCol); + const pageSize = 2; + const pipeline = randomCol + .pipeline() + .select('title', 'rating', '__name__') + .sort( + Field.of('rating').descending(), + Field.of('__name__').ascending() + ); + + let results = await pipeline.limit(pageSize).execute(); + expectResults( + results, + { title: 'The Lord of the Rings', rating: 4.7 }, + { title: 'Jonathan Strange & Mr Norrell', rating: 4.6 } + ); + + const lastDoc = results[results.length - 1]; + + results = await pipeline + .where( + orFunction( + andFunction( + Field.of('rating').eq(lastDoc.get('rating')), + Field.of('__path__').gt(lastDoc.ref?.path) + ), + Field.of('rating').lt(lastDoc.get('rating')) + ) + ) + .limit(pageSize) + .execute(); + expectResults( + results, + { title: 'Pride and Prejudice', rating: 4.5 }, + { title: 'Crime and Punishment', rating: 4.3 } + ); + }); + + it('supports pagination with offsets', async () => { + await addBooks(randomCol); + + const secondFilterField = '__path__'; + + const pipeline = randomCol + .pipeline() + .select('title', 'rating', secondFilterField) + .sort( + Field.of('rating').descending(), + Field.of(secondFilterField).ascending() + ); + + const pageSize = 2; + let currPage = 0; + + let results = await pipeline + .offset(currPage++ * pageSize) + .limit(pageSize) + .execute(); + + expectResults( + results, + { + title: 'The Lord of the Rings', + rating: 4.7 + }, + { title: 'Dune', rating: 4.6 } + ); + + results = await pipeline + .offset(currPage++ * pageSize) + .limit(pageSize) + .execute(); + expectResults( + results, + { + title: 'Jonathan Strange & Mr Norrell', + rating: 4.6 + }, + { title: 'The Master and Margarita', rating: 4.6 } + ); + + results = await pipeline + .offset(currPage++ * pageSize) + .limit(pageSize) + .execute(); + expectResults( + results, + { + title: 'A Long Way to a Small, Angry Planet', + rating: 4.6 + }, + { + title: 'Pride and Prejudice', + rating: 4.5 + } + ); + }); + }); }); - // skip: arrayConcat not supported - // it.skip('arrayConcat works', async () => { - // const results = await randomCol - // .pipeline() - // .select( - // Field.of('tags').arrayConcat(['newTag1', 'newTag2']).as('modifiedTags') - // ) - // .limit(1) - // .execute(); - // expectResults(results, { - // modifiedTags: ['comedy', 'space', 'adventure', 'newTag1', 'newTag2'] - // }); - // }); - - it('testStrConcat', async () => { - const results = await randomCol - .pipeline() - .select( - Field.of('author').strConcat(' - ', Field.of('title')).as('bookInfo') - ) - .limit(1) - .execute(); - expectResults(results, { - bookInfo: "Douglas Adams - The Hitchhiker's Guide to the Galaxy" + describe('modular API', () => { + it('works when creating a pipeline from a Firestore instance', async () => { + const myPipeline = pipeline(firestore) + .collection(randomCol.path) + .where(lt(Field.of('published'), 1984)) + .aggregate({ + accumulators: [avgFunction('rating').as('avgRating')], + groups: ['genre'] + }) + .where(gt('avgRating', 4.3)) + .sort(Field.of('avgRating').descending()); + + const results = await execute(myPipeline); + + expectResults( + results, + { avgRating: 4.7, genre: 'Fantasy' }, + { avgRating: 4.5, genre: 'Romance' }, + { avgRating: 4.4, genre: 'Science Fiction' } + ); + }); + + it('works when creating a pipeline from a collection', async () => { + const myPipeline = pipeline(randomCol) + .where(lt(Field.of('published'), 1984)) + .aggregate({ + accumulators: [avgFunction('rating').as('avgRating')], + groups: ['genre'] + }) + .where(gt('avgRating', 4.3)) + .sort(Field.of('avgRating').descending()); + + const results = await execute(myPipeline); + + expectResults( + results, + { avgRating: 4.7, genre: 'Fantasy' }, + { avgRating: 4.5, genre: 'Romance' }, + { avgRating: 4.4, genre: 'Science Fiction' } + ); }); }); + }); - it('testStartsWith', async () => { - const results = await randomCol - .pipeline() - .where(startsWith('title', 'The')) - .select('title') - .sort(Field.of('title').ascending()) - .execute(); - expectResults( - results, - { title: 'The Great Gatsby' }, - { title: "The Handmaid's Tale" }, - { title: "The Hitchhiker's Guide to the Galaxy" }, - { title: 'The Lord of the Rings' } + // This is the Query integration tests from the lite API (no cache support) + // with some additional test cases added for more complete coverage. + describe('Query to Pipeline', () => { + function verifyResults( + actual: Array>, + ...expected: DocumentData[] + ): void { + expect(actual.length).to.equal(expected.length); + + for (let i = 0; i < expected.length; ++i) { + expect(actual[i].data()).to.deep.equal(expected[i]); + } + } + + it('supports default query', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { 1: { foo: 1 } }, + async collRef => { + const result = await collRef.pipeline().execute(); + verifyResults(result, { foo: 1 }); + } ); }); - it('testEndsWith', async () => { - const results = await randomCol - .pipeline() - .where(endsWith('title', 'y')) - .select('title') - .sort(Field.of('title').descending()) - .execute(); - expectResults( - results, - { title: "The Hitchhiker's Guide to the Galaxy" }, - { title: 'The Great Gatsby' } + it('supports filtered query', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 } + }, + async collRef => { + const query1 = query(collRef, where('foo', '==', 1)); + const result = await query1.pipeline().execute(); + verifyResults(result, { foo: 1 }); + } ); }); - it('testLength', async () => { - const results = await randomCol - .pipeline() - .select( - Field.of('title').charLength().as('titleLength'), - Field.of('title') - ) - .where(gt('titleLength', 20)) - .sort(Field.of('title').ascending()) - .execute(); - - expectResults( - results, - + it('supports filtered query (with FieldPath)', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, { - titleLength: 29, - title: 'One Hundred Years of Solitude' + 1: { foo: 1 }, + 2: { foo: 2 } }, + async collRef => { + const query1 = query(collRef, where(new FieldPath('foo'), '==', 1)); + const result = await query1.pipeline().execute(); + verifyResults(result, { foo: 1 }); + } + ); + }); + + it('supports ordered query (with default order)', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, { - titleLength: 36, - title: "The Hitchhiker's Guide to the Galaxy" + 1: { foo: 1 }, + 2: { foo: 2 } }, + async collRef => { + const query1 = query(collRef, orderBy('foo')); + const result = await query1.pipeline().execute(); + verifyResults(result, { foo: 1 }, { foo: 2 }); + } + ); + }); + + it('supports ordered query (with asc)', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, { - titleLength: 21, - title: 'The Lord of the Rings' + 1: { foo: 1 }, + 2: { foo: 2 } }, - { - titleLength: 21, - title: 'To Kill a Mockingbird' + async collRef => { + const query1 = query(collRef, orderBy('foo', 'asc')); + const result = await query1.pipeline().execute(); + verifyResults(result, { foo: 1 }, { foo: 2 }); } ); }); - // skip: toLower not supported - // it.skip('testToLowercase', async () => { - // const results = await randomCol - // .pipeline() - // .select(Field.of('title').toLower().as('lowercaseTitle')) - // .limit(1) - // .execute(); - // expectResults(results, { - // lowercaseTitle: "the hitchhiker's guide to the galaxy" - // }); - // }); - - // skip: toUpper not supported - // it.skip('testToUppercase', async () => { - // const results = await randomCol - // .pipeline() - // .select(Field.of('author').toUpper().as('uppercaseAuthor')) - // .limit(1) - // .execute(); - // expectResults(results, { uppercaseAuthor: 'DOUGLAS ADAMS' }); - // }); - - // skip: trim not supported - // it.skip('testTrim', async () => { - // const results = await randomCol - // .pipeline() - // .addFields(strConcat(' ', Field.of('title'), ' ').as('spacedTitle')) - // .select( - // Field.of('spacedTitle').trim().as('trimmedTitle'), - // Field.of('spacedTitle') - // ) - // .limit(1) - // .execute(); - // expectResults(results, { - // spacedTitle: " The Hitchhiker's Guide to the Galaxy ", - // trimmedTitle: "The Hitchhiker's Guide to the Galaxy" - // }); - // }); - - it('testLike', async () => { - const results = await randomCol - .pipeline() - .where(like('title', '%Guide%')) - .select('title') - .execute(); - expectResults(results, { title: "The Hitchhiker's Guide to the Galaxy" }); + it('supports ordered query (with desc)', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 } + }, + async collRef => { + const query1 = query(collRef, orderBy('foo', 'desc')); + const result = await query1.pipeline().execute(); + verifyResults(result, { foo: 2 }, { foo: 1 }); + } + ); }); - it('testRegexContains', async () => { - const results = await randomCol - .pipeline() - .where(regexContains('title', '(?i)(the|of)')) - .execute(); - expect(results.length).to.equal(5); + it('supports limit query', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 } + }, + async collRef => { + const query1 = query(collRef, orderBy('foo'), limit(1)); + const result = await query1.pipeline().execute(); + verifyResults(result, { foo: 1 }); + } + ); }); - it('testRegexMatches', async () => { - const results = await randomCol - .pipeline() - .where(regexMatch('title', '.*(?i)(the|of).*')) - .execute(); - expect(results.length).to.equal(5); + it('supports limitToLast query', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 }, + 3: { foo: 3 } + }, + async collRef => { + const query1 = query(collRef, orderBy('foo'), limitToLast(2)); + const result = await query1.pipeline().execute(); + verifyResults(result, { foo: 2 }, { foo: 3 }); + } + ); }); - it('testArithmeticOperations', async () => { - const results = await randomCol - .pipeline() - .select( - add(Field.of('rating'), 1).as('ratingPlusOne'), - subtract(Field.of('published'), 1900).as('yearsSince1900'), - Field.of('rating').multiply(10).as('ratingTimesTen'), - Field.of('rating').divide(2).as('ratingDividedByTwo') - ) - .limit(1) - .execute(); - expectResults(results, { - ratingPlusOne: 5.2, - yearsSince1900: 79, - ratingTimesTen: 42, - ratingDividedByTwo: 2.1 - }); + it('supports startAt', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 } + }, + async collRef => { + const query1 = query(collRef, orderBy('foo'), startAt(2)); + const result = await query1.pipeline().execute(); + verifyResults(result, { foo: 2 }); + } + ); }); - it('testComparisonOperators', async () => { - const results = await randomCol - .pipeline() - .where( - andFunction( - gt('rating', 4.2), - lte(Field.of('rating'), 4.5), - neq('genre', 'Science Fiction') - ) - ) - .select('rating', 'title') - .sort(Field.of('title').ascending()) - .execute(); - expectResults( - results, - { rating: 4.3, title: 'Crime and Punishment' }, + it('supports startAfter (with DocumentReference)', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, { - rating: 4.3, - title: 'One Hundred Years of Solitude' + 1: { id: 1, foo: 1, bar: 1, baz: 1 }, + 2: { id: 2, foo: 1, bar: 1, baz: 2 }, + 3: { id: 3, foo: 1, bar: 1, baz: 2 }, + 4: { id: 4, foo: 1, bar: 2, baz: 1 }, + 5: { id: 5, foo: 1, bar: 2, baz: 2 }, + 6: { id: 6, foo: 1, bar: 2, baz: 2 }, + 7: { id: 7, foo: 2, bar: 1, baz: 1 }, + 8: { id: 8, foo: 2, bar: 1, baz: 2 }, + 9: { id: 9, foo: 2, bar: 1, baz: 2 }, + 10: { id: 10, foo: 2, bar: 2, baz: 1 }, + 11: { id: 11, foo: 2, bar: 2, baz: 2 }, + 12: { id: 12, foo: 2, bar: 2, baz: 2 } }, - { rating: 4.5, title: 'Pride and Prejudice' } + async collRef => { + let docRef = await getDoc(doc(collRef, '2')); + let query1 = query( + collRef, + orderBy('foo'), + orderBy('bar'), + orderBy('baz'), + startAfter(docRef) + ); + let result = await query1.pipeline().execute(); + verifyResults( + result, + { id: 3, foo: 1, bar: 1, baz: 2 }, + { id: 4, foo: 1, bar: 2, baz: 1 }, + { id: 5, foo: 1, bar: 2, baz: 2 }, + { id: 6, foo: 1, bar: 2, baz: 2 }, + { id: 7, foo: 2, bar: 1, baz: 1 }, + { id: 8, foo: 2, bar: 1, baz: 2 }, + { id: 9, foo: 2, bar: 1, baz: 2 }, + { id: 10, foo: 2, bar: 2, baz: 1 }, + { id: 11, foo: 2, bar: 2, baz: 2 }, + { id: 12, foo: 2, bar: 2, baz: 2 } + ); + + docRef = await getDoc(doc(collRef, '3')); + query1 = query( + collRef, + orderBy('foo'), + orderBy('bar'), + orderBy('baz'), + startAfter(docRef) + ); + result = await query1.pipeline().execute(); + verifyResults( + result, + { id: 4, foo: 1, bar: 2, baz: 1 }, + { id: 5, foo: 1, bar: 2, baz: 2 }, + { id: 6, foo: 1, bar: 2, baz: 2 }, + { id: 7, foo: 2, bar: 1, baz: 1 }, + { id: 8, foo: 2, bar: 1, baz: 2 }, + { id: 9, foo: 2, bar: 1, baz: 2 }, + { id: 10, foo: 2, bar: 2, baz: 1 }, + { id: 11, foo: 2, bar: 2, baz: 2 }, + { id: 12, foo: 2, bar: 2, baz: 2 } + ); + } ); }); - it('testLogicalOperators', async () => { - const results = await randomCol - .pipeline() - .where( - orFunction( - andFunction(gt('rating', 4.5), eq('genre', 'Science Fiction')), - lt('published', 1900) - ) - ) - .select('title') - .sort(Field.of('title').ascending()) - .execute(); - expectResults( - results, - { title: 'Crime and Punishment' }, - { title: 'Dune' }, - { title: 'Pride and Prejudice' } + it('supports startAt (with DocumentReference)', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { id: 1, foo: 1, bar: 1, baz: 1 }, + 2: { id: 2, foo: 1, bar: 1, baz: 2 }, + 3: { id: 3, foo: 1, bar: 1, baz: 2 }, + 4: { id: 4, foo: 1, bar: 2, baz: 1 }, + 5: { id: 5, foo: 1, bar: 2, baz: 2 }, + 6: { id: 6, foo: 1, bar: 2, baz: 2 }, + 7: { id: 7, foo: 2, bar: 1, baz: 1 }, + 8: { id: 8, foo: 2, bar: 1, baz: 2 }, + 9: { id: 9, foo: 2, bar: 1, baz: 2 }, + 10: { id: 10, foo: 2, bar: 2, baz: 1 }, + 11: { id: 11, foo: 2, bar: 2, baz: 2 }, + 12: { id: 12, foo: 2, bar: 2, baz: 2 } + }, + async collRef => { + let docRef = await getDoc(doc(collRef, '2')); + let query1 = query( + collRef, + orderBy('foo'), + orderBy('bar'), + orderBy('baz'), + startAt(docRef) + ); + let result = await query1.pipeline().execute(); + verifyResults( + result, + { id: 2, foo: 1, bar: 1, baz: 2 }, + { id: 3, foo: 1, bar: 1, baz: 2 }, + { id: 4, foo: 1, bar: 2, baz: 1 }, + { id: 5, foo: 1, bar: 2, baz: 2 }, + { id: 6, foo: 1, bar: 2, baz: 2 }, + { id: 7, foo: 2, bar: 1, baz: 1 }, + { id: 8, foo: 2, bar: 1, baz: 2 }, + { id: 9, foo: 2, bar: 1, baz: 2 }, + { id: 10, foo: 2, bar: 2, baz: 1 }, + { id: 11, foo: 2, bar: 2, baz: 2 }, + { id: 12, foo: 2, bar: 2, baz: 2 } + ); + + docRef = await getDoc(doc(collRef, '3')); + query1 = query( + collRef, + orderBy('foo'), + orderBy('bar'), + orderBy('baz'), + startAt(docRef) + ); + result = await query1.pipeline().execute(); + verifyResults( + result, + { id: 3, foo: 1, bar: 1, baz: 2 }, + { id: 4, foo: 1, bar: 2, baz: 1 }, + { id: 5, foo: 1, bar: 2, baz: 2 }, + { id: 6, foo: 1, bar: 2, baz: 2 }, + { id: 7, foo: 2, bar: 1, baz: 1 }, + { id: 8, foo: 2, bar: 1, baz: 2 }, + { id: 9, foo: 2, bar: 1, baz: 2 }, + { id: 10, foo: 2, bar: 2, baz: 1 }, + { id: 11, foo: 2, bar: 2, baz: 2 }, + { id: 12, foo: 2, bar: 2, baz: 2 } + ); + } ); }); - it('testChecks', async () => { - const results = await randomCol - .pipeline() - .where(not(Field.of('rating').isNaN())) - .select( - Field.of('rating').eq(null).as('ratingIsNull'), - not(Field.of('rating').isNaN()).as('ratingIsNotNaN') - ) - .limit(1) - .execute(); - expectResults(results, { ratingIsNull: false, ratingIsNotNaN: true }); + it('supports startAfter', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 } + }, + async collRef => { + const query1 = query(collRef, orderBy('foo'), startAfter(1)); + const result = await query1.pipeline().execute(); + verifyResults(result, { foo: 2 }); + } + ); }); - it('testMapGet', async () => { - const results = await randomCol - .pipeline() - .select( - Field.of('awards').mapGet('hugo').as('hugoAward'), - Field.of('awards').mapGet('others').as('others'), - Field.of('title') - ) - .where(eq('hugoAward', true)) - .execute(); - expectResults( - results, + it('supports endAt', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, { - hugoAward: true, - title: "The Hitchhiker's Guide to the Galaxy", - others: { unknown: { year: 1980 } } + 1: { foo: 1 }, + 2: { foo: 2 } }, - { hugoAward: true, title: 'Dune', others: null } + async collRef => { + const query1 = query(collRef, orderBy('foo'), endAt(1)); + const result = await query1.pipeline().execute(); + verifyResults(result, { foo: 1 }); + } ); }); - // it('testParent', async () => { - // const results = await randomCol - // .pipeline() - // .select( - // parent(randomCol.doc('chile').collection('subCollection').path).as( - // 'parent' - // ) - // ) - // .limit(1) - // .execute(); - // expect(results[0].data().parent.endsWith('/books')).to.be.true; - // }); - // - // it('testCollectionId', async () => { - // const results = await randomCol - // .pipeline() - // .select(collectionId(randomCol.doc('chile')).as('collectionId')) - // .limit(1) - // .execute(); - // expectResults(results, {collectionId: 'books'}); - // }); - - it('testDistanceFunctions', async () => { - const sourceVector = [0.1, 0.1]; - const targetVector = [0.5, 0.8]; - const results = await randomCol - .pipeline() - .select( - cosineDistance(Constant.vector(sourceVector), targetVector).as( - 'cosineDistance' - ), - dotProduct(Constant.vector(sourceVector), targetVector).as( - 'dotProductDistance' - ), - euclideanDistance(Constant.vector(sourceVector), targetVector).as( - 'euclideanDistance' - ) - ) - .limit(1) - .execute(); - - expectResults(results, { - cosineDistance: 0.02560880430538015, - dotProductDistance: 0.13, - euclideanDistance: 0.806225774829855 - }); + it('supports endBefore', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 } + }, + async collRef => { + const query1 = query(collRef, orderBy('foo'), endBefore(2)); + const result = await query1.pipeline().execute(); + verifyResults(result, { foo: 1 }); + } + ); }); - it('testNestedFields', async () => { - const results = await randomCol - .pipeline() - .where(eq('awards.hugo', true)) - .select('title', 'awards.hugo') - .execute(); - expectResults( - results, - { title: "The Hitchhiker's Guide to the Galaxy", 'awards.hugo': true }, - { title: 'Dune', 'awards.hugo': true } + it('supports pagination', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 } + }, + async collRef => { + let query1 = query(collRef, orderBy('foo'), limit(1)); + const pipeline1 = query1.pipeline(); + let result = await pipeline1.execute(); + verifyResults(result, { foo: 1 }); + + // Pass the document snapshot from the previous result + query1 = query(query1, startAfter(result[0].get('foo'))); + result = await query1.pipeline().execute(); + verifyResults(result, { foo: 2 }); + } ); }); - it('test mapGet with field name including . notation', async () => { - const results = await randomCol - .pipeline() - .where(eq('awards.hugo', true)) - .select( - 'title', - Field.of('nestedField.level.1'), - mapGet('nestedField', 'level.1').mapGet('level.2').as('nested') - ) - .execute(); - expectResults( - results, + it('supports pagination on DocumentIds', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, { - title: "The Hitchhiker's Guide to the Galaxy", - 'nestedField.level.`1`': null, - nested: true + 1: { foo: 1 }, + 2: { foo: 2 } }, - { title: 'Dune', 'nestedField.level.`1`': null, nested: null } + async collRef => { + let query1 = query( + collRef, + orderBy('foo'), + orderBy(documentId(), 'asc'), + limit(1) + ); + const pipeline1 = query1.pipeline(); + let result = await pipeline1.execute(); + verifyResults(result, { foo: 1 }); + + // Pass the document snapshot from the previous result + query1 = query( + query1, + startAfter(result[0].get('foo'), result[0].ref?.id) + ); + result = await query1.pipeline().execute(); + verifyResults(result, { foo: 2 }); + } ); }); - it('supports internal serialization to proto', async () => { - const pipeline = firestore - .pipeline() - .collection('books') - .where(eq('awards.hugo', true)) - .select( - 'title', - Field.of('nestedField.level.1'), - mapGet('nestedField', 'level.1').mapGet('level.2').as('nested') - ); - - const proto = _internalPipelineToExecutePipelineRequestProto(pipeline); - expect(proto).not.to.be.null; + it('supports collection groups', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + {}, + async collRef => { + const collectionGroupId = `${collRef.id}group`; + + const fooDoc = doc( + collRef.firestore, + `${collRef.id}/foo/${collectionGroupId}/doc1` + ); + const barDoc = doc( + collRef.firestore, + `${collRef.id}/bar/baz/boo/${collectionGroupId}/doc2` + ); + await setDoc(fooDoc, { foo: 1 }); + await setDoc(barDoc, { bar: 1 }); + + const query1 = collectionGroup(collRef.firestore, collectionGroupId); + const result = await query1.pipeline().execute(); + + verifyResults(result, { bar: 1 }, { foo: 1 }); + } + ); }); - // TODO(pipeline) support converter - // it('pipeline converter works', async () => { - // interface AppModel {myTitle: string; myAuthor: string; myPublished: number} - // const converter: FirestorePipelineConverter = { - // fromFirestore(result: FirebaseFirestore.PipelineResult): AppModel { - // return { - // myTitle: result.data()!.title as string, - // myAuthor: result.data()!.author as string, - // myPublished: result.data()!.published as number, - // }; - // }, - // }; - // - // const results = await firestore - // .pipeline() - // .collection(randomCol.path) - // .sort(Field.of('published').ascending()) - // .limit(2) - // .withConverter(converter) - // .execute(); - // - // const objs = results.map(r => r.data()); - // expect(objs[0]).to.deep.equal({ - // myAuthor: 'Jane Austen', - // myPublished: 1813, - // myTitle: 'Pride and Prejudice', - // }); - // expect(objs[1]).to.deep.equal({ - // myAuthor: 'Fyodor Dostoevsky', - // myPublished: 1866, - // myTitle: 'Crime and Punishment', - // }); - // }); - }); + it('supports query over collection path with special characters', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + {}, + async collRef => { + const docWithSpecials = doc(collRef, 'so!@#$%^&*()_+special'); + + const collectionWithSpecials = collection( + docWithSpecials, + 'so!@#$%^&*()_+special' + ); + await addDoc(collectionWithSpecials, { foo: 1 }); + await addDoc(collectionWithSpecials, { foo: 2 }); + + const result = await query( + collectionWithSpecials, + orderBy('foo', 'asc') + ) + .pipeline() + .execute(); - describe('modular API', () => { - it('works when creating a pipeline from a Firestore instance', async () => { - const myPipeline = pipeline(firestore) - .collection(randomCol.path) - .where(lt(Field.of('published'), 1984)) - .aggregate({ - accumulators: [avgFunction('rating').as('avgRating')], - groups: ['genre'] - }) - .where(gt('avgRating', 4.3)) - .sort(Field.of('avgRating').descending()); - - const results = await execute(myPipeline); - - expectResults( - results, - { avgRating: 4.7, genre: 'Fantasy' }, - { avgRating: 4.5, genre: 'Romance' }, - { avgRating: 4.4, genre: 'Science Fiction' } + verifyResults(result, { foo: 1 }, { foo: 2 }); + } + ); + }); + + it('supports multiple inequality on same field', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + '01': { id: 1, foo: 1, bar: 1, baz: 1 }, + '02': { id: 2, foo: 1, bar: 1, baz: 2 }, + '03': { id: 3, foo: 1, bar: 1, baz: 2 }, + '04': { id: 4, foo: 1, bar: 2, baz: 1 }, + '05': { id: 5, foo: 1, bar: 2, baz: 2 }, + '06': { id: 6, foo: 1, bar: 2, baz: 2 }, + '07': { id: 7, foo: 2, bar: 1, baz: 1 }, + '08': { id: 8, foo: 2, bar: 1, baz: 2 }, + '09': { id: 9, foo: 2, bar: 1, baz: 2 }, + '10': { id: 10, foo: 2, bar: 2, baz: 1 }, + '11': { id: 11, foo: 2, bar: 2, baz: 2 }, + '12': { id: 12, foo: 2, bar: 2, baz: 2 } + }, + async collRef => { + const query1 = query( + collRef, + and(where('id', '>', 2), where('id', '<=', 10)) + ); + const result = await query1.pipeline().execute(); + verifyResults( + result, + { id: 3, foo: 1, bar: 1, baz: 2 }, + { id: 4, foo: 1, bar: 2, baz: 1 }, + { id: 5, foo: 1, bar: 2, baz: 2 }, + { id: 6, foo: 1, bar: 2, baz: 2 }, + { id: 7, foo: 2, bar: 1, baz: 1 }, + { id: 8, foo: 2, bar: 1, baz: 2 }, + { id: 9, foo: 2, bar: 1, baz: 2 }, + { id: 10, foo: 2, bar: 2, baz: 1 } + ); + } ); }); - it('works when creating a pipeline from a collection', async () => { - const myPipeline = pipeline(randomCol) - .where(lt(Field.of('published'), 1984)) - .aggregate({ - accumulators: [avgFunction('rating').as('avgRating')], - groups: ['genre'] - }) - .where(gt('avgRating', 4.3)) - .sort(Field.of('avgRating').descending()); - - const results = await execute(myPipeline); - - expectResults( - results, - { avgRating: 4.7, genre: 'Fantasy' }, - { avgRating: 4.5, genre: 'Romance' }, - { avgRating: 4.4, genre: 'Science Fiction' } + it('supports multiple inequality on different fields', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + '01': { id: 1, foo: 1, bar: 1, baz: 1 }, + '02': { id: 2, foo: 1, bar: 1, baz: 2 }, + '03': { id: 3, foo: 1, bar: 1, baz: 2 }, + '04': { id: 4, foo: 1, bar: 2, baz: 1 }, + '05': { id: 5, foo: 1, bar: 2, baz: 2 }, + '06': { id: 6, foo: 1, bar: 2, baz: 2 }, + '07': { id: 7, foo: 2, bar: 1, baz: 1 }, + '08': { id: 8, foo: 2, bar: 1, baz: 2 }, + '09': { id: 9, foo: 2, bar: 1, baz: 2 }, + '10': { id: 10, foo: 2, bar: 2, baz: 1 }, + '11': { id: 11, foo: 2, bar: 2, baz: 2 }, + '12': { id: 12, foo: 2, bar: 2, baz: 2 } + }, + async collRef => { + const query1 = query( + collRef, + and(where('id', '>=', 2), where('baz', '<', 2)) + ); + const result = await query1.pipeline().execute(); + verifyResults( + result, + { id: 4, foo: 1, bar: 2, baz: 1 }, + { id: 7, foo: 2, bar: 1, baz: 1 }, + { id: 10, foo: 2, bar: 2, baz: 1 } + ); + } ); }); }); diff --git a/packages/firestore/test/integration/util/firebase_export.ts b/packages/firestore/test/integration/util/firebase_export.ts index f58b3ce045b..a6739dfe72f 100644 --- a/packages/firestore/test/integration/util/firebase_export.ts +++ b/packages/firestore/test/integration/util/firebase_export.ts @@ -51,4 +51,5 @@ export function newTestFirestore( } export * from '../../../src'; +export * from '../../../pipelines/pipelines'; export { PrivateSettings }; diff --git a/repo-scripts/prune-dts/extract-public-api.ts b/repo-scripts/prune-dts/extract-public-api.ts index c7517399565..4e3c0c3c1fc 100644 --- a/repo-scripts/prune-dts/extract-public-api.ts +++ b/repo-scripts/prune-dts/extract-public-api.ts @@ -141,7 +141,8 @@ export async function generateApi( typescriptDtsPath: string, rollupDtsPath: string, untrimmedRollupDtsPath: string, - publicDtsPath: string + publicDtsPath: string, + otherExportDtsPaths: string[] ): Promise { console.log(`Configuring API Extractor for ${packageName}`); writeTypeScriptConfig(packageRoot); @@ -160,7 +161,7 @@ export async function generateApi( }); console.log('Generated rollup DTS'); - pruneDts(rollupDtsPath, publicDtsPath); + pruneDts(rollupDtsPath, publicDtsPath, otherExportDtsPaths); console.log('Pruned DTS file'); await addBlankLines(publicDtsPath); console.log('Added blank lines after imports'); @@ -221,6 +222,13 @@ const argv = yargs 'The output file for the customer-facing .d.ts file that only ' + 'includes the public APIs', require: true + }, + otherExportsPublicDtsFiles: { + type: 'string', + desc: + 'Optional. A comma-separated list of customer-facing of .d.ts' + + 'files for other exports from this package.', + require: false } }) .parseSync(); @@ -231,5 +239,10 @@ void generateApi( path.resolve(argv.typescriptDts), path.resolve(argv.rollupDts), path.resolve(argv.untrimmedRollupDts), - path.resolve(argv.publicDts) + path.resolve(argv.publicDts), + argv.otherExportsPublicDtsFiles + ? argv.otherExportsPublicDtsFiles + .split(',') + .map(filePath => path.resolve(filePath)) + : [] ); diff --git a/repo-scripts/prune-dts/prune-dts.ts b/repo-scripts/prune-dts/prune-dts.ts index 70cfc2933bb..087d12a3d4b 100644 --- a/repo-scripts/prune-dts/prune-dts.ts +++ b/repo-scripts/prune-dts/prune-dts.ts @@ -18,6 +18,7 @@ import * as yargs from 'yargs'; import * as ts from 'typescript'; import * as fs from 'fs'; +import * as path from 'path'; import { ESLint } from 'eslint'; /** @@ -33,16 +34,32 @@ import { ESLint } from 'eslint'; * @param inputLocation The file path to the .d.ts produced by API explorer. * @param outputLocation The output location for the pruned .d.ts file. */ -export function pruneDts(inputLocation: string, outputLocation: string): void { +export function pruneDts( + inputLocation: string, + outputLocation: string, + otherExportFileLocations: string[] = [] +): void { const compilerOptions = {}; const host = ts.createCompilerHost(compilerOptions); - const program = ts.createProgram([inputLocation], compilerOptions, host); + const program = ts.createProgram( + [inputLocation, ...otherExportFileLocations], + compilerOptions, + host + ); const printer: ts.Printer = ts.createPrinter(); const sourceFile = program.getSourceFile(inputLocation)!; + const otherExportSourceFiles = otherExportFileLocations + .map(otherFileLocation => program.getSourceFile(otherFileLocation)) + .filter(value => value !== undefined) as ts.SourceFile[]; const result: ts.TransformationResult = ts.transform(sourceFile, [ - dropPrivateApiTransformer.bind(null, program, host) + dropPrivateApiTransformer.bind( + null, + program, + host, + otherExportSourceFiles + ) ]); const transformedSourceFile: ts.SourceFile = result.transformed[0]; let content = printer.printFile(transformedSourceFile); @@ -503,14 +520,59 @@ function extractExportedSymbol( return undefined; } +function findExternalExport( + typeChecker: ts.TypeChecker, + sourceFile: ts.SourceFile, + node: + | ts.InterfaceDeclaration + | ts.ClassDeclaration + | ts.TypeAliasDeclaration + | ts.EnumDeclaration, + otherExportSourceFiles: ts.SourceFile[] +): ts.SourceFile | undefined { + if (!node.name) return undefined; + + const localSymbolName = node.name.text; + + for (const otherExportSourceFile of otherExportSourceFiles) { + const otherExportedSymbols = typeChecker.getExportsOfModule( + typeChecker.getSymbolAtLocation(otherExportSourceFile)! + ); + + for (const symbol of otherExportedSymbols) { + // TODO: ideally this would compare definitions to handle the case + // of name collisions with different definitions. However, this + // implementation currently does not handle function exports, + // which is the only place we expect name collisions. + if (symbol.name === localSymbolName) { + return otherExportSourceFile; + } + } + } + + return undefined; +} + function dropPrivateApiTransformer( program: ts.Program, host: ts.CompilerHost, + otherExportSourceFiles: ts.SourceFile[], context: ts.TransformationContext ): ts.Transformer { const typeChecker = program.getTypeChecker(); return (sourceFile: ts.SourceFile) => { + const imports: Record> = {}; + + function ensureImportsForFile(filename: string): Array { + let importsForFile = imports[filename]; + if (!importsForFile) { + importsForFile = []; + imports[filename] = importsForFile; + } + return importsForFile; + } + function visit(node: ts.Node): ts.Node { if ( ts.isInterfaceDeclaration(node) || @@ -531,6 +593,30 @@ function dropPrivateApiTransformer( } } + if ( + ts.isInterfaceDeclaration(node) || + ts.isClassDeclaration(node) || + ts.isTypeAliasDeclaration(node) || + ts.isEnumDeclaration(node) + ) { + // Remove any types that are exported externally + const externalExportFile = findExternalExport( + typeChecker, + sourceFile, + node, + otherExportSourceFiles + ); + if (externalExportFile && node.name) { + ensureImportsForFile( + path.relative( + path.dirname(sourceFile.fileName), + externalExportFile.fileName + ) + ).push(node.name.text); + return ts.factory.createNotEmittedStatement(node); + } + } + if (ts.isConstructorDeclaration(node)) { // Replace internal constructors with private constructors. return maybeHideConstructor(node); @@ -580,7 +666,40 @@ function dropPrivateApiTransformer( context ) as T; } - return visitNodeAndChildren(sourceFile); + const result = visitNodeAndChildren(sourceFile); + + const moreImports: ts.ImportDeclaration[] = []; + for (let filename in imports) { + const importSpecifiers: ts.ImportSpecifier[] = []; + for (let identifier of imports[filename]) { + importSpecifiers.push( + ts.factory.createImportSpecifier( + false, + undefined, + ts.factory.createIdentifier(identifier) + ) + ); + } + let outFileName = filename.startsWith('.') ? filename : `./${filename}`; + outFileName = outFileName.replace('.d.ts', ''); + const importDeclaration = ts.factory.createImportDeclaration( + [], + ts.factory.createImportClause( + true, + undefined, + ts.factory.createNamedImports(importSpecifiers) + ), + ts.factory.createStringLiteral(outFileName, true) + ); + + moreImports.push(importDeclaration); + } + + return ts.factory.updateSourceFile( + result, + [...moreImports, ...result.statements], + true + ); }; } From d18310a853419755fd2f2a53bea86c766b3024c3 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Fri, 21 Mar 2025 15:03:19 -0600 Subject: [PATCH 50/59] Markduckworth/ppl mep (#8801) * Multiple entry points for main package. * MEP for firestore lite building * Fix issue with external exports * Refactor to support multiple entry points for the lite SDK. Fixes import issues and makes code organization across /pipelines and /lite/pipeliens * Type and comment cleanup * Make PipelineSource generic and remove useFluentPipelines * Remove converter and placeholders for converter. * cleanup: remove documentReferenceFactory * Linting and formatting * Update the typings export for pipelines and lite pipelines so that it auguments the Firestore and Query classes. * Add missing Expr export * Lint fixes * TODO cleanup * update api review * Query to Proto with integration tests * API tweaks from review. Selectable, FilterCondition, and Accumulator are abstract classes not interfaces. Removed extraneous Pipeline.sort overload * Remove console.log statements from prune-dts.ts * code cleanup in prune-dts * Add missing imports to pipelines.ts * If argument to FunctionExpr is a plain object or array, convert these to expression using map(...) or array(...) * Add tests for evaluating expressions in arrays and maps * implement new FunctionExpressions as standalone functions * Fix typo and formatting in pipeline.test.ts * Implement support for genericStage and genericFunction * Implement new function expressions as methods on the Expr class. * Pipeline test reorganization * Implementing new stages Sample, Union, Unnest, Replace * Rename FilterCondition to BooleanExpr * Update functions with variadic params to match signatures of the backend * Fix and implementation. * Refactor AggregateFunction out of Expr * Add ScalarExpr class and make Expr a base class of AggregateFunction * fixing missing imports and renames * Remove classes for individual function types * Separate scalar expressions and aggregate functions into different class hierarchies * Remove deleted Expr classes from the pipelines exports * Replace not(fn()) with notFn() in the query to pipeline conversion * Fix circular dependency between user_data_reader and expressions * removing modular pipeline creation and removing fluent pipline execution. This was a decision from API review * Change return type of execute from PipelineResult[] to PipelineSnapshot * Renames for API review: FunctionExpr, BooleanExpr, params * missing readonly * Build and test fixes * Replace Field.of() with field() * Add missing export PipelineSnaphsot * Replace Constant.of() with constant() * Removed constant(...) overloads to create a map or array. Use the array or map function instead. * Implemented and documented ascending|descending(fieldName) as a convenient way to create orderings for a specific field * fix tests creating a constant map and array * Remove genericFunction, genericAggregateFunction, and genericBooleanExpr. Replace usage with constructor * Pipeline result timestamp testing * Testing timestamp edge cases * Query to pipeline conversion is performed from the PipelineSource class rather than the Query class * Timestamp tests and fix pipeline tests for change in pipeline creation from a classic query * test fix * Refactor and rename all functions to match API proposal changes after API review. * Fix build issues * New integration util pipeline_export file to support the pipelines subpackage * Rename several FunctionExpr standalone exports from Function to . Meets API design * Removing the all-packages api report script because it is no longer needed * Remove any from the public api surface * lint fix * Code cleanup * FindNearest integration tests * Filling in gaps in test coverage * Implement Pipeline tests for the lite SDK * Fixed a build issue with the lite SDK * Improved error message context when invalid user data is passed to a pipeline without being wrapped in a call to constant(...) * Fix typo in old error message * Fix lite pipeline exports * api-review files * Fixing tests and improving test coverage * PR feedback * Updating replaceWith to take an Expr * yarn format --- .../firestore-lite-pipelines.api.md | 2147 ++---- common/api-review/firestore-pipelines.api.md | 1435 ++-- common/api-review/firestore.api.md | 1343 +--- .../firestore/lite/pipelines/package.json | 2 +- .../firestore/lite/pipelines/pipelines.d.ts | 2 +- .../firestore/lite/pipelines/pipelines.ts | 108 +- packages/firestore/package.json | 5 +- packages/firestore/pipelines/pipelines.d.ts | 7 +- packages/firestore/src/api.ts | 3 +- packages/firestore/src/api/parse_context.ts | 45 + packages/firestore/src/api/pipeline.ts | 66 +- packages/firestore/src/api/pipeline_impl.ts | 111 +- packages/firestore/src/api_pipelines.ts | 116 +- packages/firestore/src/core/pipeline-util.ts | 184 +- .../firestore/src/lite-api/expressions.ts | 6051 +++++++++-------- .../firestore/src/lite-api/pipeline-result.ts | 71 +- .../firestore/src/lite-api/pipeline-source.ts | 84 +- packages/firestore/src/lite-api/pipeline.ts | 738 +- .../firestore/src/lite-api/pipeline_impl.ts | 126 +- packages/firestore/src/lite-api/reference.ts | 2 +- packages/firestore/src/lite-api/snapshot.ts | 5 +- packages/firestore/src/lite-api/stage.ts | 147 +- .../src/lite-api/user_data_reader.ts | 53 +- packages/firestore/src/remote/datastore.ts | 10 +- packages/firestore/src/remote/serializer.ts | 26 +- packages/firestore/src/util/types.ts | 4 + .../test/integration/api/pipeline.test.ts | 4207 ++++++++---- .../integration/api/query_to_pipeline.test.ts | 827 +++ .../test/integration/util/firebase_export.ts | 1 - .../test/integration/util/helpers.ts | 7 + .../integration/util/pipeline_export.ts} | 16 +- packages/firestore/test/lite/pipeline.test.ts | 2919 ++++++++ 32 files changed, 12181 insertions(+), 8687 deletions(-) create mode 100644 packages/firestore/test/integration/api/query_to_pipeline.test.ts rename packages/firestore/{src/all_packages.ts => test/integration/util/pipeline_export.ts} (61%) create mode 100644 packages/firestore/test/lite/pipeline.test.ts diff --git a/common/api-review/firestore-lite-pipelines.api.md b/common/api-review/firestore-lite-pipelines.api.md index d1536c8a626..28746295ae5 100644 --- a/common/api-review/firestore-lite-pipelines.api.md +++ b/common/api-review/firestore-lite-pipelines.api.md @@ -7,276 +7,204 @@ import { FirebaseApp } from '@firebase/app'; // @beta -export interface Accumulator { - // (undocumented) - accumulator: true; - add(other: Accumulator): Add; - add(other: any): Add; - arrayConcat(...arrays: Accumulator[]): ArrayConcat; - arrayConcat(...arrays: any[][]): ArrayConcat; - arrayContains(element: Accumulator): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Accumulator[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Accumulator[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Accumulator): CosineDistance; - // Warning: (ae-forgotten-export) The symbol "VectorValue" needs to be exported by the entry point pipelines.d.ts - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Accumulator): Divide; - divide(other: any): Divide; - dotProduct(other: Accumulator): DotProduct; - dotProduct(other: VectorValue): DotProduct; - // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Accumulator): EndsWith; - eq(other: Accumulator): Eq; - eq(other: any): Eq; - eqAny(...others: Accumulator[]): EqAny; +export function add(first: Expr, second: Expr | unknown, ...others: Array): FunctionExpr; + +// @beta +export function add(fieldName: string, second: Expr | unknown, ...others: Array): FunctionExpr; + +// @beta (undocumented) +export class AddFields implements Stage { + constructor(fields: Map); // (undocumented) - eqAny(...others: any[]): EqAny; - euclideanDistance(other: Accumulator): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; + name: string; +} + +// @beta (undocumented) +export class Aggregate implements Stage { + constructor(accumulators: Map, groups: Map); // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; + name: string; +} + +// @beta +export class AggregateFunction { + constructor(name: string, params: Expr[]); + as(name: string): AggregateWithAlias; // (undocumented) exprType: ExprType; - gt(other: Accumulator): Gt; - gt(other: any): Gt; - gte(other: Accumulator): Gte; - gte(other: any): Gte; - isNaN(): IsNan; - like(pattern: string): Like; + } + +// @beta +export class AggregateWithAlias { + constructor(aggregate: AggregateFunction, alias: string); // (undocumented) - like(pattern: Accumulator): Like; - logicalMaximum(other: Accumulator): LogicalMaximum; - logicalMaximum(other: any): LogicalMaximum; - logicalMinimum(other: Accumulator): LogicalMinimum; - logicalMinimum(other: any): LogicalMinimum; - lt(other: Accumulator): Lt; - lt(other: any): Lt; - lte(other: Accumulator): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - maximum(): Maximum; - minimum(): Minimum; - mod(other: Accumulator): Mod; - mod(other: any): Mod; - multiply(other: Accumulator): Multiply; - multiply(other: any): Multiply; - neq(other: Accumulator): Neq; - neq(other: any): Neq; - notEqAny(...others: Accumulator[]): FirestoreFunction; + readonly aggregate: AggregateFunction; // (undocumented) - notEqAny(...others: any[]): FirestoreFunction; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Accumulator): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Accumulator): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Accumulator, replace: Accumulator): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Accumulator, replace: Accumulator): ReplaceFirst; - reverse(): Reverse; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Accumulator): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Accumulator): StrContains; - subtract(other: Accumulator): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Accumulator, amount: Accumulator): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Accumulator, amount: Accumulator): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - vectorLength(): VectorLength; + readonly alias: string; } // @beta -export type AccumulatorTarget = ExprWithAlias; +export function and(first: BooleanExpr, second: BooleanExpr, ...more: BooleanExpr[]): BooleanExpr; -// @beta (undocumented) -export class Add extends FirestoreFunction { - constructor(left: Accumulator, right: Accumulator); - } +// @beta +export function array(elements: unknown[]): FunctionExpr; // @beta -export function add(left: Accumulator, right: Accumulator): Add; +export function arrayConcat(firstArray: Expr, secondArray: Expr | unknown[], ...otherArrays: Array): FunctionExpr; // @beta -export function add(left: Accumulator, right: any): Add; +export function arrayConcat(firstArrayField: string, secondArray: Expr | unknown[], ...otherArrays: Array): FunctionExpr; // @beta -export function add(left: string, right: Accumulator): Add; +export function arrayContains(array: Expr, element: Expr): FunctionExpr; // @beta -export function add(left: string, right: any): Add; +export function arrayContains(array: Expr, element: unknown): FunctionExpr; -// @beta (undocumented) -export class AddFields implements Stage { - constructor(fields: Map); - // (undocumented) - name: string; -} +// @beta +export function arrayContains(fieldName: string, element: Expr): FunctionExpr; -// @beta (undocumented) -export class Aggregate implements Stage { - constructor(accumulators: Map, groups: Map); - // (undocumented) - name: string; -} +// @beta +export function arrayContains(fieldName: string, element: unknown): BooleanExpr; -// @beta (undocumented) -export class And extends FirestoreFunction implements FilterCondition { - constructor(conditions: FilterCondition[]); - // (undocumented) - filterable: true; -} +// @beta +export function arrayContainsAll(array: Expr, values: Array): BooleanExpr; -// @beta (undocumented) -export class ArrayConcat extends FirestoreFunction { - constructor(array: Accumulator, elements: Accumulator[]); - } +// @beta +export function arrayContainsAll(fieldName: string, values: Array): BooleanExpr; // @beta -export function arrayConcat(array: Accumulator, elements: Accumulator[]): ArrayConcat; +export function arrayContainsAll(array: Expr, arrayExpression: Expr): BooleanExpr; // @beta -export function arrayConcat(array: Accumulator, elements: any[]): ArrayConcat; +export function arrayContainsAll(fieldName: string, arrayExpression: Expr): BooleanExpr; // @beta -export function arrayConcat(array: string, elements: Accumulator[]): ArrayConcat; +export function arrayContainsAny(array: Expr, values: Array): BooleanExpr; // @beta -export function arrayConcat(array: string, elements: any[]): ArrayConcat; +export function arrayContainsAny(fieldName: string, values: Array): BooleanExpr; -// @beta (undocumented) -export class ArrayContains extends FirestoreFunction implements FilterCondition { - constructor(array: Accumulator, element: Accumulator); - // (undocumented) - filterable: true; -} +// @beta +export function arrayContainsAny(array: Expr, values: Expr): BooleanExpr; // @beta -export function arrayContains(array: Accumulator, element: Accumulator): ArrayContains; +export function arrayContainsAny(fieldName: string, values: Expr): BooleanExpr; // @beta -export function arrayContains(array: Accumulator, element: any): ArrayContains; +export function arrayLength(array: Expr): FunctionExpr; // @beta -export function arrayContains(array: string, element: Accumulator): ArrayContains; +export function arrayOffset(arrayField: string, offset: number): FunctionExpr; // @beta -export function arrayContains(array: string, element: any): ArrayContains; +export function arrayOffset(arrayField: string, offsetExpr: Expr): FunctionExpr; -// @beta (undocumented) -export class ArrayContainsAll extends FirestoreFunction implements FilterCondition { - constructor(array: Accumulator, values: Accumulator[]); - // (undocumented) - filterable: true; - } +// @beta +export function arrayOffset(arrayExpression: Expr, offset: number): FunctionExpr; // @beta -export function arrayContainsAll(array: Accumulator, values: Accumulator[]): ArrayContainsAll; +export function arrayOffset(arrayExpression: Expr, offsetExpr: Expr): FunctionExpr; // @beta -export function arrayContainsAll(array: Accumulator, values: any[]): ArrayContainsAll; +export function ascending(expr: Expr): Ordering; // @beta -export function arrayContainsAll(array: string, values: Accumulator[]): ArrayContainsAll; +export function ascending(fieldName: string): Ordering; // @beta -export function arrayContainsAll(array: string, values: any[]): ArrayContainsAll; +export function avg(expression: Expr): AggregateFunction; -// @beta (undocumented) -export class ArrayContainsAny extends FirestoreFunction implements FilterCondition { - constructor(array: Accumulator, values: Accumulator[]); - // (undocumented) - filterable: true; - } +// @beta +export function avg(fieldName: string): AggregateFunction; +// Warning: (ae-forgotten-export) The symbol "Bytes" needs to be exported by the entry point pipelines.d.ts +// // @beta -export function arrayContainsAny(array: Accumulator, values: Accumulator[]): ArrayContainsAny; +export function bitAnd(field: string, otherBits: number | Bytes): FunctionExpr; // @beta -export function arrayContainsAny(array: Accumulator, values: any[]): ArrayContainsAny; +export function bitAnd(field: string, bitsExpression: Expr): FunctionExpr; // @beta -export function arrayContainsAny(array: string, values: Accumulator[]): ArrayContainsAny; +export function bitAnd(bitsExpression: Expr, otherBits: number | Bytes): FunctionExpr; // @beta -export function arrayContainsAny(array: string, values: any[]): ArrayContainsAny; +export function bitAnd(bitsExpression: Expr, otherBitsExpression: Expr): FunctionExpr; -// @beta (undocumented) -export class ArrayElement extends FirestoreFunction { - constructor(); -} +// @beta +export function bitLeftShift(field: string, y: number): FunctionExpr; -// @beta (undocumented) -export class ArrayLength extends FirestoreFunction { - constructor(array: Accumulator); - } +// @beta +export function bitLeftShift(field: string, numberExpr: Expr): FunctionExpr; // @beta -export function arrayLength(array: Accumulator): ArrayLength; +export function bitLeftShift(xValue: Expr, y: number): FunctionExpr; -// @beta (undocumented) -export class ArrayReverse extends FirestoreFunction { - constructor(array: Accumulator); - } +// @beta +export function bitLeftShift(xValue: Expr, numberExpr: Expr): FunctionExpr; // @beta -export function ascending(expr: Accumulator): Ordering; +export function bitNot(field: string): FunctionExpr; -// @beta (undocumented) -export class Avg extends FirestoreFunction implements Accumulator { - constructor(value: Accumulator, distinct: boolean); - // (undocumented) - accumulator: true; - } +// @beta +export function bitNot(bitsValueExpression: Expr): FunctionExpr; -// @beta (undocumented) -export class ByteLength extends FirestoreFunction { - constructor(value: Accumulator); - } +// @beta +export function bitOr(field: string, otherBits: number | Bytes): FunctionExpr; // @beta -export function byteLength(expr: Accumulator): ByteLength; +export function bitOr(field: string, bitsExpression: Expr): FunctionExpr; // @beta -export function byteLength(field: string): ByteLength; +export function bitOr(bitsExpression: Expr, otherBits: number | Bytes): FunctionExpr; -// @beta (undocumented) -export class CharLength extends FirestoreFunction { - constructor(value: Accumulator); - } +// @beta +export function bitOr(bitsExpression: Expr, otherBitsExpression: Expr): FunctionExpr; + +// @beta +export function bitRightShift(field: string, y: number): FunctionExpr; + +// @beta +export function bitRightShift(field: string, numberExpr: Expr): FunctionExpr; + +// @beta +export function bitRightShift(xValue: Expr, y: number): FunctionExpr; + +// @beta +export function bitRightShift(xValue: Expr, numberExpr: Expr): FunctionExpr; + +// @beta +export function bitXor(field: string, otherBits: number | Bytes): FunctionExpr; // @beta -export function charLength(field: string): CharLength; +export function bitXor(field: string, bitsExpression: Expr): FunctionExpr; // @beta -export function charLength(expr: Accumulator): CharLength; +export function bitXor(bitsExpression: Expr, otherBits: number | Bytes): FunctionExpr; + +// @beta +export function bitXor(bitsExpression: Expr, otherBitsExpression: Expr): FunctionExpr; + +// @beta +export class BooleanExpr extends FunctionExpr { + countIf(): AggregateFunction; + // (undocumented) + filterable: true; + not(): BooleanExpr; +} + +// @beta +export function byteLength(expr: Expr): FunctionExpr; + +// @beta +export function byteLength(fieldName: string): FunctionExpr; + +// @beta +export function charLength(fieldName: string): FunctionExpr; + +// @beta +export function charLength(stringExpression: Expr): FunctionExpr; // @beta (undocumented) export class CollectionGroupSource implements Stage { @@ -292,169 +220,102 @@ export class CollectionSource implements Stage { name: string; } -// @beta (undocumented) -export class Cond extends FirestoreFunction { - constructor(condition: FilterCondition, thenExpr: Accumulator, elseExpr: Accumulator); - // (undocumented) - filterable: true; - } - // @beta -export function cond(condition: FilterCondition, thenExpr: Accumulator, elseExpr: Accumulator): Cond; +export function cond(condition: BooleanExpr, thenExpr: Expr, elseExpr: Expr): FunctionExpr; // @beta -export class Constant { - add(other: Accumulator): Add; - add(other: any): Add; - arrayConcat(...arrays: Accumulator[]): ArrayConcat; - arrayConcat(...arrays: any[][]): ArrayConcat; - arrayContains(element: Accumulator): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Accumulator[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Accumulator[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Accumulator): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Accumulator): Divide; - divide(other: any): Divide; - dotProduct(other: Accumulator): DotProduct; - dotProduct(other: VectorValue): DotProduct; - // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Accumulator): EndsWith; - eq(other: Accumulator): Eq; - eq(other: any): Eq; - eqAny(...others: Accumulator[]): EqAny; +export class Constant extends Expr { // (undocumented) - eqAny(...others: any[]): EqAny; - euclideanDistance(other: Accumulator): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; - // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; - // (undocumented) - exprType: ExprType; - gt(other: Accumulator): Gt; - gt(other: any): Gt; - gte(other: Accumulator): Gte; - gte(other: any): Gte; - isNaN(): IsNan; - like(pattern: string): Like; - // (undocumented) - like(pattern: Accumulator): Like; - logicalMaximum(other: Accumulator): LogicalMaximum; - logicalMaximum(other: any): LogicalMaximum; - logicalMinimum(other: Accumulator): LogicalMinimum; - logicalMinimum(other: any): LogicalMinimum; - lt(other: Accumulator): Lt; - lt(other: any): Lt; - lte(other: Accumulator): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - maximum(): Maximum; - minimum(): Minimum; - mod(other: Accumulator): Mod; - mod(other: any): Mod; - multiply(other: Accumulator): Multiply; - multiply(other: any): Multiply; - neq(other: Accumulator): Neq; - neq(other: any): Neq; - notEqAny(...others: Accumulator[]): FirestoreFunction; - // (undocumented) - notEqAny(...others: any[]): FirestoreFunction; - static of(value: number): Constant; - static of(value: string): Constant; - static of(value: boolean): Constant; - static of(value: null): Constant; - static of(value: undefined): Constant; - // Warning: (ae-forgotten-export) The symbol "GeoPoint" needs to be exported by the entry point pipelines.d.ts - static of(value: GeoPoint): Constant; - // Warning: (ae-forgotten-export) The symbol "Timestamp" needs to be exported by the entry point pipelines.d.ts - static of(value: Timestamp): Constant; - static of(value: Date): Constant; - static of(value: Uint8Array): Constant; - // Warning: (ae-forgotten-export) The symbol "DocumentReference" needs to be exported by the entry point pipelines.d.ts - static of(value: DocumentReference): Constant; - static of(value: any[]): Constant; - static of(value: Map): Constant; - static of(value: VectorValue): Constant; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Accumulator): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Accumulator): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Accumulator, replace: Accumulator): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Accumulator, replace: Accumulator): ReplaceFirst; - reverse(): Reverse; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Accumulator): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Accumulator): StrContains; - subtract(other: Accumulator): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Accumulator, amount: Accumulator): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Accumulator, amount: Accumulator): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - static vector(value: number[] | VectorValue): Constant; - vectorLength(): VectorLength; -} - -// @beta (undocumented) -export class CosineDistance extends FirestoreFunction { - constructor(vector1: Accumulator, vector2: Accumulator); + readonly exprType: ExprType; } +// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta +// +// @public +export function constant(value: number): Constant; + +// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta +// +// @public +export function constant(value: string): Constant; + +// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta +// +// @public +export function constant(value: boolean): Constant; + +// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta +// +// @public +export function constant(value: null): Constant; + +// Warning: (ae-forgotten-export) The symbol "GeoPoint" needs to be exported by the entry point pipelines.d.ts +// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta +// +// @public +export function constant(value: GeoPoint): Constant; + +// Warning: (ae-forgotten-export) The symbol "Timestamp" needs to be exported by the entry point pipelines.d.ts +// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta +// +// @public +export function constant(value: Timestamp): Constant; + +// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta +// +// @public +export function constant(value: Date): Constant; + +// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta +// +// @public +export function constant(value: Bytes): Constant; + +// Warning: (ae-forgotten-export) The symbol "DocumentReference" needs to be exported by the entry point pipelines.d.ts +// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta +// +// @public +export function constant(value: DocumentReference): Constant; + +// Warning: (ae-forgotten-export) The symbol "VectorValue" needs to be exported by the entry point pipelines.d.ts +// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta +// +// @public +export function constant(value: VectorValue): Constant; + +// Warning: (ae-incompatible-release-tags) The symbol "constantVector" is marked as @public, but its signature references "Constant" which is marked as @beta +// +// @public +export function constantVector(value: number[] | VectorValue): Constant; + // @beta -export function cosineDistance(expr: string, other: number[]): CosineDistance; +export function cosineDistance(fieldName: string, vector: number[] | VectorValue): FunctionExpr; // @beta -export function cosineDistance(expr: string, other: VectorValue): CosineDistance; +export function cosineDistance(fieldName: string, vectorExpression: Expr): FunctionExpr; // @beta -export function cosineDistance(expr: string, other: Accumulator): CosineDistance; +export function cosineDistance(vectorExpression: Expr, vector: number[] | Expr): FunctionExpr; // @beta -export function cosineDistance(expr: Accumulator, other: number[]): CosineDistance; +export function cosineDistance(vectorExpression: Expr, otherVectorExpression: Expr): FunctionExpr; // @beta -export function cosineDistance(expr: Accumulator, other: VectorValue): CosineDistance; +export function count(expression: Expr): AggregateFunction; + +// Warning: (ae-incompatible-release-tags) The symbol "count" is marked as @public, but its signature references "AggregateFunction" which is marked as @beta +// +// @public +export function count(fieldName: string): AggregateFunction; // @beta -export function cosineDistance(expr: Accumulator, other: Accumulator): CosineDistance; +export function countAll(): AggregateFunction; -// @beta (undocumented) -export class Count extends FirestoreFunction implements Accumulator { - constructor(value: Accumulator | undefined, distinct: boolean); - // (undocumented) - accumulator: true; - } +// @beta +export function countIf(booleanExpr: BooleanExpr): AggregateFunction; // @beta -export function countAll(): Count; +export function currentContext(): FunctionExpr; // @beta (undocumented) export class DatabaseSource implements Stage { @@ -463,31 +324,35 @@ export class DatabaseSource implements Stage { } // @beta -export function descending(expr: Accumulator): Ordering; +export function descending(expr: Expr): Ordering; + +// @beta +export function descending(fieldName: string): Ordering; // @beta (undocumented) export class Distinct implements Stage { - constructor(groups: Map); + constructor(groups: Map); // (undocumented) name: string; } -// @beta (undocumented) -export class Divide extends FirestoreFunction { - constructor(left: Accumulator, right: Accumulator); - } +// @beta +export function divide(left: Expr, right: Expr): FunctionExpr; + +// @beta +export function divide(expression: Expr, value: unknown): FunctionExpr; // @beta -export function divide(left: Accumulator, right: Accumulator): Divide; +export function divide(fieldName: string, expressions: Expr): FunctionExpr; // @beta -export function divide(left: Accumulator, right: any): Divide; +export function divide(fieldName: string, value: unknown): FunctionExpr; // @beta -export function divide(left: string, right: Accumulator): Divide; +export function documentId(documentPath: string | DocumentReference): FunctionExpr; // @beta -export function divide(left: string, right: any): Divide; +export function documentId(documentPathExpr: Expr): FunctionExpr; // @beta (undocumented) export class DocumentsSource implements Stage { @@ -495,574 +360,350 @@ export class DocumentsSource implements Stage { // (undocumented) name: string; // (undocumented) - static of(refs: DocumentReference[]): DocumentsSource; + static of(refs: Array): DocumentsSource; } -// @beta (undocumented) -export class DotProduct extends FirestoreFunction { - constructor(vector1: Accumulator, vector2: Accumulator); - } - // @beta -export function dotProduct(expr: string, other: number[]): DotProduct; +export function dotProduct(fieldName: string, vector: number[] | VectorValue): FunctionExpr; // @beta -export function dotProduct(expr: string, other: VectorValue): DotProduct; +export function dotProduct(fieldName: string, vectorExpression: Expr): FunctionExpr; // @beta -export function dotProduct(expr: string, other: Accumulator): DotProduct; +export function dotProduct(vectorExpression: Expr, vector: number[] | VectorValue): FunctionExpr; // @beta -export function dotProduct(expr: Accumulator, other: number[]): DotProduct; +export function dotProduct(vectorExpression: Expr, otherVectorExpression: Expr): FunctionExpr; // @beta -export function dotProduct(expr: Accumulator, other: VectorValue): DotProduct; +export function endsWith(fieldName: string, suffix: string): BooleanExpr; // @beta -export function dotProduct(expr: Accumulator, other: Accumulator): DotProduct; - -// @beta (undocumented) -export class EndsWith extends FirestoreFunction implements FilterCondition { - constructor(expr: Accumulator, suffix: Accumulator); - // (undocumented) - filterable: true; - } +export function endsWith(fieldName: string, suffix: Expr): BooleanExpr; // @beta -export function endsWith(expr: string, suffix: string): EndsWith; +export function endsWith(stringExpression: Expr, suffix: string): BooleanExpr; // @beta -export function endsWith(expr: string, suffix: Accumulator): EndsWith; +export function endsWith(stringExpression: Expr, suffix: Expr): BooleanExpr; // @beta -export function endsWith(expr: Accumulator, suffix: string): EndsWith; +export function eq(left: Expr, right: Expr): BooleanExpr; // @beta -export function endsWith(expr: Accumulator, suffix: Accumulator): EndsWith; - -// @beta (undocumented) -export class Eq extends FirestoreFunction implements FilterCondition { - constructor(left: Accumulator, right: Accumulator); - // (undocumented) - filterable: true; - } - -// @beta -export function eq(left: Accumulator, right: Accumulator): Eq; - -// @beta -export function eq(left: Accumulator, right: any): Eq; - -// @beta -export function eq(left: string, right: Accumulator): Eq; - -// @beta -export function eq(left: string, right: any): Eq; - -// @beta (undocumented) -export class EqAny extends FirestoreFunction implements FilterCondition { - constructor(left: Accumulator, others: Accumulator[]); - // (undocumented) - filterable: true; - } - -// @beta -export function eqAny(element: Accumulator, others: Accumulator[]): EqAny; +export function eq(expression: Expr, value: unknown): BooleanExpr; // @beta -export function eqAny(element: Accumulator, others: any[]): EqAny; +export function eq(fieldName: string, expression: Expr): BooleanExpr; // @beta -export function eqAny(element: string, others: Accumulator[]): EqAny; +export function eq(fieldName: string, value: unknown): BooleanExpr; // @beta -export function eqAny(element: string, others: any[]): EqAny; - -// @beta (undocumented) -export class EuclideanDistance extends FirestoreFunction { - constructor(vector1: Accumulator, vector2: Accumulator); - } +export function eqAny(expression: Expr, values: Array): BooleanExpr; // @beta -export function euclideanDistance(expr: string, other: number[]): EuclideanDistance; +export function eqAny(expression: Expr, arrayExpression: Expr): BooleanExpr; // @beta -export function euclideanDistance(expr: string, other: VectorValue): EuclideanDistance; +export function eqAny(fieldName: string, values: Array): BooleanExpr; // @beta -export function euclideanDistance(expr: string, other: Accumulator): EuclideanDistance; +export function eqAny(fieldName: string, arrayExpression: Expr): BooleanExpr; // @beta -export function euclideanDistance(expr: Accumulator, other: number[]): EuclideanDistance; +export function euclideanDistance(fieldName: string, vector: number[] | VectorValue): FunctionExpr; // @beta -export function euclideanDistance(expr: Accumulator, other: VectorValue): EuclideanDistance; +export function euclideanDistance(fieldName: string, vectorExpression: Expr): FunctionExpr; // @beta -export function euclideanDistance(expr: Accumulator, other: Accumulator): EuclideanDistance; +export function euclideanDistance(vectorExpression: Expr, vector: number[] | VectorValue): FunctionExpr; // @beta -export function execute(pipeline: Pipeline): Promise; +export function euclideanDistance(vectorExpression: Expr, otherVectorExpression: Expr): FunctionExpr; -// @beta (undocumented) -export class Exists extends FirestoreFunction implements FilterCondition { - constructor(expr: Accumulator); - // (undocumented) - filterable: true; +// @public +export function execute(pipeline: Pipeline): Promise; + +// @beta +export function exists(value: Expr): BooleanExpr; + +// @beta +export function exists(fieldName: string): BooleanExpr; + +// @beta +export abstract class Expr { + add(second: Expr | unknown, ...others: Array): FunctionExpr; + /* Excluded from this release type: _readUserData */ + arrayConcat(secondArray: Expr | unknown[], ...otherArrays: Array): FunctionExpr; + /* Excluded from this release type: _readUserData */ + arrayContains(expression: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + arrayContains(value: unknown): BooleanExpr; + /* Excluded from this release type: _readUserData */ + arrayContainsAll(values: Array): BooleanExpr; + /* Excluded from this release type: _readUserData */ + arrayContainsAll(arrayExpression: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + arrayContainsAny(values: Array): BooleanExpr; + /* Excluded from this release type: _readUserData */ + arrayContainsAny(arrayExpression: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + arrayLength(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + arrayOffset(offset: number): FunctionExpr; + /* Excluded from this release type: _readUserData */ + arrayOffset(offsetExpr: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + as(name: string): ExprWithAlias; + /* Excluded from this release type: _readUserData */ + ascending(): Ordering; + /* Excluded from this release type: _readUserData */ + avg(): AggregateFunction; + /* Excluded from this release type: _readUserData */ + bitAnd(otherBits: number | Bytes): FunctionExpr; + /* Excluded from this release type: _readUserData */ + bitAnd(bitsExpression: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + bitLeftShift(y: number): FunctionExpr; + /* Excluded from this release type: _readUserData */ + bitLeftShift(numberExpr: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + bitNot(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + bitOr(otherBits: number | Bytes): FunctionExpr; + /* Excluded from this release type: _readUserData */ + bitOr(bitsExpression: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + bitRightShift(y: number): FunctionExpr; + /* Excluded from this release type: _readUserData */ + bitRightShift(numberExpr: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + bitXor(otherBits: number | Bytes): FunctionExpr; + /* Excluded from this release type: _readUserData */ + bitXor(bitsExpression: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + byteLength(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + charLength(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + cosineDistance(vectorExpression: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + cosineDistance(vector: VectorValue | number[]): FunctionExpr; + /* Excluded from this release type: _readUserData */ + count(): AggregateFunction; + /* Excluded from this release type: _readUserData */ + descending(): Ordering; + /* Excluded from this release type: _readUserData */ + divide(other: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + divide(other: unknown): FunctionExpr; + /* Excluded from this release type: _readUserData */ + documentId(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + dotProduct(vectorExpression: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + dotProduct(vector: VectorValue | number[]): FunctionExpr; + /* Excluded from this release type: _readUserData */ + endsWith(suffix: string): BooleanExpr; + /* Excluded from this release type: _readUserData */ + endsWith(suffix: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + eq(expression: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + eq(value: unknown): BooleanExpr; + /* Excluded from this release type: _readUserData */ + eqAny(values: Array): BooleanExpr; + /* Excluded from this release type: _readUserData */ + eqAny(arrayExpression: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + euclideanDistance(vectorExpression: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + euclideanDistance(vector: VectorValue | number[]): FunctionExpr; + /* Excluded from this release type: _readUserData */ + exists(): BooleanExpr; + /* Excluded from this release type: _readUserData */ + // (undocumented) + abstract readonly exprType: ExprType; + /* Excluded from this release type: _readUserData */ + gt(expression: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + gt(value: unknown): BooleanExpr; + /* Excluded from this release type: _readUserData */ + gte(expression: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + gte(value: unknown): BooleanExpr; + /* Excluded from this release type: _readUserData */ + ifError(catchExpr: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + ifError(catchValue: unknown): FunctionExpr; + /* Excluded from this release type: _readUserData */ + isAbsent(): BooleanExpr; + /* Excluded from this release type: _readUserData */ + isError(): BooleanExpr; + /* Excluded from this release type: _readUserData */ + isNan(): BooleanExpr; + /* Excluded from this release type: _readUserData */ + isNotNan(): BooleanExpr; + /* Excluded from this release type: _readUserData */ + isNotNull(): BooleanExpr; + /* Excluded from this release type: _readUserData */ + isNull(): BooleanExpr; + /* Excluded from this release type: _readUserData */ + like(pattern: string): FunctionExpr; + /* Excluded from this release type: _readUserData */ + like(pattern: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + logicalMaximum(second: Expr | unknown, ...others: Array): FunctionExpr; + /* Excluded from this release type: _readUserData */ + logicalMinimum(second: Expr | unknown, ...others: Array): FunctionExpr; + /* Excluded from this release type: _readUserData */ + lt(experession: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + lt(value: unknown): BooleanExpr; + /* Excluded from this release type: _readUserData */ + lte(expression: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + lte(value: unknown): BooleanExpr; + /* Excluded from this release type: _readUserData */ + manhattanDistance(vector: VectorValue | number[]): FunctionExpr; + /* Excluded from this release type: _readUserData */ + manhattanDistance(vectorExpression: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + mapGet(subfield: string): FunctionExpr; + /* Excluded from this release type: _readUserData */ + mapMerge(secondMap: Record | Expr, ...otherMaps: Array | Expr>): FunctionExpr; + /* Excluded from this release type: _readUserData */ + mapRemove(key: string): FunctionExpr; + /* Excluded from this release type: _readUserData */ + mapRemove(keyExpr: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + maximum(): AggregateFunction; + /* Excluded from this release type: _readUserData */ + minimum(): AggregateFunction; + /* Excluded from this release type: _readUserData */ + mod(expression: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + mod(value: unknown): FunctionExpr; + /* Excluded from this release type: _readUserData */ + multiply(second: Expr | unknown, ...others: Array): FunctionExpr; + /* Excluded from this release type: _readUserData */ + neq(expression: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + neq(value: unknown): BooleanExpr; + /* Excluded from this release type: _readUserData */ + notEqAny(values: Array): BooleanExpr; + /* Excluded from this release type: _readUserData */ + notEqAny(arrayExpression: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + regexContains(pattern: string): BooleanExpr; + /* Excluded from this release type: _readUserData */ + regexContains(pattern: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + regexMatch(pattern: string): BooleanExpr; + /* Excluded from this release type: _readUserData */ + regexMatch(pattern: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + replaceAll(find: string, replace: string): FunctionExpr; + /* Excluded from this release type: _readUserData */ + replaceAll(find: Expr, replace: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + replaceFirst(find: string, replace: string): FunctionExpr; + /* Excluded from this release type: _readUserData */ + replaceFirst(find: Expr, replace: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + reverse(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + startsWith(prefix: string): BooleanExpr; + /* Excluded from this release type: _readUserData */ + startsWith(prefix: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + strConcat(secondString: Expr | string, ...otherStrings: Array): FunctionExpr; + /* Excluded from this release type: _readUserData */ + strContains(substring: string): BooleanExpr; + /* Excluded from this release type: _readUserData */ + strContains(expr: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + substr(position: number, length?: number): FunctionExpr; + /* Excluded from this release type: _readUserData */ + substr(position: Expr, length?: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + subtract(other: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + subtract(other: unknown): FunctionExpr; + /* Excluded from this release type: _readUserData */ + sum(): AggregateFunction; + /* Excluded from this release type: _readUserData */ + timestampAdd(unit: Expr, amount: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): FunctionExpr; + /* Excluded from this release type: _readUserData */ + timestampSub(unit: Expr, amount: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): FunctionExpr; + /* Excluded from this release type: _readUserData */ + timestampToUnixMicros(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + timestampToUnixMillis(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + timestampToUnixSeconds(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + toLower(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + toUpper(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + trim(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + unixMicrosToTimestamp(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + unixMillisToTimestamp(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + unixSecondsToTimestamp(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + vectorLength(): FunctionExpr; } // @beta -export function exists(value: Accumulator): Exists; - -// @beta -export function exists(field: string): Exists; - -// @beta -export type ExprType = 'Field' | 'Constant' | 'Function' | 'ListOfExprs' | 'ExprWithAlias'; +export type ExprType = 'Field' | 'Constant' | 'Function' | 'AggregateFunction' | 'ListOfExprs' | 'ExprWithAlias'; // @beta (undocumented) -export class ExprWithAlias implements Selectable { - constructor(expr: T, alias: string); - add(other: Accumulator): Add; - add(other: any): Add; +export class ExprWithAlias implements Selectable { + constructor(expr: Expr, alias: string); // (undocumented) readonly alias: string; - arrayConcat(...arrays: Accumulator[]): ArrayConcat; - arrayConcat(...arrays: any[][]): ArrayConcat; - arrayContains(element: Accumulator): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Accumulator[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Accumulator[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Accumulator): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Accumulator): Divide; - divide(other: any): Divide; - dotProduct(other: Accumulator): DotProduct; - dotProduct(other: VectorValue): DotProduct; - // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Accumulator): EndsWith; - eq(other: Accumulator): Eq; - eq(other: any): Eq; - eqAny(...others: Accumulator[]): EqAny; - // (undocumented) - eqAny(...others: any[]): EqAny; - euclideanDistance(other: Accumulator): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; - // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; // (undocumented) - readonly expr: T; + readonly expr: Expr; // (undocumented) exprType: ExprType; - gt(other: Accumulator): Gt; - gt(other: any): Gt; - gte(other: Accumulator): Gte; - gte(other: any): Gte; - isNaN(): IsNan; - like(pattern: string): Like; - // (undocumented) - like(pattern: Accumulator): Like; - logicalMaximum(other: Accumulator): LogicalMaximum; - logicalMaximum(other: any): LogicalMaximum; - logicalMinimum(other: Accumulator): LogicalMinimum; - logicalMinimum(other: any): LogicalMinimum; - lt(other: Accumulator): Lt; - lt(other: any): Lt; - lte(other: Accumulator): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - maximum(): Maximum; - minimum(): Minimum; - mod(other: Accumulator): Mod; - mod(other: any): Mod; - multiply(other: Accumulator): Multiply; - multiply(other: any): Multiply; - neq(other: Accumulator): Neq; - neq(other: any): Neq; - notEqAny(...others: Accumulator[]): FirestoreFunction; - // (undocumented) - notEqAny(...others: any[]): FirestoreFunction; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Accumulator): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Accumulator): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Accumulator, replace: Accumulator): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Accumulator, replace: Accumulator): ReplaceFirst; - reverse(): Reverse; // (undocumented) selectable: true; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Accumulator): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Accumulator): StrContains; - subtract(other: Accumulator): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Accumulator, amount: Accumulator): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Accumulator, amount: Accumulator): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - vectorLength(): VectorLength; } // @beta -export class Field implements Selectable { - add(other: Accumulator): Add; - add(other: any): Add; - arrayConcat(...arrays: Accumulator[]): ArrayConcat; - arrayConcat(...arrays: any[][]): ArrayConcat; - arrayContains(element: Accumulator): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Accumulator[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Accumulator[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Accumulator): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Accumulator): Divide; - divide(other: any): Divide; - dotProduct(other: Accumulator): DotProduct; - dotProduct(other: VectorValue): DotProduct; +export class Field extends Expr implements Selectable { // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Accumulator): EndsWith; - eq(other: Accumulator): Eq; - eq(other: any): Eq; - eqAny(...others: Accumulator[]): EqAny; + get alias(): string; // (undocumented) - eqAny(...others: any[]): EqAny; - euclideanDistance(other: Accumulator): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; + get expr(): Expr; // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; - // (undocumented) - exprType: ExprType; + readonly exprType: ExprType; // (undocumented) fieldName(): string; - gt(other: Accumulator): Gt; - gt(other: any): Gt; - gte(other: Accumulator): Gte; - gte(other: any): Gte; - isNaN(): IsNan; - like(pattern: string): Like; - // (undocumented) - like(pattern: Accumulator): Like; - logicalMaximum(other: Accumulator): LogicalMaximum; - logicalMaximum(other: any): LogicalMaximum; - logicalMinimum(other: Accumulator): LogicalMinimum; - logicalMinimum(other: any): LogicalMinimum; - lt(other: Accumulator): Lt; - lt(other: any): Lt; - lte(other: Accumulator): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - maximum(): Maximum; - minimum(): Minimum; - mod(other: Accumulator): Mod; - mod(other: any): Mod; - multiply(other: Accumulator): Multiply; - multiply(other: any): Multiply; - neq(other: Accumulator): Neq; - neq(other: any): Neq; - notEqAny(...others: Accumulator[]): FirestoreFunction; - // (undocumented) - notEqAny(...others: any[]): FirestoreFunction; - static of(name: string): Field; - // Warning: (ae-forgotten-export) The symbol "FieldPath" needs to be exported by the entry point pipelines.d.ts - // - // (undocumented) - static of(path: FieldPath): Field; - // (undocumented) - static of(pipeline: Pipeline, name: string): Field; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Accumulator): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Accumulator): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Accumulator, replace: Accumulator): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Accumulator, replace: Accumulator): ReplaceFirst; - reverse(): Reverse; // (undocumented) selectable: true; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Accumulator): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Accumulator): StrContains; - subtract(other: Accumulator): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Accumulator, amount: Accumulator): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Accumulator, amount: Accumulator): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - vectorLength(): VectorLength; } -// @beta (undocumented) -export class Fields implements Selectable { - add(other: Accumulator): Add; - add(other: any): Add; - arrayConcat(...arrays: Accumulator[]): ArrayConcat; - arrayConcat(...arrays: any[][]): ArrayConcat; - arrayContains(element: Accumulator): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Accumulator[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Accumulator[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Accumulator): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Accumulator): Divide; - divide(other: any): Divide; - dotProduct(other: Accumulator): DotProduct; - dotProduct(other: VectorValue): DotProduct; - // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Accumulator): EndsWith; - eq(other: Accumulator): Eq; - eq(other: any): Eq; - eqAny(...others: Accumulator[]): EqAny; - // (undocumented) - eqAny(...others: any[]): EqAny; - euclideanDistance(other: Accumulator): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; - // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; - // (undocumented) - exprType: ExprType; - // (undocumented) - fieldList(): Field[]; - gt(other: Accumulator): Gt; - gt(other: any): Gt; - gte(other: Accumulator): Gte; - gte(other: any): Gte; - isNaN(): IsNan; - like(pattern: string): Like; - // (undocumented) - like(pattern: Accumulator): Like; - logicalMaximum(other: Accumulator): LogicalMaximum; - logicalMaximum(other: any): LogicalMaximum; - logicalMinimum(other: Accumulator): LogicalMinimum; - logicalMinimum(other: any): LogicalMinimum; - lt(other: Accumulator): Lt; - lt(other: any): Lt; - lte(other: Accumulator): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - maximum(): Maximum; - minimum(): Minimum; - mod(other: Accumulator): Mod; - mod(other: any): Mod; - multiply(other: Accumulator): Multiply; - multiply(other: any): Multiply; - neq(other: Accumulator): Neq; - neq(other: any): Neq; - notEqAny(...others: Accumulator[]): FirestoreFunction; - // (undocumented) - notEqAny(...others: any[]): FirestoreFunction; - // (undocumented) - static of(name: string, ...others: string[]): Fields; - // (undocumented) - static ofAll(): Fields; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Accumulator): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Accumulator): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Accumulator, replace: Accumulator): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Accumulator, replace: Accumulator): ReplaceFirst; - reverse(): Reverse; - // (undocumented) - selectable: true; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Accumulator): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Accumulator): StrContains; - subtract(other: Accumulator): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Accumulator, amount: Accumulator): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Accumulator, amount: Accumulator): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - vectorLength(): VectorLength; -} +// Warning: (ae-incompatible-release-tags) The symbol "field" is marked as @public, but its signature references "Field" which is marked as @beta +// +// @public +export function field(name: string): Field; -// @beta -export interface FilterCondition { - add(other: Accumulator): Add; - add(other: any): Add; - arrayConcat(...arrays: Accumulator[]): ArrayConcat; - arrayConcat(...arrays: any[][]): ArrayConcat; - arrayContains(element: Accumulator): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Accumulator[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Accumulator[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Accumulator): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Accumulator): Divide; - divide(other: any): Divide; - dotProduct(other: Accumulator): DotProduct; - dotProduct(other: VectorValue): DotProduct; - // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Accumulator): EndsWith; - eq(other: Accumulator): Eq; - eq(other: any): Eq; - eqAny(...others: Accumulator[]): EqAny; - // (undocumented) - eqAny(...others: any[]): EqAny; - euclideanDistance(other: Accumulator): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; - // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; - // (undocumented) - exprType: ExprType; - // (undocumented) - filterable: true; - gt(other: Accumulator): Gt; - gt(other: any): Gt; - gte(other: Accumulator): Gte; - gte(other: any): Gte; - isNaN(): IsNan; - like(pattern: string): Like; - // (undocumented) - like(pattern: Accumulator): Like; - logicalMaximum(other: Accumulator): LogicalMaximum; - logicalMaximum(other: any): LogicalMaximum; - logicalMinimum(other: Accumulator): LogicalMinimum; - logicalMinimum(other: any): LogicalMinimum; - lt(other: Accumulator): Lt; - lt(other: any): Lt; - lte(other: Accumulator): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - maximum(): Maximum; - minimum(): Minimum; - mod(other: Accumulator): Mod; - mod(other: any): Mod; - multiply(other: Accumulator): Multiply; - multiply(other: any): Multiply; - neq(other: Accumulator): Neq; - neq(other: any): Neq; - notEqAny(...others: Accumulator[]): FirestoreFunction; - // (undocumented) - notEqAny(...others: any[]): FirestoreFunction; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Accumulator): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Accumulator): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Accumulator, replace: Accumulator): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Accumulator, replace: Accumulator): ReplaceFirst; - reverse(): Reverse; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Accumulator): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Accumulator): StrContains; - subtract(other: Accumulator): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Accumulator, amount: Accumulator): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Accumulator, amount: Accumulator): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - vectorLength(): VectorLength; -} +// Warning: (ae-forgotten-export) The symbol "FieldPath" needs to be exported by the entry point pipelines.d.ts +// Warning: (ae-incompatible-release-tags) The symbol "field" is marked as @public, but its signature references "Field" which is marked as @beta +// +// @public (undocumented) +export function field(path: FieldPath): Field; // @beta (undocumented) export class FindNearest implements Stage { @@ -1077,7 +718,7 @@ export interface FindNearestOptions { // (undocumented) distanceMeasure: 'euclidean' | 'cosine' | 'dot_product'; // (undocumented) - field: Field; + field: Field | string; // (undocumented) limit?: number; // (undocumented) @@ -1085,189 +726,92 @@ export interface FindNearestOptions { } // @beta -export class FirestoreFunction { - constructor(name: string, params: Accumulator[]); - add(other: Accumulator): Add; - add(other: any): Add; - arrayConcat(...arrays: Accumulator[]): ArrayConcat; - arrayConcat(...arrays: any[][]): ArrayConcat; - arrayContains(element: Accumulator): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Accumulator[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Accumulator[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Accumulator): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Accumulator): Divide; - divide(other: any): Divide; - dotProduct(other: Accumulator): DotProduct; - dotProduct(other: VectorValue): DotProduct; - // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Accumulator): EndsWith; - eq(other: Accumulator): Eq; - eq(other: any): Eq; - eqAny(...others: Accumulator[]): EqAny; - // (undocumented) - eqAny(...others: any[]): EqAny; - euclideanDistance(other: Accumulator): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; - // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; +export class FunctionExpr extends Expr { + constructor(name: string, params: Expr[]); // (undocumented) - exprType: ExprType; - gt(other: Accumulator): Gt; - gt(other: any): Gt; - gte(other: Accumulator): Gte; - gte(other: any): Gte; - isNaN(): IsNan; - like(pattern: string): Like; - // (undocumented) - like(pattern: Accumulator): Like; - logicalMaximum(other: Accumulator): LogicalMaximum; - logicalMaximum(other: any): LogicalMaximum; - logicalMinimum(other: Accumulator): LogicalMinimum; - logicalMinimum(other: any): LogicalMinimum; - lt(other: Accumulator): Lt; - lt(other: any): Lt; - lte(other: Accumulator): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - maximum(): Maximum; - minimum(): Minimum; - mod(other: Accumulator): Mod; - mod(other: any): Mod; - multiply(other: Accumulator): Multiply; - multiply(other: any): Multiply; - neq(other: Accumulator): Neq; - neq(other: any): Neq; - notEqAny(...others: Accumulator[]): FirestoreFunction; - // (undocumented) - notEqAny(...others: any[]): FirestoreFunction; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Accumulator): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Accumulator): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Accumulator, replace: Accumulator): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Accumulator, replace: Accumulator): ReplaceFirst; - reverse(): Reverse; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Accumulator): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Accumulator): StrContains; - subtract(other: Accumulator): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Accumulator, amount: Accumulator): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Accumulator, amount: Accumulator): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - vectorLength(): VectorLength; -} - -// @beta -export function genericFunction(name: string, params: Accumulator[]): FirestoreFunction; + readonly exprType: ExprType; + } // @beta (undocumented) export class GenericStage implements Stage { - constructor(name: string, params: unknown[]); // (undocumented) name: string; -} - -// @beta (undocumented) -export class Gt extends FirestoreFunction implements FilterCondition { - constructor(left: Accumulator, right: Accumulator); - // (undocumented) - filterable: true; } // @beta -export function gt(left: Accumulator, right: Accumulator): Gt; +export function gt(left: Expr, right: Expr): BooleanExpr; // @beta -export function gt(left: Accumulator, right: any): Gt; +export function gt(expression: Expr, value: unknown): BooleanExpr; // @beta -export function gt(left: string, right: Accumulator): Gt; +export function gt(fieldName: string, expression: Expr): BooleanExpr; // @beta -export function gt(left: string, right: any): Gt; +export function gt(fieldName: string, value: unknown): BooleanExpr; -// @beta (undocumented) -export class Gte extends FirestoreFunction implements FilterCondition { - constructor(left: Accumulator, right: Accumulator); - // (undocumented) - filterable: true; - } +// @beta +export function gte(left: Expr, right: Expr): BooleanExpr; // @beta -export function gte(left: Accumulator, right: Accumulator): Gte; +export function gte(expression: Expr, value: unknown): BooleanExpr; // @beta -export function gte(left: Accumulator, right: any): Gte; +export function gte(fieldName: string, value: Expr): BooleanExpr; // @beta -export function gte(left: string, right: Accumulator): Gte; +export function gte(fieldName: string, value: unknown): BooleanExpr; // @beta -export function gte(left: string, right: any): Gte; +export function ifError(tryExpr: Expr, catchExpr: Expr): FunctionExpr; -// @beta (undocumented) -export class IsNan extends FirestoreFunction implements FilterCondition { - constructor(expr: Accumulator); - // (undocumented) - filterable: true; -} +// @beta +export function ifError(tryExpr: Expr, catchValue: unknown): FunctionExpr; // @beta -export function isNan(value: Accumulator): IsNan; +export function isAbsent(value: Expr): BooleanExpr; // @beta -export function isNan(value: string): IsNan; +export function isAbsent(field: string): BooleanExpr; -// @beta (undocumented) -export class Like extends FirestoreFunction implements FilterCondition { - constructor(expr: Accumulator, pattern: Accumulator); - // (undocumented) - filterable: true; - } +// @beta +export function isError(value: Expr): BooleanExpr; + +// @beta +export function isNan(value: Expr): BooleanExpr; + +// @beta +export function isNan(fieldName: string): BooleanExpr; + +// @beta +export function isNotNan(value: Expr): BooleanExpr; + +// @beta +export function isNotNan(value: string): BooleanExpr; + +// @beta +export function isNotNull(value: Expr): BooleanExpr; // @beta -export function like(left: string, pattern: string): Like; +export function isNotNull(value: string): BooleanExpr; // @beta -export function like(left: string, pattern: Accumulator): Like; +export function isNull(value: Expr): BooleanExpr; // @beta -export function like(left: Accumulator, pattern: string): Like; +export function isNull(value: string): BooleanExpr; // @beta -export function like(left: Accumulator, pattern: Accumulator): Like; +export function like(fieldName: string, pattern: string): BooleanExpr; + +// @beta +export function like(fieldName: string, pattern: Expr): BooleanExpr; + +// @beta +export function like(stringExpression: Expr, pattern: string): BooleanExpr; + +// @beta +export function like(stringExpression: Expr, pattern: Expr): BooleanExpr; // @beta (undocumented) export class Limit implements Stage { @@ -1280,192 +824,140 @@ export class Limit implements Stage { name: string; } -// @beta (undocumented) -export class LogicalMaximum extends FirestoreFunction { - constructor(left: Accumulator, right: Accumulator); - } +// @beta +export function logicalMaximum(first: Expr, second: Expr | unknown, ...others: Array): FunctionExpr; // @beta -export function logicalMaximum(left: Accumulator, right: Accumulator): LogicalMaximum; +export function logicalMaximum(fieldName: string, second: Expr | unknown, ...others: Array): FunctionExpr; // @beta -export function logicalMaximum(left: Accumulator, right: any): LogicalMaximum; +export function logicalMinimum(first: Expr, second: Expr | unknown, ...others: Array): FunctionExpr; // @beta -export function logicalMaximum(left: string, right: Accumulator): LogicalMaximum; +export function logicalMinimum(fieldName: string, second: Expr | unknown, ...others: Array): FunctionExpr; // @beta -export function logicalMaximum(left: string, right: any): LogicalMaximum; +export function lt(left: Expr, right: Expr): BooleanExpr; -// @beta (undocumented) -export class LogicalMinimum extends FirestoreFunction { - constructor(left: Accumulator, right: Accumulator); - } +// @beta +export function lt(expression: Expr, value: unknown): BooleanExpr; // @beta -export function logicalMinimum(left: Accumulator, right: Accumulator): LogicalMinimum; +export function lt(fieldName: string, expression: Expr): BooleanExpr; // @beta -export function logicalMinimum(left: Accumulator, right: any): LogicalMinimum; +export function lt(fieldName: string, value: unknown): BooleanExpr; // @beta -export function logicalMinimum(left: string, right: Accumulator): LogicalMinimum; +export function lte(left: Expr, right: Expr): BooleanExpr; // @beta -export function logicalMinimum(left: string, right: any): LogicalMinimum; +export function lte(expression: Expr, value: unknown): BooleanExpr; -// @beta (undocumented) -export class Lt extends FirestoreFunction implements FilterCondition { - constructor(left: Accumulator, right: Accumulator); - // (undocumented) - filterable: true; - } +// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Expr" which is marked as @beta +// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "BooleanExpr" which is marked as @beta +// +// @public +export function lte(fieldName: string, expression: Expr): BooleanExpr; // @beta -export function lt(left: Accumulator, right: Accumulator): Lt; +export function lte(fieldName: string, value: unknown): BooleanExpr; // @beta -export function lt(left: Accumulator, right: any): Lt; +export function manhattanDistance(fieldName: string, vector: number[] | VectorValue): FunctionExpr; // @beta -export function lt(left: string, right: Accumulator): Lt; +export function manhattanDistance(fieldName: string, vectorExpression: Expr): FunctionExpr; // @beta -export function lt(left: string, right: any): Lt; - -// @beta (undocumented) -export class Lte extends FirestoreFunction implements FilterCondition { - constructor(left: Accumulator, right: Accumulator); - // (undocumented) - filterable: true; - } +export function manhattanDistance(vectorExpression: Expr, vector: number[] | VectorValue): FunctionExpr; // @beta -export function lte(left: Accumulator, right: Accumulator): Lte; +export function manhattanDistance(vectorExpression: Expr, otherVectorExpression: Expr): FunctionExpr; // @beta -export function lte(left: Accumulator, right: any): Lte; - -// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Accumulator" which is marked as @beta -// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Lte" which is marked as @beta -// -// @public -export function lte(left: string, right: Accumulator): Lte; +export function map(elements: Record): FunctionExpr; // @beta -export function lte(left: string, right: any): Lte; - -// @beta (undocumented) -export class MapGet extends FirestoreFunction { - constructor(map: Accumulator, name: string); -} +export function mapGet(fieldName: string, subField: string): FunctionExpr; // @beta -export function mapGet(mapField: string, subField: string): MapGet; +export function mapGet(mapExpression: Expr, subField: string): FunctionExpr; // @beta -export function mapGet(mapExpr: Accumulator, subField: string): MapGet; - -// @beta (undocumented) -export class Maximum extends FirestoreFunction implements Accumulator { - constructor(value: Accumulator, distinct: boolean); - // (undocumented) - accumulator: true; - } +export function mapMerge(mapField: string, secondMap: Record | Expr, ...otherMaps: Array | Expr>): FunctionExpr; // @beta -export function maximum(value: Accumulator): Maximum; +export function mapMerge(firstMap: Record | Expr, secondMap: Record | Expr, ...otherMaps: Array | Expr>): FunctionExpr; // @beta -export function maximum(value: string): Maximum; - -// @beta (undocumented) -export class Minimum extends FirestoreFunction implements Accumulator { - constructor(value: Accumulator, distinct: boolean); - // (undocumented) - accumulator: true; - } +export function mapRemove(mapField: string, key: string): FunctionExpr; // @beta -export function minimum(value: Accumulator): Minimum; +export function mapRemove(mapExpr: Expr, key: string): FunctionExpr; // @beta -export function minimum(value: string): Minimum; - -// @beta (undocumented) -export class Mod extends FirestoreFunction { - constructor(left: Accumulator, right: Accumulator); - } +export function mapRemove(mapField: string, keyExpr: Expr): FunctionExpr; // @beta -export function mod(left: Accumulator, right: Accumulator): Mod; +export function mapRemove(mapExpr: Expr, keyExpr: Expr): FunctionExpr; // @beta -export function mod(left: Accumulator, right: any): Mod; +export function maximum(expression: Expr): AggregateFunction; // @beta -export function mod(left: string, right: Accumulator): Mod; +export function maximum(fieldName: string): AggregateFunction; // @beta -export function mod(left: string, right: any): Mod; +export function minimum(expression: Expr): AggregateFunction; -// @beta (undocumented) -export class Multiply extends FirestoreFunction { - constructor(left: Accumulator, right: Accumulator); - } +// @beta +export function minimum(fieldName: string): AggregateFunction; // @beta -export function multiply(left: Accumulator, right: Accumulator): Multiply; +export function mod(left: Expr, right: Expr): FunctionExpr; // @beta -export function multiply(left: Accumulator, right: any): Multiply; +export function mod(expression: Expr, value: unknown): FunctionExpr; // @beta -export function multiply(left: string, right: Accumulator): Multiply; +export function mod(fieldName: string, expression: Expr): FunctionExpr; // @beta -export function multiply(left: string, right: any): Multiply; +export function mod(fieldName: string, value: unknown): FunctionExpr; -// @beta (undocumented) -export class Neq extends FirestoreFunction implements FilterCondition { - constructor(left: Accumulator, right: Accumulator); - // (undocumented) - filterable: true; - } +// @beta +export function multiply(first: Expr, second: Expr | unknown, ...others: Array): FunctionExpr; // @beta -export function neq(left: Accumulator, right: Accumulator): Neq; +export function multiply(fieldName: string, second: Expr | unknown, ...others: Array): FunctionExpr; // @beta -export function neq(left: Accumulator, right: any): Neq; +export function neq(left: Expr, right: Expr): BooleanExpr; // @beta -export function neq(left: string, right: Accumulator): Neq; +export function neq(expression: Expr, value: unknown): BooleanExpr; // @beta -export function neq(left: string, right: any): Neq; +export function neq(fieldName: string, expression: Expr): BooleanExpr; -// @beta (undocumented) -export class Not extends FirestoreFunction implements FilterCondition { - constructor(expr: Accumulator); - // (undocumented) - filterable: true; -} +// @beta +export function neq(fieldName: string, value: unknown): BooleanExpr; // @beta -export function not(filter: FilterCondition): Not; +export function not(booleanExpr: BooleanExpr): BooleanExpr; // @beta -export function notEqAny(element: Accumulator, others: Accumulator[]): FirestoreFunction; +export function notEqAny(element: Expr, values: Array): BooleanExpr; // @beta -export function notEqAny(element: Accumulator, others: any[]): FirestoreFunction; +export function notEqAny(fieldName: string, values: Array): BooleanExpr; // @beta -export function notEqAny(element: string, others: Accumulator[]): FirestoreFunction; +export function notEqAny(element: Expr, arrayExpression: Expr): BooleanExpr; // @beta -export function notEqAny(element: string, others: any[]): FirestoreFunction; +export function notEqAny(fieldName: string, arrayExpression: Expr): BooleanExpr; // @beta (undocumented) export class Offset implements Stage { @@ -1474,79 +966,75 @@ export class Offset implements Stage { name: string; } -// @beta (undocumented) -export class Or extends FirestoreFunction implements FilterCondition { - constructor(conditions: FilterCondition[]); - // (undocumented) - filterable: true; -} +// @beta +export function or(first: BooleanExpr, second: BooleanExpr, ...more: BooleanExpr[]): BooleanExpr; // @beta export class Ordering { - constructor(expr: Accumulator, direction: 'ascending' | 'descending'); + constructor(expr: Expr, direction: 'ascending' | 'descending'); // (undocumented) readonly direction: 'ascending' | 'descending'; // (undocumented) - readonly expr: Accumulator; + readonly expr: Expr; } // @public export class Pipeline { /* Excluded from this release type: _db */ // Warning: (ae-incompatible-release-tags) The symbol "addFields" is marked as @public, but its signature references "Selectable" which is marked as @beta - addFields(...fields: Selectable[]): Pipeline; + addFields(field: Selectable, ...additionalFields: Selectable[]): Pipeline; /* Excluded from this release type: _userDataWriter */ - // Warning: (ae-incompatible-release-tags) The symbol "aggregate" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta - aggregate(...accumulators: AccumulatorTarget[]): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "aggregate" is marked as @public, but its signature references "AggregateWithAlias" which is marked as @beta + aggregate(accumulator: AggregateWithAlias, ...additionalAccumulators: AggregateWithAlias[]): Pipeline; /* Excluded from this release type: _userDataWriter */ aggregate(options: { - accumulators: AccumulatorTarget[]; + accumulators: AggregateWithAlias[]; groups?: Array; }): Pipeline; /* Excluded from this release type: _userDataWriter */ // Warning: (ae-incompatible-release-tags) The symbol "distinct" is marked as @public, but its signature references "Selectable" which is marked as @beta - distinct(...groups: Array): Pipeline; - /* Excluded from this release type: _userDataWriter */ - // Warning: (ae-incompatible-release-tags) The symbol "execute" is marked as @public, but its signature references "PipelineResult" which is marked as @beta - execute(): Promise; + distinct(group: string | Selectable, ...additionalGroups: Array): Pipeline; /* Excluded from this release type: _userDataWriter */ // Warning: (ae-incompatible-release-tags) The symbol "findNearest" is marked as @public, but its signature references "FindNearestOptions" which is marked as @beta // // (undocumented) findNearest(options: FindNearestOptions): Pipeline; /* Excluded from this release type: _userDataWriter */ - genericStage(name: string, params: any[]): Pipeline; + genericStage(name: string, params: unknown[]): Pipeline; /* Excluded from this release type: _userDataWriter */ limit(limit: number): Pipeline; /* Excluded from this release type: _userDataWriter */ offset(offset: number): Pipeline; /* Excluded from this release type: _userDataWriter */ + // Warning: (ae-incompatible-release-tags) The symbol "removeFields" is marked as @public, but its signature references "Field" which is marked as @beta + removeFields(fieldValue: Field | string, ...additionalFields: Array): Pipeline; + /* Excluded from this release type: _userDataWriter */ + // Warning: (ae-incompatible-release-tags) The symbol "replaceWith" is marked as @public, but its signature references "Field" which is marked as @beta + replaceWith(fieldValue: Field | string): Pipeline; + /* Excluded from this release type: _userDataWriter */ + sample(documents: number): Pipeline; + /* Excluded from this release type: _userDataWriter */ + sample(options: { + percentage: number; + } | { + documents: number; + }): Pipeline; + /* Excluded from this release type: _userDataWriter */ // Warning: (ae-incompatible-release-tags) The symbol "select" is marked as @public, but its signature references "Selectable" which is marked as @beta - select(...selections: Array): Pipeline; + select(selection: Selectable | string, ...additionalSelections: Array): Pipeline; /* Excluded from this release type: _userDataWriter */ // Warning: (ae-incompatible-release-tags) The symbol "sort" is marked as @public, but its signature references "Ordering" which is marked as @beta - sort(...orderings: Ordering[]): Pipeline; + sort(ordering: Ordering, ...additionalOrderings: Ordering[]): Pipeline; /* Excluded from this release type: _userDataWriter */ - // (undocumented) - sort(options: { - orderings: Ordering[]; - }): Pipeline; + union(other: Pipeline): Pipeline; /* Excluded from this release type: _userDataWriter */ - // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "FilterCondition" which is marked as @beta - where(condition: FilterCondition): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "unnest" is marked as @public, but its signature references "Selectable" which is marked as @beta + unnest(selectable: Selectable, indexField?: string): Pipeline; + /* Excluded from this release type: _userDataWriter */ + // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "BooleanExpr" which is marked as @beta + where(condition: BooleanExpr): Pipeline; } -// Warning: (ae-forgotten-export) The symbol "Firestore" needs to be exported by the entry point pipelines.d.ts -// Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta -// -// @public -export function pipeline(firestore: Firestore): PipelineSource; - -// Warning: (ae-forgotten-export) The symbol "Query" needs to be exported by the entry point pipelines.d.ts -// -// @public -export function pipeline(query: Query): Pipeline; - // Warning: (ae-forgotten-export) The symbol "DocumentData" needs to be exported by the entry point pipelines.d.ts // // @beta @@ -1556,215 +1044,109 @@ export class PipelineResult { /* Excluded from this release type: __constructor */ get createTime(): Timestamp | undefined; data(): AppModelType | undefined; - get executionTime(): Timestamp; - get(fieldPath: string | FieldPath): any; + get(fieldPath: string | FieldPath | Field): any; get id(): string | undefined; get ref(): DocumentReference | undefined; get updateTime(): Timestamp | undefined; } +// @public (undocumented) +export class PipelineSnapshot { + // Warning: (ae-incompatible-release-tags) The symbol "__constructor" is marked as @public, but its signature references "PipelineResult" which is marked as @beta + constructor(pipeline: Pipeline, results: PipelineResult[], executionTime?: Timestamp); + get executionTime(): Timestamp; + get pipeline(): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "results" is marked as @public, but its signature references "PipelineResult" which is marked as @beta + get results(): PipelineResult[]; +} + // @beta export class PipelineSource { + collection(collectionPath: string): PipelineType; + /* Excluded from this release type: _createPipeline */ + /* Excluded from this release type: __constructor */ + // Warning: (ae-forgotten-export) The symbol "Query" needs to be exported by the entry point pipelines.d.ts + collection(collectionReference: Query): PipelineType; /* Excluded from this release type: _createPipeline */ /* Excluded from this release type: __constructor */ - // (undocumented) - collection(collectionPath: string): PipelineType; - // (undocumented) collectionGroup(collectionId: string): PipelineType; - // (undocumented) + /* Excluded from this release type: _createPipeline */ + /* Excluded from this release type: __constructor */ + createFrom(query: Query): Pipeline; + /* Excluded from this release type: _createPipeline */ + /* Excluded from this release type: __constructor */ database(): PipelineType; - // (undocumented) - documents(docs: DocumentReference[]): PipelineType; + /* Excluded from this release type: _createPipeline */ + /* Excluded from this release type: __constructor */ + documents(docs: Array): PipelineType; } -// @beta (undocumented) -export class RegexContains extends FirestoreFunction implements FilterCondition { - constructor(expr: Accumulator, pattern: Accumulator); - // (undocumented) - filterable: true; - } - // @beta -export function regexContains(left: string, pattern: string): RegexContains; +export function rand(): FunctionExpr; // @beta -export function regexContains(left: string, pattern: Accumulator): RegexContains; +export function regexContains(fieldName: string, pattern: string): BooleanExpr; // @beta -export function regexContains(left: Accumulator, pattern: string): RegexContains; +export function regexContains(fieldName: string, pattern: Expr): BooleanExpr; // @beta -export function regexContains(left: Accumulator, pattern: Accumulator): RegexContains; - -// @beta (undocumented) -export class RegexMatch extends FirestoreFunction implements FilterCondition { - constructor(expr: Accumulator, pattern: Accumulator); - // (undocumented) - filterable: true; - } +export function regexContains(stringExpression: Expr, pattern: string): BooleanExpr; // @beta -export function regexMatch(left: string, pattern: string): RegexMatch; +export function regexContains(stringExpression: Expr, pattern: Expr): BooleanExpr; // @beta -export function regexMatch(left: string, pattern: Accumulator): RegexMatch; +export function regexMatch(fieldName: string, pattern: string): BooleanExpr; // @beta -export function regexMatch(left: Accumulator, pattern: string): RegexMatch; +export function regexMatch(fieldName: string, pattern: Expr): BooleanExpr; // @beta -export function regexMatch(left: Accumulator, pattern: Accumulator): RegexMatch; - -// @beta (undocumented) -export class ReplaceAll extends FirestoreFunction { - constructor(value: Accumulator, find: Accumulator, replace: Accumulator); - } +export function regexMatch(stringExpression: Expr, pattern: string): BooleanExpr; // @beta -export function replaceAll(value: Accumulator, find: string, replace: string): ReplaceAll; +export function regexMatch(stringExpression: Expr, pattern: Expr): BooleanExpr; // @beta -export function replaceAll(value: Accumulator, find: Accumulator, replace: Accumulator): ReplaceAll; +export function replaceAll(value: Expr, find: string, replace: string): FunctionExpr; // @beta -export function replaceAll(field: string, find: string, replace: string): ReplaceAll; - -// @beta (undocumented) -export class ReplaceFirst extends FirestoreFunction { - constructor(value: Accumulator, find: Accumulator, replace: Accumulator); - } +export function replaceAll(value: Expr, find: Expr, replace: Expr): FunctionExpr; // @beta -export function replaceFirst(value: Accumulator, find: string, replace: string): ReplaceFirst; +export function replaceAll(fieldName: string, find: string, replace: string): FunctionExpr; // @beta -export function replaceFirst(value: Accumulator, find: Accumulator, replace: Accumulator): ReplaceFirst; +export function replaceFirst(value: Expr, find: string, replace: string): FunctionExpr; // @beta -export function replaceFirst(field: string, find: string, replace: string): ReplaceFirst; +export function replaceFirst(value: Expr, find: Expr, replace: Expr): FunctionExpr; -// @beta (undocumented) -export class Reverse extends FirestoreFunction { - constructor(value: Accumulator); - } +// @beta +export function replaceFirst(fieldName: string, find: string, replace: string): FunctionExpr; // @beta -export function reverse(expr: Accumulator): Reverse; +export function reverse(stringExpression: Expr): FunctionExpr; // @beta -export function reverse(field: string): Reverse; +export function reverse(field: string): FunctionExpr; // @beta (undocumented) export class Select implements Stage { - constructor(projections: Map); + constructor(projections: Map); // (undocumented) name: string; } // @beta export interface Selectable { - add(other: Accumulator): Add; - add(other: any): Add; - arrayConcat(...arrays: Accumulator[]): ArrayConcat; - arrayConcat(...arrays: any[][]): ArrayConcat; - arrayContains(element: Accumulator): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Accumulator[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Accumulator[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Accumulator): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Accumulator): Divide; - divide(other: any): Divide; - dotProduct(other: Accumulator): DotProduct; - dotProduct(other: VectorValue): DotProduct; - // (undocumented) - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Accumulator): EndsWith; - eq(other: Accumulator): Eq; - eq(other: any): Eq; - eqAny(...others: Accumulator[]): EqAny; // (undocumented) - eqAny(...others: any[]): EqAny; - euclideanDistance(other: Accumulator): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; - // (undocumented) - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; - // (undocumented) - exprType: ExprType; - gt(other: Accumulator): Gt; - gt(other: any): Gt; - gte(other: Accumulator): Gte; - gte(other: any): Gte; - isNaN(): IsNan; - like(pattern: string): Like; - // (undocumented) - like(pattern: Accumulator): Like; - logicalMaximum(other: Accumulator): LogicalMaximum; - logicalMaximum(other: any): LogicalMaximum; - logicalMinimum(other: Accumulator): LogicalMinimum; - logicalMinimum(other: any): LogicalMinimum; - lt(other: Accumulator): Lt; - lt(other: any): Lt; - lte(other: Accumulator): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - maximum(): Maximum; - minimum(): Minimum; - mod(other: Accumulator): Mod; - mod(other: any): Mod; - multiply(other: Accumulator): Multiply; - multiply(other: any): Multiply; - neq(other: Accumulator): Neq; - neq(other: any): Neq; - notEqAny(...others: Accumulator[]): FirestoreFunction; + readonly alias: string; // (undocumented) - notEqAny(...others: any[]): FirestoreFunction; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Accumulator): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Accumulator): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Accumulator, replace: Accumulator): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Accumulator, replace: Accumulator): ReplaceFirst; - reverse(): Reverse; + readonly expr: Expr; // (undocumented) selectable: true; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Accumulator): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Accumulator): StrContains; - subtract(other: Accumulator): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Accumulator, amount: Accumulator): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Accumulator, amount: Accumulator): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - vectorLength(): VectorLength; } // @beta (undocumented) @@ -1780,240 +1162,153 @@ export interface Stage { name: string; } -// @beta (undocumented) -export class StartsWith extends FirestoreFunction implements FilterCondition { - constructor(expr: Accumulator, prefix: Accumulator); - // (undocumented) - filterable: true; - } - // @beta -export function startsWith(expr: string, prefix: string): StartsWith; +export function startsWith(fieldName: string, prefix: string): BooleanExpr; // @beta -export function startsWith(expr: string, prefix: Accumulator): StartsWith; +export function startsWith(fieldName: string, prefix: Expr): BooleanExpr; // @beta -export function startsWith(expr: Accumulator, prefix: string): StartsWith; +export function startsWith(stringExpression: Expr, prefix: string): BooleanExpr; // @beta -export function startsWith(expr: Accumulator, prefix: Accumulator): StartsWith; - -// @beta (undocumented) -export class StrConcat extends FirestoreFunction { - constructor(first: Accumulator, rest: Accumulator[]); - } +export function startsWith(stringExpression: Expr, prefix: Expr): BooleanExpr; // @beta -export function strConcat(first: string, ...elements: Array): StrConcat; +export function strConcat(fieldName: string, secondString: Expr | string, ...otherStrings: Array): FunctionExpr; // @beta -export function strConcat(first: Accumulator, ...elements: Array): StrConcat; - -// @beta (undocumented) -export class StrContains extends FirestoreFunction implements FilterCondition { - constructor(expr: Accumulator, substring: Accumulator); - // (undocumented) - filterable: true; - } +export function strConcat(firstString: Expr, secondString: Expr | string, ...otherStrings: Array): FunctionExpr; // @beta -export function strContains(left: string, substring: string): StrContains; +export function strContains(fieldName: string, substring: string): BooleanExpr; // @beta -export function strContains(left: string, substring: Accumulator): StrContains; +export function strContains(fieldName: string, substring: Expr): BooleanExpr; // @beta -export function strContains(left: Accumulator, substring: string): StrContains; +export function strContains(stringExpression: Expr, substring: string): BooleanExpr; // @beta -export function strContains(left: Accumulator, substring: Accumulator): StrContains; - -// @beta (undocumented) -export class Subtract extends FirestoreFunction { - constructor(left: Accumulator, right: Accumulator); - } +export function strContains(stringExpression: Expr, substring: Expr): BooleanExpr; // @beta -export function subtract(left: Accumulator, right: Accumulator): Subtract; +export function substr(field: string, position: number, length?: number): FunctionExpr; // @beta -export function subtract(left: Accumulator, right: any): Subtract; +export function substr(input: Expr, position: number, length?: number): FunctionExpr; // @beta -export function subtract(left: string, right: Accumulator): Subtract; +export function substr(field: string, position: Expr, length?: Expr): FunctionExpr; // @beta -export function subtract(left: string, right: any): Subtract; - -// @beta (undocumented) -export class Sum extends FirestoreFunction implements Accumulator { - constructor(value: Accumulator, distinct: boolean); - // (undocumented) - accumulator: true; - } - -// @beta (undocumented) -export class TimestampAdd extends FirestoreFunction { - constructor(timestamp: Accumulator, unit: Accumulator, amount: Accumulator); - } +export function substr(input: Expr, position: Expr, length?: Expr): FunctionExpr; // @beta -export function timestampAdd(timestamp: Accumulator, unit: Accumulator, amount: Accumulator): TimestampAdd; +export function subtract(left: Expr, right: Expr): FunctionExpr; // @beta -export function timestampAdd(timestamp: Accumulator, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; +export function subtract(expression: Expr, value: unknown): FunctionExpr; // @beta -export function timestampAdd(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - -// @beta (undocumented) -export class TimestampSub extends FirestoreFunction { - constructor(timestamp: Accumulator, unit: Accumulator, amount: Accumulator); - } +export function subtract(fieldName: string, expression: Expr): FunctionExpr; // @beta -export function timestampSub(timestamp: Accumulator, unit: Accumulator, amount: Accumulator): TimestampSub; +export function subtract(fieldName: string, value: unknown): FunctionExpr; // @beta -export function timestampSub(timestamp: Accumulator, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; +export function timestampAdd(timestamp: Expr, unit: Expr, amount: Expr): FunctionExpr; // @beta -export function timestampSub(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - -// @beta (undocumented) -export class TimestampToUnixMicros extends FirestoreFunction { - constructor(input: Accumulator); - } +export function timestampAdd(timestamp: Expr, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): FunctionExpr; // @beta -export function timestampToUnixMicros(expr: Accumulator): TimestampToUnixMicros; +export function timestampAdd(fieldName: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): FunctionExpr; // @beta -export function timestampToUnixMicros(field: string): TimestampToUnixMicros; - -// @beta (undocumented) -export class TimestampToUnixMillis extends FirestoreFunction { - constructor(input: Accumulator); - } +export function timestampSub(timestamp: Expr, unit: Expr, amount: Expr): FunctionExpr; // @beta -export function timestampToUnixMillis(expr: Accumulator): TimestampToUnixMillis; +export function timestampSub(timestamp: Expr, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): FunctionExpr; // @beta -export function timestampToUnixMillis(field: string): TimestampToUnixMillis; - -// @beta (undocumented) -export class TimestampToUnixSeconds extends FirestoreFunction { - constructor(input: Accumulator); - } +export function timestampSub(fieldName: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): FunctionExpr; // @beta -export function timestampToUnixSeconds(expr: Accumulator): TimestampToUnixSeconds; +export function timestampToUnixMicros(expr: Expr): FunctionExpr; // @beta -export function timestampToUnixSeconds(field: string): TimestampToUnixSeconds; - -// @beta (undocumented) -export class ToLower extends FirestoreFunction { - constructor(expr: Accumulator); - } +export function timestampToUnixMicros(fieldName: string): FunctionExpr; // @beta -export function toLower(expr: string): ToLower; +export function timestampToUnixMillis(expr: Expr): FunctionExpr; // @beta -export function toLower(expr: Accumulator): ToLower; - -// @beta (undocumented) -export class ToUpper extends FirestoreFunction { - constructor(expr: Accumulator); - } +export function timestampToUnixMillis(fieldName: string): FunctionExpr; // @beta -export function toUpper(expr: string): ToUpper; +export function timestampToUnixSeconds(expr: Expr): FunctionExpr; // @beta -export function toUpper(expr: Accumulator): ToUpper; - -// @beta (undocumented) -export class Trim extends FirestoreFunction { - constructor(expr: Accumulator); - } +export function timestampToUnixSeconds(fieldName: string): FunctionExpr; // @beta -export function trim(expr: string): Trim; +export function toLower(fieldName: string): FunctionExpr; // @beta -export function trim(expr: Accumulator): Trim; +export function toLower(stringExpression: Expr): FunctionExpr; -// @beta (undocumented) -export class UnixMicrosToTimestamp extends FirestoreFunction { - constructor(input: Accumulator); - } +// @beta +export function toUpper(fieldName: string): FunctionExpr; // @beta -export function unixMicrosToTimestamp(expr: Accumulator): UnixMicrosToTimestamp; +export function toUpper(stringExpression: Expr): FunctionExpr; // @beta -export function unixMicrosToTimestamp(field: string): UnixMicrosToTimestamp; +export function trim(fieldName: string): FunctionExpr; -// @beta (undocumented) -export class UnixMillisToTimestamp extends FirestoreFunction { - constructor(input: Accumulator); - } +// @beta +export function trim(stringExpression: Expr): FunctionExpr; // @beta -export function unixMillisToTimestamp(expr: Accumulator): UnixMillisToTimestamp; +export function unixMicrosToTimestamp(expr: Expr): FunctionExpr; // @beta -export function unixMillisToTimestamp(field: string): UnixMillisToTimestamp; +export function unixMicrosToTimestamp(fieldName: string): FunctionExpr; -// @beta (undocumented) -export class UnixSecondsToTimestamp extends FirestoreFunction { - constructor(input: Accumulator); - } +// @beta +export function unixMillisToTimestamp(expr: Expr): FunctionExpr; // @beta -export function unixSecondsToTimestamp(expr: Accumulator): UnixSecondsToTimestamp; +export function unixMillisToTimestamp(fieldName: string): FunctionExpr; // @beta -export function unixSecondsToTimestamp(field: string): UnixSecondsToTimestamp; +export function unixSecondsToTimestamp(expr: Expr): FunctionExpr; -// @beta (undocumented) -export class VectorLength extends FirestoreFunction { - constructor(value: Accumulator); - } +// @beta +export function unixSecondsToTimestamp(fieldName: string): FunctionExpr; // @beta -export function vectorLength(expr: Accumulator): VectorLength; +export function vectorLength(vectorExpression: Expr): FunctionExpr; // @beta -export function vectorLength(field: string): VectorLength; +export function vectorLength(fieldName: string): FunctionExpr; // @beta (undocumented) export class Where implements Stage { - constructor(condition: FilterCondition); + constructor(condition: BooleanExpr); // (undocumented) name: string; } -// @beta (undocumented) -export class Xor extends FirestoreFunction implements FilterCondition { - constructor(conditions: FilterCondition[]); - // (undocumented) - filterable: true; -} - // @beta -export function xor(left: FilterCondition, ...right: FilterCondition[]): Xor; +export function xor(first: BooleanExpr, second: BooleanExpr, ...additionalConditions: BooleanExpr[]): BooleanExpr; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/pipelines.d.ts:10253:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/pipelines.d.ts:10254:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/pipelines.d.ts:10283:9 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/pipelines.d.ts:4613:9 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AggregateWithAlias" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/lite/pipelines.d.ts:4614:9 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta // (No @packageDocumentation comment for this package) diff --git a/common/api-review/firestore-pipelines.api.md b/common/api-review/firestore-pipelines.api.md index 375f5dfd976..baedbf6b08a 100644 --- a/common/api-review/firestore-pipelines.api.md +++ b/common/api-review/firestore-pipelines.api.md @@ -7,30 +7,10 @@ import { FirebaseApp } from '@firebase/app'; // @beta -export interface Accumulator extends Expr { - // (undocumented) - accumulator: true; -} - -// @beta -export type AccumulatorTarget = ExprWithAlias; - -// @beta (undocumented) -export class Add extends FirestoreFunction { - constructor(left: Expr, right: Expr); - } +export function add(first: Expr, second: Expr | unknown, ...others: Array): FunctionExpr; // @beta -export function add(left: Expr, right: Expr): Add; - -// @beta -export function add(left: Expr, right: any): Add; - -// @beta -export function add(left: string, right: Expr): Add; - -// @beta -export function add(left: string, right: any): Add; +export function add(fieldName: string, second: Expr | unknown, ...others: Array): FunctionExpr; // @beta (undocumented) export class AddFields implements Stage { @@ -41,150 +21,190 @@ export class AddFields implements Stage { // @beta (undocumented) export class Aggregate implements Stage { - constructor(accumulators: Map, groups: Map); + constructor(accumulators: Map, groups: Map); // (undocumented) name: string; } -// @beta (undocumented) -export class And extends FirestoreFunction implements FilterCondition { - constructor(conditions: FilterCondition[]); +// @beta +export class AggregateFunction { + constructor(name: string, params: Expr[]); + as(name: string): AggregateWithAlias; // (undocumented) - filterable: true; + exprType: ExprType; + } + +// @beta +export class AggregateWithAlias { + constructor(aggregate: AggregateFunction, alias: string); + // (undocumented) + readonly aggregate: AggregateFunction; + // (undocumented) + readonly alias: string; } // @beta -export function andFunction(left: FilterCondition, ...right: FilterCondition[]): And; +export function and(first: BooleanExpr, second: BooleanExpr, ...more: BooleanExpr[]): BooleanExpr; -// @beta (undocumented) -export class ArrayConcat extends FirestoreFunction { - constructor(array: Expr, elements: Expr[]); - } +// @beta +export function array(elements: unknown[]): FunctionExpr; // @beta -export function arrayConcat(array: Expr, elements: Expr[]): ArrayConcat; +export function arrayConcat(firstArray: Expr, secondArray: Expr | unknown[], ...otherArrays: Array): FunctionExpr; // @beta -export function arrayConcat(array: Expr, elements: any[]): ArrayConcat; +export function arrayConcat(firstArrayField: string, secondArray: Expr | unknown[], ...otherArrays: Array): FunctionExpr; // @beta -export function arrayConcat(array: string, elements: Expr[]): ArrayConcat; +export function arrayContains(array: Expr, element: Expr): FunctionExpr; // @beta -export function arrayConcat(array: string, elements: any[]): ArrayConcat; +export function arrayContains(array: Expr, element: unknown): FunctionExpr; -// @beta (undocumented) -export class ArrayContains extends FirestoreFunction implements FilterCondition { - constructor(array: Expr, element: Expr); - // (undocumented) - filterable: true; -} +// @beta +export function arrayContains(fieldName: string, element: Expr): FunctionExpr; // @beta -export function arrayContains(array: Expr, element: Expr): ArrayContains; +export function arrayContains(fieldName: string, element: unknown): BooleanExpr; // @beta -export function arrayContains(array: Expr, element: any): ArrayContains; +export function arrayContainsAll(array: Expr, values: Array): BooleanExpr; // @beta -export function arrayContains(array: string, element: Expr): ArrayContains; +export function arrayContainsAll(fieldName: string, values: Array): BooleanExpr; // @beta -export function arrayContains(array: string, element: any): ArrayContains; +export function arrayContainsAll(array: Expr, arrayExpression: Expr): BooleanExpr; -// @beta (undocumented) -export class ArrayContainsAll extends FirestoreFunction implements FilterCondition { - constructor(array: Expr, values: Expr[]); - // (undocumented) - filterable: true; - } +// @beta +export function arrayContainsAll(fieldName: string, arrayExpression: Expr): BooleanExpr; // @beta -export function arrayContainsAll(array: Expr, values: Expr[]): ArrayContainsAll; +export function arrayContainsAny(array: Expr, values: Array): BooleanExpr; // @beta -export function arrayContainsAll(array: Expr, values: any[]): ArrayContainsAll; +export function arrayContainsAny(fieldName: string, values: Array): BooleanExpr; // @beta -export function arrayContainsAll(array: string, values: Expr[]): ArrayContainsAll; +export function arrayContainsAny(array: Expr, values: Expr): BooleanExpr; // @beta -export function arrayContainsAll(array: string, values: any[]): ArrayContainsAll; +export function arrayContainsAny(fieldName: string, values: Expr): BooleanExpr; -// @beta (undocumented) -export class ArrayContainsAny extends FirestoreFunction implements FilterCondition { - constructor(array: Expr, values: Expr[]); - // (undocumented) - filterable: true; - } +// @beta +export function arrayLength(array: Expr): FunctionExpr; // @beta -export function arrayContainsAny(array: Expr, values: Expr[]): ArrayContainsAny; +export function arrayOffset(arrayField: string, offset: number): FunctionExpr; // @beta -export function arrayContainsAny(array: Expr, values: any[]): ArrayContainsAny; +export function arrayOffset(arrayField: string, offsetExpr: Expr): FunctionExpr; // @beta -export function arrayContainsAny(array: string, values: Expr[]): ArrayContainsAny; +export function arrayOffset(arrayExpression: Expr, offset: number): FunctionExpr; // @beta -export function arrayContainsAny(array: string, values: any[]): ArrayContainsAny; +export function arrayOffset(arrayExpression: Expr, offsetExpr: Expr): FunctionExpr; -// @beta (undocumented) -export class ArrayElement extends FirestoreFunction { - constructor(); -} +// @beta +export function ascending(expr: Expr): Ordering; -// @beta (undocumented) -export class ArrayLength extends FirestoreFunction { - constructor(array: Expr); - } +// @beta +export function ascending(fieldName: string): Ordering; // @beta -export function arrayLength(array: Expr): ArrayLength; +export function avg(expression: Expr): AggregateFunction; -// @beta (undocumented) -export class ArrayReverse extends FirestoreFunction { - constructor(array: Expr); - } +// @beta +export function avg(fieldName: string): AggregateFunction; +// Warning: (ae-forgotten-export) The symbol "Bytes" needs to be exported by the entry point pipelines.d.ts +// // @beta -export function ascending(expr: Expr): Ordering; +export function bitAnd(field: string, otherBits: number | Bytes): FunctionExpr; -// @beta (undocumented) -export class Avg extends FirestoreFunction implements Accumulator { - constructor(value: Expr, distinct: boolean); - // (undocumented) - accumulator: true; - } +// @beta +export function bitAnd(field: string, bitsExpression: Expr): FunctionExpr; // @beta -export function avgFunction(value: Expr): Avg; +export function bitAnd(bitsExpression: Expr, otherBits: number | Bytes): FunctionExpr; // @beta -export function avgFunction(value: string): Avg; +export function bitAnd(bitsExpression: Expr, otherBitsExpression: Expr): FunctionExpr; -// @beta (undocumented) -export class ByteLength extends FirestoreFunction { - constructor(value: Expr); - } +// @beta +export function bitLeftShift(field: string, y: number): FunctionExpr; // @beta -export function byteLength(expr: Expr): ByteLength; +export function bitLeftShift(field: string, numberExpr: Expr): FunctionExpr; // @beta -export function byteLength(field: string): ByteLength; +export function bitLeftShift(xValue: Expr, y: number): FunctionExpr; -// @beta (undocumented) -export class CharLength extends FirestoreFunction { - constructor(value: Expr); - } +// @beta +export function bitLeftShift(xValue: Expr, numberExpr: Expr): FunctionExpr; + +// @beta +export function bitNot(field: string): FunctionExpr; + +// @beta +export function bitNot(bitsValueExpression: Expr): FunctionExpr; // @beta -export function charLength(field: string): CharLength; +export function bitOr(field: string, otherBits: number | Bytes): FunctionExpr; // @beta -export function charLength(expr: Expr): CharLength; +export function bitOr(field: string, bitsExpression: Expr): FunctionExpr; + +// @beta +export function bitOr(bitsExpression: Expr, otherBits: number | Bytes): FunctionExpr; + +// @beta +export function bitOr(bitsExpression: Expr, otherBitsExpression: Expr): FunctionExpr; + +// @beta +export function bitRightShift(field: string, y: number): FunctionExpr; + +// @beta +export function bitRightShift(field: string, numberExpr: Expr): FunctionExpr; + +// @beta +export function bitRightShift(xValue: Expr, y: number): FunctionExpr; + +// @beta +export function bitRightShift(xValue: Expr, numberExpr: Expr): FunctionExpr; + +// @beta +export function bitXor(field: string, otherBits: number | Bytes): FunctionExpr; + +// @beta +export function bitXor(field: string, bitsExpression: Expr): FunctionExpr; + +// @beta +export function bitXor(bitsExpression: Expr, otherBits: number | Bytes): FunctionExpr; + +// @beta +export function bitXor(bitsExpression: Expr, otherBitsExpression: Expr): FunctionExpr; + +// @beta +export class BooleanExpr extends FunctionExpr { + countIf(): AggregateFunction; + // (undocumented) + filterable: true; + not(): BooleanExpr; +} + +// @beta +export function byteLength(expr: Expr): FunctionExpr; + +// @beta +export function byteLength(fieldName: string): FunctionExpr; + +// @beta +export function charLength(fieldName: string): FunctionExpr; + +// @beta +export function charLength(stringExpression: Expr): FunctionExpr; // @beta (undocumented) export class CollectionGroupSource implements Stage { @@ -200,80 +220,97 @@ export class CollectionSource implements Stage { name: string; } -// @beta (undocumented) -export class Cond extends FirestoreFunction { - constructor(condition: FilterCondition, thenExpr: Expr, elseExpr: Expr); - // (undocumented) - filterable: true; - } - // @beta -export function cond(condition: FilterCondition, thenExpr: Expr, elseExpr: Expr): Cond; +export function cond(condition: BooleanExpr, thenExpr: Expr, elseExpr: Expr): FunctionExpr; // @beta export class Constant extends Expr { // (undocumented) - exprType: ExprType; - static of(value: number): Constant; - static of(value: string): Constant; - static of(value: boolean): Constant; - static of(value: null): Constant; - static of(value: undefined): Constant; - // Warning: (ae-forgotten-export) The symbol "GeoPoint" needs to be exported by the entry point pipelines.d.ts - static of(value: GeoPoint): Constant; - // Warning: (ae-forgotten-export) The symbol "Timestamp" needs to be exported by the entry point pipelines.d.ts - static of(value: Timestamp): Constant; - static of(value: Date): Constant; - static of(value: Uint8Array): Constant; - // Warning: (ae-forgotten-export) The symbol "DocumentReference" needs to be exported by the entry point pipelines.d.ts - static of(value: DocumentReference): Constant; - static of(value: any[]): Constant; - static of(value: Map): Constant; - // Warning: (ae-forgotten-export) The symbol "VectorValue" needs to be exported by the entry point pipelines.d.ts - static of(value: VectorValue): Constant; - static vector(value: number[] | VectorValue): Constant; -} - -// @beta (undocumented) -export class CosineDistance extends FirestoreFunction { - constructor(vector1: Expr, vector2: Expr); + readonly exprType: ExprType; } -// @beta -export function cosineDistance(expr: string, other: number[]): CosineDistance; +// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta +// +// @public +export function constant(value: number): Constant; + +// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta +// +// @public +export function constant(value: string): Constant; + +// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta +// +// @public +export function constant(value: boolean): Constant; + +// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta +// +// @public +export function constant(value: null): Constant; + +// Warning: (ae-forgotten-export) The symbol "GeoPoint" needs to be exported by the entry point pipelines.d.ts +// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta +// +// @public +export function constant(value: GeoPoint): Constant; + +// Warning: (ae-forgotten-export) The symbol "Timestamp" needs to be exported by the entry point pipelines.d.ts +// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta +// +// @public +export function constant(value: Timestamp): Constant; + +// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta +// +// @public +export function constant(value: Date): Constant; + +// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta +// +// @public +export function constant(value: Bytes): Constant; + +// Warning: (ae-forgotten-export) The symbol "DocumentReference" needs to be exported by the entry point pipelines.d.ts +// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta +// +// @public +export function constant(value: DocumentReference): Constant; + +// Warning: (ae-forgotten-export) The symbol "VectorValue" needs to be exported by the entry point pipelines.d.ts +// Warning: (ae-incompatible-release-tags) The symbol "constant" is marked as @public, but its signature references "Constant" which is marked as @beta +// +// @public +export function constant(value: VectorValue): Constant; // @beta -export function cosineDistance(expr: string, other: VectorValue): CosineDistance; +export function cosineDistance(fieldName: string, vector: number[] | VectorValue): FunctionExpr; // @beta -export function cosineDistance(expr: string, other: Expr): CosineDistance; +export function cosineDistance(fieldName: string, vectorExpression: Expr): FunctionExpr; // @beta -export function cosineDistance(expr: Expr, other: number[]): CosineDistance; +export function cosineDistance(vectorExpression: Expr, vector: number[] | Expr): FunctionExpr; // @beta -export function cosineDistance(expr: Expr, other: VectorValue): CosineDistance; +export function cosineDistance(vectorExpression: Expr, otherVectorExpression: Expr): FunctionExpr; // @beta -export function cosineDistance(expr: Expr, other: Expr): CosineDistance; +export function count(expression: Expr): AggregateFunction; -// @beta (undocumented) -export class Count extends FirestoreFunction implements Accumulator { - constructor(value: Expr | undefined, distinct: boolean); - // (undocumented) - accumulator: true; - } +// Warning: (ae-incompatible-release-tags) The symbol "count" is marked as @public, but its signature references "AggregateFunction" which is marked as @beta +// +// @public +export function count(fieldName: string): AggregateFunction; // @beta -export function countAll(): Count; +export function countAll(): AggregateFunction; // @beta -export function countFunction(value: Expr): Count; +export function countIf(booleanExpr: BooleanExpr): AggregateFunction; -// Warning: (ae-incompatible-release-tags) The symbol "countFunction" is marked as @public, but its signature references "Count" which is marked as @beta -// -// @public -export function countFunction(value: string): Count; +// @beta +export function currentContext(): FunctionExpr; // @beta (undocumented) export class DatabaseSource implements Stage { @@ -284,6 +321,9 @@ export class DatabaseSource implements Stage { // @beta export function descending(expr: Expr): Ordering; +// @beta +export function descending(fieldName: string): Ordering; + // @beta (undocumented) export class Distinct implements Stage { constructor(groups: Map); @@ -291,22 +331,23 @@ export class Distinct implements Stage { name: string; } -// @beta (undocumented) -export class Divide extends FirestoreFunction { - constructor(left: Expr, right: Expr); - } +// @beta +export function divide(left: Expr, right: Expr): FunctionExpr; // @beta -export function divide(left: Expr, right: Expr): Divide; +export function divide(expression: Expr, value: unknown): FunctionExpr; // @beta -export function divide(left: Expr, right: any): Divide; +export function divide(fieldName: string, expressions: Expr): FunctionExpr; // @beta -export function divide(left: string, right: Expr): Divide; +export function divide(fieldName: string, value: unknown): FunctionExpr; // @beta -export function divide(left: string, right: any): Divide; +export function documentId(documentPath: string | DocumentReference): FunctionExpr; + +// @beta +export function documentId(documentPathExpr: Expr): FunctionExpr; // @beta (undocumented) export class DocumentsSource implements Stage { @@ -314,239 +355,320 @@ export class DocumentsSource implements Stage { // (undocumented) name: string; // (undocumented) - static of(refs: DocumentReference[]): DocumentsSource; + static of(refs: Array): DocumentsSource; } -// @beta (undocumented) -export class DotProduct extends FirestoreFunction { - constructor(vector1: Expr, vector2: Expr); - } - -// @beta -export function dotProduct(expr: string, other: number[]): DotProduct; - // @beta -export function dotProduct(expr: string, other: VectorValue): DotProduct; +export function dotProduct(fieldName: string, vector: number[] | VectorValue): FunctionExpr; // @beta -export function dotProduct(expr: string, other: Expr): DotProduct; +export function dotProduct(fieldName: string, vectorExpression: Expr): FunctionExpr; // @beta -export function dotProduct(expr: Expr, other: number[]): DotProduct; +export function dotProduct(vectorExpression: Expr, vector: number[] | VectorValue): FunctionExpr; // @beta -export function dotProduct(expr: Expr, other: VectorValue): DotProduct; +export function dotProduct(vectorExpression: Expr, otherVectorExpression: Expr): FunctionExpr; // @beta -export function dotProduct(expr: Expr, other: Expr): DotProduct; - -// @beta (undocumented) -export class EndsWith extends FirestoreFunction implements FilterCondition { - constructor(expr: Expr, suffix: Expr); - // (undocumented) - filterable: true; - } +export function endsWith(fieldName: string, suffix: string): BooleanExpr; // @beta -export function endsWith(expr: string, suffix: string): EndsWith; +export function endsWith(fieldName: string, suffix: Expr): BooleanExpr; // @beta -export function endsWith(expr: string, suffix: Expr): EndsWith; +export function endsWith(stringExpression: Expr, suffix: string): BooleanExpr; // @beta -export function endsWith(expr: Expr, suffix: string): EndsWith; +export function endsWith(stringExpression: Expr, suffix: Expr): BooleanExpr; // @beta -export function endsWith(expr: Expr, suffix: Expr): EndsWith; - -// @beta (undocumented) -export class Eq extends FirestoreFunction implements FilterCondition { - constructor(left: Expr, right: Expr); - // (undocumented) - filterable: true; - } +export function eq(left: Expr, right: Expr): BooleanExpr; // @beta -export function eq(left: Expr, right: Expr): Eq; +export function eq(expression: Expr, value: unknown): BooleanExpr; // @beta -export function eq(left: Expr, right: any): Eq; +export function eq(fieldName: string, expression: Expr): BooleanExpr; // @beta -export function eq(left: string, right: Expr): Eq; +export function eq(fieldName: string, value: unknown): BooleanExpr; // @beta -export function eq(left: string, right: any): Eq; - -// @beta (undocumented) -export class EqAny extends FirestoreFunction implements FilterCondition { - constructor(left: Expr, others: Expr[]); - // (undocumented) - filterable: true; - } +export function eqAny(expression: Expr, values: Array): BooleanExpr; // @beta -export function eqAny(element: Expr, others: Expr[]): EqAny; +export function eqAny(expression: Expr, arrayExpression: Expr): BooleanExpr; // @beta -export function eqAny(element: Expr, others: any[]): EqAny; +export function eqAny(fieldName: string, values: Array): BooleanExpr; // @beta -export function eqAny(element: string, others: Expr[]): EqAny; +export function eqAny(fieldName: string, arrayExpression: Expr): BooleanExpr; // @beta -export function eqAny(element: string, others: any[]): EqAny; - -// @beta (undocumented) -export class EuclideanDistance extends FirestoreFunction { - constructor(vector1: Expr, vector2: Expr); - } +export function euclideanDistance(fieldName: string, vector: number[] | VectorValue): FunctionExpr; // @beta -export function euclideanDistance(expr: string, other: number[]): EuclideanDistance; +export function euclideanDistance(fieldName: string, vectorExpression: Expr): FunctionExpr; // @beta -export function euclideanDistance(expr: string, other: VectorValue): EuclideanDistance; +export function euclideanDistance(vectorExpression: Expr, vector: number[] | VectorValue): FunctionExpr; // @beta -export function euclideanDistance(expr: string, other: Expr): EuclideanDistance; - -// @beta -export function euclideanDistance(expr: Expr, other: number[]): EuclideanDistance; - -// @beta -export function euclideanDistance(expr: Expr, other: VectorValue): EuclideanDistance; - -// @beta -export function euclideanDistance(expr: Expr, other: Expr): EuclideanDistance; - -// Warning: (ae-incompatible-release-tags) The symbol "execute" is marked as @public, but its signature references "PipelineResult" which is marked as @beta -// -// @public (undocumented) -export function execute(pipeline: Pipeline): Promise; +export function euclideanDistance(vectorExpression: Expr, otherVectorExpression: Expr): FunctionExpr; -// @beta (undocumented) -export class Exists extends FirestoreFunction implements FilterCondition { - constructor(expr: Expr); - // (undocumented) - filterable: true; -} +// @public +export function execute(pipeline: Pipeline): Promise; // @beta -export function exists(value: Expr): Exists; +export function exists(value: Expr): BooleanExpr; // @beta -export function exists(field: string): Exists; +export function exists(fieldName: string): BooleanExpr; // @beta export abstract class Expr { - add(other: Expr): Add; - add(other: any): Add; - arrayConcat(...arrays: Expr[]): ArrayConcat; - arrayConcat(...arrays: any[][]): ArrayConcat; - arrayContains(element: Expr): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Expr[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Expr[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; + add(second: Expr | unknown, ...others: Array): FunctionExpr; + /* Excluded from this release type: _readUserData */ + arrayConcat(secondArray: Expr | unknown[], ...otherArrays: Array): FunctionExpr; + /* Excluded from this release type: _readUserData */ + arrayContains(expression: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + arrayContains(value: unknown): BooleanExpr; + /* Excluded from this release type: _readUserData */ + arrayContainsAll(values: Array): BooleanExpr; + /* Excluded from this release type: _readUserData */ + arrayContainsAll(arrayExpression: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + arrayContainsAny(values: Array): BooleanExpr; + /* Excluded from this release type: _readUserData */ + arrayContainsAny(arrayExpression: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + arrayLength(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + arrayOffset(offset: number): FunctionExpr; + /* Excluded from this release type: _readUserData */ + arrayOffset(offsetExpr: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + as(name: string): ExprWithAlias; + /* Excluded from this release type: _readUserData */ ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Expr): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; + /* Excluded from this release type: _readUserData */ + avg(): AggregateFunction; + /* Excluded from this release type: _readUserData */ + bitAnd(otherBits: number | Bytes): FunctionExpr; + /* Excluded from this release type: _readUserData */ + bitAnd(bitsExpression: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + bitLeftShift(y: number): FunctionExpr; + /* Excluded from this release type: _readUserData */ + bitLeftShift(numberExpr: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + bitNot(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + bitOr(otherBits: number | Bytes): FunctionExpr; + /* Excluded from this release type: _readUserData */ + bitOr(bitsExpression: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + bitRightShift(y: number): FunctionExpr; + /* Excluded from this release type: _readUserData */ + bitRightShift(numberExpr: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + bitXor(otherBits: number | Bytes): FunctionExpr; + /* Excluded from this release type: _readUserData */ + bitXor(bitsExpression: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + byteLength(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + charLength(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + cosineDistance(vectorExpression: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + cosineDistance(vector: VectorValue | number[]): FunctionExpr; + /* Excluded from this release type: _readUserData */ + count(): AggregateFunction; + /* Excluded from this release type: _readUserData */ descending(): Ordering; - divide(other: Expr): Divide; - divide(other: any): Divide; - dotProduct(other: Expr): DotProduct; - dotProduct(other: VectorValue): DotProduct; - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Expr): EndsWith; - eq(other: Expr): Eq; - eq(other: any): Eq; - eqAny(...others: Expr[]): EqAny; - eqAny(...others: any[]): EqAny; - euclideanDistance(other: Expr): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; - // (undocumented) - abstract exprType: ExprType; - gt(other: Expr): Gt; - gt(other: any): Gt; - gte(other: Expr): Gte; - gte(other: any): Gte; - isNaN(): IsNan; - like(pattern: string): Like; - like(pattern: Expr): Like; - logicalMaximum(other: Expr): LogicalMaximum; - logicalMaximum(other: any): LogicalMaximum; - logicalMinimum(other: Expr): LogicalMinimum; - logicalMinimum(other: any): LogicalMinimum; - lt(other: Expr): Lt; - lt(other: any): Lt; - lte(other: Expr): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - maximum(): Maximum; - minimum(): Minimum; - mod(other: Expr): Mod; - mod(other: any): Mod; - multiply(other: Expr): Multiply; - multiply(other: any): Multiply; - neq(other: Expr): Neq; - neq(other: any): Neq; - notEqAny(...others: Expr[]): NotEqAny; - notEqAny(...others: any[]): NotEqAny; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Expr): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Expr): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Expr, replace: Expr): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Expr, replace: Expr): ReplaceFirst; - reverse(): Reverse; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Expr): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Expr): StrContains; - subtract(other: Expr): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Expr, amount: Expr): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Expr, amount: Expr): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - vectorLength(): VectorLength; + /* Excluded from this release type: _readUserData */ + divide(other: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + divide(other: unknown): FunctionExpr; + /* Excluded from this release type: _readUserData */ + documentId(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + dotProduct(vectorExpression: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + dotProduct(vector: VectorValue | number[]): FunctionExpr; + /* Excluded from this release type: _readUserData */ + endsWith(suffix: string): BooleanExpr; + /* Excluded from this release type: _readUserData */ + endsWith(suffix: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + eq(expression: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + eq(value: unknown): BooleanExpr; + /* Excluded from this release type: _readUserData */ + eqAny(values: Array): BooleanExpr; + /* Excluded from this release type: _readUserData */ + eqAny(arrayExpression: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + euclideanDistance(vectorExpression: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + euclideanDistance(vector: VectorValue | number[]): FunctionExpr; + /* Excluded from this release type: _readUserData */ + exists(): BooleanExpr; + /* Excluded from this release type: _readUserData */ + // (undocumented) + abstract readonly exprType: ExprType; + /* Excluded from this release type: _readUserData */ + gt(expression: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + gt(value: unknown): BooleanExpr; + /* Excluded from this release type: _readUserData */ + gte(expression: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + gte(value: unknown): BooleanExpr; + /* Excluded from this release type: _readUserData */ + ifError(catchExpr: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + ifError(catchValue: unknown): FunctionExpr; + /* Excluded from this release type: _readUserData */ + isAbsent(): BooleanExpr; + /* Excluded from this release type: _readUserData */ + isError(): BooleanExpr; + /* Excluded from this release type: _readUserData */ + isNan(): BooleanExpr; + /* Excluded from this release type: _readUserData */ + isNotNan(): BooleanExpr; + /* Excluded from this release type: _readUserData */ + isNotNull(): BooleanExpr; + /* Excluded from this release type: _readUserData */ + isNull(): BooleanExpr; + /* Excluded from this release type: _readUserData */ + like(pattern: string): FunctionExpr; + /* Excluded from this release type: _readUserData */ + like(pattern: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + logicalMaximum(second: Expr | unknown, ...others: Array): FunctionExpr; + /* Excluded from this release type: _readUserData */ + logicalMinimum(second: Expr | unknown, ...others: Array): FunctionExpr; + /* Excluded from this release type: _readUserData */ + lt(experession: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + lt(value: unknown): BooleanExpr; + /* Excluded from this release type: _readUserData */ + lte(expression: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + lte(value: unknown): BooleanExpr; + /* Excluded from this release type: _readUserData */ + manhattanDistance(vector: VectorValue | number[]): FunctionExpr; + /* Excluded from this release type: _readUserData */ + manhattanDistance(vectorExpression: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + mapGet(subfield: string): FunctionExpr; + /* Excluded from this release type: _readUserData */ + mapMerge(secondMap: Record | Expr, ...otherMaps: Array | Expr>): FunctionExpr; + /* Excluded from this release type: _readUserData */ + mapRemove(key: string): FunctionExpr; + /* Excluded from this release type: _readUserData */ + mapRemove(keyExpr: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + maximum(): AggregateFunction; + /* Excluded from this release type: _readUserData */ + minimum(): AggregateFunction; + /* Excluded from this release type: _readUserData */ + mod(expression: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + mod(value: unknown): FunctionExpr; + /* Excluded from this release type: _readUserData */ + multiply(second: Expr | unknown, ...others: Array): FunctionExpr; + /* Excluded from this release type: _readUserData */ + neq(expression: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + neq(value: unknown): BooleanExpr; + /* Excluded from this release type: _readUserData */ + notEqAny(values: Array): BooleanExpr; + /* Excluded from this release type: _readUserData */ + notEqAny(arrayExpression: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + regexContains(pattern: string): BooleanExpr; + /* Excluded from this release type: _readUserData */ + regexContains(pattern: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + regexMatch(pattern: string): BooleanExpr; + /* Excluded from this release type: _readUserData */ + regexMatch(pattern: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + replaceAll(find: string, replace: string): FunctionExpr; + /* Excluded from this release type: _readUserData */ + replaceAll(find: Expr, replace: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + replaceFirst(find: string, replace: string): FunctionExpr; + /* Excluded from this release type: _readUserData */ + replaceFirst(find: Expr, replace: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + reverse(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + startsWith(prefix: string): BooleanExpr; + /* Excluded from this release type: _readUserData */ + startsWith(prefix: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + strConcat(secondString: Expr | string, ...otherStrings: Array): FunctionExpr; + /* Excluded from this release type: _readUserData */ + strContains(substring: string): BooleanExpr; + /* Excluded from this release type: _readUserData */ + strContains(expr: Expr): BooleanExpr; + /* Excluded from this release type: _readUserData */ + substr(position: number, length?: number): FunctionExpr; + /* Excluded from this release type: _readUserData */ + substr(position: Expr, length?: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + subtract(other: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + subtract(other: unknown): FunctionExpr; + /* Excluded from this release type: _readUserData */ + sum(): AggregateFunction; + /* Excluded from this release type: _readUserData */ + timestampAdd(unit: Expr, amount: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): FunctionExpr; + /* Excluded from this release type: _readUserData */ + timestampSub(unit: Expr, amount: Expr): FunctionExpr; + /* Excluded from this release type: _readUserData */ + timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): FunctionExpr; + /* Excluded from this release type: _readUserData */ + timestampToUnixMicros(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + timestampToUnixMillis(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + timestampToUnixSeconds(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + toLower(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + toUpper(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + trim(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + unixMicrosToTimestamp(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + unixMillisToTimestamp(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + unixSecondsToTimestamp(): FunctionExpr; + /* Excluded from this release type: _readUserData */ + vectorLength(): FunctionExpr; } // @beta -export type ExprType = 'Field' | 'Constant' | 'Function' | 'ListOfExprs' | 'ExprWithAlias'; +export type ExprType = 'Field' | 'Constant' | 'Function' | 'AggregateFunction' | 'ListOfExprs' | 'ExprWithAlias'; // @beta (undocumented) -export class ExprWithAlias extends Expr implements Selectable { - constructor(expr: T, alias: string); +export class ExprWithAlias implements Selectable { + constructor(expr: Expr, alias: string); // (undocumented) readonly alias: string; // (undocumented) - readonly expr: T; + readonly expr: Expr; // (undocumented) exprType: ExprType; // (undocumented) @@ -556,39 +678,27 @@ export class ExprWithAlias extends Expr implements Selectable { // @beta export class Field extends Expr implements Selectable { // (undocumented) - exprType: ExprType; + get alias(): string; // (undocumented) - fieldName(): string; - static of(name: string): Field; - // Warning: (ae-forgotten-export) The symbol "FieldPath" needs to be exported by the entry point pipelines.d.ts - // + get expr(): Expr; // (undocumented) - static of(path: FieldPath): Field; + readonly exprType: ExprType; // (undocumented) - static of(pipeline: Pipeline, name: string): Field; + fieldName(): string; // (undocumented) selectable: true; } -// @beta (undocumented) -export class Fields extends Expr implements Selectable { - // (undocumented) - exprType: ExprType; - // (undocumented) - fieldList(): Field[]; - // (undocumented) - static of(name: string, ...others: string[]): Fields; - // (undocumented) - static ofAll(): Fields; - // (undocumented) - selectable: true; -} +// Warning: (ae-incompatible-release-tags) The symbol "field" is marked as @public, but its signature references "Field" which is marked as @beta +// +// @public +export function field(name: string): Field; -// @beta -export interface FilterCondition extends Expr { - // (undocumented) - filterable: true; -} +// Warning: (ae-forgotten-export) The symbol "FieldPath" needs to be exported by the entry point pipelines.d.ts +// Warning: (ae-incompatible-release-tags) The symbol "field" is marked as @public, but its signature references "Field" which is marked as @beta +// +// @public (undocumented) +export function field(path: FieldPath): Field; // @beta (undocumented) export class FindNearest implements Stage { @@ -603,7 +713,7 @@ export interface FindNearestOptions { // (undocumented) distanceMeasure: 'euclidean' | 'cosine' | 'dot_product'; // (undocumented) - field: Field; + field: Field | string; // (undocumented) limit?: number; // (undocumented) @@ -611,91 +721,92 @@ export interface FindNearestOptions { } // @beta -export class FirestoreFunction extends Expr { +export class FunctionExpr extends Expr { constructor(name: string, params: Expr[]); // (undocumented) - exprType: ExprType; + readonly exprType: ExprType; } -// @beta -export function genericFunction(name: string, params: Expr[]): FirestoreFunction; - // @beta (undocumented) export class GenericStage implements Stage { - constructor(name: string, params: unknown[]); // (undocumented) name: string; -} - -// @beta (undocumented) -export class Gt extends FirestoreFunction implements FilterCondition { - constructor(left: Expr, right: Expr); - // (undocumented) - filterable: true; } // @beta -export function gt(left: Expr, right: Expr): Gt; +export function gt(left: Expr, right: Expr): BooleanExpr; // @beta -export function gt(left: Expr, right: any): Gt; +export function gt(expression: Expr, value: unknown): BooleanExpr; // @beta -export function gt(left: string, right: Expr): Gt; +export function gt(fieldName: string, expression: Expr): BooleanExpr; // @beta -export function gt(left: string, right: any): Gt; +export function gt(fieldName: string, value: unknown): BooleanExpr; -// @beta (undocumented) -export class Gte extends FirestoreFunction implements FilterCondition { - constructor(left: Expr, right: Expr); - // (undocumented) - filterable: true; - } +// @beta +export function gte(left: Expr, right: Expr): BooleanExpr; // @beta -export function gte(left: Expr, right: Expr): Gte; +export function gte(expression: Expr, value: unknown): BooleanExpr; // @beta -export function gte(left: Expr, right: any): Gte; +export function gte(fieldName: string, value: Expr): BooleanExpr; // @beta -export function gte(left: string, right: Expr): Gte; +export function gte(fieldName: string, value: unknown): BooleanExpr; // @beta -export function gte(left: string, right: any): Gte; +export function ifError(tryExpr: Expr, catchExpr: Expr): FunctionExpr; -// @beta (undocumented) -export class IsNan extends FirestoreFunction implements FilterCondition { - constructor(expr: Expr); - // (undocumented) - filterable: true; -} +// @beta +export function ifError(tryExpr: Expr, catchValue: unknown): FunctionExpr; // @beta -export function isNan(value: Expr): IsNan; +export function isAbsent(value: Expr): BooleanExpr; // @beta -export function isNan(value: string): IsNan; +export function isAbsent(field: string): BooleanExpr; -// @beta (undocumented) -export class Like extends FirestoreFunction implements FilterCondition { - constructor(expr: Expr, pattern: Expr); - // (undocumented) - filterable: true; - } +// @beta +export function isError(value: Expr): BooleanExpr; + +// @beta +export function isNan(value: Expr): BooleanExpr; // @beta -export function like(left: string, pattern: string): Like; +export function isNan(fieldName: string): BooleanExpr; // @beta -export function like(left: string, pattern: Expr): Like; +export function isNotNan(value: Expr): BooleanExpr; // @beta -export function like(left: Expr, pattern: string): Like; +export function isNotNan(value: string): BooleanExpr; // @beta -export function like(left: Expr, pattern: Expr): Like; +export function isNotNull(value: Expr): BooleanExpr; + +// @beta +export function isNotNull(value: string): BooleanExpr; + +// @beta +export function isNull(value: Expr): BooleanExpr; + +// @beta +export function isNull(value: string): BooleanExpr; + +// @beta +export function like(fieldName: string, pattern: string): BooleanExpr; + +// @beta +export function like(fieldName: string, pattern: Expr): BooleanExpr; + +// @beta +export function like(stringExpression: Expr, pattern: string): BooleanExpr; + +// @beta +export function like(stringExpression: Expr, pattern: Expr): BooleanExpr; // @beta (undocumented) export class Limit implements Stage { @@ -708,199 +819,140 @@ export class Limit implements Stage { name: string; } -// @beta (undocumented) -export class LogicalMaximum extends FirestoreFunction { - constructor(left: Expr, right: Expr); - } +// @beta +export function logicalMaximum(first: Expr, second: Expr | unknown, ...others: Array): FunctionExpr; // @beta -export function logicalMaximum(left: Expr, right: Expr): LogicalMaximum; +export function logicalMaximum(fieldName: string, second: Expr | unknown, ...others: Array): FunctionExpr; // @beta -export function logicalMaximum(left: Expr, right: any): LogicalMaximum; +export function logicalMinimum(first: Expr, second: Expr | unknown, ...others: Array): FunctionExpr; // @beta -export function logicalMaximum(left: string, right: Expr): LogicalMaximum; +export function logicalMinimum(fieldName: string, second: Expr | unknown, ...others: Array): FunctionExpr; // @beta -export function logicalMaximum(left: string, right: any): LogicalMaximum; +export function lt(left: Expr, right: Expr): BooleanExpr; -// @beta (undocumented) -export class LogicalMinimum extends FirestoreFunction { - constructor(left: Expr, right: Expr); - } +// @beta +export function lt(expression: Expr, value: unknown): BooleanExpr; // @beta -export function logicalMinimum(left: Expr, right: Expr): LogicalMinimum; +export function lt(fieldName: string, expression: Expr): BooleanExpr; // @beta -export function logicalMinimum(left: Expr, right: any): LogicalMinimum; +export function lt(fieldName: string, value: unknown): BooleanExpr; // @beta -export function logicalMinimum(left: string, right: Expr): LogicalMinimum; +export function lte(left: Expr, right: Expr): BooleanExpr; // @beta -export function logicalMinimum(left: string, right: any): LogicalMinimum; +export function lte(expression: Expr, value: unknown): BooleanExpr; -// @beta (undocumented) -export class Lt extends FirestoreFunction implements FilterCondition { - constructor(left: Expr, right: Expr); - // (undocumented) - filterable: true; - } +// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Expr" which is marked as @beta +// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "BooleanExpr" which is marked as @beta +// +// @public +export function lte(fieldName: string, expression: Expr): BooleanExpr; // @beta -export function lt(left: Expr, right: Expr): Lt; +export function lte(fieldName: string, value: unknown): BooleanExpr; // @beta -export function lt(left: Expr, right: any): Lt; +export function manhattanDistance(fieldName: string, vector: number[] | VectorValue): FunctionExpr; // @beta -export function lt(left: string, right: Expr): Lt; +export function manhattanDistance(fieldName: string, vectorExpression: Expr): FunctionExpr; // @beta -export function lt(left: string, right: any): Lt; - -// @beta (undocumented) -export class Lte extends FirestoreFunction implements FilterCondition { - constructor(left: Expr, right: Expr); - // (undocumented) - filterable: true; - } +export function manhattanDistance(vectorExpression: Expr, vector: number[] | VectorValue): FunctionExpr; // @beta -export function lte(left: Expr, right: Expr): Lte; +export function manhattanDistance(vectorExpression: Expr, otherVectorExpression: Expr): FunctionExpr; // @beta -export function lte(left: Expr, right: any): Lte; - -// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Expr" which is marked as @beta -// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Lte" which is marked as @beta -// -// @public -export function lte(left: string, right: Expr): Lte; +export function map(elements: Record): FunctionExpr; // @beta -export function lte(left: string, right: any): Lte; - -// @beta (undocumented) -export class MapGet extends FirestoreFunction { - constructor(map: Expr, name: string); -} +export function mapGet(fieldName: string, subField: string): FunctionExpr; // @beta -export function mapGet(mapField: string, subField: string): MapGet; +export function mapGet(mapExpression: Expr, subField: string): FunctionExpr; // @beta -export function mapGet(mapExpr: Expr, subField: string): MapGet; - -// @beta (undocumented) -export class Maximum extends FirestoreFunction implements Accumulator { - constructor(value: Expr, distinct: boolean); - // (undocumented) - accumulator: true; - } +export function mapMerge(mapField: string, secondMap: Record | Expr, ...otherMaps: Array | Expr>): FunctionExpr; // @beta -export function maximum(value: Expr): Maximum; +export function mapMerge(firstMap: Record | Expr, secondMap: Record | Expr, ...otherMaps: Array | Expr>): FunctionExpr; // @beta -export function maximum(value: string): Maximum; - -// @beta (undocumented) -export class Minimum extends FirestoreFunction implements Accumulator { - constructor(value: Expr, distinct: boolean); - // (undocumented) - accumulator: true; - } +export function mapRemove(mapField: string, key: string): FunctionExpr; // @beta -export function minimum(value: Expr): Minimum; +export function mapRemove(mapExpr: Expr, key: string): FunctionExpr; // @beta -export function minimum(value: string): Minimum; - -// @beta (undocumented) -export class Mod extends FirestoreFunction { - constructor(left: Expr, right: Expr); - } +export function mapRemove(mapField: string, keyExpr: Expr): FunctionExpr; // @beta -export function mod(left: Expr, right: Expr): Mod; +export function mapRemove(mapExpr: Expr, keyExpr: Expr): FunctionExpr; // @beta -export function mod(left: Expr, right: any): Mod; +export function maximum(expression: Expr): AggregateFunction; // @beta -export function mod(left: string, right: Expr): Mod; +export function maximum(fieldName: string): AggregateFunction; // @beta -export function mod(left: string, right: any): Mod; - -// @beta (undocumented) -export class Multiply extends FirestoreFunction { - constructor(left: Expr, right: Expr); - } +export function minimum(expression: Expr): AggregateFunction; // @beta -export function multiply(left: Expr, right: Expr): Multiply; +export function minimum(fieldName: string): AggregateFunction; // @beta -export function multiply(left: Expr, right: any): Multiply; +export function mod(left: Expr, right: Expr): FunctionExpr; // @beta -export function multiply(left: string, right: Expr): Multiply; +export function mod(expression: Expr, value: unknown): FunctionExpr; // @beta -export function multiply(left: string, right: any): Multiply; +export function mod(fieldName: string, expression: Expr): FunctionExpr; -// @beta (undocumented) -export class Neq extends FirestoreFunction implements FilterCondition { - constructor(left: Expr, right: Expr); - // (undocumented) - filterable: true; - } +// @beta +export function mod(fieldName: string, value: unknown): FunctionExpr; // @beta -export function neq(left: Expr, right: Expr): Neq; +export function multiply(first: Expr, second: Expr | unknown, ...others: Array): FunctionExpr; // @beta -export function neq(left: Expr, right: any): Neq; +export function multiply(fieldName: string, second: Expr | unknown, ...others: Array): FunctionExpr; // @beta -export function neq(left: string, right: Expr): Neq; +export function neq(left: Expr, right: Expr): BooleanExpr; // @beta -export function neq(left: string, right: any): Neq; +export function neq(expression: Expr, value: unknown): BooleanExpr; -// @beta (undocumented) -export class Not extends FirestoreFunction implements FilterCondition { - constructor(expr: Expr); - // (undocumented) - filterable: true; -} +// @beta +export function neq(fieldName: string, expression: Expr): BooleanExpr; // @beta -export function not(filter: FilterCondition): Not; +export function neq(fieldName: string, value: unknown): BooleanExpr; -// @beta (undocumented) -export class NotEqAny extends FirestoreFunction implements FilterCondition { - constructor(left: Expr, others: Expr[]); - // (undocumented) - filterable: true; - } +// @beta +export function not(booleanExpr: BooleanExpr): BooleanExpr; // @beta -export function notEqAny(element: Expr, others: Expr[]): NotEqAny; +export function notEqAny(element: Expr, values: Array): BooleanExpr; // @beta -export function notEqAny(element: Expr, others: any[]): NotEqAny; +export function notEqAny(fieldName: string, values: Array): BooleanExpr; // @beta -export function notEqAny(element: string, others: Expr[]): NotEqAny; +export function notEqAny(element: Expr, arrayExpression: Expr): BooleanExpr; // @beta -export function notEqAny(element: string, others: any[]): NotEqAny; +export function notEqAny(fieldName: string, arrayExpression: Expr): BooleanExpr; // @beta (undocumented) export class Offset implements Stage { @@ -909,12 +961,8 @@ export class Offset implements Stage { name: string; } -// @beta (undocumented) -export class Or extends FirestoreFunction implements FilterCondition { - constructor(conditions: FilterCondition[]); - // (undocumented) - filterable: true; -} +// @beta +export function or(first: BooleanExpr, second: BooleanExpr, ...more: BooleanExpr[]): BooleanExpr; // @beta export class Ordering { @@ -925,56 +973,46 @@ export class Ordering { readonly expr: Expr; } -// @beta -export function orFunction(left: FilterCondition, ...right: FilterCondition[]): Or; - // @public (undocumented) export class Pipeline { - /* Excluded from this release type: newPipeline */ // Warning: (ae-incompatible-release-tags) The symbol "addFields" is marked as @public, but its signature references "Selectable" which is marked as @beta - addFields(...fields: Selectable[]): Pipeline; - // Warning: (ae-incompatible-release-tags) The symbol "aggregate" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta - aggregate(...accumulators: AccumulatorTarget[]): Pipeline; - aggregate(options: { accumulators: AccumulatorTarget[]; groups?: Array; }): Pipeline; + addFields(field: Selectable, ...additionalFields: Selectable[]): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "aggregate" is marked as @public, but its signature references "AggregateWithAlias" which is marked as @beta + aggregate(accumulator: AggregateWithAlias, ...additionalAccumulators: AggregateWithAlias[]): Pipeline; + aggregate(options: { accumulators: AggregateWithAlias[]; groups?: Array; }): Pipeline; // Warning: (ae-incompatible-release-tags) The symbol "distinct" is marked as @public, but its signature references "Selectable" which is marked as @beta - distinct(...groups: Array): Pipeline; - // Warning: (ae-incompatible-release-tags) The symbol "execute" is marked as @public, but its signature references "PipelineResult" which is marked as @beta - execute(): Promise; + distinct(group: string | Selectable, ...additionalGroups: Array): Pipeline; // Warning: (ae-incompatible-release-tags) The symbol "findNearest" is marked as @public, but its signature references "FindNearestOptions" which is marked as @beta // // (undocumented) findNearest(options: FindNearestOptions): Pipeline; - genericStage(name: string, params: any[]): Pipeline; + genericStage(name: string, params: unknown[]): Pipeline; limit(limit: number): Pipeline; offset(offset: number): Pipeline; readUserData: any; + // Warning: (ae-incompatible-release-tags) The symbol "removeFields" is marked as @public, but its signature references "Field" which is marked as @beta + removeFields(fieldValue: Field | string, ...additionalFields: Array): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "replaceWith" is marked as @public, but its signature references "Field" which is marked as @beta + replaceWith(fieldValue: Field | string): Pipeline; + sample(documents: number): Pipeline; + sample(options: { percentage: number; } | { documents: number; }): Pipeline; // Warning: (ae-incompatible-release-tags) The symbol "select" is marked as @public, but its signature references "Selectable" which is marked as @beta - select(...selections: Array): Pipeline; + select(selection: Selectable | string, ...additionalSelections: Array): Pipeline; // (undocumented) selectablesToMap: any; // Warning: (ae-incompatible-release-tags) The symbol "sort" is marked as @public, but its signature references "Ordering" which is marked as @beta - sort(...orderings: Ordering[]): Pipeline; - // (undocumented) - sort(options: { orderings: Ordering[]; }): Pipeline; + sort(ordering: Ordering, ...additionalOrderings: Ordering[]): Pipeline; // (undocumented) stages: any; + union(other: Pipeline): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "unnest" is marked as @public, but its signature references "Selectable" which is marked as @beta + unnest(selectable: Selectable, indexField?: string): Pipeline; // (undocumented) userDataReader: any; - // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "FilterCondition" which is marked as @beta - where(condition: FilterCondition): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "BooleanExpr" which is marked as @beta + where(condition: BooleanExpr): Pipeline; } -// Warning: (ae-forgotten-export) The symbol "Firestore" needs to be exported by the entry point pipelines.d.ts -// Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta -// -// @public -export function pipeline(firestore: Firestore): PipelineSource; - -// Warning: (ae-forgotten-export) The symbol "Query" needs to be exported by the entry point pipelines.d.ts -// -// @public -export function pipeline(query: Query): Pipeline; - // Warning: (ae-forgotten-export) The symbol "DocumentData" needs to be exported by the entry point pipelines.d.ts // // @beta @@ -984,103 +1022,93 @@ export class PipelineResult { /* Excluded from this release type: __constructor */ get createTime(): Timestamp | undefined; data(): AppModelType | undefined; - get executionTime(): Timestamp; - get(fieldPath: string | FieldPath): any; + get(fieldPath: string | FieldPath | Field): any; get id(): string | undefined; get ref(): DocumentReference | undefined; get updateTime(): Timestamp | undefined; } +// @public (undocumented) +export class PipelineSnapshot { + // Warning: (ae-incompatible-release-tags) The symbol "__constructor" is marked as @public, but its signature references "PipelineResult" which is marked as @beta + constructor(pipeline: Pipeline, results: PipelineResult[], executionTime?: Timestamp); + get executionTime(): Timestamp; + get pipeline(): Pipeline; + // Warning: (ae-incompatible-release-tags) The symbol "results" is marked as @public, but its signature references "PipelineResult" which is marked as @beta + get results(): PipelineResult[]; +} + // @beta export class PipelineSource { + collection(collectionPath: string): PipelineType; + /* Excluded from this release type: _createPipeline */ + /* Excluded from this release type: __constructor */ + // Warning: (ae-forgotten-export) The symbol "Query" needs to be exported by the entry point pipelines.d.ts + collection(collectionReference: Query): PipelineType; /* Excluded from this release type: _createPipeline */ /* Excluded from this release type: __constructor */ - // (undocumented) - collection(collectionPath: string): PipelineType; - // (undocumented) collectionGroup(collectionId: string): PipelineType; - // (undocumented) + /* Excluded from this release type: _createPipeline */ + /* Excluded from this release type: __constructor */ + createFrom(query: Query): Pipeline; + /* Excluded from this release type: _createPipeline */ + /* Excluded from this release type: __constructor */ database(): PipelineType; - // (undocumented) - documents(docs: DocumentReference[]): PipelineType; + /* Excluded from this release type: _createPipeline */ + /* Excluded from this release type: __constructor */ + documents(docs: Array): PipelineType; } -// @beta (undocumented) -export class RegexContains extends FirestoreFunction implements FilterCondition { - constructor(expr: Expr, pattern: Expr); - // (undocumented) - filterable: true; - } - // @beta -export function regexContains(left: string, pattern: string): RegexContains; +export function rand(): FunctionExpr; // @beta -export function regexContains(left: string, pattern: Expr): RegexContains; +export function regexContains(fieldName: string, pattern: string): BooleanExpr; // @beta -export function regexContains(left: Expr, pattern: string): RegexContains; +export function regexContains(fieldName: string, pattern: Expr): BooleanExpr; // @beta -export function regexContains(left: Expr, pattern: Expr): RegexContains; - -// @beta (undocumented) -export class RegexMatch extends FirestoreFunction implements FilterCondition { - constructor(expr: Expr, pattern: Expr); - // (undocumented) - filterable: true; - } +export function regexContains(stringExpression: Expr, pattern: string): BooleanExpr; // @beta -export function regexMatch(left: string, pattern: string): RegexMatch; +export function regexContains(stringExpression: Expr, pattern: Expr): BooleanExpr; // @beta -export function regexMatch(left: string, pattern: Expr): RegexMatch; +export function regexMatch(fieldName: string, pattern: string): BooleanExpr; // @beta -export function regexMatch(left: Expr, pattern: string): RegexMatch; +export function regexMatch(fieldName: string, pattern: Expr): BooleanExpr; // @beta -export function regexMatch(left: Expr, pattern: Expr): RegexMatch; - -// @beta (undocumented) -export class ReplaceAll extends FirestoreFunction { - constructor(value: Expr, find: Expr, replace: Expr); - } +export function regexMatch(stringExpression: Expr, pattern: string): BooleanExpr; // @beta -export function replaceAll(value: Expr, find: string, replace: string): ReplaceAll; +export function regexMatch(stringExpression: Expr, pattern: Expr): BooleanExpr; // @beta -export function replaceAll(value: Expr, find: Expr, replace: Expr): ReplaceAll; +export function replaceAll(value: Expr, find: string, replace: string): FunctionExpr; // @beta -export function replaceAll(field: string, find: string, replace: string): ReplaceAll; - -// @beta (undocumented) -export class ReplaceFirst extends FirestoreFunction { - constructor(value: Expr, find: Expr, replace: Expr); - } +export function replaceAll(value: Expr, find: Expr, replace: Expr): FunctionExpr; // @beta -export function replaceFirst(value: Expr, find: string, replace: string): ReplaceFirst; +export function replaceAll(fieldName: string, find: string, replace: string): FunctionExpr; // @beta -export function replaceFirst(value: Expr, find: Expr, replace: Expr): ReplaceFirst; +export function replaceFirst(value: Expr, find: string, replace: string): FunctionExpr; // @beta -export function replaceFirst(field: string, find: string, replace: string): ReplaceFirst; +export function replaceFirst(value: Expr, find: Expr, replace: Expr): FunctionExpr; -// @beta (undocumented) -export class Reverse extends FirestoreFunction { - constructor(value: Expr); - } +// @beta +export function replaceFirst(fieldName: string, find: string, replace: string): FunctionExpr; // @beta -export function reverse(expr: Expr): Reverse; +export function reverse(stringExpression: Expr): FunctionExpr; // @beta -export function reverse(field: string): Reverse; +export function reverse(field: string): FunctionExpr; // @beta (undocumented) export class Select implements Stage { @@ -1090,7 +1118,11 @@ export class Select implements Stage { } // @beta -export interface Selectable extends Expr { +export interface Selectable { + // (undocumented) + readonly alias: string; + // (undocumented) + readonly expr: Expr; // (undocumented) selectable: true; } @@ -1108,246 +1140,159 @@ export interface Stage { name: string; } -// @beta (undocumented) -export class StartsWith extends FirestoreFunction implements FilterCondition { - constructor(expr: Expr, prefix: Expr); - // (undocumented) - filterable: true; - } - // @beta -export function startsWith(expr: string, prefix: string): StartsWith; +export function startsWith(fieldName: string, prefix: string): BooleanExpr; // @beta -export function startsWith(expr: string, prefix: Expr): StartsWith; +export function startsWith(fieldName: string, prefix: Expr): BooleanExpr; // @beta -export function startsWith(expr: Expr, prefix: string): StartsWith; +export function startsWith(stringExpression: Expr, prefix: string): BooleanExpr; // @beta -export function startsWith(expr: Expr, prefix: Expr): StartsWith; - -// @beta (undocumented) -export class StrConcat extends FirestoreFunction { - constructor(first: Expr, rest: Expr[]); - } +export function startsWith(stringExpression: Expr, prefix: Expr): BooleanExpr; // @beta -export function strConcat(first: string, ...elements: Array): StrConcat; +export function strConcat(fieldName: string, secondString: Expr | string, ...otherStrings: Array): FunctionExpr; // @beta -export function strConcat(first: Expr, ...elements: Array): StrConcat; - -// @beta (undocumented) -export class StrContains extends FirestoreFunction implements FilterCondition { - constructor(expr: Expr, substring: Expr); - // (undocumented) - filterable: true; - } +export function strConcat(firstString: Expr, secondString: Expr | string, ...otherStrings: Array): FunctionExpr; // @beta -export function strContains(left: string, substring: string): StrContains; +export function strContains(fieldName: string, substring: string): BooleanExpr; // @beta -export function strContains(left: string, substring: Expr): StrContains; +export function strContains(fieldName: string, substring: Expr): BooleanExpr; // @beta -export function strContains(left: Expr, substring: string): StrContains; +export function strContains(stringExpression: Expr, substring: string): BooleanExpr; // @beta -export function strContains(left: Expr, substring: Expr): StrContains; - -// @beta (undocumented) -export class Subtract extends FirestoreFunction { - constructor(left: Expr, right: Expr); - } +export function strContains(stringExpression: Expr, substring: Expr): BooleanExpr; // @beta -export function subtract(left: Expr, right: Expr): Subtract; +export function substr(field: string, position: number, length?: number): FunctionExpr; // @beta -export function subtract(left: Expr, right: any): Subtract; +export function substr(input: Expr, position: number, length?: number): FunctionExpr; // @beta -export function subtract(left: string, right: Expr): Subtract; +export function substr(field: string, position: Expr, length?: Expr): FunctionExpr; // @beta -export function subtract(left: string, right: any): Subtract; - -// @beta (undocumented) -export class Sum extends FirestoreFunction implements Accumulator { - constructor(value: Expr, distinct: boolean); - // (undocumented) - accumulator: true; - } +export function substr(input: Expr, position: Expr, length?: Expr): FunctionExpr; // @beta -export function sumFunction(value: Expr): Sum; +export function subtract(left: Expr, right: Expr): FunctionExpr; // @beta -export function sumFunction(value: string): Sum; - -// @beta (undocumented) -export class TimestampAdd extends FirestoreFunction { - constructor(timestamp: Expr, unit: Expr, amount: Expr); - } +export function subtract(expression: Expr, value: unknown): FunctionExpr; // @beta -export function timestampAdd(timestamp: Expr, unit: Expr, amount: Expr): TimestampAdd; +export function subtract(fieldName: string, expression: Expr): FunctionExpr; // @beta -export function timestampAdd(timestamp: Expr, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; +export function subtract(fieldName: string, value: unknown): FunctionExpr; // @beta -export function timestampAdd(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - -// @beta (undocumented) -export class TimestampSub extends FirestoreFunction { - constructor(timestamp: Expr, unit: Expr, amount: Expr); - } +export function sum(expression: Expr): AggregateFunction; // @beta -export function timestampSub(timestamp: Expr, unit: Expr, amount: Expr): TimestampSub; +export function sum(fieldName: string): AggregateFunction; // @beta -export function timestampSub(timestamp: Expr, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; +export function timestampAdd(timestamp: Expr, unit: Expr, amount: Expr): FunctionExpr; // @beta -export function timestampSub(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - -// @beta (undocumented) -export class TimestampToUnixMicros extends FirestoreFunction { - constructor(input: Expr); - } +export function timestampAdd(timestamp: Expr, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): FunctionExpr; // @beta -export function timestampToUnixMicros(expr: Expr): TimestampToUnixMicros; +export function timestampAdd(fieldName: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): FunctionExpr; // @beta -export function timestampToUnixMicros(field: string): TimestampToUnixMicros; - -// @beta (undocumented) -export class TimestampToUnixMillis extends FirestoreFunction { - constructor(input: Expr); - } +export function timestampSub(timestamp: Expr, unit: Expr, amount: Expr): FunctionExpr; // @beta -export function timestampToUnixMillis(expr: Expr): TimestampToUnixMillis; +export function timestampSub(timestamp: Expr, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): FunctionExpr; // @beta -export function timestampToUnixMillis(field: string): TimestampToUnixMillis; - -// @beta (undocumented) -export class TimestampToUnixSeconds extends FirestoreFunction { - constructor(input: Expr); - } +export function timestampSub(fieldName: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): FunctionExpr; // @beta -export function timestampToUnixSeconds(expr: Expr): TimestampToUnixSeconds; +export function timestampToUnixMicros(expr: Expr): FunctionExpr; // @beta -export function timestampToUnixSeconds(field: string): TimestampToUnixSeconds; - -// @beta (undocumented) -export class ToLower extends FirestoreFunction { - constructor(expr: Expr); - } +export function timestampToUnixMicros(fieldName: string): FunctionExpr; // @beta -export function toLower(expr: string): ToLower; +export function timestampToUnixMillis(expr: Expr): FunctionExpr; // @beta -export function toLower(expr: Expr): ToLower; - -// @beta (undocumented) -export class ToUpper extends FirestoreFunction { - constructor(expr: Expr); - } +export function timestampToUnixMillis(fieldName: string): FunctionExpr; // @beta -export function toUpper(expr: string): ToUpper; +export function timestampToUnixSeconds(expr: Expr): FunctionExpr; // @beta -export function toUpper(expr: Expr): ToUpper; - -// @beta (undocumented) -export class Trim extends FirestoreFunction { - constructor(expr: Expr); - } +export function timestampToUnixSeconds(fieldName: string): FunctionExpr; // @beta -export function trim(expr: string): Trim; +export function toLower(fieldName: string): FunctionExpr; // @beta -export function trim(expr: Expr): Trim; +export function toLower(stringExpression: Expr): FunctionExpr; -// @beta (undocumented) -export class UnixMicrosToTimestamp extends FirestoreFunction { - constructor(input: Expr); - } +// @beta +export function toUpper(fieldName: string): FunctionExpr; // @beta -export function unixMicrosToTimestamp(expr: Expr): UnixMicrosToTimestamp; +export function toUpper(stringExpression: Expr): FunctionExpr; // @beta -export function unixMicrosToTimestamp(field: string): UnixMicrosToTimestamp; +export function trim(fieldName: string): FunctionExpr; -// @beta (undocumented) -export class UnixMillisToTimestamp extends FirestoreFunction { - constructor(input: Expr); - } +// @beta +export function trim(stringExpression: Expr): FunctionExpr; // @beta -export function unixMillisToTimestamp(expr: Expr): UnixMillisToTimestamp; +export function unixMicrosToTimestamp(expr: Expr): FunctionExpr; // @beta -export function unixMillisToTimestamp(field: string): UnixMillisToTimestamp; +export function unixMicrosToTimestamp(fieldName: string): FunctionExpr; -// @beta (undocumented) -export class UnixSecondsToTimestamp extends FirestoreFunction { - constructor(input: Expr); - } +// @beta +export function unixMillisToTimestamp(expr: Expr): FunctionExpr; // @beta -export function unixSecondsToTimestamp(expr: Expr): UnixSecondsToTimestamp; +export function unixMillisToTimestamp(fieldName: string): FunctionExpr; // @beta -export function unixSecondsToTimestamp(field: string): UnixSecondsToTimestamp; +export function unixSecondsToTimestamp(expr: Expr): FunctionExpr; -// @beta (undocumented) -export class VectorLength extends FirestoreFunction { - constructor(value: Expr); - } +// @beta +export function unixSecondsToTimestamp(fieldName: string): FunctionExpr; // @beta -export function vectorLength(expr: Expr): VectorLength; +export function vectorLength(vectorExpression: Expr): FunctionExpr; // @beta -export function vectorLength(field: string): VectorLength; +export function vectorLength(fieldName: string): FunctionExpr; // @beta (undocumented) export class Where implements Stage { - constructor(condition: FilterCondition); + constructor(condition: BooleanExpr); // (undocumented) name: string; } -// @beta (undocumented) -export class Xor extends FirestoreFunction implements FilterCondition { - constructor(conditions: FilterCondition[]); - // (undocumented) - filterable: true; -} - // @beta -export function xor(left: FilterCondition, ...right: FilterCondition[]): Xor; +export function xor(first: BooleanExpr, second: BooleanExpr, ...additionalConditions: BooleanExpr[]): BooleanExpr; // Warnings were encountered during analysis: // -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/pipelines.d.ts:3983:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/pipelines.d.ts:3983:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/pipelines.d.ts:4010:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/pipelines.d.ts:4552:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AggregateWithAlias" which is marked as @beta +// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/pipelines.d.ts:4552:62 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta // (No @packageDocumentation comment for this package) diff --git a/common/api-review/firestore.api.md b/common/api-review/firestore.api.md index 6f0e14206c2..34b56b97f21 100644 --- a/common/api-review/firestore.api.md +++ b/common/api-review/firestore.api.md @@ -9,54 +9,14 @@ import { FirebaseApp } from '@firebase/app'; import { FirebaseError } from '@firebase/util'; import { LogLevelString as LogLevel } from '@firebase/logger'; -// @beta -export interface Accumulator extends Expr { - // (undocumented) - accumulator: true; -} - -// @beta -export type AccumulatorTarget = ExprWithAlias; - -// @beta (undocumented) -export class Add extends FirestoreFunction { - constructor(left: Expr, right: Expr); - } - -// @beta -export function add(left: Expr, right: Expr): Add; - -// @beta -export function add(left: Expr, right: any): Add; - -// @beta -export function add(left: string, right: Expr): Add; - -// @beta -export function add(left: string, right: any): Add; - // @public export function addDoc(reference: CollectionReference, data: WithFieldValue): Promise>; -// @beta (undocumented) -export class AddFields implements Stage { - constructor(fields: Map); - // (undocumented) - name: string; -} - // @public export type AddPrefixToKeys> = { [K in keyof T & string as `${Prefix}.${K}`]+?: string extends K ? any : T[K]; }; -// @beta (undocumented) -export class Aggregate implements Stage { - constructor(accumulators: Map, groups: Map); - // (undocumented) - name: string; -} - // @public export class AggregateField { readonly aggregateType: AggregateType; @@ -93,147 +53,18 @@ export type AggregateSpecData = { // @public export type AggregateType = 'count' | 'avg' | 'sum'; -// @beta (undocumented) -export class And extends FirestoreFunction implements FilterCondition { - constructor(conditions: (FilterCondition)[]); - // (undocumented) - filterable: true; -} - // @public export function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; -// @beta -export function andFunction(left: FilterCondition, ...right: (FilterCondition)[]): And; - -// @beta (undocumented) -export class ArrayConcat extends FirestoreFunction { - constructor(array: Expr, elements: Expr[]); - } - -// @beta -export function arrayConcat(array: Expr, elements: Expr[]): ArrayConcat; - -// @beta -export function arrayConcat(array: Expr, elements: any[]): ArrayConcat; - -// @beta -export function arrayConcat(array: string, elements: Expr[]): ArrayConcat; - -// @beta -export function arrayConcat(array: string, elements: any[]): ArrayConcat; - -// @beta (undocumented) -export class ArrayContains extends FirestoreFunction implements FilterCondition { - constructor(array: Expr, element: Expr); - // (undocumented) - filterable: true; -} - -// @beta -export function arrayContains(array: Expr, element: Expr): ArrayContains; - -// @beta -export function arrayContains(array: Expr, element: any): ArrayContains; - -// @beta -export function arrayContains(array: string, element: Expr): ArrayContains; - -// @beta -export function arrayContains(array: string, element: any): ArrayContains; - -// @beta (undocumented) -export class ArrayContainsAll extends FirestoreFunction implements FilterCondition { - constructor(array: Expr, values: Expr[]); - // (undocumented) - filterable: true; - } - -// @beta -export function arrayContainsAll(array: Expr, values: Expr[]): ArrayContainsAll; - -// @beta -export function arrayContainsAll(array: Expr, values: any[]): ArrayContainsAll; - -// @beta -export function arrayContainsAll(array: string, values: Expr[]): ArrayContainsAll; - -// @beta -export function arrayContainsAll(array: string, values: any[]): ArrayContainsAll; - -// @beta (undocumented) -export class ArrayContainsAny extends FirestoreFunction implements FilterCondition { - constructor(array: Expr, values: Expr[]); - // (undocumented) - filterable: true; - } - -// @beta -export function arrayContainsAny(array: Expr, values: Expr[]): ArrayContainsAny; - -// @beta -export function arrayContainsAny(array: Expr, values: any[]): ArrayContainsAny; - -// @beta -export function arrayContainsAny(array: string, values: Expr[]): ArrayContainsAny; - -// @beta -export function arrayContainsAny(array: string, values: any[]): ArrayContainsAny; - -// @beta (undocumented) -export class ArrayElement extends FirestoreFunction { - constructor(); -} - -// @beta (undocumented) -export class ArrayLength extends FirestoreFunction { - constructor(array: Expr); - } - -// @beta -export function arrayLength(array: Expr): ArrayLength; - // @public export function arrayRemove(...elements: unknown[]): FieldValue; -// @beta (undocumented) -export class ArrayReverse extends FirestoreFunction { - constructor(array: Expr); - } - // @public export function arrayUnion(...elements: unknown[]): FieldValue; -// @beta -export function ascending(expr: Expr): Ordering; - // @public export function average(field: string | FieldPath): AggregateField; -// @beta (undocumented) -export class Avg extends FirestoreFunction implements Accumulator { - constructor(value: Expr, distinct: boolean); - // (undocumented) - accumulator: true; - } - -// @beta -export function avgFunction(value: Expr): Avg; - -// @beta -export function avgFunction(value: string): Avg; - -// @beta (undocumented) -export class ByteLength extends FirestoreFunction { - constructor(value: Expr); - } - -// @beta -export function byteLength(expr: Expr): ByteLength; - -// @beta -export function byteLength(field: string): ByteLength; - // @public export class Bytes { static fromBase64String(base64: string): Bytes; @@ -247,17 +78,6 @@ export class Bytes { // @public export const CACHE_SIZE_UNLIMITED = -1; -// @beta (undocumented) -export class CharLength extends FirestoreFunction { - constructor(value: Expr); - } - -// @beta -export function charLength(field: string): CharLength; - -// @beta -export function charLength(expr: Expr): CharLength; - // @public export type ChildUpdateFields = V extends Record ? AddPrefixToKeys> : never; @@ -276,13 +96,6 @@ export function collection(refer // @public export function collectionGroup(firestore: Firestore, collectionId: string): Query; -// @beta (undocumented) -export class CollectionGroupSource implements Stage { - constructor(collectionId: string); - // (undocumented) - name: string; -} - // @public export class CollectionReference extends Query { get id(): string; @@ -293,98 +106,14 @@ export class CollectionReference; } -// @beta (undocumented) -export class CollectionSource implements Stage { - constructor(collectionPath: string); - // (undocumented) - name: string; -} - -// @beta (undocumented) -export class Cond extends FirestoreFunction { - constructor(condition: FilterCondition, thenExpr: Expr, elseExpr: Expr); - // (undocumented) - filterable: true; - } - -// @beta -export function cond(condition: FilterCondition, thenExpr: Expr, elseExpr: Expr): Cond; - // @public export function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: { mockUserToken?: EmulatorMockTokenOptions | string; }): void; -// @beta -export class Constant extends Expr { - // (undocumented) - exprType: ExprType; - static of(value: number): Constant; - static of(value: string): Constant; - static of(value: boolean): Constant; - static of(value: null): Constant; - static of(value: undefined): Constant; - static of(value: GeoPoint): Constant; - static of(value: Timestamp): Constant; - static of(value: Date): Constant; - static of(value: Uint8Array): Constant; - static of(value: DocumentReference): Constant; - static of(value: any[]): Constant; - static of(value: Map): Constant; - static of(value: VectorValue): Constant; - static vector(value: number[] | VectorValue): Constant; -} - -// @beta (undocumented) -export class CosineDistance extends FirestoreFunction { - constructor(vector1: Expr, vector2: Expr); - } - -// @beta -export function cosineDistance(expr: string, other: number[]): CosineDistance; - -// @beta -export function cosineDistance(expr: string, other: VectorValue): CosineDistance; - -// @beta -export function cosineDistance(expr: string, other: Expr): CosineDistance; - -// @beta -export function cosineDistance(expr: Expr, other: number[]): CosineDistance; - -// @beta -export function cosineDistance(expr: Expr, other: VectorValue): CosineDistance; - -// @beta -export function cosineDistance(expr: Expr, other: Expr): CosineDistance; - -// @beta (undocumented) -export class Count extends FirestoreFunction implements Accumulator { - constructor(value: Expr | undefined, distinct: boolean); - // (undocumented) - accumulator: true; - } - // @public export function count(): AggregateField; -// @beta -export function countAll(): Count; - -// @beta -export function countFunction(value: Expr): Count; - -// Warning: (ae-incompatible-release-tags) The symbol "countFunction" is marked as @public, but its signature references "Count" which is marked as @beta -// -// @public -export function countFunction(value: string): Count; - -// @beta (undocumented) -export class DatabaseSource implements Stage { - // (undocumented) - name: string; -} - // @public export function deleteAllPersistentCacheIndexes(indexManager: PersistentCacheIndexManager): void; @@ -394,39 +123,12 @@ export function deleteDoc(refere // @public export function deleteField(): FieldValue; -// @beta -export function descending(expr: Expr): Ordering; - // @public export function disableNetwork(firestore: Firestore): Promise; // @public export function disablePersistentCacheIndexAutoCreation(indexManager: PersistentCacheIndexManager): void; -// @beta (undocumented) -export class Distinct implements Stage { - constructor(groups: Map); - // (undocumented) - name: string; -} - -// @beta (undocumented) -export class Divide extends FirestoreFunction { - constructor(left: Expr, right: Expr); - } - -// @beta -export function divide(left: Expr, right: Expr): Divide; - -// @beta -export function divide(left: Expr, right: any): Divide; - -// @beta -export function divide(left: string, right: Expr): Divide; - -// @beta -export function divide(left: string, right: any): Divide; - // @public export function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference; @@ -478,38 +180,6 @@ export class DocumentSnapshot; } -// @beta (undocumented) -export class DocumentsSource implements Stage { - constructor(docPaths: string[]); - // (undocumented) - name: string; - // (undocumented) - static of(refs: DocumentReference[]): DocumentsSource; -} - -// @beta (undocumented) -export class DotProduct extends FirestoreFunction { - constructor(vector1: Expr, vector2: Expr); - } - -// @beta -export function dotProduct(expr: string, other: number[]): DotProduct; - -// @beta -export function dotProduct(expr: string, other: VectorValue): DotProduct; - -// @beta -export function dotProduct(expr: string, other: Expr): DotProduct; - -// @beta -export function dotProduct(expr: Expr, other: number[]): DotProduct; - -// @beta -export function dotProduct(expr: Expr, other: VectorValue): DotProduct; - -// @beta -export function dotProduct(expr: Expr, other: Expr): DotProduct; - export { EmulatorMockTokenOptions } // @public @deprecated @@ -536,290 +206,22 @@ export function endBefore(snapsh // @public export function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint; -// @beta (undocumented) -export class EndsWith extends FirestoreFunction implements FilterCondition { - constructor(expr: Expr, suffix: Expr); - // (undocumented) - filterable: true; - } - -// @beta -export function endsWith(expr: string, suffix: string): EndsWith; - -// @beta -export function endsWith(expr: string, suffix: Expr): EndsWith; - -// @beta -export function endsWith(expr: Expr, suffix: string): EndsWith; - -// @beta -export function endsWith(expr: Expr, suffix: Expr): EndsWith; - -// @beta (undocumented) -export class Eq extends FirestoreFunction implements FilterCondition { - constructor(left: Expr, right: Expr); - // (undocumented) - filterable: true; - } - -// @beta -export function eq(left: Expr, right: Expr): Eq; - -// @beta -export function eq(left: Expr, right: any): Eq; - -// @beta -export function eq(left: string, right: Expr): Eq; - -// @beta -export function eq(left: string, right: any): Eq; - -// @beta (undocumented) -export class EqAny extends FirestoreFunction implements FilterCondition { - constructor(left: Expr, others: Expr[]); - // (undocumented) - filterable: true; - } - -// @beta -export function eqAny(element: Expr, others: Expr[]): EqAny; - -// @beta -export function eqAny(element: Expr, others: any[]): EqAny; - -// @beta -export function eqAny(element: string, others: Expr[]): EqAny; - -// @beta -export function eqAny(element: string, others: any[]): EqAny; - -// @beta (undocumented) -export class EuclideanDistance extends FirestoreFunction { - constructor(vector1: Expr, vector2: Expr); - } - -// @beta -export function euclideanDistance(expr: string, other: number[]): EuclideanDistance; - -// @beta -export function euclideanDistance(expr: string, other: VectorValue): EuclideanDistance; - -// @beta -export function euclideanDistance(expr: string, other: Expr): EuclideanDistance; - -// @beta -export function euclideanDistance(expr: Expr, other: number[]): EuclideanDistance; - -// @beta -export function euclideanDistance(expr: Expr, other: VectorValue): EuclideanDistance; - -// @beta -export function euclideanDistance(expr: Expr, other: Expr): EuclideanDistance; - -// Warning: (ae-incompatible-release-tags) The symbol "execute" is marked as @public, but its signature references "PipelineResult" which is marked as @beta -// -// @public (undocumented) -export function execute(pipeline: Pipeline): Promise; - -// @beta (undocumented) -export class Exists extends FirestoreFunction implements FilterCondition { - constructor(expr: Expr); - // (undocumented) - filterable: true; -} - -// @beta -export function exists(value: Expr): Exists; - -// @beta -export function exists(field: string): Exists; - // @public export interface ExperimentalLongPollingOptions { timeoutSeconds?: number; } -// @beta -export abstract class Expr { - add(other: Expr): Add; - add(other: any): Add; - arrayConcat(...arrays: Expr[]): ArrayConcat; - arrayConcat(...arrays: any[][]): ArrayConcat; - arrayContains(element: Expr): ArrayContains; - arrayContains(element: any): ArrayContains; - arrayContainsAll(...values: Expr[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAny(...values: Expr[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayLength(): ArrayLength; - as(name: string): ExprWithAlias; - ascending(): Ordering; - avg(): Avg; - byteLength(): ByteLength; - charLength(): CharLength; - cosineDistance(other: Expr): CosineDistance; - cosineDistance(other: VectorValue): CosineDistance; - cosineDistance(other: number[]): CosineDistance; - count(): Count; - descending(): Ordering; - divide(other: Expr): Divide; - divide(other: any): Divide; - dotProduct(other: Expr): DotProduct; - dotProduct(other: VectorValue): DotProduct; - dotProduct(other: number[]): DotProduct; - endsWith(suffix: string): EndsWith; - endsWith(suffix: Expr): EndsWith; - eq(other: Expr): Eq; - eq(other: any): Eq; - eqAny(...others: Expr[]): EqAny; - eqAny(...others: any[]): EqAny; - euclideanDistance(other: Expr): EuclideanDistance; - euclideanDistance(other: VectorValue): EuclideanDistance; - euclideanDistance(other: number[]): EuclideanDistance; - exists(): Exists; - // (undocumented) - abstract exprType: ExprType; - gt(other: Expr): Gt; - gt(other: any): Gt; - gte(other: Expr): Gte; - gte(other: any): Gte; - isNaN(): IsNan; - like(pattern: string): Like; - like(pattern: Expr): Like; - logicalMaximum(other: Expr): LogicalMaximum; - logicalMaximum(other: any): LogicalMaximum; - logicalMinimum(other: Expr): LogicalMinimum; - logicalMinimum(other: any): LogicalMinimum; - lt(other: Expr): Lt; - lt(other: any): Lt; - lte(other: Expr): Lte; - lte(other: any): Lte; - mapGet(subfield: string): MapGet; - maximum(): Maximum; - minimum(): Minimum; - mod(other: Expr): Mod; - mod(other: any): Mod; - multiply(other: Expr): Multiply; - multiply(other: any): Multiply; - neq(other: Expr): Neq; - neq(other: any): Neq; - notEqAny(...others: Expr[]): NotEqAny; - notEqAny(...others: any[]): NotEqAny; - regexContains(pattern: string): RegexContains; - regexContains(pattern: Expr): RegexContains; - regexMatch(pattern: string): RegexMatch; - regexMatch(pattern: Expr): RegexMatch; - replaceAll(find: string, replace: string): ReplaceAll; - replaceAll(find: Expr, replace: Expr): ReplaceAll; - replaceFirst(find: string, replace: string): ReplaceFirst; - replaceFirst(find: Expr, replace: Expr): ReplaceFirst; - reverse(): Reverse; - startsWith(prefix: string): StartsWith; - startsWith(prefix: Expr): StartsWith; - strConcat(...elements: Array): StrConcat; - strContains(substring: string): StrContains; - strContains(expr: Expr): StrContains; - subtract(other: Expr): Subtract; - subtract(other: any): Subtract; - sum(): Sum; - timestampAdd(unit: Expr, amount: Expr): TimestampAdd; - timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - timestampSub(unit: Expr, amount: Expr): TimestampSub; - timestampSub(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - timestampToUnixMicros(): TimestampToUnixMicros; - timestampToUnixMillis(): TimestampToUnixMillis; - timestampToUnixSeconds(): TimestampToUnixSeconds; - toLower(): ToLower; - toUpper(): ToUpper; - trim(): Trim; - unixMicrosToTimestamp(): UnixMicrosToTimestamp; - unixMillisToTimestamp(): UnixMillisToTimestamp; - unixSecondsToTimestamp(): UnixSecondsToTimestamp; - vectorLength(): VectorLength; -} - -// @beta -export type ExprType = 'Field' | 'Constant' | 'Function' | 'ListOfExprs' | 'ExprWithAlias'; - -// @beta (undocumented) -export class ExprWithAlias extends Expr implements Selectable { - constructor(expr: T, alias: string); - // (undocumented) - readonly alias: string; - // (undocumented) - readonly expr: T; - // (undocumented) - exprType: ExprType; - // (undocumented) - selectable: true; -} - -// @beta -export class Field extends Expr implements Selectable { - // (undocumented) - exprType: ExprType; - // (undocumented) - fieldName(): string; - static of(name: string): Field; - // (undocumented) - static of(path: FieldPath): Field; - // (undocumented) - static of(pipeline: Pipeline, name: string): Field; - // (undocumented) - selectable: true; -} - // @public export class FieldPath { constructor(...fieldNames: string[]); isEqual(other: FieldPath): boolean; } -// @beta (undocumented) -export class Fields extends Expr implements Selectable { - // (undocumented) - exprType: ExprType; - // (undocumented) - fieldList(): Field[]; - // (undocumented) - static of(name: string, ...others: string[]): Fields; - // (undocumented) - static ofAll(): Fields; - // (undocumented) - selectable: true; -} - // @public export abstract class FieldValue { abstract isEqual(other: FieldValue): boolean; } -// @beta -export interface FilterCondition extends Expr { - // (undocumented) - filterable: true; -} - -// @beta (undocumented) -export class FindNearest implements Stage { - // (undocumented) - name: string; -} - -// @beta (undocumented) -export interface FindNearestOptions { - // (undocumented) - distanceField?: string; - // (undocumented) - distanceMeasure: 'euclidean' | 'cosine' | 'dot_product'; - // (undocumented) - field: Field; - // (undocumented) - limit?: number; - // (undocumented) - vectorValue: VectorValue | number[]; -} - // @public export class Firestore { get app(): FirebaseApp; @@ -844,13 +246,6 @@ export class FirestoreError extends FirebaseError { // @public export type FirestoreErrorCode = 'cancelled' | 'unknown' | 'invalid-argument' | 'deadline-exceeded' | 'not-found' | 'already-exists' | 'permission-denied' | 'resource-exhausted' | 'failed-precondition' | 'aborted' | 'out-of-range' | 'unimplemented' | 'internal' | 'unavailable' | 'data-loss' | 'unauthenticated'; -// @beta -export class FirestoreFunction extends Expr { - constructor(name: string, params: Expr[]); - // (undocumented) - exprType: ExprType; - } - // @public export type FirestoreLocalCache = MemoryLocalCache | PersistentLocalCache; @@ -866,16 +261,6 @@ export interface FirestoreSettings { ssl?: boolean; } -// @beta -export function genericFunction(name: string, params: Expr[]): FirestoreFunction; - -// @beta (undocumented) -export class GenericStage implements Stage { - constructor(name: string, params: unknown[]); - // (undocumented) - name: string; -} - // @public export class GeoPoint { constructor(latitude: number, longitude: number); @@ -929,44 +314,6 @@ export function getFirestore(app: FirebaseApp, databaseId: string): Firestore; // @public export function getPersistentCacheIndexManager(firestore: Firestore): PersistentCacheIndexManager | null; -// @beta (undocumented) -export class Gt extends FirestoreFunction implements FilterCondition { - constructor(left: Expr, right: Expr); - // (undocumented) - filterable: true; - } - -// @beta -export function gt(left: Expr, right: Expr): Gt; - -// @beta -export function gt(left: Expr, right: any): Gt; - -// @beta -export function gt(left: string, right: Expr): Gt; - -// @beta -export function gt(left: string, right: any): Gt; - -// @beta (undocumented) -export class Gte extends FirestoreFunction implements FilterCondition { - constructor(left: Expr, right: Expr); - // (undocumented) - filterable: true; - } - -// @beta -export function gte(left: Expr, right: Expr): Gte; - -// @beta -export function gte(left: Expr, right: any): Gte; - -// @beta -export function gte(left: string, right: Expr): Gte; - -// @beta -export function gte(left: string, right: any): Gte; - // @public export function increment(n: number): FieldValue; @@ -997,45 +344,6 @@ export interface IndexField { // @public export function initializeFirestore(app: FirebaseApp, settings: FirestoreSettings, databaseId?: string): Firestore; -// @beta (undocumented) -export class IsNan extends FirestoreFunction implements FilterCondition { - constructor(expr: Expr); - // (undocumented) - filterable: true; -} - -// @beta -export function isNan(value: Expr): IsNan; - -// @beta -export function isNan(value: string): IsNan; - -// @beta (undocumented) -export class Like extends FirestoreFunction implements FilterCondition { - constructor(expr: Expr, pattern: Expr); - // (undocumented) - filterable: true; - } - -// @beta -export function like(left: string, pattern: string): Like; - -// @beta -export function like(left: string, pattern: Expr): Like; - -// @beta -export function like(left: Expr, pattern: string): Like; - -// @beta -export function like(left: Expr, pattern: Expr): Like; - -// @beta (undocumented) -export class Limit implements Stage { - constructor(limit: number); - // (undocumented) - name: string; -} - // @public export function limit(limit: number): QueryLimitConstraint; @@ -1056,114 +364,15 @@ export class LoadBundleTask implements PromiseLike { } // @public -export interface LoadBundleTaskProgress { - bytesLoaded: number; - documentsLoaded: number; - taskState: TaskState; - totalBytes: number; - totalDocuments: number; -} - -// @beta (undocumented) -export class LogicalMaximum extends FirestoreFunction { - constructor(left: Expr, right: Expr); - } - -// @beta -export function logicalMaximum(left: Expr, right: Expr): LogicalMaximum; - -// @beta -export function logicalMaximum(left: Expr, right: any): LogicalMaximum; - -// @beta -export function logicalMaximum(left: string, right: Expr): LogicalMaximum; - -// @beta -export function logicalMaximum(left: string, right: any): LogicalMaximum; - -// @beta (undocumented) -export class LogicalMinimum extends FirestoreFunction { - constructor(left: Expr, right: Expr); - } - -// @beta -export function logicalMinimum(left: Expr, right: Expr): LogicalMinimum; - -// @beta -export function logicalMinimum(left: Expr, right: any): LogicalMinimum; - -// @beta -export function logicalMinimum(left: string, right: Expr): LogicalMinimum; - -// @beta -export function logicalMinimum(left: string, right: any): LogicalMinimum; - -export { LogLevel } - -// @beta (undocumented) -export class Lt extends FirestoreFunction implements FilterCondition { - constructor(left: Expr, right: Expr); - // (undocumented) - filterable: true; - } - -// @beta -export function lt(left: Expr, right: Expr): Lt; - -// @beta -export function lt(left: Expr, right: any): Lt; - -// @beta -export function lt(left: string, right: Expr): Lt; - -// @beta -export function lt(left: string, right: any): Lt; - -// @beta (undocumented) -export class Lte extends FirestoreFunction implements FilterCondition { - constructor(left: Expr, right: Expr); - // (undocumented) - filterable: true; - } - -// @beta -export function lte(left: Expr, right: Expr): Lte; - -// @beta -export function lte(left: Expr, right: any): Lte; - -// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Expr" which is marked as @beta -// Warning: (ae-incompatible-release-tags) The symbol "lte" is marked as @public, but its signature references "Lte" which is marked as @beta -// -// @public -export function lte(left: string, right: Expr): Lte; - -// @beta -export function lte(left: string, right: any): Lte; - -// @beta (undocumented) -export class MapGet extends FirestoreFunction { - constructor(map: Expr, name: string); -} - -// @beta -export function mapGet(mapField: string, subField: string): MapGet; - -// @beta -export function mapGet(mapExpr: Expr, subField: string): MapGet; - -// @beta (undocumented) -export class Maximum extends FirestoreFunction implements Accumulator { - constructor(value: Expr, distinct: boolean); - // (undocumented) - accumulator: true; - } - -// @beta -export function maximum(value: Expr): Maximum; +export interface LoadBundleTaskProgress { + bytesLoaded: number; + documentsLoaded: number; + taskState: TaskState; + totalBytes: number; + totalDocuments: number; +} -// @beta -export function maximum(value: string): Maximum; +export { LogLevel } // @public export interface MemoryCacheSettings { @@ -1202,116 +411,14 @@ export function memoryLruGarbageCollector(settings?: { cacheSizeBytes?: number; }): MemoryLruGarbageCollector; -// @beta (undocumented) -export class Minimum extends FirestoreFunction implements Accumulator { - constructor(value: Expr, distinct: boolean); - // (undocumented) - accumulator: true; - } - -// @beta -export function minimum(value: Expr): Minimum; - -// @beta -export function minimum(value: string): Minimum; - -// @beta (undocumented) -export class Mod extends FirestoreFunction { - constructor(left: Expr, right: Expr); - } - -// @beta -export function mod(left: Expr, right: Expr): Mod; - -// @beta -export function mod(left: Expr, right: any): Mod; - -// @beta -export function mod(left: string, right: Expr): Mod; - -// @beta -export function mod(left: string, right: any): Mod; - -// @beta (undocumented) -export class Multiply extends FirestoreFunction { - constructor(left: Expr, right: Expr); - } - -// @beta -export function multiply(left: Expr, right: Expr): Multiply; - -// @beta -export function multiply(left: Expr, right: any): Multiply; - -// @beta -export function multiply(left: string, right: Expr): Multiply; - -// @beta -export function multiply(left: string, right: any): Multiply; - // @public export function namedQuery(firestore: Firestore, name: string): Promise; -// @beta (undocumented) -export class Neq extends FirestoreFunction implements FilterCondition { - constructor(left: Expr, right: Expr); - // (undocumented) - filterable: true; - } - -// @beta -export function neq(left: Expr, right: Expr): Neq; - -// @beta -export function neq(left: Expr, right: any): Neq; - -// @beta -export function neq(left: string, right: Expr): Neq; - -// @beta -export function neq(left: string, right: any): Neq; - // @public export type NestedUpdateFields> = UnionToIntersection<{ [K in keyof T & string]: ChildUpdateFields; }[keyof T & string]>; -// @beta (undocumented) -export class Not extends FirestoreFunction implements FilterCondition { - constructor(expr: Expr); - // (undocumented) - filterable: true; -} - -// @beta -export function not(filter: FilterCondition): Not; - -// @beta (undocumented) -export class NotEqAny extends FirestoreFunction implements FilterCondition { - constructor(left: Expr, others: Expr[]); - // (undocumented) - filterable: true; - } - -// @beta -export function notEqAny(element: Expr, others: Expr[]): NotEqAny; - -// @beta -export function notEqAny(element: Expr, others: any[]): NotEqAny; - -// @beta -export function notEqAny(element: string, others: Expr[]): NotEqAny; - -// @beta -export function notEqAny(element: string, others: any[]): NotEqAny; - -// @beta (undocumented) -export class Offset implements Stage { - constructor(offset: number); - // (undocumented) - name: string; - } - // @public export function onSnapshot(reference: DocumentReference, observer: { next?: (snapshot: DocumentSnapshot) => void; @@ -1362,13 +469,6 @@ export function onSnapshotsInSync(firestore: Firestore, observer: { // @public export function onSnapshotsInSync(firestore: Firestore, onSync: () => void): Unsubscribe; -// @beta (undocumented) -export class Or extends FirestoreFunction implements FilterCondition { - constructor(conditions: (FilterCondition)[]); - // (undocumented) - filterable: true; -} - // @public export function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint; @@ -1378,18 +478,6 @@ export function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDir // @public export type OrderByDirection = 'desc' | 'asc'; -// @beta -export class Ordering { - constructor(expr: Expr, direction: 'ascending' | 'descending'); - // (undocumented) - readonly direction: 'ascending' | 'descending'; - // (undocumented) - readonly expr: Expr; -} - -// @beta -export function orFunction(left: FilterCondition, ...right: (FilterCondition)[]): Or; - // @public export type PartialWithFieldValue = Partial | (T extends Primitive ? T : T extends {} ? { [K in keyof T]?: PartialWithFieldValue | FieldValue; @@ -1446,78 +534,6 @@ export interface PersistentSingleTabManagerSettings { // @public export type PersistentTabManager = PersistentSingleTabManager | PersistentMultipleTabManager; -// @public (undocumented) -export class Pipeline { - /* Excluded from this release type: newPipeline */ - // Warning: (ae-incompatible-release-tags) The symbol "addFields" is marked as @public, but its signature references "Selectable" which is marked as @beta - addFields(...fields: Selectable[]): Pipeline; - // Warning: (ae-incompatible-release-tags) The symbol "aggregate" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta - aggregate(...accumulators: AccumulatorTarget[]): Pipeline; - aggregate(options: { accumulators: AccumulatorTarget[]; groups?: Array; }): Pipeline; - // Warning: (ae-incompatible-release-tags) The symbol "distinct" is marked as @public, but its signature references "Selectable" which is marked as @beta - distinct(...groups: Array): Pipeline; - // Warning: (ae-incompatible-release-tags) The symbol "execute" is marked as @public, but its signature references "PipelineResult" which is marked as @beta - execute(): Promise; - // Warning: (ae-incompatible-release-tags) The symbol "findNearest" is marked as @public, but its signature references "FindNearestOptions" which is marked as @beta - // - // (undocumented) - findNearest(options: FindNearestOptions): Pipeline; - genericStage(name: string, params: any[]): Pipeline; - limit(limit: number): Pipeline; - offset(offset: number): Pipeline; - readUserData: any; - // Warning: (ae-incompatible-release-tags) The symbol "select" is marked as @public, but its signature references "Selectable" which is marked as @beta - select(...selections: Array): Pipeline; - // (undocumented) - selectablesToMap: any; - // Warning: (ae-incompatible-release-tags) The symbol "sort" is marked as @public, but its signature references "Ordering" which is marked as @beta - sort(...orderings: Ordering[]): Pipeline; - // (undocumented) - sort(options: { orderings: Ordering[]; }): Pipeline; - // (undocumented) - stages: any; - // (undocumented) - userDataReader: any; - // Warning: (ae-incompatible-release-tags) The symbol "where" is marked as @public, but its signature references "FilterCondition" which is marked as @beta - where(condition: FilterCondition): Pipeline; -} - -// Warning: (ae-incompatible-release-tags) The symbol "pipeline" is marked as @public, but its signature references "PipelineSource" which is marked as @beta -// -// @public -export function pipeline(firestore: Firestore): PipelineSource; - -// @public -export function pipeline(query: Query): Pipeline; - -// @beta -export class PipelineResult { - /* Excluded from this release type: _ref */ - /* Excluded from this release type: _fields */ - /* Excluded from this release type: __constructor */ - get createTime(): Timestamp | undefined; - data(): AppModelType | undefined; - get executionTime(): Timestamp; - get(fieldPath: string | FieldPath): any; - get id(): string | undefined; - get ref(): DocumentReference | undefined; - get updateTime(): Timestamp | undefined; -} - -// @beta -export class PipelineSource { - /* Excluded from this release type: _createPipeline */ - /* Excluded from this release type: __constructor */ - // (undocumented) - collection(collectionPath: string): PipelineType; - // (undocumented) - collectionGroup(collectionId: string): PipelineType; - // (undocumented) - database(): PipelineType; - // (undocumented) - documents(docs: DocumentReference[]): PipelineType; -} - // @public export type Primitive = string | number | boolean | undefined | null; @@ -1604,99 +620,9 @@ export class QueryStartAtConstraint extends QueryConstraint { // @public export function refEqual(left: DocumentReference | CollectionReference, right: DocumentReference | CollectionReference): boolean; -// @beta (undocumented) -export class RegexContains extends FirestoreFunction implements FilterCondition { - constructor(expr: Expr, pattern: Expr); - // (undocumented) - filterable: true; - } - -// @beta -export function regexContains(left: string, pattern: string): RegexContains; - -// @beta -export function regexContains(left: string, pattern: Expr): RegexContains; - -// @beta -export function regexContains(left: Expr, pattern: string): RegexContains; - -// @beta -export function regexContains(left: Expr, pattern: Expr): RegexContains; - -// @beta (undocumented) -export class RegexMatch extends FirestoreFunction implements FilterCondition { - constructor(expr: Expr, pattern: Expr); - // (undocumented) - filterable: true; - } - -// @beta -export function regexMatch(left: string, pattern: string): RegexMatch; - -// @beta -export function regexMatch(left: string, pattern: Expr): RegexMatch; - -// @beta -export function regexMatch(left: Expr, pattern: string): RegexMatch; - -// @beta -export function regexMatch(left: Expr, pattern: Expr): RegexMatch; - -// @beta (undocumented) -export class ReplaceAll extends FirestoreFunction { - constructor(value: Expr, find: Expr, replace: Expr); - } - -// @beta -export function replaceAll(value: Expr, find: string, replace: string): ReplaceAll; - -// @beta -export function replaceAll(value: Expr, find: Expr, replace: Expr): ReplaceAll; - -// @beta -export function replaceAll(field: string, find: string, replace: string): ReplaceAll; - -// @beta (undocumented) -export class ReplaceFirst extends FirestoreFunction { - constructor(value: Expr, find: Expr, replace: Expr); - } - -// @beta -export function replaceFirst(value: Expr, find: string, replace: string): ReplaceFirst; - -// @beta -export function replaceFirst(value: Expr, find: Expr, replace: Expr): ReplaceFirst; - -// @beta -export function replaceFirst(field: string, find: string, replace: string): ReplaceFirst; - -// @beta (undocumented) -export class Reverse extends FirestoreFunction { - constructor(value: Expr); - } - -// @beta -export function reverse(expr: Expr): Reverse; - -// @beta -export function reverse(field: string): Reverse; - // @public export function runTransaction(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise, options?: TransactionOptions): Promise; -// @beta (undocumented) -export class Select implements Stage { - constructor(projections: Map); - // (undocumented) - name: string; - } - -// @beta -export interface Selectable extends Expr { - // (undocumented) - selectable: true; -} - // @public export function serverTimestamp(): FieldValue; @@ -1743,19 +669,6 @@ export interface SnapshotOptions { readonly serverTimestamps?: 'estimate' | 'previous' | 'none'; } -// @beta (undocumented) -export class Sort implements Stage { - constructor(orders: Ordering[]); - // (undocumented) - name: string; - } - -// @beta (undocumented) -export interface Stage { - // (undocumented) - name: string; -} - // @public export function startAfter(snapshot: DocumentSnapshot): QueryStartAtConstraint; @@ -1768,88 +681,9 @@ export function startAt(snapshot // @public export function startAt(...fieldValues: unknown[]): QueryStartAtConstraint; -// @beta (undocumented) -export class StartsWith extends FirestoreFunction implements FilterCondition { - constructor(expr: Expr, prefix: Expr); - // (undocumented) - filterable: true; - } - -// @beta -export function startsWith(expr: string, prefix: string): StartsWith; - -// @beta -export function startsWith(expr: string, prefix: Expr): StartsWith; - -// @beta -export function startsWith(expr: Expr, prefix: string): StartsWith; - -// @beta -export function startsWith(expr: Expr, prefix: Expr): StartsWith; - -// @beta (undocumented) -export class StrConcat extends FirestoreFunction { - constructor(first: Expr, rest: Expr[]); - } - -// @beta -export function strConcat(first: string, ...elements: Array): StrConcat; - -// @beta -export function strConcat(first: Expr, ...elements: Array): StrConcat; - -// @beta (undocumented) -export class StrContains extends FirestoreFunction implements FilterCondition { - constructor(expr: Expr, substring: Expr); - // (undocumented) - filterable: true; - } - -// @beta -export function strContains(left: string, substring: string): StrContains; - -// @beta -export function strContains(left: string, substring: Expr): StrContains; - -// @beta -export function strContains(left: Expr, substring: string): StrContains; - -// @beta -export function strContains(left: Expr, substring: Expr): StrContains; - -// @beta (undocumented) -export class Subtract extends FirestoreFunction { - constructor(left: Expr, right: Expr); - } - -// @beta -export function subtract(left: Expr, right: Expr): Subtract; - -// @beta -export function subtract(left: Expr, right: any): Subtract; - -// @beta -export function subtract(left: string, right: Expr): Subtract; - -// @beta -export function subtract(left: string, right: any): Subtract; - -// @beta (undocumented) -export class Sum extends FirestoreFunction implements Accumulator { - constructor(value: Expr, distinct: boolean); - // (undocumented) - accumulator: true; - } - // @public export function sum(field: string | FieldPath): AggregateField; -// @beta -export function sumFunction(value: Expr): Sum; - -// @beta -export function sumFunction(value: string): Sum; - // @public export type TaskState = 'Error' | 'Running' | 'Success'; @@ -1877,89 +711,6 @@ export class Timestamp { valueOf(): string; } -// @beta (undocumented) -export class TimestampAdd extends FirestoreFunction { - constructor(timestamp: Expr, unit: Expr, amount: Expr); - } - -// @beta -export function timestampAdd(timestamp: Expr, unit: Expr, amount: Expr): TimestampAdd; - -// @beta -export function timestampAdd(timestamp: Expr, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - -// @beta -export function timestampAdd(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampAdd; - -// @beta (undocumented) -export class TimestampSub extends FirestoreFunction { - constructor(timestamp: Expr, unit: Expr, amount: Expr); - } - -// @beta -export function timestampSub(timestamp: Expr, unit: Expr, amount: Expr): TimestampSub; - -// @beta -export function timestampSub(timestamp: Expr, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - -// @beta -export function timestampSub(field: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): TimestampSub; - -// @beta (undocumented) -export class TimestampToUnixMicros extends FirestoreFunction { - constructor(input: Expr); - } - -// @beta -export function timestampToUnixMicros(expr: Expr): TimestampToUnixMicros; - -// @beta -export function timestampToUnixMicros(field: string): TimestampToUnixMicros; - -// @beta (undocumented) -export class TimestampToUnixMillis extends FirestoreFunction { - constructor(input: Expr); - } - -// @beta -export function timestampToUnixMillis(expr: Expr): TimestampToUnixMillis; - -// @beta -export function timestampToUnixMillis(field: string): TimestampToUnixMillis; - -// @beta (undocumented) -export class TimestampToUnixSeconds extends FirestoreFunction { - constructor(input: Expr); - } - -// @beta -export function timestampToUnixSeconds(expr: Expr): TimestampToUnixSeconds; - -// @beta -export function timestampToUnixSeconds(field: string): TimestampToUnixSeconds; - -// @beta (undocumented) -export class ToLower extends FirestoreFunction { - constructor(expr: Expr); - } - -// @beta -export function toLower(expr: string): ToLower; - -// @beta -export function toLower(expr: Expr): ToLower; - -// @beta (undocumented) -export class ToUpper extends FirestoreFunction { - constructor(expr: Expr); - } - -// @beta -export function toUpper(expr: string): ToUpper; - -// @beta -export function toUpper(expr: Expr): ToUpper; - // @public export class Transaction { delete(documentRef: DocumentReference): this; @@ -1975,53 +726,9 @@ export interface TransactionOptions { readonly maxAttempts?: number; } -// @beta (undocumented) -export class Trim extends FirestoreFunction { - constructor(expr: Expr); - } - -// @beta -export function trim(expr: string): Trim; - -// @beta -export function trim(expr: Expr): Trim; - // @public export type UnionToIntersection = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never; -// @beta (undocumented) -export class UnixMicrosToTimestamp extends FirestoreFunction { - constructor(input: Expr); - } - -// @beta -export function unixMicrosToTimestamp(expr: Expr): UnixMicrosToTimestamp; - -// @beta -export function unixMicrosToTimestamp(field: string): UnixMicrosToTimestamp; - -// @beta (undocumented) -export class UnixMillisToTimestamp extends FirestoreFunction { - constructor(input: Expr); - } - -// @beta -export function unixMillisToTimestamp(expr: Expr): UnixMillisToTimestamp; - -// @beta -export function unixMillisToTimestamp(field: string): UnixMillisToTimestamp; - -// @beta (undocumented) -export class UnixSecondsToTimestamp extends FirestoreFunction { - constructor(input: Expr); - } - -// @beta -export function unixSecondsToTimestamp(expr: Expr): UnixSecondsToTimestamp; - -// @beta -export function unixSecondsToTimestamp(field: string): UnixSecondsToTimestamp; - // @public export interface Unsubscribe { (): void; @@ -2041,17 +748,6 @@ export function updateDoc(refere // @public export function vector(values?: number[]): VectorValue; -// @beta (undocumented) -export class VectorLength extends FirestoreFunction { - constructor(value: Expr); - } - -// @beta -export function vectorLength(expr: Expr): VectorLength; - -// @beta -export function vectorLength(field: string): VectorLength; - // @public export class VectorValue { /* Excluded from this release type: __constructor */ @@ -2062,13 +758,6 @@ export class VectorValue { // @public export function waitForPendingWrites(firestore: Firestore): Promise; -// @beta (undocumented) -export class Where implements Stage { - constructor(condition: FilterCondition); - // (undocumented) - name: string; -} - // @public export function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryFieldFilterConstraint; @@ -2093,21 +782,5 @@ export class WriteBatch { // @public export function writeBatch(firestore: Firestore): WriteBatch; -// @beta (undocumented) -export class Xor extends FirestoreFunction implements FilterCondition { - constructor(conditions: (FilterCondition)[]); - // (undocumented) - filterable: true; -} - -// @beta -export function xor(left: FilterCondition, ...right: (FilterCondition)[]): Xor; - - -// Warnings were encountered during analysis: -// -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/all_packages.d.ts:5962:26 - (ae-incompatible-release-tags) The symbol "accumulators" is marked as @public, but its signature references "AccumulatorTarget" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/all_packages.d.ts:5962:61 - (ae-incompatible-release-tags) The symbol "groups" is marked as @public, but its signature references "Selectable" which is marked as @beta -// /Users/markduckworth/projects/firebase-js-sdk/packages/firestore/dist/all_packages.d.ts:5989:21 - (ae-incompatible-release-tags) The symbol "orderings" is marked as @public, but its signature references "Ordering" which is marked as @beta ``` diff --git a/packages/firestore/lite/pipelines/package.json b/packages/firestore/lite/pipelines/package.json index 349e25e3ac3..e7989c2ea97 100644 --- a/packages/firestore/lite/pipelines/package.json +++ b/packages/firestore/lite/pipelines/package.json @@ -6,7 +6,7 @@ "module": "../../dist/lite/pipelines.browser.esm2017.js", "browser": "../../dist/lite/pipelines.browser.esm2017.js", "react-native": "../../dist/lite/pipelines.rn.esm2017.js", - "typings": "../../dist/lite/pipelines.d.ts", + "typings": "./pipelines.d.ts", "private": true, "engines": { "node": ">=18.0.0" diff --git a/packages/firestore/lite/pipelines/pipelines.d.ts b/packages/firestore/lite/pipelines/pipelines.d.ts index e1243ebe907..81336456656 100644 --- a/packages/firestore/lite/pipelines/pipelines.d.ts +++ b/packages/firestore/lite/pipelines/pipelines.d.ts @@ -19,7 +19,7 @@ import { PipelineSource, Pipeline } from '../../dist/lite/pipelines'; // Augument the Firestore class with the pipeline() method. // This is stripped from dist/lite/pipelines.d.ts during the build // so it needs to be re-added here. -declare module '@firebase/firestore' { +declare module '@firebase/firestore/lite' { interface Firestore { pipeline(): PipelineSource; } diff --git a/packages/firestore/lite/pipelines/pipelines.ts b/packages/firestore/lite/pipelines/pipelines.ts index d3e31f5e52b..e03e5f4883b 100644 --- a/packages/firestore/lite/pipelines/pipelines.ts +++ b/packages/firestore/lite/pipelines/pipelines.ts @@ -50,11 +50,14 @@ export type { export { PipelineSource } from '../../src/lite-api/pipeline-source'; -export { PipelineResult } from '../../src/lite-api/pipeline-result'; +export { + PipelineResult, + PipelineSnapshot +} from '../../src/lite-api/pipeline-result'; export { Pipeline } from '../../src/lite-api/pipeline'; -export { pipeline, execute } from '../../src/lite-api/pipeline_impl'; +export { execute } from '../../src/lite-api/pipeline_impl'; export { Stage, @@ -76,14 +79,44 @@ export { } from '../../src/lite-api/stage'; export { + Expr, + field, + and, + array, + arrayOffset, + constant, add, subtract, multiply, + avg, + bitAnd, + substr, + constantVector, + bitLeftShift, + bitNot, + count, + mapMerge, + mapRemove, + bitOr, + ifError, + isAbsent, + isError, + or, + rand, + bitRightShift, + bitXor, divide, + isNotNan, + map, + isNotNull, + isNull, mod, + documentId, eq, neq, lt, + countIf, + currentContext, lte, gt, gte, @@ -132,79 +165,16 @@ export { timestampToUnixSeconds, timestampAdd, timestampSub, - genericFunction, ascending, descending, ExprWithAlias, Field, - Fields, Constant, - FirestoreFunction, - Add, - Subtract, - Multiply, - Divide, - Mod, - Eq, - Neq, - Lt, - Lte, - Gt, - Gte, - ArrayConcat, - ArrayReverse, - ArrayContains, - ArrayContainsAll, - ArrayContainsAny, - ArrayLength, - ArrayElement, - EqAny, - IsNan, - Exists, - Not, - And, - Or, - Xor, - Cond, - LogicalMaximum, - LogicalMinimum, - Reverse, - ReplaceFirst, - ReplaceAll, - CharLength, - ByteLength, - Like, - RegexContains, - RegexMatch, - StrContains, - StartsWith, - EndsWith, - ToLower, - ToUpper, - Trim, - StrConcat, - MapGet, - Count, - Sum, - Avg, - Minimum, - Maximum, - CosineDistance, - DotProduct, - EuclideanDistance, - VectorLength, - UnixMicrosToTimestamp, - TimestampToUnixMicros, - UnixMillisToTimestamp, - TimestampToUnixMillis, - UnixSecondsToTimestamp, - TimestampToUnixSeconds, - TimestampAdd, - TimestampSub, + FunctionExpr, Ordering, ExprType, - AccumulatorTarget, + AggregateWithAlias, Selectable, - FilterCondition, - Accumulator + BooleanExpr, + AggregateFunction } from '../../src/lite-api/expressions'; diff --git a/packages/firestore/package.json b/packages/firestore/package.json index 8dc84db4315..c11536d3c1b 100644 --- a/packages/firestore/package.json +++ b/packages/firestore/package.json @@ -48,12 +48,11 @@ "test:minified": "(cd ../../integration/firestore ; yarn test)", "trusted-type-check": "tsec -p tsconfig.json --noEmit", "api-report:main": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node ../../repo-scripts/prune-dts/extract-public-api.ts --package firestore --packageRoot . --typescriptDts ./dist/firestore/src/index.d.ts --rollupDts ./dist/private.d.ts --untrimmedRollupDts ./dist/internal.d.ts --publicDts ./dist/index.d.ts", - "api-report:all-packages": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node ../../repo-scripts/prune-dts/extract-public-api.ts --package firestore --packageRoot . --typescriptDts ./dist/firestore/src/all_packages.d.ts --rollupDts ./dist/private.all_packages.d.ts --untrimmedRollupDts ./dist/internal.all_packages.d.ts --publicDts ./dist/all_packages.d.ts", "api-report:pipelines": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node ../../repo-scripts/prune-dts/extract-public-api.ts --package firestore-pipelines --packageRoot . --typescriptDts ./dist/firestore/pipelines/pipelines.d.ts --rollupDts ./dist/private.pipelines.d.ts --untrimmedRollupDts ./dist/internal.pipelines.d.ts --publicDts ./dist/pipelines.d.ts --otherExportsPublicDtsFiles ./dist/index.d.ts", "api-report:lite": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node ../../repo-scripts/prune-dts/extract-public-api.ts --package firestore-lite --packageRoot . --typescriptDts ./dist/firestore/lite/index.d.ts --rollupDts ./dist/lite/private.d.ts --untrimmedRollupDts ./dist/lite/internal.d.ts --publicDts ./dist/lite/index.d.ts", - "api-report:lite:pipelines": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node ../../repo-scripts/prune-dts/extract-public-api.ts --package firestore-lite-pipelines --packageRoot . --typescriptDts ./dist/firestore/lite/pipelines/pipelines.d.ts --rollupDts ./dist/lite/private.pipelines.d.ts --untrimmedRollupDts ./dist/lite/internal.pipelines.d.ts --publicDts ./dist/lite/pipelines.d.ts --otherExportsPublicDtsFiles ./dist/index.d.ts", + "api-report:lite:pipelines": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node ../../repo-scripts/prune-dts/extract-public-api.ts --package firestore-lite-pipelines --packageRoot . --typescriptDts ./dist/firestore/lite/pipelines/pipelines.d.ts --rollupDts ./dist/lite/private.pipelines.d.ts --untrimmedRollupDts ./dist/lite/internal.pipelines.d.ts --publicDts ./dist/lite/pipelines.d.ts --otherExportsPublicDtsFiles ./dist/lite/index.d.ts", "api-report:api-json": "rm -rf temp && api-extractor run --local --verbose", - "api-report": "run-s --npm-path npm api-report:main api-report:pipelines api-report:all-packages api-report:lite api-report:lite:pipelines && yarn api-report:api-json", + "api-report": "run-s --npm-path npm api-report:main api-report:pipelines api-report:lite api-report:lite:pipelines && yarn api-report:api-json", "doc": "api-documenter markdown --input temp --output docs", "typings:public": "node ../../scripts/build/use_typings.js ./dist/all-packages.d.ts" }, diff --git a/packages/firestore/pipelines/pipelines.d.ts b/packages/firestore/pipelines/pipelines.d.ts index 5e7944e5731..e7edb233991 100644 --- a/packages/firestore/pipelines/pipelines.d.ts +++ b/packages/firestore/pipelines/pipelines.d.ts @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {PipelineSource, Pipeline} from "../dist/pipelines"; +import { PipelineSource, Pipeline } from '../dist/pipelines'; // Augument the Firestore and Query classes with the pipeline() method. // This is stripped from dist/lite/pipelines.d.ts during the build @@ -23,9 +23,6 @@ declare module '@firebase/firestore' { interface Firestore { pipeline(): PipelineSource; } - interface Query { - pipeline(): Pipeline; - } } -export * from "../dist/pipelines"; +export * from '../dist/pipelines'; diff --git a/packages/firestore/src/api.ts b/packages/firestore/src/api.ts index 14390d57b49..ea969c6b94c 100644 --- a/packages/firestore/src/api.ts +++ b/packages/firestore/src/api.ts @@ -224,8 +224,7 @@ export { isBase64Available as _isBase64Available } from './platform/base64'; export { DatabaseId as _DatabaseId } from './core/database_info'; export { _internalQueryToProtoQueryTarget, - _internalAggregationQueryToProtoRunAggregationQueryRequest, - _internalPipelineToExecutePipelineRequestProto + _internalAggregationQueryToProtoRunAggregationQueryRequest } from './remote/internal_serializer'; export { cast as _cast, diff --git a/packages/firestore/src/api/parse_context.ts b/packages/firestore/src/api/parse_context.ts index ce3c221f66e..2381bcff4cd 100644 --- a/packages/firestore/src/api/parse_context.ts +++ b/packages/firestore/src/api/parse_context.ts @@ -16,8 +16,53 @@ */ import { DatabaseId } from '../core/database_info'; +import { UserDataSource } from '../lite-api/user_data_reader'; +import { DocumentKey } from '../model/document_key'; +import { FieldTransform } from '../model/mutation'; +import { FieldPath as InternalFieldPath } from '../model/path'; +import { JsonProtoSerializer } from '../remote/serializer'; +import { FirestoreError } from '../util/error'; + +/** Contains the settings that are mutated as we parse user data. */ +export interface ContextSettings { + /** Indicates what kind of API method this data came from. */ + readonly dataSource: UserDataSource; + /** The name of the method the user called to create the ParseContext. */ + readonly methodName: string; + /** The document the user is attempting to modify, if that applies. */ + readonly targetDoc?: DocumentKey; + /** + * A path within the object being parsed. This could be an empty path (in + * which case the context represents the root of the data being parsed), or a + * nonempty path (indicating the context represents a nested location within + * the data). + */ + readonly path?: InternalFieldPath; + /** + * Whether or not this context corresponds to an element of an array. + * If not set, elements are treated as if they were outside of arrays. + */ + readonly arrayElement?: boolean; + /** + * Whether or not a converter was specified in this context. If true, error + * messages will reference the converter when invalid data is provided. + */ + readonly hasConverter?: boolean; +} export interface ParseContext { + readonly settings: ContextSettings; readonly databaseId: DatabaseId; + readonly serializer: JsonProtoSerializer; readonly ignoreUndefinedProperties: boolean; + fieldTransforms: FieldTransform[]; + fieldMask: InternalFieldPath[]; + get path(): InternalFieldPath | undefined; + get dataSource(): UserDataSource; + contextWith(configuration: Partial): ParseContext; + childContextForField(field: string): ParseContext; + childContextForFieldPath(field: InternalFieldPath): ParseContext; + childContextForArray(index: number): ParseContext; + createError(reason: string): FirestoreError; + contains(fieldPath: InternalFieldPath): boolean; } diff --git a/packages/firestore/src/api/pipeline.ts b/packages/firestore/src/api/pipeline.ts index aaddf00274b..e7cd6e875eb 100644 --- a/packages/firestore/src/api/pipeline.ts +++ b/packages/firestore/src/api/pipeline.ts @@ -15,16 +15,12 @@ * limitations under the License. */ -import { firestoreClientExecutePipeline } from '../core/firestore_client'; import { Pipeline as LitePipeline } from '../lite-api/pipeline'; -import { PipelineResult } from '../lite-api/pipeline-result'; -import { DocumentReference } from '../lite-api/reference'; import { Stage } from '../lite-api/stage'; import { UserDataReader } from '../lite-api/user_data_reader'; import { AbstractUserDataWriter } from '../lite-api/user_data_writer'; -import { cast } from '../util/input_validation'; -import { ensureFirestoreConfigured, Firestore } from './database'; +import { Firestore } from './database'; export class Pipeline extends LitePipeline { /** @@ -41,66 +37,8 @@ export class Pipeline extends LitePipeline { db: Firestore, userDataReader: UserDataReader, userDataWriter: AbstractUserDataWriter, - stages: Stage[], - converter: unknown = {} + stages: Stage[] ): Pipeline { return new Pipeline(db, userDataReader, userDataWriter, stages); } - - /** - * Executes this pipeline and returns a Promise to represent the asynchronous operation. - * - *

The returned Promise can be used to track the progress of the pipeline execution - * and retrieve the results (or handle any errors) asynchronously. - * - *

The pipeline results are returned as a list of {@link PipelineResult} objects. Each {@link - * PipelineResult} typically represents a single key/value map that has passed through all the - * stages of the pipeline, however this might differ depending on the stages involved in the - * pipeline. For example: - * - *

    - *
  • If there are no stages or only transformation stages, each {@link PipelineResult} - * represents a single document.
  • - *
  • If there is an aggregation, only a single {@link PipelineResult} is returned, - * representing the aggregated results over the entire dataset .
  • - *
  • If there is an aggregation stage with grouping, each {@link PipelineResult} represents a - * distinct group and its associated aggregated values.
  • - *
- * - *

Example: - * - * ```typescript - * const futureResults = await firestore.pipeline().collection("books") - * .where(gt(Field.of("rating"), 4.5)) - * .select("title", "author", "rating") - * .execute(); - * ``` - * - * @return A Promise representing the asynchronous pipeline execution. - */ - execute(): Promise { - const firestore = cast(this._db, Firestore); - const client = ensureFirestoreConfigured(firestore); - return firestoreClientExecutePipeline(client, this).then(result => { - const docs = result - // Currently ignore any response from ExecutePipeline that does - // not contain any document data in the `fields` property. - .filter(element => !!element.fields) - .map( - element => - new PipelineResult( - this._userDataWriter, - element.key?.path - ? new DocumentReference(firestore, null, element.key) - : undefined, - element.fields, - element.executionTime?.toTimestamp(), - element.createTime?.toTimestamp(), - element.updateTime?.toTimestamp() - ) - ); - - return docs; - }); - } } diff --git a/packages/firestore/src/api/pipeline_impl.ts b/packages/firestore/src/api/pipeline_impl.ts index 9e7c25e69ab..ba6e08105bb 100644 --- a/packages/firestore/src/api/pipeline_impl.ts +++ b/packages/firestore/src/api/pipeline_impl.ts @@ -16,16 +16,16 @@ */ import { Pipeline } from '../api/pipeline'; -import { toPipeline } from '../core/pipeline-util'; +import { firestoreClientExecutePipeline } from '../core/firestore_client'; import { Pipeline as LitePipeline } from '../lite-api/pipeline'; -import { PipelineResult } from '../lite-api/pipeline-result'; +import { PipelineResult, PipelineSnapshot } from '../lite-api/pipeline-result'; import { PipelineSource } from '../lite-api/pipeline-source'; import { Stage } from '../lite-api/stage'; import { newUserDataReader } from '../lite-api/user_data_reader'; import { cast } from '../util/input_validation'; -import { Firestore } from './database'; -import { Query } from './reference'; +import { ensureFirestoreConfigured, Firestore } from './database'; +import { DocumentReference } from './reference'; import { ExpUserDataWriter } from './user_data_writer'; declare module './database' { @@ -35,49 +35,78 @@ declare module './database' { } /** - * Experimental Modular API for console testing. - * @param firestore - */ -export function pipeline(firestore: Firestore): PipelineSource; - -/** - * Experimental Modular API for console testing. - * @param query + * Executes this pipeline and returns a Promise to represent the asynchronous operation. + * + * The returned Promise can be used to track the progress of the pipeline execution + * and retrieve the results (or handle any errors) asynchronously. + * + * The pipeline results are returned as a {@link PipelineSnapshot} that contains + * a list of {@link PipelineResult} objects. Each {@link PipelineResult} typically + * represents a single key/value map that has passed through all the + * stages of the pipeline, however this might differ depending on the stages involved in the + * pipeline. For example: + * + *

    + *
  • If there are no stages or only transformation stages, each {@link PipelineResult} + * represents a single document.
  • + *
  • If there is an aggregation, only a single {@link PipelineResult} is returned, + * representing the aggregated results over the entire dataset .
  • + *
  • If there is an aggregation stage with grouping, each {@link PipelineResult} represents a + * distinct group and its associated aggregated values.
  • + *
+ * + *

Example: + * + * ```typescript + * const snapshot: PipelineSnapshot = await execute(firestore.pipeline().collection("books") + * .where(gt(field("rating"), 4.5)) + * .select("title", "author", "rating")); + * + * const results: PipelineResults = snapshot.results; + * ``` + * + * @param pipeline The pipeline to execute. + * @return A Promise representing the asynchronous pipeline execution. */ -export function pipeline(query: Query): Pipeline; +export function execute(pipeline: LitePipeline): Promise { + const firestore = cast(pipeline._db, Firestore); + const client = ensureFirestoreConfigured(firestore); + return firestoreClientExecutePipeline(client, pipeline).then(result => { + // Get the execution time from the first result. + // firestoreClientExecutePipeline returns at least one PipelineStreamElement + // even if the returned document set is empty. + const executionTime = + result.length > 0 ? result[0].executionTime?.toTimestamp() : undefined; -export function pipeline( - firestoreOrQuery: Firestore | Query -): PipelineSource | Pipeline { - if (firestoreOrQuery instanceof Firestore) { - const firestore = firestoreOrQuery; - return new PipelineSource((stages: Stage[]) => { - return new Pipeline( - firestore, - newUserDataReader(firestore), - new ExpUserDataWriter(firestore), - stages + const docs = result + // Currently ignore any response from ExecutePipeline that does + // not contain any document data in the `fields` property. + .filter(element => !!element.fields) + .map( + element => + new PipelineResult( + pipeline._userDataWriter, + element.key?.path + ? new DocumentReference(firestore, null, element.key) + : undefined, + element.fields, + element.createTime?.toTimestamp(), + element.updateTime?.toTimestamp() + ) ); - }); - } else { - const query = firestoreOrQuery; - const db = cast(query.firestore, Firestore); - const litePipeline: LitePipeline = toPipeline(query._query, db); - return cast(litePipeline, Pipeline); - } -} - -export function execute(pipeline: LitePipeline): Promise { - return pipeline.execute(); + return new PipelineSnapshot(pipeline, docs, executionTime); + }); } // Augment the Firestore class with the pipeline() factory method Firestore.prototype.pipeline = function (): PipelineSource { - return pipeline(this); -}; - -// Augment the Query class with the pipeline() factory method -Query.prototype.pipeline = function (): Pipeline { - return pipeline(this); + return new PipelineSource(this._databaseId, (stages: Stage[]) => { + return new Pipeline( + this, + newUserDataReader(this), + new ExpUserDataWriter(this), + stages + ); + }); }; diff --git a/packages/firestore/src/api_pipelines.ts b/packages/firestore/src/api_pipelines.ts index 90fe836932f..ad7815af3e4 100644 --- a/packages/firestore/src/api_pipelines.ts +++ b/packages/firestore/src/api_pipelines.ts @@ -17,11 +17,15 @@ export { PipelineSource } from './lite-api/pipeline-source'; -export { PipelineResult } from './lite-api/pipeline-result'; +export { + PipelineResult, + PipelineSnapshot, + pipelineResultEqual +} from './lite-api/pipeline-result'; export { Pipeline } from './api/pipeline'; -export { pipeline, execute } from './api/pipeline_impl'; +export { execute } from './api/pipeline_impl'; export { Stage, @@ -43,6 +47,8 @@ export { } from './lite-api/stage'; export { + field, + constant, add, subtract, multiply, @@ -85,11 +91,11 @@ export { strConcat, mapGet, countAll, - countFunction, - sumFunction, - avgFunction, - andFunction, - orFunction, + count, + sum, + avg, + and, + or, minimum, maximum, cosineDistance, @@ -104,84 +110,44 @@ export { timestampToUnixSeconds, timestampAdd, timestampSub, - genericFunction, ascending, descending, + countIf, + bitAnd, + bitOr, + bitXor, + bitNot, + bitLeftShift, + bitRightShift, + rand, + array, + arrayOffset, + currentContext, + isError, + ifError, + isAbsent, + isNull, + isNotNull, + isNotNan, + map, + mapRemove, + mapMerge, + documentId, + substr, Expr, ExprWithAlias, Field, - Fields, Constant, - FirestoreFunction, - Add, - Subtract, - Multiply, - Divide, - Mod, - Eq, - Neq, - Lt, - Lte, - Gt, - Gte, - ArrayConcat, - ArrayReverse, - ArrayContains, - ArrayContainsAll, - ArrayContainsAny, - ArrayLength, - ArrayElement, - EqAny, - NotEqAny, - IsNan, - Exists, - Not, - And, - Or, - Xor, - Cond, - LogicalMaximum, - LogicalMinimum, - Reverse, - ReplaceFirst, - ReplaceAll, - CharLength, - ByteLength, - Like, - RegexContains, - RegexMatch, - StrContains, - StartsWith, - EndsWith, - ToLower, - ToUpper, - Trim, - StrConcat, - MapGet, - Count, - Sum, - Avg, - Minimum, - Maximum, - CosineDistance, - DotProduct, - EuclideanDistance, - VectorLength, - UnixMicrosToTimestamp, - TimestampToUnixMicros, - UnixMillisToTimestamp, - TimestampToUnixMillis, - UnixSecondsToTimestamp, - TimestampToUnixSeconds, - TimestampAdd, - TimestampSub, + FunctionExpr, Ordering } from './lite-api/expressions'; export type { ExprType, - AccumulatorTarget, + AggregateWithAlias, Selectable, - FilterCondition, - Accumulator + BooleanExpr, + AggregateFunction } from './lite-api/expressions'; + +export { _internalPipelineToExecutePipelineRequestProto } from './remote/internal_serializer'; diff --git a/packages/firestore/src/core/pipeline-util.ts b/packages/firestore/src/core/pipeline-util.ts index 0800eba85ea..4409daffc2e 100644 --- a/packages/firestore/src/core/pipeline-util.ts +++ b/packages/firestore/src/core/pipeline-util.ts @@ -15,22 +15,20 @@ * limitations under the License. */ -import { Firestore } from '../api/database'; +import { Firestore } from '../lite-api/database'; import { Constant, Field, - FilterCondition, - not, - andFunction, - orFunction, + BooleanExpr, + and, + or, Ordering, - And, lt, gt, lte, gte, eq, - Or + field } from '../lite-api/expressions'; import { Pipeline } from '../lite-api/pipeline'; import { doc } from '../lite-api/reference'; @@ -56,56 +54,89 @@ import { /* eslint @typescript-eslint/no-explicit-any: 0 */ -export function toPipelineFilterCondition(f: FilterInternal): FilterCondition { +export function toPipelineBooleanExpr(f: FilterInternal): BooleanExpr { if (f instanceof FieldFilterInternal) { - const field = Field.of(f.field.toString()); + const fieldValue = field(f.field.toString()); if (isNanValue(f.value)) { if (f.op === Operator.EQUAL) { - return andFunction(field.exists(), field.isNaN()); + return and(fieldValue.exists(), fieldValue.isNan()); } else { - return andFunction(field.exists(), not(field.isNaN())); + return and(fieldValue.exists(), fieldValue.isNotNan()); } } else if (isNullValue(f.value)) { if (f.op === Operator.EQUAL) { - return andFunction(field.exists(), field.eq(null)); + return and(fieldValue.exists(), fieldValue.isNull()); } else { - return andFunction(field.exists(), not(field.eq(null))); + return and(fieldValue.exists(), fieldValue.isNotNull()); } } else { // Comparison filters const value = f.value; switch (f.op) { case Operator.LESS_THAN: - return andFunction(field.exists(), field.lt(value)); + return and( + fieldValue.exists(), + fieldValue.lt(Constant._fromProto(value)) + ); case Operator.LESS_THAN_OR_EQUAL: - return andFunction(field.exists(), field.lte(value)); + return and( + fieldValue.exists(), + fieldValue.lte(Constant._fromProto(value)) + ); case Operator.GREATER_THAN: - return andFunction(field.exists(), field.gt(value)); + return and( + fieldValue.exists(), + fieldValue.gt(Constant._fromProto(value)) + ); case Operator.GREATER_THAN_OR_EQUAL: - return andFunction(field.exists(), field.gte(value)); + return and( + fieldValue.exists(), + fieldValue.gte(Constant._fromProto(value)) + ); case Operator.EQUAL: - return andFunction(field.exists(), field.eq(value)); + return and( + fieldValue.exists(), + fieldValue.eq(Constant._fromProto(value)) + ); case Operator.NOT_EQUAL: - return andFunction(field.exists(), field.neq(value)); + return and( + fieldValue.exists(), + fieldValue.neq(Constant._fromProto(value)) + ); case Operator.ARRAY_CONTAINS: - return andFunction(field.exists(), field.arrayContains(value)); + return and( + fieldValue.exists(), + fieldValue.arrayContains(Constant._fromProto(value)) + ); case Operator.IN: { const values = value?.arrayValue?.values?.map((val: any) => - Constant.of(val) + Constant._fromProto(val) ); - return andFunction(field.exists(), field.eqAny(...values!)); + if (!values) { + return and(fieldValue.exists(), fieldValue.eqAny([])); + } else if (values.length === 1) { + return and(fieldValue.exists(), fieldValue.eq(values[0])); + } else { + return and(fieldValue.exists(), fieldValue.eqAny(values)); + } } case Operator.ARRAY_CONTAINS_ANY: { const values = value?.arrayValue?.values?.map((val: any) => - Constant.of(val) + Constant._fromProto(val) ); - return andFunction(field.exists(), field.arrayContainsAny(values!)); + return and(fieldValue.exists(), fieldValue.arrayContainsAny(values!)); } case Operator.NOT_IN: { const values = value?.arrayValue?.values?.map((val: any) => - Constant.of(val) + Constant._fromProto(val) ); - return andFunction(field.exists(), not(field.eqAny(...values!))); + if (!values) { + return and(fieldValue.exists(), fieldValue.notEqAny([])); + } else if (values.length === 1) { + return and(fieldValue.exists(), fieldValue.neq(values[0])); + } else { + return and(fieldValue.exists(), fieldValue.notEqAny(values)); + } } default: fail('Unexpected operator'); @@ -114,16 +145,12 @@ export function toPipelineFilterCondition(f: FilterInternal): FilterCondition { } else if (f instanceof CompositeFilterInternal) { switch (f.op) { case CompositeOperator.AND: { - const conditions = f - .getFilters() - .map(f => toPipelineFilterCondition(f)); - return andFunction(conditions[0], ...conditions.slice(1)); + const conditions = f.getFilters().map(f => toPipelineBooleanExpr(f)); + return and(conditions[0], conditions[1], ...conditions.slice(2)); } case CompositeOperator.OR: { - const conditions = f - .getFilters() - .map(f => toPipelineFilterCondition(f)); - return orFunction(conditions[0], ...conditions.slice(1)); + const conditions = f.getFilters().map(f => toPipelineBooleanExpr(f)); + return or(conditions[0], conditions[1], ...conditions.slice(2)); } default: fail('Unexpected operator'); @@ -155,17 +182,21 @@ export function toPipeline(query: Query, db: Firestore): Pipeline { // filters for (const filter of query.filters) { - pipeline = pipeline.where(toPipelineFilterCondition(filter)); + pipeline = pipeline.where(toPipelineBooleanExpr(filter)); } // orders const orders = queryNormalizedOrderBy(query); const existsConditions = orders.map(order => - Field.of(order.field.canonicalString()).exists() + field(order.field.canonicalString()).exists() ); if (existsConditions.length > 1) { pipeline = pipeline.where( - andFunction(existsConditions[0], ...existsConditions.slice(1)) + and( + existsConditions[0], + existsConditions[1], + ...existsConditions.slice(2) + ) ); } else { pipeline = pipeline.where(existsConditions[0]); @@ -173,42 +204,45 @@ export function toPipeline(query: Query, db: Firestore): Pipeline { const orderings = orders.map(order => order.dir === Direction.ASCENDING - ? Field.of(order.field.canonicalString()).ascending() - : Field.of(order.field.canonicalString()).descending() + ? field(order.field.canonicalString()).ascending() + : field(order.field.canonicalString()).descending() ); - if (query.limitType === LimitType.Last) { - pipeline = pipeline.sort(...reverseOrderings(orderings)); - // cursors - if (query.startAt !== null) { - pipeline = pipeline.where( - whereConditionsFromCursor(query.startAt, orderings, 'before') - ); - } + if (orderings.length > 0) { + if (query.limitType === LimitType.Last) { + const actualOrderings = reverseOrderings(orderings); + pipeline = pipeline.sort(actualOrderings[0], ...actualOrderings.slice(1)); + // cursors + if (query.startAt !== null) { + pipeline = pipeline.where( + whereConditionsFromCursor(query.startAt, orderings, 'after') + ); + } - if (query.endAt !== null) { - pipeline = pipeline.where( - whereConditionsFromCursor(query.endAt, orderings, 'after') - ); - } + if (query.endAt !== null) { + pipeline = pipeline.where( + whereConditionsFromCursor(query.endAt, orderings, 'before') + ); + } - pipeline = pipeline._limit(query.limit!, true); - pipeline = pipeline.sort(...orderings); - } else { - pipeline = pipeline.sort(...orderings); - if (query.startAt !== null) { - pipeline = pipeline.where( - whereConditionsFromCursor(query.startAt, orderings, 'after') - ); - } - if (query.endAt !== null) { - pipeline = pipeline.where( - whereConditionsFromCursor(query.endAt, orderings, 'before') - ); - } + pipeline = pipeline._limit(query.limit!, true); + pipeline = pipeline.sort(orderings[0], ...orderings.slice(1)); + } else { + pipeline = pipeline.sort(orderings[0], ...orderings.slice(1)); + if (query.startAt !== null) { + pipeline = pipeline.where( + whereConditionsFromCursor(query.startAt, orderings, 'after') + ); + } + if (query.endAt !== null) { + pipeline = pipeline.where( + whereConditionsFromCursor(query.endAt, orderings, 'before') + ); + } - if (query.limit !== null) { - pipeline = pipeline.limit(query.limit); + if (query.limit !== null) { + pipeline = pipeline.limit(query.limit); + } } } @@ -219,19 +253,19 @@ function whereConditionsFromCursor( bound: Bound, orderings: Ordering[], position: 'before' | 'after' -): FilterCondition { +): BooleanExpr { const cursors = bound.position.map(value => Constant._fromProto(value)); const filterFunc = position === 'before' ? lt : gt; const filterInclusiveFunc = position === 'before' ? lte : gte; - const orConditions = []; + const orConditions: BooleanExpr[] = []; for (let i = 1; i <= orderings.length; i++) { const cursorSubset = cursors.slice(0, i); - const conditions = cursorSubset.map((cursor, index) => { + const conditions: BooleanExpr[] = cursorSubset.map((cursor, index) => { if (index < cursorSubset.length - 1) { return eq(orderings[index].expr as Field, cursor); - } else if (!!bound.inclusive && i === orderings.length) { + } else if (bound.inclusive && i === orderings.length - 1) { return filterInclusiveFunc(orderings[index].expr as Field, cursor); } else { return filterFunc(orderings[index].expr as Field, cursor); @@ -241,13 +275,15 @@ function whereConditionsFromCursor( if (conditions.length === 1) { orConditions.push(conditions[0]); } else { - orConditions.push(new And(conditions)); + orConditions.push( + and(conditions[0], conditions[1], ...conditions.slice(2)) + ); } } if (orConditions.length === 1) { return orConditions[0]; } else { - return new Or(orConditions); + return or(orConditions[0], orConditions[1], ...orConditions.slice(2)); } } diff --git a/packages/firestore/src/lite-api/expressions.ts b/packages/firestore/src/lite-api/expressions.ts index 03e5c5e747e..6eaebf2c4f0 100644 --- a/packages/firestore/src/lite-api/expressions.ts +++ b/packages/firestore/src/lite-api/expressions.ts @@ -15,8 +15,7 @@ * limitations under the License. */ -/* eslint @typescript-eslint/no-explicit-any: 0 */ - +import { ParseContext } from '../api/parse_context'; import { DOCUMENT_KEY_NAME, FieldPath as InternalFieldPath @@ -24,17 +23,19 @@ import { import { Value as ProtoValue } from '../protos/firestore_proto_api'; import { JsonProtoSerializer, - ProtoSerializable, + ProtoValueSerializable, + toMapValue, toStringValue, UserData } from '../remote/serializer'; import { hardAssert } from '../util/assert'; +import { isPlainObject } from '../util/input_validation'; import { isFirestoreValue } from '../util/proto'; +import { isString } from '../util/types'; import { Bytes } from './bytes'; -import { documentId, FieldPath } from './field_path'; +import { documentId as documentIdFieldPath, FieldPath } from './field_path'; import { GeoPoint } from './geo_point'; -import { Pipeline } from './pipeline'; import { DocumentReference } from './reference'; import { Timestamp } from './timestamp'; import { @@ -54,9 +55,72 @@ export type ExprType = | 'Field' | 'Constant' | 'Function' + | 'AggregateFunction' | 'ListOfExprs' | 'ExprWithAlias'; +/** + * Converts a value to an Expr, Returning either a Constant, MapFunction, + * ArrayFunction, or the input itself (if it's already an expression). + * + * @private + * @internal + * @param value + */ +function valueToDefaultExpr(value: unknown): Expr { + let result: Expr | undefined; + if (value instanceof Expr) { + return value; + } else if (isPlainObject(value)) { + result = map(value as Record); + } else if (value instanceof Array) { + result = array(value); + } else { + result = new Constant(value); + } + + result._createdFromLiteral = true; + return result; +} + +/** + * Converts a value to an Expr, Returning either a Constant, MapFunction, + * ArrayFunction, or the input itself (if it's already an expression). + * + * @private + * @internal + * @param value + */ +function vectorToExpr(value: VectorValue | number[] | Expr): Expr { + if (value instanceof Expr) { + return value; + } else { + const result = constantVector(value); + result._createdFromLiteral = true; + return result; + } +} + +/** + * Converts a value to an Expr, Returning either a Constant, MapFunction, + * ArrayFunction, or the input itself (if it's already an expression). + * If the input is a string, it is assumed to be a field name, and a + * field(value) is returned. + * + * @private + * @internal + * @param value + */ +function fieldOrExpression(value: unknown): Expr { + if (isString(value)) { + const result = field(value); + result._createdFromLiteral = true; + return result; + } else { + return valueToDefaultExpr(value); + } +} + /** * @beta * @@ -69,44 +133,55 @@ export type ExprType = * - **Field references:** Access values from document fields. * - **Literals:** Represent constant values (strings, numbers, booleans). * - **Function calls:** Apply functions to one or more expressions. - * - **Aggregations:** Calculate aggregate values (e.g., sum, average) over a set of documents. * * The `Expr` class provides a fluent API for building expressions. You can chain together * method calls to create complex expressions. */ -export abstract class Expr implements ProtoSerializable, UserData { - abstract exprType: ExprType; +export abstract class Expr implements ProtoValueSerializable, UserData { + abstract readonly exprType: ExprType; /** - * Creates an expression that adds this expression to another expression. - * - * ```typescript - * // Add the value of the 'quantity' field and the 'reserve' field. - * Field.of("quantity").add(Field.of("reserve")); - * ``` - * - * @param other The expression to add to this expression. - * @return A new `Expr` representing the addition operation. + * @internal + * @private + * Indicates if this expression was created from a literal value passed + * by the caller. + */ + _createdFromLiteral: boolean = false; + + /** + * @private + * @internal + */ + abstract _toProto(serializer: JsonProtoSerializer): ProtoValue; + _protoValueType = 'ProtoValue' as const; + + /** + * @private + * @internal */ - add(other: Expr): Add; + abstract _readUserData( + dataReader: UserDataReader, + context?: ParseContext + ): void; /** - * Creates an expression that adds this expression to a constant value. + * Creates an expression that adds this expression to another expression. * * ```typescript - * // Add 5 to the value of the 'age' field - * Field.of("age").add(5); + * // Add the value of the 'quantity' field and the 'reserve' field. + * field("quantity").add(field("reserve")); * ``` * - * @param other The constant value to add. + * @param second The expression or literal to add to this expression. + * @param others Optional additional expressions or literals to add to this expression. * @return A new `Expr` representing the addition operation. */ - add(other: any): Add; - add(other: any): Add { - if (other instanceof Expr) { - return new Add(this, other); - } - return new Add(this, Constant.of(other)); + add(second: Expr | unknown, ...others: Array): FunctionExpr { + const values = [second, ...others]; + return new FunctionExpr('add', [ + this, + ...values.map(value => valueToDefaultExpr(value)) + ]); } /** @@ -114,31 +189,28 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Subtract the 'discount' field from the 'price' field - * Field.of("price").subtract(Field.of("discount")); + * field("price").subtract(field("discount")); * ``` * * @param other The expression to subtract from this expression. * @return A new `Expr` representing the subtraction operation. */ - subtract(other: Expr): Subtract; + subtract(other: Expr): FunctionExpr; /** * Creates an expression that subtracts a constant value from this expression. * * ```typescript * // Subtract 20 from the value of the 'total' field - * Field.of("total").subtract(20); + * field("total").subtract(20); * ``` * * @param other The constant value to subtract. * @return A new `Expr` representing the subtraction operation. */ - subtract(other: any): Subtract; - subtract(other: any): Subtract { - if (other instanceof Expr) { - return new Subtract(this, other); - } - return new Subtract(this, Constant.of(other)); + subtract(other: number): FunctionExpr; + subtract(other: number | Expr): FunctionExpr { + return new FunctionExpr('subtract', [this, valueToDefaultExpr(other)]); } /** @@ -146,31 +218,22 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Multiply the 'quantity' field by the 'price' field - * Field.of("quantity").multiply(Field.of("price")); - * ``` - * - * @param other The expression to multiply by. - * @return A new `Expr` representing the multiplication operation. - */ - multiply(other: Expr): Multiply; - - /** - * Creates an expression that multiplies this expression by a constant value. - * - * ```typescript - * // Multiply the 'value' field by 2 - * Field.of("value").multiply(2); + * field("quantity").multiply(field("price")); * ``` * - * @param other The constant value to multiply by. + * @param second The second expression or literal to multiply by. + * @param others Optional additional expressions or literals to multiply by. * @return A new `Expr` representing the multiplication operation. */ - multiply(other: any): Multiply; - multiply(other: any): Multiply { - if (other instanceof Expr) { - return new Multiply(this, other); - } - return new Multiply(this, Constant.of(other)); + multiply( + second: Expr | number, + ...others: Array + ): FunctionExpr { + return new FunctionExpr('multiply', [ + this, + valueToDefaultExpr(second), + ...others.map(value => valueToDefaultExpr(value)) + ]); } /** @@ -178,31 +241,28 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Divide the 'total' field by the 'count' field - * Field.of("total").divide(Field.of("count")); + * field("total").divide(field("count")); * ``` * * @param other The expression to divide by. * @return A new `Expr` representing the division operation. */ - divide(other: Expr): Divide; + divide(other: Expr): FunctionExpr; /** * Creates an expression that divides this expression by a constant value. * * ```typescript * // Divide the 'value' field by 10 - * Field.of("value").divide(10); + * field("value").divide(10); * ``` * * @param other The constant value to divide by. * @return A new `Expr` representing the division operation. */ - divide(other: any): Divide; - divide(other: any): Divide { - if (other instanceof Expr) { - return new Divide(this, other); - } - return new Divide(this, Constant.of(other)); + divide(other: number): FunctionExpr; + divide(other: number | Expr): FunctionExpr { + return new FunctionExpr('divide', [this, valueToDefaultExpr(other)]); } /** @@ -210,237 +270,57 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Calculate the remainder of dividing the 'value' field by the 'divisor' field - * Field.of("value").mod(Field.of("divisor")); + * field("value").mod(field("divisor")); * ``` * - * @param other The expression to divide by. + * @param expression The expression to divide by. * @return A new `Expr` representing the modulo operation. */ - mod(other: Expr): Mod; + mod(expression: Expr): FunctionExpr; /** * Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value. * * ```typescript * // Calculate the remainder of dividing the 'value' field by 10 - * Field.of("value").mod(10); + * field("value").mod(10); * ``` * - * @param other The constant value to divide by. + * @param value The constant value to divide by. * @return A new `Expr` representing the modulo operation. */ - mod(other: any): Mod; - mod(other: any): Mod { - if (other instanceof Expr) { - return new Mod(this, other); - } - return new Mod(this, Constant.of(other)); + mod(value: number): FunctionExpr; + mod(other: number | Expr): FunctionExpr { + return new FunctionExpr('mod', [this, valueToDefaultExpr(other)]); } - // /** - // * Creates an expression that applies a bitwise AND operation between this expression and another expression. - // * - // * ```typescript - // * // Calculate the bitwise AND of 'field1' and 'field2'. - // * Field.of("field1").bitAnd(Field.of("field2")); - // * ``` - // * - // * @param other The right operand expression. - // * @return A new {@code Expr} representing the bitwise AND operation. - // */ - // bitAnd(other: Expr): BitAnd; - // - // /** - // * Creates an expression that applies a bitwise AND operation between this expression and a constant value. - // * - // * ```typescript - // * // Calculate the bitwise AND of 'field1' and 0xFF. - // * Field.of("field1").bitAnd(0xFF); - // * ``` - // * - // * @param other The right operand constant. - // * @return A new {@code Expr} representing the bitwise AND operation. - // */ - // bitAnd(other: any): BitAnd; - // bitAnd(other: any): BitAnd { - // if (other instanceof Expr) { - // return new BitAnd(this, other); - // } - // return new BitAnd(this, Constant.of(other)); - // } - // - // /** - // * Creates an expression that applies a bitwise OR operation between this expression and another expression. - // * - // * ```typescript - // * // Calculate the bitwise OR of 'field1' and 'field2'. - // * Field.of("field1").bitOr(Field.of("field2")); - // * ``` - // * - // * @param other The right operand expression. - // * @return A new {@code Expr} representing the bitwise OR operation. - // */ - // bitOr(other: Expr): BitOr; - // - // /** - // * Creates an expression that applies a bitwise OR operation between this expression and a constant value. - // * - // * ```typescript - // * // Calculate the bitwise OR of 'field1' and 0xFF. - // * Field.of("field1").bitOr(0xFF); - // * ``` - // * - // * @param other The right operand constant. - // * @return A new {@code Expr} representing the bitwise OR operation. - // */ - // bitOr(other: any): BitOr; - // bitOr(other: any): BitOr { - // if (other instanceof Expr) { - // return new BitOr(this, other); - // } - // return new BitOr(this, Constant.of(other)); - // } - // - // /** - // * Creates an expression that applies a bitwise XOR operation between this expression and another expression. - // * - // * ```typescript - // * // Calculate the bitwise XOR of 'field1' and 'field2'. - // * Field.of("field1").bitXor(Field.of("field2")); - // * ``` - // * - // * @param other The right operand expression. - // * @return A new {@code Expr} representing the bitwise XOR operation. - // */ - // bitXor(other: Expr): BitXor; - // - // /** - // * Creates an expression that applies a bitwise XOR operation between this expression and a constant value. - // * - // * ```typescript - // * // Calculate the bitwise XOR of 'field1' and 0xFF. - // * Field.of("field1").bitXor(0xFF); - // * ``` - // * - // * @param other The right operand constant. - // * @return A new {@code Expr} representing the bitwise XOR operation. - // */ - // bitXor(other: any): BitXor; - // bitXor(other: any): BitXor { - // if (other instanceof Expr) { - // return new BitXor(this, other); - // } - // return new BitXor(this, Constant.of(other)); - // } - // - // /** - // * Creates an expression that applies a bitwise NOT operation to this expression. - // * - // * ```typescript - // * // Calculate the bitwise NOT of 'field1'. - // * Field.of("field1").bitNot(); - // * ``` - // * - // * @return A new {@code Expr} representing the bitwise NOT operation. - // */ - // bitNot(): BitNot { - // return new BitNot(this); - // } - // - // /** - // * Creates an expression that applies a bitwise left shift operation between this expression and another expression. - // * - // * ```typescript - // * // Calculate the bitwise left shift of 'field1' by 'field2' bits. - // * Field.of("field1").bitLeftShift(Field.of("field2")); - // * ``` - // * - // * @param other The right operand expression representing the number of bits to shift. - // * @return A new {@code Expr} representing the bitwise left shift operation. - // */ - // bitLeftShift(other: Expr): BitLeftShift; - // - // /** - // * Creates an expression that applies a bitwise left shift operation between this expression and a constant value. - // * - // * ```typescript - // * // Calculate the bitwise left shift of 'field1' by 2 bits. - // * Field.of("field1").bitLeftShift(2); - // * ``` - // * - // * @param other The right operand constant representing the number of bits to shift. - // * @return A new {@code Expr} representing the bitwise left shift operation. - // */ - // bitLeftShift(other: number): BitLeftShift; - // bitLeftShift(other: Expr | number): BitLeftShift { - // if (typeof other === 'number') { - // return new BitLeftShift(this, Constant.of(other)); - // } - // return new BitLeftShift(this, other as Expr); - // } - // - // /** - // * Creates an expression that applies a bitwise right shift operation between this expression and another expression. - // * - // * ```typescript - // * // Calculate the bitwise right shift of 'field1' by 'field2' bits. - // * Field.of("field1").bitRightShift(Field.of("field2")); - // * ``` - // * - // * @param other The right operand expression representing the number of bits to shift. - // * @return A new {@code Expr} representing the bitwise right shift operation. - // */ - // bitRightShift(other: Expr): BitRightShift; - // - // /** - // * Creates an expression that applies a bitwise right shift operation between this expression and a constant value. - // * - // * ```typescript - // * // Calculate the bitwise right shift of 'field1' by 2 bits. - // * Field.of("field1").bitRightShift(2); - // * ``` - // * - // * @param other The right operand constant representing the number of bits to shift. - // * @return A new {@code Expr} representing the bitwise right shift operation. - // */ - // bitRightShift(other: number): BitRightShift; - // bitRightShift(other: Expr | number): BitRightShift { - // if (typeof other === 'number') { - // return new BitRightShift(this, Constant.of(other)); - // } - // return new BitRightShift(this, other as Expr); - // } - /** * Creates an expression that checks if this expression is equal to another expression. * * ```typescript * // Check if the 'age' field is equal to 21 - * Field.of("age").eq(21); + * field("age").eq(21); * ``` * - * @param other The expression to compare for equality. + * @param expression The expression to compare for equality. * @return A new `Expr` representing the equality comparison. */ - eq(other: Expr): Eq; + eq(expression: Expr): BooleanExpr; /** * Creates an expression that checks if this expression is equal to a constant value. * * ```typescript * // Check if the 'city' field is equal to "London" - * Field.of("city").eq("London"); + * field("city").eq("London"); * ``` * - * @param other The constant value to compare for equality. + * @param value The constant value to compare for equality. * @return A new `Expr` representing the equality comparison. */ - eq(other: any): Eq; - eq(other: any): Eq { - if (other instanceof Expr) { - return new Eq(this, other); - } - return new Eq(this, Constant.of(other)); + eq(value: unknown): BooleanExpr; + eq(other: unknown): BooleanExpr { + return new BooleanExpr('eq', [this, valueToDefaultExpr(other)]); } /** @@ -448,31 +328,28 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'status' field is not equal to "completed" - * Field.of("status").neq("completed"); + * field("status").neq("completed"); * ``` * - * @param other The expression to compare for inequality. + * @param expression The expression to compare for inequality. * @return A new `Expr` representing the inequality comparison. */ - neq(other: Expr): Neq; + neq(expression: Expr): BooleanExpr; /** * Creates an expression that checks if this expression is not equal to a constant value. * * ```typescript * // Check if the 'country' field is not equal to "USA" - * Field.of("country").neq("USA"); + * field("country").neq("USA"); * ``` * - * @param other The constant value to compare for inequality. + * @param value The constant value to compare for inequality. * @return A new `Expr` representing the inequality comparison. */ - neq(other: any): Neq; - neq(other: any): Neq { - if (other instanceof Expr) { - return new Neq(this, other); - } - return new Neq(this, Constant.of(other)); + neq(value: unknown): BooleanExpr; + neq(other: unknown): BooleanExpr { + return new BooleanExpr('neq', [this, valueToDefaultExpr(other)]); } /** @@ -480,31 +357,28 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'age' field is less than 'limit' - * Field.of("age").lt(Field.of('limit')); + * field("age").lt(field('limit')); * ``` * - * @param other The expression to compare for less than. + * @param experession The expression to compare for less than. * @return A new `Expr` representing the less than comparison. */ - lt(other: Expr): Lt; + lt(experession: Expr): BooleanExpr; /** * Creates an expression that checks if this expression is less than a constant value. * * ```typescript * // Check if the 'price' field is less than 50 - * Field.of("price").lt(50); + * field("price").lt(50); * ``` * - * @param other The constant value to compare for less than. + * @param value The constant value to compare for less than. * @return A new `Expr` representing the less than comparison. */ - lt(other: any): Lt; - lt(other: any): Lt { - if (other instanceof Expr) { - return new Lt(this, other); - } - return new Lt(this, Constant.of(other)); + lt(value: unknown): BooleanExpr; + lt(other: unknown): BooleanExpr { + return new BooleanExpr('lt', [this, valueToDefaultExpr(other)]); } /** @@ -513,31 +387,28 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'quantity' field is less than or equal to 20 - * Field.of("quantity").lte(Constant.of(20)); + * field("quantity").lte(constant(20)); * ``` * - * @param other The expression to compare for less than or equal to. + * @param expression The expression to compare for less than or equal to. * @return A new `Expr` representing the less than or equal to comparison. */ - lte(other: Expr): Lte; + lte(expression: Expr): BooleanExpr; /** * Creates an expression that checks if this expression is less than or equal to a constant value. * * ```typescript * // Check if the 'score' field is less than or equal to 70 - * Field.of("score").lte(70); + * field("score").lte(70); * ``` * - * @param other The constant value to compare for less than or equal to. + * @param value The constant value to compare for less than or equal to. * @return A new `Expr` representing the less than or equal to comparison. */ - lte(other: any): Lte; - lte(other: any): Lte { - if (other instanceof Expr) { - return new Lte(this, other); - } - return new Lte(this, Constant.of(other)); + lte(value: unknown): BooleanExpr; + lte(other: unknown): BooleanExpr { + return new BooleanExpr('lte', [this, valueToDefaultExpr(other)]); } /** @@ -545,31 +416,28 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'age' field is greater than the 'limit' field - * Field.of("age").gt(Field.of("limit")); + * field("age").gt(field("limit")); * ``` * - * @param other The expression to compare for greater than. + * @param expression The expression to compare for greater than. * @return A new `Expr` representing the greater than comparison. */ - gt(other: Expr): Gt; + gt(expression: Expr): BooleanExpr; /** * Creates an expression that checks if this expression is greater than a constant value. * * ```typescript * // Check if the 'price' field is greater than 100 - * Field.of("price").gt(100); + * field("price").gt(100); * ``` * - * @param other The constant value to compare for greater than. + * @param value The constant value to compare for greater than. * @return A new `Expr` representing the greater than comparison. */ - gt(other: any): Gt; - gt(other: any): Gt { - if (other instanceof Expr) { - return new Gt(this, other); - } - return new Gt(this, Constant.of(other)); + gt(value: unknown): BooleanExpr; + gt(other: unknown): BooleanExpr { + return new BooleanExpr('gt', [this, valueToDefaultExpr(other)]); } /** @@ -578,13 +446,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 - * Field.of("quantity").gte(Field.of('requirement').add(1)); + * field("quantity").gte(field('requirement').add(1)); * ``` * - * @param other The expression to compare for greater than or equal to. + * @param expression The expression to compare for greater than or equal to. * @return A new `Expr` representing the greater than or equal to comparison. */ - gte(other: Expr): Gte; + gte(expression: Expr): BooleanExpr; /** * Creates an expression that checks if this expression is greater than or equal to a constant @@ -592,18 +460,15 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'score' field is greater than or equal to 80 - * Field.of("score").gte(80); + * field("score").gte(80); * ``` * - * @param other The constant value to compare for greater than or equal to. + * @param value The constant value to compare for greater than or equal to. * @return A new `Expr` representing the greater than or equal to comparison. */ - gte(other: any): Gte; - gte(other: any): Gte { - if (other instanceof Expr) { - return new Gte(this, other); - } - return new Gte(this, Constant.of(other)); + gte(value: unknown): BooleanExpr; + gte(other: unknown): BooleanExpr { + return new BooleanExpr('gte', [this, valueToDefaultExpr(other)]); } /** @@ -611,31 +476,19 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Combine the 'items' array with another array field. - * Field.of("items").arrayConcat(Field.of("otherItems")); + * field("items").arrayConcat(field("otherItems")); * ``` - * - * @param arrays The array expressions to concatenate. + * @param secondArray Second array expression or array literal to concatenate. + * @param otherArrays Optional additional array expressions or array literals to concatenate. * @return A new `Expr` representing the concatenated array. */ - arrayConcat(...arrays: Expr[]): ArrayConcat; - - /** - * Creates an expression that concatenates an array with one or more other arrays. - * - * ```typescript - * // Combine the 'tags' array with a new array and an array field - * Field.of("tags").arrayConcat(Arrays.asList("newTag1", "newTag2"), Field.of("otherTag")); - * ``` - * - * @param arrays The arrays to concatenate. - * @return A new `Expr` representing the concatenated arrays. - */ - arrayConcat(...arrays: any[][]): ArrayConcat; - arrayConcat(...arrays: any[]): ArrayConcat { - const exprValues = arrays.map(value => - value instanceof Expr ? value : Constant.of(value) - ); - return new ArrayConcat(this, exprValues); + arrayConcat( + secondArray: Expr | unknown[], + ...otherArrays: Array + ): FunctionExpr { + const elements = [secondArray, ...otherArrays]; + const exprValues = elements.map(value => valueToDefaultExpr(value)); + return new FunctionExpr('array_concat', [this, ...exprValues]); } /** @@ -643,63 +496,63 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'sizes' array contains the value from the 'selectedSize' field - * Field.of("sizes").arrayContains(Field.of("selectedSize")); + * field("sizes").arrayContains(field("selectedSize")); * ``` * - * @param element The element to search for in the array. + * @param expression The element to search for in the array. * @return A new `Expr` representing the 'array_contains' comparison. */ - arrayContains(element: Expr): ArrayContains; + arrayContains(expression: Expr): BooleanExpr; /** * Creates an expression that checks if an array contains a specific value. * * ```typescript * // Check if the 'colors' array contains "red" - * Field.of("colors").arrayContains("red"); + * field("colors").arrayContains("red"); * ``` * - * @param element The element to search for in the array. + * @param value The element to search for in the array. * @return A new `Expr` representing the 'array_contains' comparison. */ - arrayContains(element: any): ArrayContains; - arrayContains(element: any): ArrayContains { - if (element instanceof Expr) { - return new ArrayContains(this, element); - } - return new ArrayContains(this, Constant.of(element)); + arrayContains(value: unknown): BooleanExpr; + arrayContains(element: unknown): BooleanExpr { + return new BooleanExpr('array_contains', [ + this, + valueToDefaultExpr(element) + ]); } /** * Creates an expression that checks if an array contains all the specified elements. * * ```typescript - * // Check if the 'tags' array contains both "news" and "sports" - * Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + * // Check if the 'tags' array contains both the value in field "tag1" and the literal value "tag2" + * field("tags").arrayContainsAll([field("tag1"), "tag2"]); * ``` * * @param values The elements to check for in the array. * @return A new `Expr` representing the 'array_contains_all' comparison. */ - arrayContainsAll(...values: Expr[]): ArrayContainsAll; + arrayContainsAll(values: Array): BooleanExpr; /** * Creates an expression that checks if an array contains all the specified elements. * * ```typescript - * // Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" - * Field.of("tags").arrayContainsAll(Field.of("tag1"), Field.of("tag2")); + * // Check if the 'tags' array contains both of the values from field "tag1" and the literal value "tag2" + * field("tags").arrayContainsAll(array([field("tag1"), "tag2"])); * ``` * - * @param values The elements to check for in the array. + * @param arrayExpression The elements to check for in the array. * @return A new `Expr` representing the 'array_contains_all' comparison. */ - arrayContainsAll(...values: any[]): ArrayContainsAll; - arrayContainsAll(...values: any[]): ArrayContainsAll { - const exprValues = values.map(value => - value instanceof Expr ? value : Constant.of(value) - ); - return new ArrayContainsAll(this, exprValues); + arrayContainsAll(arrayExpression: Expr): BooleanExpr; + arrayContainsAll(values: unknown[] | Expr): BooleanExpr { + const normalizedExpr = Array.isArray(values) + ? new ListOfExprs(values.map(valueToDefaultExpr)) + : values; + return new BooleanExpr('array_contains_all', [this, normalizedExpr]); } /** @@ -707,13 +560,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'categories' array contains either values from field "cate1" or "cate2" - * Field.of("categories").arrayContainsAny(Field.of("cate1"), Field.of("cate2")); + * field("categories").arrayContainsAny([field("cate1"), field("cate2")]); * ``` * * @param values The elements to check for in the array. * @return A new `Expr` representing the 'array_contains_any' comparison. */ - arrayContainsAny(...values: Expr[]): ArrayContainsAny; + arrayContainsAny(values: Array): BooleanExpr; /** * Creates an expression that checks if an array contains any of the specified elements. @@ -721,18 +574,18 @@ export abstract class Expr implements ProtoSerializable, UserData { * ```typescript * // Check if the 'groups' array contains either the value from the 'userGroup' field * // or the value "guest" - * Field.of("groups").arrayContainsAny(Field.of("userGroup"), "guest"); + * field("groups").arrayContainsAny(array([field("userGroup"), "guest"])); * ``` * - * @param values The elements to check for in the array. + * @param arrayExpression The elements to check for in the array. * @return A new `Expr` representing the 'array_contains_any' comparison. */ - arrayContainsAny(...values: any[]): ArrayContainsAny; - arrayContainsAny(...values: any[]): ArrayContainsAny { - const exprValues = values.map(value => - value instanceof Expr ? value : Constant.of(value) - ); - return new ArrayContainsAny(this, exprValues); + arrayContainsAny(arrayExpression: Expr): BooleanExpr; + arrayContainsAny(values: Array | Expr): BooleanExpr { + const normalizedExpr = Array.isArray(values) + ? new ListOfExprs(values.map(valueToDefaultExpr)) + : values; + return new BooleanExpr('array_contains_any', [this, normalizedExpr]); } /** @@ -740,13 +593,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Get the number of items in the 'cart' array - * Field.of("cart").arrayLength(); + * field("cart").arrayLength(); * ``` * * @return A new `Expr` representing the length of the array. */ - arrayLength(): ArrayLength { - return new ArrayLength(this); + arrayLength(): FunctionExpr { + return new FunctionExpr('array_length', [this]); } /** @@ -755,13 +608,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' - * Field.of("category").eqAny("Electronics", Field.of("primaryType")); + * field("category").eqAny("Electronics", field("primaryType")); * ``` * - * @param others The values or expressions to check against. + * @param values The values or expressions to check against. * @return A new `Expr` representing the 'IN' comparison. */ - eqAny(...others: Expr[]): EqAny; + eqAny(values: Array): BooleanExpr; /** * Creates an expression that checks if this expression is equal to any of the provided values or @@ -769,18 +622,18 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' - * Field.of("category").eqAny("Electronics", Field.of("primaryType")); + * field("category").eqAny(array(["Electronics", field("primaryType")])); * ``` * - * @param others The values or expressions to check against. + * @param arrayExpression An expression that evaluates to an array of values to check against. * @return A new `Expr` representing the 'IN' comparison. */ - eqAny(...others: any[]): EqAny; - eqAny(...others: any[]): EqAny { - const exprOthers = others.map(other => - other instanceof Expr ? other : Constant.of(other) - ); - return new EqAny(this, exprOthers); + eqAny(arrayExpression: Expr): BooleanExpr; + eqAny(others: unknown[] | Expr): BooleanExpr { + const exprOthers = Array.isArray(others) + ? new ListOfExprs(others.map(valueToDefaultExpr)) + : others; + return new BooleanExpr('eq_any', [this, exprOthers]); } /** @@ -789,32 +642,31 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' - * Field.of("status").notEqAny("pending", Field.of("rejectedStatus")); + * field("status").notEqAny(["pending", field("rejectedStatus")]); * ``` * - * @param others The values or expressions to check against. + * @param values The values or expressions to check against. * @return A new `Expr` representing the 'NotEqAny' comparison. */ - notEqAny(...others: Expr[]): NotEqAny; + notEqAny(values: Array): BooleanExpr; /** - * Creates an expression that checks if this expression is not equal to any of the provided values or - * expressions. + * Creates an expression that checks if this expression is not equal to any of the values in the evaluated expression. * * ```typescript - * // Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' - * Field.of("status").notEqAny("pending", Field.of("rejectedStatus")); + * // Check if the 'status' field is not equal to any value in the field 'rejectedStatuses' + * field("status").notEqAny(field('rejectedStatuses')); * ``` * - * @param others The values or expressions to check against. + * @param arrayExpression The values or expressions to check against. * @return A new `Expr` representing the 'NotEqAny' comparison. */ - notEqAny(...others: any[]): NotEqAny; - notEqAny(...others: any[]): NotEqAny { - const exprOthers = others.map(other => - other instanceof Expr ? other : Constant.of(other) - ); - return new NotEqAny(this, exprOthers); + notEqAny(arrayExpression: Expr): BooleanExpr; + notEqAny(others: unknown[] | Expr): BooleanExpr { + const exprOthers = Array.isArray(others) + ? new ListOfExprs(others.map(valueToDefaultExpr)) + : others; + return new BooleanExpr('not_eq_any', [this, exprOthers]); } /** @@ -822,13 +674,27 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the result of a calculation is NaN - * Field.of("value").divide(0).isNaN(); + * field("value").divide(0).isNaN(); * ``` * * @return A new `Expr` representing the 'isNaN' check. */ - isNaN(): IsNan { - return new IsNan(this); + isNan(): BooleanExpr { + return new BooleanExpr('is_nan', [this]); + } + + /** + * Creates an expression that checks if this expression evaluates to 'Null'. + * + * ```typescript + * // Check if the result of a calculation is NaN + * field("value").isNull(); + * ``` + * + * @return A new `Expr` representing the 'isNull' check. + */ + isNull(): BooleanExpr { + return new BooleanExpr('is_null', [this]); } /** @@ -836,13 +702,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the document has a field named "phoneNumber" - * Field.of("phoneNumber").exists(); + * field("phoneNumber").exists(); * ``` * * @return A new `Expr` representing the 'exists' check. */ - exists(): Exists { - return new Exists(this); + exists(): BooleanExpr { + return new BooleanExpr('exists', [this]); } /** @@ -850,13 +716,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Get the character length of the 'name' field in its UTF-8 form. - * Field.of("name").charLength(); + * field("name").charLength(); * ``` * * @return A new `Expr` representing the length of the string. */ - charLength(): CharLength { - return new CharLength(this); + charLength(): FunctionExpr { + return new FunctionExpr('char_length', [this]); } /** @@ -864,31 +730,28 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'title' field contains the word "guide" (case-sensitive) - * Field.of("title").like("%guide%"); + * field("title").like("%guide%"); * ``` * * @param pattern The pattern to search for. You can use "%" as a wildcard character. * @return A new `Expr` representing the 'like' comparison. */ - like(pattern: string): Like; + like(pattern: string): FunctionExpr; /** * Creates an expression that performs a case-sensitive string comparison. * * ```typescript * // Check if the 'title' field contains the word "guide" (case-sensitive) - * Field.of("title").like("%guide%"); + * field("title").like("%guide%"); * ``` * * @param pattern The pattern to search for. You can use "%" as a wildcard character. * @return A new `Expr` representing the 'like' comparison. */ - like(pattern: Expr): Like; - like(stringOrExpr: string | Expr): Like { - if (typeof stringOrExpr === 'string') { - return new Like(this, Constant.of(stringOrExpr)); - } - return new Like(this, stringOrExpr as Expr); + like(pattern: Expr): FunctionExpr; + like(stringOrExpr: string | Expr): FunctionExpr { + return new FunctionExpr('like', [this, valueToDefaultExpr(stringOrExpr)]); } /** @@ -897,13 +760,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'description' field contains "example" (case-insensitive) - * Field.of("description").regexContains("(?i)example"); + * field("description").regexContains("(?i)example"); * ``` * * @param pattern The regular expression to use for the search. * @return A new `Expr` representing the 'contains' comparison. */ - regexContains(pattern: string): RegexContains; + regexContains(pattern: string): BooleanExpr; /** * Creates an expression that checks if a string contains a specified regular expression as a @@ -911,18 +774,18 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'description' field contains the regular expression stored in field 'regex' - * Field.of("description").regexContains(Field.of("regex")); + * field("description").regexContains(field("regex")); * ``` * * @param pattern The regular expression to use for the search. * @return A new `Expr` representing the 'contains' comparison. */ - regexContains(pattern: Expr): RegexContains; - regexContains(stringOrExpr: string | Expr): RegexContains { - if (typeof stringOrExpr === 'string') { - return new RegexContains(this, Constant.of(stringOrExpr)); - } - return new RegexContains(this, stringOrExpr as Expr); + regexContains(pattern: Expr): BooleanExpr; + regexContains(stringOrExpr: string | Expr): BooleanExpr { + return new BooleanExpr('regex_contains', [ + this, + valueToDefaultExpr(stringOrExpr) + ]); } /** @@ -930,31 +793,31 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'email' field matches a valid email pattern - * Field.of("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + * field("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); * ``` * * @param pattern The regular expression to use for the match. * @return A new `Expr` representing the regular expression match. */ - regexMatch(pattern: string): RegexMatch; + regexMatch(pattern: string): BooleanExpr; /** * Creates an expression that checks if a string matches a specified regular expression. * * ```typescript * // Check if the 'email' field matches a regular expression stored in field 'regex' - * Field.of("email").regexMatch(Field.of("regex")); + * field("email").regexMatch(field("regex")); * ``` * * @param pattern The regular expression to use for the match. * @return A new `Expr` representing the regular expression match. */ - regexMatch(pattern: Expr): RegexMatch; - regexMatch(stringOrExpr: string | Expr): RegexMatch { - if (typeof stringOrExpr === 'string') { - return new RegexMatch(this, Constant.of(stringOrExpr)); - } - return new RegexMatch(this, stringOrExpr as Expr); + regexMatch(pattern: Expr): BooleanExpr; + regexMatch(stringOrExpr: string | Expr): BooleanExpr { + return new BooleanExpr('regex_match', [ + this, + valueToDefaultExpr(stringOrExpr) + ]); } /** @@ -962,31 +825,31 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'description' field contains "example". - * Field.of("description").strContains("example"); + * field("description").strContains("example"); * ``` * * @param substring The substring to search for. * @return A new `Expr` representing the 'contains' comparison. */ - strContains(substring: string): StrContains; + strContains(substring: string): BooleanExpr; /** * Creates an expression that checks if a string contains the string represented by another expression. * * ```typescript * // Check if the 'description' field contains the value of the 'keyword' field. - * Field.of("description").strContains(Field.of("keyword")); + * field("description").strContains(field("keyword")); * ``` * * @param expr The expression representing the substring to search for. * @return A new `Expr` representing the 'contains' comparison. */ - strContains(expr: Expr): StrContains; - strContains(stringOrExpr: string | Expr): StrContains { - if (typeof stringOrExpr === 'string') { - return new StrContains(this, Constant.of(stringOrExpr)); - } - return new StrContains(this, stringOrExpr as Expr); + strContains(expr: Expr): BooleanExpr; + strContains(stringOrExpr: string | Expr): BooleanExpr { + return new BooleanExpr('str_contains', [ + this, + valueToDefaultExpr(stringOrExpr) + ]); } /** @@ -994,13 +857,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'name' field starts with "Mr." - * Field.of("name").startsWith("Mr."); + * field("name").startsWith("Mr."); * ``` * * @param prefix The prefix to check for. * @return A new `Expr` representing the 'starts with' comparison. */ - startsWith(prefix: string): StartsWith; + startsWith(prefix: string): BooleanExpr; /** * Creates an expression that checks if a string starts with a given prefix (represented as an @@ -1008,18 +871,18 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'fullName' field starts with the value of the 'firstName' field - * Field.of("fullName").startsWith(Field.of("firstName")); + * field("fullName").startsWith(field("firstName")); * ``` * * @param prefix The prefix expression to check for. * @return A new `Expr` representing the 'starts with' comparison. */ - startsWith(prefix: Expr): StartsWith; - startsWith(stringOrExpr: string | Expr): StartsWith { - if (typeof stringOrExpr === 'string') { - return new StartsWith(this, Constant.of(stringOrExpr)); - } - return new StartsWith(this, stringOrExpr as Expr); + startsWith(prefix: Expr): BooleanExpr; + startsWith(stringOrExpr: string | Expr): BooleanExpr { + return new BooleanExpr('starts_with', [ + this, + valueToDefaultExpr(stringOrExpr) + ]); } /** @@ -1027,13 +890,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'filename' field ends with ".txt" - * Field.of("filename").endsWith(".txt"); + * field("filename").endsWith(".txt"); * ``` * * @param suffix The postfix to check for. * @return A new `Expr` representing the 'ends with' comparison. */ - endsWith(suffix: string): EndsWith; + endsWith(suffix: string): BooleanExpr; /** * Creates an expression that checks if a string ends with a given postfix (represented as an @@ -1041,18 +904,18 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Check if the 'url' field ends with the value of the 'extension' field - * Field.of("url").endsWith(Field.of("extension")); + * field("url").endsWith(field("extension")); * ``` * * @param suffix The postfix expression to check for. * @return A new `Expr` representing the 'ends with' comparison. */ - endsWith(suffix: Expr): EndsWith; - endsWith(stringOrExpr: string | Expr): EndsWith { - if (typeof stringOrExpr === 'string') { - return new EndsWith(this, Constant.of(stringOrExpr)); - } - return new EndsWith(this, stringOrExpr as Expr); + endsWith(suffix: Expr): BooleanExpr; + endsWith(stringOrExpr: string | Expr): BooleanExpr { + return new BooleanExpr('ends_with', [ + this, + valueToDefaultExpr(stringOrExpr) + ]); } /** @@ -1060,13 +923,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Convert the 'name' field to lowercase - * Field.of("name").toLower(); + * field("name").toLower(); * ``` * * @return A new `Expr` representing the lowercase string. */ - toLower(): ToLower { - return new ToLower(this); + toLower(): FunctionExpr { + return new FunctionExpr('to_lower', [this]); } /** @@ -1074,13 +937,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Convert the 'title' field to uppercase - * Field.of("title").toUpper(); + * field("title").toUpper(); * ``` * * @return A new `Expr` representing the uppercase string. */ - toUpper(): ToUpper { - return new ToUpper(this); + toUpper(): FunctionExpr { + return new FunctionExpr('to_upper', [this]); } /** @@ -1088,13 +951,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Trim whitespace from the 'userInput' field - * Field.of("userInput").trim(); + * field("userInput").trim(); * ``` * * @return A new `Expr` representing the trimmed string. */ - trim(): Trim { - return new Trim(this); + trim(): FunctionExpr { + return new FunctionExpr('trim', [this]); } /** @@ -1102,17 +965,20 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Combine the 'firstName', " ", and 'lastName' fields into a single string - * Field.of("firstName").strConcat(Constant.of(" "), Field.of("lastName")); + * field("firstName").strConcat(constant(" "), field("lastName")); * ``` * - * @param elements The expressions (typically strings) to concatenate. + * @param secondString The additional expression or string literal to concatenate. + * @param otherStrings Optional additional expressions or string literals to concatenate. * @return A new `Expr` representing the concatenated string. */ - strConcat(...elements: Array): StrConcat { - const exprs = elements.map(e => - typeof e === 'string' ? Constant.of(e) : (e as Expr) - ); - return new StrConcat(this, exprs); + strConcat( + secondString: Expr | string, + ...otherStrings: Array + ): FunctionExpr { + const elements = [secondString, ...otherStrings]; + const exprs = elements.map(valueToDefaultExpr); + return new FunctionExpr('str_concat', [this, ...exprs]); } /** @@ -1120,13 +986,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Reverse the value of the 'myString' field. - * Field.of("myString").reverse(); + * field("myString").reverse(); * ``` * * @return A new {@code Expr} representing the reversed string. */ - reverse(): Reverse { - return new Reverse(this); + reverse(): FunctionExpr { + return new FunctionExpr('reverse', [this]); } /** @@ -1134,14 +1000,14 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Replace the first occurrence of "hello" with "hi" in the 'message' field - * Field.of("message").replaceFirst("hello", "hi"); + * field("message").replaceFirst("hello", "hi"); * ``` * * @param find The substring to search for. * @param replace The substring to replace the first occurrence of 'find' with. * @return A new {@code Expr} representing the string with the first occurrence replaced. */ - replaceFirst(find: string, replace: string): ReplaceFirst; + replaceFirst(find: string, replace: string): FunctionExpr; /** * Creates an expression that replaces the first occurrence of a substring within this string expression with another substring, @@ -1149,23 +1015,20 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field - * Field.of("message").replaceFirst(Field.of("findField"), Field.of("replaceField")); + * field("message").replaceFirst(field("findField"), field("replaceField")); * ``` * * @param find The expression representing the substring to search for. * @param replace The expression representing the substring to replace the first occurrence of 'find' with. * @return A new {@code Expr} representing the string with the first occurrence replaced. */ - replaceFirst(find: Expr, replace: Expr): ReplaceFirst; - replaceFirst(find: Expr | string, replace: Expr | string): ReplaceFirst { - const normalizedFind = typeof find === 'string' ? Constant.of(find) : find; - const normalizedReplace = - typeof replace === 'string' ? Constant.of(replace) : replace; - return new ReplaceFirst( + replaceFirst(find: Expr, replace: Expr): FunctionExpr; + replaceFirst(find: Expr | string, replace: Expr | string): FunctionExpr { + return new FunctionExpr('replace_first', [ this, - normalizedFind as Expr, - normalizedReplace as Expr - ); + valueToDefaultExpr(find), + valueToDefaultExpr(replace) + ]); } /** @@ -1173,14 +1036,14 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Replace all occurrences of "hello" with "hi" in the 'message' field - * Field.of("message").replaceAll("hello", "hi"); + * field("message").replaceAll("hello", "hi"); * ``` * * @param find The substring to search for. * @param replace The substring to replace all occurrences of 'find' with. * @return A new {@code Expr} representing the string with all occurrences replaced. */ - replaceAll(find: string, replace: string): ReplaceAll; + replaceAll(find: string, replace: string): FunctionExpr; /** * Creates an expression that replaces all occurrences of a substring within this string expression with another substring, @@ -1188,23 +1051,20 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field - * Field.of("message").replaceAll(Field.of("findField"), Field.of("replaceField")); + * field("message").replaceAll(field("findField"), field("replaceField")); * ``` * * @param find The expression representing the substring to search for. * @param replace The expression representing the substring to replace all occurrences of 'find' with. * @return A new {@code Expr} representing the string with all occurrences replaced. */ - replaceAll(find: Expr, replace: Expr): ReplaceAll; - replaceAll(find: Expr | string, replace: Expr | string): ReplaceAll { - const normalizedFind = typeof find === 'string' ? Constant.of(find) : find; - const normalizedReplace = - typeof replace === 'string' ? Constant.of(replace) : replace; - return new ReplaceAll( + replaceAll(find: Expr, replace: Expr): FunctionExpr; + replaceAll(find: Expr | string, replace: Expr | string): FunctionExpr { + return new FunctionExpr('replace_all', [ this, - normalizedFind as Expr, - normalizedReplace as Expr - ); + valueToDefaultExpr(find), + valueToDefaultExpr(replace) + ]); } /** @@ -1212,13 +1072,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Calculate the length of the 'myString' field in bytes. - * Field.of("myString").byteLength(); + * field("myString").byteLength(); * ``` * * @return A new {@code Expr} representing the length of the string in bytes. */ - byteLength(): ByteLength { - return new ByteLength(this); + byteLength(): FunctionExpr { + return new FunctionExpr('byte_length', [this]); } /** @@ -1226,14 +1086,14 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Get the 'city' value from the 'address' map field - * Field.of("address").mapGet("city"); + * field("address").mapGet("city"); * ``` * * @param subfield The key to access in the map. * @return A new `Expr` representing the value associated with the given key in the map. */ - mapGet(subfield: string): MapGet { - return new MapGet(this, subfield); + mapGet(subfield: string): FunctionExpr { + return new FunctionExpr('map_get', [this, constant(subfield)]); } /** @@ -1242,13 +1102,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Count the total number of products - * Field.of("productId").count().as("totalProducts"); + * field("productId").count().as("totalProducts"); * ``` * - * @return A new `Accumulator` representing the 'count' aggregation. + * @return A new `AggregateFunction` representing the 'count' aggregation. */ - count(): Count { - return new Count(this, false); + count(): AggregateFunction { + return new AggregateFunction('count', [this]); } /** @@ -1256,13 +1116,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Calculate the total revenue from a set of orders - * Field.of("orderAmount").sum().as("totalRevenue"); + * field("orderAmount").sum().as("totalRevenue"); * ``` * - * @return A new `Accumulator` representing the 'sum' aggregation. + * @return A new `AggregateFunction` representing the 'sum' aggregation. */ - sum(): Sum { - return new Sum(this, false); + sum(): AggregateFunction { + return new AggregateFunction('sum', [this]); } /** @@ -1271,13 +1131,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Calculate the average age of users - * Field.of("age").avg().as("averageAge"); + * field("age").avg().as("averageAge"); * ``` * - * @return A new `Accumulator` representing the 'avg' aggregation. + * @return A new `AggregateFunction` representing the 'avg' aggregation. */ - avg(): Avg { - return new Avg(this, false); + avg(): AggregateFunction { + return new AggregateFunction('avg', [this]); } /** @@ -1285,13 +1145,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Find the lowest price of all products - * Field.of("price").minimum().as("lowestPrice"); + * field("price").minimum().as("lowestPrice"); * ``` * - * @return A new `Accumulator` representing the 'min' aggregation. + * @return A new `AggregateFunction` representing the 'min' aggregation. */ - minimum(): Minimum { - return new Minimum(this, false); + minimum(): AggregateFunction { + return new AggregateFunction('minimum', [this]); } /** @@ -1299,13 +1159,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Find the highest score in a leaderboard - * Field.of("score").maximum().as("highestScore"); + * field("score").maximum().as("highestScore"); * ``` * - * @return A new `Accumulator` representing the 'max' aggregation. + * @return A new `AggregateFunction` representing the 'max' aggregation. */ - maximum(): Maximum { - return new Maximum(this, false); + maximum(): AggregateFunction { + return new AggregateFunction('maximum', [this]); } /** @@ -1313,31 +1173,22 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Returns the larger value between the 'timestamp' field and the current timestamp. - * Field.of("timestamp").logicalMaximum(Function.currentTimestamp()); - * ``` - * - * @param other The expression to compare with. - * @return A new {@code Expr} representing the logical max operation. - */ - logicalMaximum(other: Expr): LogicalMaximum; - - /** - * Creates an expression that returns the larger value between this expression and a constant value, based on Firestore's value type ordering. - * - * ```typescript - * // Returns the larger value between the 'value' field and 10. - * Field.of("value").logicalMaximum(10); + * field("timestamp").logicalMaximum(Function.currentTimestamp()); * ``` * - * @param other The constant value to compare with. + * @param second The second expression or literal to compare with. + * @param others Optional additional expressions or literals to compare with. * @return A new {@code Expr} representing the logical max operation. */ - logicalMaximum(other: any): LogicalMaximum; - logicalMaximum(other: any): LogicalMaximum { - if (other instanceof Expr) { - return new LogicalMaximum(this, other as Expr); - } - return new LogicalMaximum(this, Constant.of(other)); + logicalMaximum( + second: Expr | unknown, + ...others: Array + ): FunctionExpr { + const values = [second, ...others]; + return new FunctionExpr('logical_maximum', [ + this, + ...values.map(valueToDefaultExpr) + ]); } /** @@ -1345,31 +1196,22 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Returns the smaller value between the 'timestamp' field and the current timestamp. - * Field.of("timestamp").logicalMinimum(Function.currentTimestamp()); - * ``` - * - * @param other The expression to compare with. - * @return A new {@code Expr} representing the logical min operation. - */ - logicalMinimum(other: Expr): LogicalMinimum; - - /** - * Creates an expression that returns the smaller value between this expression and a constant value, based on Firestore's value type ordering. - * - * ```typescript - * // Returns the smaller value between the 'value' field and 10. - * Field.of("value").logicalMinimum(10); + * field("timestamp").logicalMinimum(Function.currentTimestamp()); * ``` * - * @param other The constant value to compare with. + * @param second The second expression or literal to compare with. + * @param others Optional additional expressions or literals to compare with. * @return A new {@code Expr} representing the logical min operation. */ - logicalMinimum(other: any): LogicalMinimum; - logicalMinimum(other: any): LogicalMinimum { - if (other instanceof Expr) { - return new LogicalMinimum(this, other as Expr); - } - return new LogicalMinimum(this, Constant.of(other)); + logicalMinimum( + second: Expr | unknown, + ...others: Array + ): FunctionExpr { + const values = [second, ...others]; + return new FunctionExpr('logical_minimum', [ + this, + ...values.map(valueToDefaultExpr) + ]); } /** @@ -1377,13 +1219,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Get the vector length (dimension) of the field 'embedding'. - * Field.of("embedding").vectorLength(); + * field("embedding").vectorLength(); * ``` * * @return A new {@code Expr} representing the length of the vector. */ - vectorLength(): VectorLength { - return new VectorLength(this); + vectorLength(): FunctionExpr { + return new FunctionExpr('vector_length', [this]); } /** @@ -1391,46 +1233,27 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Calculate the cosine distance between the 'userVector' field and the 'itemVector' field - * Field.of("userVector").cosineDistance(Field.of("itemVector")); + * field("userVector").cosineDistance(field("itemVector")); * ``` * - * @param other The other vector (represented as an Expr) to compare against. + * @param vectorExpression The other vector (represented as an Expr) to compare against. * @return A new `Expr` representing the cosine distance between the two vectors. */ - cosineDistance(other: Expr): CosineDistance; + cosineDistance(vectorExpression: Expr): FunctionExpr; /** * Calculates the Cosine distance between two vectors. * * ```typescript * // Calculate the Cosine distance between the 'location' field and a target location - * Field.of("location").cosineDistance(new VectorValue([37.7749, -122.4194])); + * field("location").cosineDistance(new VectorValue([37.7749, -122.4194])); * ``` * - * @param other The other vector (as a VectorValue) to compare against. + * @param vector The other vector (as a VectorValue) to compare against. * @return A new `Expr` representing the Cosine* distance between the two vectors. */ - cosineDistance(other: VectorValue): CosineDistance; - /** - * Calculates the Cosine distance between two vectors. - * - * ```typescript - * // Calculate the Cosine distance between the 'location' field and a target location - * Field.of("location").cosineDistance([37.7749, -122.4194]); - * ``` - * - * @param other The other vector (as an array of numbers) to compare against. - * @return A new `Expr` representing the Cosine distance between the two vectors. - */ - cosineDistance(other: number[]): CosineDistance; - cosineDistance(other: Expr | VectorValue | number[]): CosineDistance { - if (other instanceof Expr) { - return new CosineDistance(this, other as Expr); - } else { - return new CosineDistance( - this, - Constant.vector(other as VectorValue | number[]) - ); - } + cosineDistance(vector: VectorValue | number[]): FunctionExpr; + cosineDistance(other: Expr | VectorValue | number[]): FunctionExpr { + return new FunctionExpr('cosine_distance', [this, vectorToExpr(other)]); } /** @@ -1438,48 +1261,28 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Calculate the dot product between a feature vector and a target vector - * Field.of("features").dotProduct([0.5, 0.8, 0.2]); + * field("features").dotProduct([0.5, 0.8, 0.2]); * ``` * - * @param other The other vector (as an array of numbers) to calculate with. + * @param vectorExpression The other vector (as an array of numbers) to calculate with. * @return A new `Expr` representing the dot product between the two vectors. */ - dotProduct(other: Expr): DotProduct; + dotProduct(vectorExpression: Expr): FunctionExpr; /** * Calculates the dot product between two vectors. * * ```typescript * // Calculate the dot product between a feature vector and a target vector - * Field.of("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); + * field("features").dotProduct(new VectorValue([0.5, 0.8, 0.2])); * ``` * - * @param other The other vector (as an array of numbers) to calculate with. + * @param vector The other vector (as an array of numbers) to calculate with. * @return A new `Expr` representing the dot product between the two vectors. */ - dotProduct(other: VectorValue): DotProduct; - - /** - * Calculates the dot product between two vectors. - * - * ```typescript - * // Calculate the dot product between a feature vector and a target vector - * Field.of("features").dotProduct([0.5, 0.8, 0.2]); - * ``` - * - * @param other The other vector (as an array of numbers) to calculate with. - * @return A new `Expr` representing the dot product between the two vectors. - */ - dotProduct(other: number[]): DotProduct; - dotProduct(other: Expr | VectorValue | number[]): DotProduct { - if (other instanceof Expr) { - return new DotProduct(this, other as Expr); - } else { - return new DotProduct( - this, - Constant.vector(other as VectorValue | number[]) - ); - } + dotProduct(vector: VectorValue | number[]): FunctionExpr; + dotProduct(other: Expr | VectorValue | number[]): FunctionExpr { + return new FunctionExpr('dot_product', [this, vectorToExpr(other)]); } /** @@ -1487,48 +1290,28 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Calculate the Euclidean distance between the 'location' field and a target location - * Field.of("location").euclideanDistance([37.7749, -122.4194]); - * ``` - * - * @param other The other vector (as an array of numbers) to calculate with. - * @return A new `Expr` representing the Euclidean distance between the two vectors. - */ - euclideanDistance(other: Expr): EuclideanDistance; - - /** - * Calculates the Euclidean distance between two vectors. - * - * ```typescript - * // Calculate the Euclidean distance between the 'location' field and a target location - * Field.of("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); + * field("location").euclideanDistance([37.7749, -122.4194]); * ``` * - * @param other The other vector (as a VectorValue) to compare against. + * @param vectorExpression The other vector (as an array of numbers) to calculate with. * @return A new `Expr` representing the Euclidean distance between the two vectors. */ - euclideanDistance(other: VectorValue): EuclideanDistance; + euclideanDistance(vectorExpression: Expr): FunctionExpr; /** * Calculates the Euclidean distance between two vectors. * * ```typescript * // Calculate the Euclidean distance between the 'location' field and a target location - * Field.of("location").euclideanDistance([37.7749, -122.4194]); + * field("location").euclideanDistance(new VectorValue([37.7749, -122.4194])); * ``` * - * @param other The other vector (as an array of numbers) to compare against. + * @param vector The other vector (as a VectorValue) to compare against. * @return A new `Expr` representing the Euclidean distance between the two vectors. */ - euclideanDistance(other: number[]): EuclideanDistance; - euclideanDistance(other: Expr | VectorValue | number[]): EuclideanDistance { - if (other instanceof Expr) { - return new EuclideanDistance(this, other as Expr); - } else { - return new EuclideanDistance( - this, - Constant.vector(other as VectorValue | number[]) - ); - } + euclideanDistance(vector: VectorValue | number[]): FunctionExpr; + euclideanDistance(other: Expr | VectorValue | number[]): FunctionExpr { + return new FunctionExpr('euclidean_distance', [this, vectorToExpr(other)]); } /** @@ -1537,13 +1320,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Interpret the 'microseconds' field as microseconds since epoch. - * Field.of("microseconds").unixMicrosToTimestamp(); + * field("microseconds").unixMicrosToTimestamp(); * ``` * * @return A new {@code Expr} representing the timestamp. */ - unixMicrosToTimestamp(): UnixMicrosToTimestamp { - return new UnixMicrosToTimestamp(this); + unixMicrosToTimestamp(): FunctionExpr { + return new FunctionExpr('unix_micros_to_timestamp', [this]); } /** @@ -1551,13 +1334,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Convert the 'timestamp' field to microseconds since epoch. - * Field.of("timestamp").timestampToUnixMicros(); + * field("timestamp").timestampToUnixMicros(); * ``` * * @return A new {@code Expr} representing the number of microseconds since epoch. */ - timestampToUnixMicros(): TimestampToUnixMicros { - return new TimestampToUnixMicros(this); + timestampToUnixMicros(): FunctionExpr { + return new FunctionExpr('timestamp_to_unix_micros', [this]); } /** @@ -1566,13 +1349,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Interpret the 'milliseconds' field as milliseconds since epoch. - * Field.of("milliseconds").unixMillisToTimestamp(); + * field("milliseconds").unixMillisToTimestamp(); * ``` * * @return A new {@code Expr} representing the timestamp. */ - unixMillisToTimestamp(): UnixMillisToTimestamp { - return new UnixMillisToTimestamp(this); + unixMillisToTimestamp(): FunctionExpr { + return new FunctionExpr('unix_millis_to_timestamp', [this]); } /** @@ -1580,13 +1363,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Convert the 'timestamp' field to milliseconds since epoch. - * Field.of("timestamp").timestampToUnixMillis(); + * field("timestamp").timestampToUnixMillis(); * ``` * * @return A new {@code Expr} representing the number of milliseconds since epoch. */ - timestampToUnixMillis(): TimestampToUnixMillis { - return new TimestampToUnixMillis(this); + timestampToUnixMillis(): FunctionExpr { + return new FunctionExpr('timestamp_to_unix_millis', [this]); } /** @@ -1595,13 +1378,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Interpret the 'seconds' field as seconds since epoch. - * Field.of("seconds").unixSecondsToTimestamp(); + * field("seconds").unixSecondsToTimestamp(); * ``` * * @return A new {@code Expr} representing the timestamp. */ - unixSecondsToTimestamp(): UnixSecondsToTimestamp { - return new UnixSecondsToTimestamp(this); + unixSecondsToTimestamp(): FunctionExpr { + return new FunctionExpr('unix_seconds_to_timestamp', [this]); } /** @@ -1609,13 +1392,13 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Convert the 'timestamp' field to seconds since epoch. - * Field.of("timestamp").timestampToUnixSeconds(); + * field("timestamp").timestampToUnixSeconds(); * ``` * * @return A new {@code Expr} representing the number of seconds since epoch. */ - timestampToUnixSeconds(): TimestampToUnixSeconds { - return new TimestampToUnixSeconds(this); + timestampToUnixSeconds(): FunctionExpr { + return new FunctionExpr('timestamp_to_unix_seconds', [this]); } /** @@ -1623,21 +1406,21 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. - * Field.of("timestamp").timestampAdd(Field.of("unit"), Field.of("amount")); + * field("timestamp").timestampAdd(field("unit"), field("amount")); * ``` * * @param unit The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. * @param amount The expression evaluates to amount of the unit. * @return A new {@code Expr} representing the resulting timestamp. */ - timestampAdd(unit: Expr, amount: Expr): TimestampAdd; + timestampAdd(unit: Expr, amount: Expr): FunctionExpr; /** * Creates an expression that adds a specified amount of time to this timestamp expression. * * ```typescript * // Add 1 day to the 'timestamp' field. - * Field.of("timestamp").timestampAdd("day", 1); + * field("timestamp").timestampAdd("day", 1); * ``` * * @param unit The unit of time to add (e.g., "day", "hour"). @@ -1647,7 +1430,7 @@ export abstract class Expr implements ProtoSerializable, UserData { timestampAdd( unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number - ): TimestampAdd; + ): FunctionExpr; timestampAdd( unit: | Expr @@ -1658,15 +1441,12 @@ export abstract class Expr implements ProtoSerializable, UserData { | 'hour' | 'day', amount: Expr | number - ): TimestampAdd { - const normalizedUnit = typeof unit === 'string' ? Constant.of(unit) : unit; - const normalizedAmount = - typeof amount === 'number' ? Constant.of(amount) : amount; - return new TimestampAdd( + ): FunctionExpr { + return new FunctionExpr('timestamp_add', [ this, - normalizedUnit as Expr, - normalizedAmount as Expr - ); + valueToDefaultExpr(unit), + valueToDefaultExpr(amount) + ]); } /** @@ -1674,21 +1454,21 @@ export abstract class Expr implements ProtoSerializable, UserData { * * ```typescript * // Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. - * Field.of("timestamp").timestampSub(Field.of("unit"), Field.of("amount")); + * field("timestamp").timestampSub(field("unit"), field("amount")); * ``` * * @param unit The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'. * @param amount The expression evaluates to amount of the unit. * @return A new {@code Expr} representing the resulting timestamp. */ - timestampSub(unit: Expr, amount: Expr): TimestampSub; + timestampSub(unit: Expr, amount: Expr): FunctionExpr; /** * Creates an expression that subtracts a specified amount of time from this timestamp expression. * * ```typescript * // Subtract 1 day from the 'timestamp' field. - * Field.of("timestamp").timestampSub("day", 1); + * field("timestamp").timestampSub("day", 1); * ``` * * @param unit The unit of time to subtract (e.g., "day", "hour"). @@ -1698,7 +1478,7 @@ export abstract class Expr implements ProtoSerializable, UserData { timestampSub( unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number - ): TimestampSub; + ): FunctionExpr; timestampSub( unit: | Expr @@ -1709,129 +1489,557 @@ export abstract class Expr implements ProtoSerializable, UserData { | 'hour' | 'day', amount: Expr | number - ): TimestampSub { - const normalizedUnit = typeof unit === 'string' ? Constant.of(unit) : unit; - const normalizedAmount = - typeof amount === 'number' ? Constant.of(amount) : amount; - return new TimestampSub( + ): FunctionExpr { + return new FunctionExpr('timestamp_sub', [ this, - normalizedUnit as Expr, - normalizedAmount as Expr - ); + valueToDefaultExpr(unit), + valueToDefaultExpr(amount) + ]); } /** - * Creates an {@link Ordering} that sorts documents in ascending order based on this expression. + * @beta + * + * Creates an expression that applies a bitwise AND operation between this expression and a constant. * * ```typescript - * // Sort documents by the 'name' field in ascending order - * pipeline().collection("users") - * .sort(Field.of("name").ascending()); + * // Calculate the bitwise AND of 'field1' and 0xFF. + * field("field1").bitAnd(0xFF); * ``` * - * @return A new `Ordering` for ascending sorting. + * @param otherBits A constant representing bits. + * @return A new {@code Expr} representing the bitwise AND operation. */ - ascending(): Ordering { - return ascending(this); - } - + bitAnd(otherBits: number | Bytes): FunctionExpr; /** - * Creates an {@link Ordering} that sorts documents in descending order based on this expression. + * @beta + * + * Creates an expression that applies a bitwise AND operation between two expressions. * * ```typescript - * // Sort documents by the 'createdAt' field in descending order - * firestore.pipeline().collection("users") - * .sort(Field.of("createdAt").descending()); + * // Calculate the bitwise AND of 'field1' and 'field2'. + * field("field1").bitAnd(field("field2")); * ``` * - * @return A new `Ordering` for descending sorting. + * @param bitsExpression An expression that returns bits when evaluated. + * @return A new {@code Expr} representing the bitwise AND operation. */ - descending(): Ordering { - return descending(this); + bitAnd(bitsExpression: Expr): FunctionExpr; + bitAnd(bitsOrExpression: number | Expr | Bytes): FunctionExpr { + return new FunctionExpr('bit_and', [ + this, + valueToDefaultExpr(bitsOrExpression) + ]); } /** - * Assigns an alias to this expression. + * @beta * - * Aliases are useful for renaming fields in the output of a stage or for giving meaningful - * names to calculated values. + * Creates an expression that applies a bitwise OR operation between this expression and a constant. * * ```typescript - * // Calculate the total price and assign it the alias "totalPrice" and add it to the output. - * firestore.pipeline().collection("items") - * .addFields(Field.of("price").multiply(Field.of("quantity")).as("totalPrice")); + * // Calculate the bitwise OR of 'field1' and 0xFF. + * field("field1").bitOr(0xFF); * ``` * - * @param name The alias to assign to this expression. - * @return A new {@link ExprWithAlias} that wraps this - * expression and associates it with the provided alias. + * @param otherBits A constant representing bits. + * @return A new {@code Expr} representing the bitwise OR operation. */ - as(name: string): ExprWithAlias { - return new ExprWithAlias(this, name); + bitOr(otherBits: number | Bytes): FunctionExpr; + /** + * @beta + * + * Creates an expression that applies a bitwise OR operation between two expressions. + * + * ```typescript + * // Calculate the bitwise OR of 'field1' and 'field2'. + * field("field1").bitOr(field("field2")); + * ``` + * + * @param bitsExpression An expression that returns bits when evaluated. + * @return A new {@code Expr} representing the bitwise OR operation. + */ + bitOr(bitsExpression: Expr): FunctionExpr; + bitOr(bitsOrExpression: number | Expr | Bytes): FunctionExpr { + return new FunctionExpr('bit_or', [ + this, + valueToDefaultExpr(bitsOrExpression) + ]); } /** - * @private - * @internal + * @beta + * + * Creates an expression that applies a bitwise XOR operation between this expression and a constant. + * + * ```typescript + * // Calculate the bitwise XOR of 'field1' and 0xFF. + * field("field1").bitXor(0xFF); + * ``` + * + * @param otherBits A constant representing bits. + * @return A new {@code Expr} representing the bitwise XOR operation. */ - abstract _toProto(serializer: JsonProtoSerializer): ProtoValue; - + bitXor(otherBits: number | Bytes): FunctionExpr; /** - * @private - * @internal + * @beta + * + * Creates an expression that applies a bitwise XOR operation between two expressions. + * + * ```typescript + * // Calculate the bitwise XOR of 'field1' and 'field2'. + * field("field1").bitXor(field("field2")); + * ``` + * + * @param bitsExpression An expression that returns bits when evaluated. + * @return A new {@code Expr} representing the bitwise XOR operation. */ - abstract _readUserData(dataReader: UserDataReader): void; -} - -/** - * @beta - * - * An interface that represents a selectable expression. - */ -export abstract class Selectable extends Expr { - selectable: true = true; -} - -/** - * @beta - * - * An interface that represents a filter condition. - */ -export abstract class FilterCondition extends Expr { - filterable: true = true; -} - -/** - * @beta - * - * An interface that represents an accumulator. - */ -export abstract class Accumulator extends Expr { - accumulator: true = true; + bitXor(bitsExpression: Expr): FunctionExpr; + bitXor(bitsOrExpression: number | Expr | Bytes): FunctionExpr { + return new FunctionExpr('bit_xor', [ + this, + valueToDefaultExpr(bitsOrExpression) + ]); + } /** - * @private - * @internal + * @beta + * + * Creates an expression that applies a bitwise NOT operation to this expression. + * + * ```typescript + * // Calculate the bitwise NOT of 'field1'. + * field("field1").bitNot(); + * ``` + * + * @return A new {@code Expr} representing the bitwise NOT operation. */ - abstract _toProto(serializer: JsonProtoSerializer): ProtoValue; -} + bitNot(): FunctionExpr { + return new FunctionExpr('bit_not', [this]); + } -/** + /** + * @beta + * + * Creates an expression that applies a bitwise left shift operation to this expression. + * + * ```typescript + * // Calculate the bitwise left shift of 'field1' by 2 bits. + * field("field1").bitLeftShift(2); + * ``` + * + * @param y The operand constant representing the number of bits to shift. + * @return A new {@code Expr} representing the bitwise left shift operation. + */ + bitLeftShift(y: number): FunctionExpr; + /** + * @beta + * + * Creates an expression that applies a bitwise left shift operation to this expression. + * + * ```typescript + * // Calculate the bitwise left shift of 'field1' by 'field2' bits. + * field("field1").bitLeftShift(field("field2")); + * ``` + * + * @param numberExpr The operand expression representing the number of bits to shift. + * @return A new {@code Expr} representing the bitwise left shift operation. + */ + bitLeftShift(numberExpr: Expr): FunctionExpr; + bitLeftShift(numberExpr: number | Expr): FunctionExpr { + return new FunctionExpr('bit_left_shift', [ + this, + valueToDefaultExpr(numberExpr) + ]); + } + + /** + * @beta + * + * Creates an expression that applies a bitwise right shift operation to this expression. + * + * ```typescript + * // Calculate the bitwise right shift of 'field1' by 2 bits. + * field("field1").bitRightShift(2); + * ``` + * + * @param right The operand constant representing the number of bits to shift. + * @return A new {@code Expr} representing the bitwise right shift operation. + */ + bitRightShift(y: number): FunctionExpr; + /** + * @beta + * + * Creates an expression that applies a bitwise right shift operation to this expression. + * + * ```typescript + * // Calculate the bitwise right shift of 'field1' by 'field2' bits. + * field("field1").bitRightShift(field("field2")); + * ``` + * + * @param numberExpr The operand expression representing the number of bits to shift. + * @return A new {@code Expr} representing the bitwise right shift operation. + */ + bitRightShift(numberExpr: Expr): FunctionExpr; + bitRightShift(numberExpr: number | Expr): FunctionExpr { + return new FunctionExpr('bit_right_shift', [ + this, + valueToDefaultExpr(numberExpr) + ]); + } + + /** + * @beta + * + * Creates an expression that returns the document ID from a path. + * + * ```typescript + * // Get the document ID from a path. + * field("__path__").documentId(); + * ``` + * + * @return A new {@code Expr} representing the documentId operation. + */ + documentId(): FunctionExpr { + return new FunctionExpr('document_id', [this]); + } + + /** + * @beta + * + * Creates an expression that returns a substring of the results of this expression. + * + * @param position Index of the first character of the substring. + * @param length Length of the substring. If not provided, the substring will + * end at the end of the input. + */ + substr(position: number, length?: number): FunctionExpr; + + /** + * @beta + * + * Creates an expression that returns a substring of the results of this expression. + * + * @param position An expression returning the index of the first character of the substring. + * @param length An expression returning the length of the substring. If not provided the + * substring will end at the end of the input. + */ + substr(position: Expr, length?: Expr): FunctionExpr; + substr(position: Expr | number, length?: Expr | number): FunctionExpr { + const positionExpr = valueToDefaultExpr(position); + if (length === undefined) { + return new FunctionExpr('substr', [this, positionExpr]); + } else { + return new FunctionExpr('substr', [ + this, + positionExpr, + valueToDefaultExpr(length) + ]); + } + } + + /** + * @beta + * Creates an expression that indexes into an array from the beginning or end + * and returns the element. If the offset exceeds the array length, an error is + * returned. A negative offset, starts from the end. + * + * ```typescript + * // Return the value in the 'tags' field array at index `1`. + * field('tags').arrayOffset(1); + * ``` + * + * @param offset The index of the element to return. + * @return A new Expr representing the 'arrayOffset' operation. + */ + arrayOffset(offset: number): FunctionExpr; + + /** + * @beta + * Creates an expression that indexes into an array from the beginning or end + * and returns the element. If the offset exceeds the array length, an error is + * returned. A negative offset, starts from the end. + * + * ```typescript + * // Return the value in the tags field array at index specified by field + * // 'favoriteTag'. + * field('tags').arrayOffset(field('favoriteTag')); + * ``` + * + * @param offsetExpr An Expr evaluating to the index of the element to return. + * @return A new Expr representing the 'arrayOffset' operation. + */ + arrayOffset(offsetExpr: Expr): FunctionExpr; + arrayOffset(offset: Expr | number): FunctionExpr { + return new FunctionExpr('array_offset', [this, valueToDefaultExpr(offset)]); + } + + /** + * @beta + * + * Creates an expression that checks if a given expression produces an error. + * + * ```typescript + * // Check if the result of a calculation is an error + * field("title").arrayContains(1).isError(); + * ``` + * + * @return A new {@code BooleanExpr} representing the 'isError' check. + */ + isError(): BooleanExpr { + return new BooleanExpr('is_error', [this]); + } + + /** + * @beta + * + * Creates an expression that returns the result of the `catchExpr` argument + * if there is an error, else return the result of this expression. + * + * ```typescript + * // Returns the first item in the title field arrays, or returns + * // the entire title field if the array is empty or the field is another type. + * field("title").arrayOffset(0).ifError(field("title")); + * ``` + * + * @param catchExpr The catch expression that will be evaluated and + * returned if this expression produces an error. + * @return A new {@code Expr} representing the 'ifError' operation. + */ + ifError(catchExpr: Expr): FunctionExpr; + + /** + * @beta + * + * Creates an expression that returns the `catch` argument if there is an + * error, else return the result of this expression. + * + * ```typescript + * // Returns the first item in the title field arrays, or returns + * // "Default Title" + * field("title").arrayOffset(0).ifError("Default Title"); + * ``` + * + * @param catchValue The value that will be returned if this expression + * produces an error. + * @return A new {@code Expr} representing the 'ifError' operation. + */ + ifError(catchValue: unknown): FunctionExpr; + ifError(catchValue: unknown): FunctionExpr { + return new FunctionExpr('if_error', [this, valueToDefaultExpr(catchValue)]); + } + + /** + * @beta + * + * Creates an expression that returns `true` if the result of this expression + * is absent. Otherwise, returns `false` even if the value is `null`. + * + * ```typescript + * // Check if the field `value` is absent. + * field("value").isAbsent(); + * ``` + * + * @return A new {@code BooleanExpr} representing the 'isAbsent' check. + */ + isAbsent(): BooleanExpr { + return new BooleanExpr('is_absent', [this]); + } + + /** + * @beta + * + * Creates an expression that checks if tbe result of an expression is not null. + * + * ```typescript + * // Check if the value of the 'name' field is not null + * field("name").isNotNull(); + * ``` + * + * @return A new {@code BooleanExpr} representing the 'isNotNull' check. + */ + isNotNull(): BooleanExpr { + return new BooleanExpr('is_not_null', [this]); + } + + /** + * @beta + * + * Creates an expression that checks if the results of this expression is NOT 'NaN' (Not a Number). + * + * ```typescript + * // Check if the result of a calculation is NOT NaN + * field("value").divide(0).isNotNan(); + * ``` + * + * @return A new {@code Expr} representing the 'isNaN' check. + */ + isNotNan(): BooleanExpr { + return new BooleanExpr('is_not_nan', [this]); + } + + /** + * @beta + * + * Creates an expression that removes a key from the map produced by evaluating this expression. + * + * ``` + * // Removes the key 'baz' from the input map. + * map({foo: 'bar', baz: true}).mapRemove('baz'); + * ``` + * + * @param key The name of the key to remove from the input map. + * @returns A new {@code FirestoreFunction} representing the 'mapRemove' operation. + */ + mapRemove(key: string): FunctionExpr; + /** + * @beta + * + * Creates an expression that removes a key from the map produced by evaluating this expression. + * + * ``` + * // Removes the key 'baz' from the input map. + * map({foo: 'bar', baz: true}).mapRemove(constant('baz')); + * ``` + * + * @param keyExpr An expression that produces the name of the key to remove from the input map. + * @returns A new {@code FirestoreFunction} representing the 'mapRemove' operation. + */ + mapRemove(keyExpr: Expr): FunctionExpr; + mapRemove(stringExpr: Expr | string): FunctionExpr { + return new FunctionExpr('map_remove', [ + this, + valueToDefaultExpr(stringExpr) + ]); + } + + /** + * @beta + * + * Creates an expression that merges multiple map values. + * + * ``` + * // Merges the map in the settings field with, a map literal, and a map in + * // that is conditionally returned by another expression + * field('settings').mapMerge({ enabled: true }, cond(field('isAdmin'), { admin: true}, {}) + * ``` + * + * @param secondMap A required second map to merge. Represented as a literal or + * an expression that returns a map. + * @param otherMaps Optional additional maps to merge. Each map is represented + * as a literal or an expression that returns a map. + * + * @returns A new {@code FirestoreFunction} representing the 'mapMerge' operation. + */ + mapMerge( + secondMap: Record | Expr, + ...otherMaps: Array | Expr> + ): FunctionExpr { + const secondMapExpr = valueToDefaultExpr(secondMap); + const otherMapExprs = otherMaps.map(valueToDefaultExpr); + return new FunctionExpr('map_merge', [ + this, + secondMapExpr, + ...otherMapExprs + ]); + } + + /** + * Creates an {@link Ordering} that sorts documents in ascending order based on this expression. + * + * ```typescript + * // Sort documents by the 'name' field in ascending order + * pipeline().collection("users") + * .sort(field("name").ascending()); + * ``` + * + * @return A new `Ordering` for ascending sorting. + */ + ascending(): Ordering { + return ascending(this); + } + + /** + * Creates an {@link Ordering} that sorts documents in descending order based on this expression. + * + * ```typescript + * // Sort documents by the 'createdAt' field in descending order + * firestore.pipeline().collection("users") + * .sort(field("createdAt").descending()); + * ``` + * + * @return A new `Ordering` for descending sorting. + */ + descending(): Ordering { + return descending(this); + } + + /** + * Assigns an alias to this expression. + * + * Aliases are useful for renaming fields in the output of a stage or for giving meaningful + * names to calculated values. + * + * ```typescript + * // Calculate the total price and assign it the alias "totalPrice" and add it to the output. + * firestore.pipeline().collection("items") + * .addFields(field("price").multiply(field("quantity")).as("totalPrice")); + * ``` + * + * @param name The alias to assign to this expression. + * @return A new {@link ExprWithAlias} that wraps this + * expression and associates it with the provided alias. + */ + as(name: string): ExprWithAlias { + return new ExprWithAlias(this, name); + } +} + +/** * @beta * - * An accumulator target, which is an expression with an alias that also implements the Accumulator interface. + * An interface that represents a selectable expression. */ -export type AccumulatorTarget = ExprWithAlias; +export interface Selectable { + selectable: true; + readonly alias: string; + readonly expr: Expr; +} /** * @beta + * + * A class that represents an aggregate function. */ -export class ExprWithAlias extends Selectable { - exprType: ExprType = 'ExprWithAlias'; - selectable = true as const; +export class AggregateFunction implements ProtoValueSerializable, UserData { + exprType: ExprType = 'AggregateFunction'; - constructor(readonly expr: T, readonly alias: string) { - super(); + /** + * @internal + * @private + * Indicates if this expression was created from a literal value passed + * by the caller. + */ + _createdFromLiteral: boolean = false; + + constructor(private name: string, private params: Expr[]) {} + + /** + * Assigns an alias to this AggregateFunction. The alias specifies the name that + * the aggregated value will have in the output document. + * + * ```typescript + * // Calculate the average price of all items and assign it the alias "averagePrice". + * firestore.pipeline().collection("items") + * .aggregate(field("price").avg().as("averagePrice")); + * ``` + * + * @param name The alias to assign to this AggregateFunction. + * @return A new {@link AggregateWithAlias} that wraps this + * AggregateFunction and associates it with the provided alias. + */ + as(name: string): AggregateWithAlias { + return new AggregateWithAlias(this, name); } /** @@ -1839,15 +2047,87 @@ export class ExprWithAlias extends Selectable { * @internal */ _toProto(serializer: JsonProtoSerializer): ProtoValue { - throw new Error('ExprWithAlias should not be serialized directly.'); + return { + functionValue: { + name: this.name, + args: this.params.map(p => p._toProto(serializer)) + } + }; } + _protoValueType = 'ProtoValue' as const; + /** * @private * @internal */ - _readUserData(dataReader: UserDataReader): void { - this.expr._readUserData(dataReader); + _readUserData(dataReader: UserDataReader, context?: ParseContext): void { + context = + this._createdFromLiteral && context + ? context + : dataReader.createContext(UserDataSource.Argument, this.name); + this.params.forEach(expr => { + return expr._readUserData(dataReader, context); + }); + } +} + +/** + * @beta + * + * An AggregateFunction with alias. + */ +export class AggregateWithAlias implements UserData { + constructor(readonly aggregate: AggregateFunction, readonly alias: string) {} + + /** + * @internal + * @private + * Indicates if this expression was created from a literal value passed + * by the caller. + */ + _createdFromLiteral: boolean = false; + + /** + * @private + * @internal + */ + _readUserData(dataReader: UserDataReader, context?: ParseContext): void { + context = + this._createdFromLiteral && context + ? context + : dataReader.createContext(UserDataSource.Argument, 'as'); + this.aggregate._readUserData(dataReader, context); + } +} + +/** + * @beta + */ +export class ExprWithAlias implements Selectable, UserData { + exprType: ExprType = 'ExprWithAlias'; + selectable = true as const; + + /** + * @internal + * @private + * Indicates if this expression was created from a literal value passed + * by the caller. + */ + _createdFromLiteral: boolean = false; + + constructor(readonly expr: Expr, readonly alias: string) {} + + /** + * @private + * @internal + */ + _readUserData(dataReader: UserDataReader, context?: ParseContext): void { + context = + this._createdFromLiteral && context + ? context + : dataReader.createContext(UserDataSource.Argument, 'as'); + this.expr._readUserData(dataReader, context); } } @@ -1856,6 +2136,7 @@ export class ExprWithAlias extends Selectable { */ class ListOfExprs extends Expr { exprType: ExprType = 'ListOfExprs'; + constructor(private exprs: Expr[]) { super(); } @@ -1893,106 +2174,36 @@ class ListOfExprs extends Expr { * * ```typescript * // Create a Field instance for the 'name' field - * const nameField = Field.of("name"); + * const nameField = field("name"); * * // Create a Field instance for a nested field 'address.city' - * const cityField = Field.of("address.city"); + * const cityField = field("address.city"); * ``` */ -export class Field extends Selectable { - exprType: ExprType = 'Field'; +export class Field extends Expr implements Selectable { + readonly exprType: ExprType = 'Field'; selectable = true as const; - private constructor( - private fieldPath: InternalFieldPath, - private pipeline: Pipeline | null = null - ) { - super(); - } - - /** - * Creates a {@code Field} instance representing the field at the given path. - * - * The path can be a simple field name (e.g., "name") or a dot-separated path to a nested field - * (e.g., "address.city"). - * - * ```typescript - * // Create a Field instance for the 'title' field - * const titleField = Field.of("title"); - * - * // Create a Field instance for a nested field 'author.firstName' - * const authorFirstNameField = Field.of("author.firstName"); - * ``` - * - * @param name The path to the field. - * @return A new {@code Field} instance representing the specified field. - */ - static of(name: string): Field; - static of(path: FieldPath): Field; - static of( - pipelineOrName: Pipeline | string | FieldPath, - name?: string - ): Field { - if (typeof pipelineOrName === 'string') { - if (DOCUMENT_KEY_NAME === pipelineOrName) { - return new Field(documentId()._internalPath); - } - return new Field(fieldPathFromArgument('of', pipelineOrName)); - } else if (pipelineOrName instanceof FieldPath) { - if (documentId().isEqual(pipelineOrName)) { - return new Field(documentId()._internalPath); - } - return new Field(pipelineOrName._internalPath); - } else { - return new Field( - fieldPathFromArgument('of', name!), - pipelineOrName as Pipeline - ); - } - } - - fieldName(): string { - return this.fieldPath.canonicalString(); - } - /** - * @private * @internal - */ - _toProto(serializer: JsonProtoSerializer): ProtoValue { - return { - fieldReferenceValue: this.fieldPath.canonicalString() - }; - } - - /** * @private - * @internal + * @hideconstructor + * @param fieldPath */ - _readUserData(dataReader: UserDataReader): void {} -} - -/** - * @beta - */ -export class Fields extends Selectable { - exprType: ExprType = 'Field'; - selectable = true as const; - - private constructor(private fields: Field[]) { + constructor(private fieldPath: InternalFieldPath) { super(); } - static of(name: string, ...others: string[]): Fields { - return new Fields([Field.of(name), ...others.map(Field.of)]); + fieldName(): string { + return this.fieldPath.canonicalString(); } - static ofAll(): Fields { - return new Fields([]); + get alias(): string { + return this.fieldName(); } - fieldList(): Field[] { - return this.fields.map(f => f); + get expr(): Expr { + return this; } /** @@ -2001,9 +2212,7 @@ export class Fields extends Selectable { */ _toProto(serializer: JsonProtoSerializer): ProtoValue { return { - arrayValue: { - values: this.fields.map(f => f._toProto(serializer)) - } + fieldReferenceValue: this.fieldPath.canonicalString() }; } @@ -2011,8 +2220,36 @@ export class Fields extends Selectable { * @private * @internal */ - _readUserData(dataReader: UserDataReader): void { - this.fields.forEach(expr => expr._readUserData(dataReader)); + _readUserData(dataReader: UserDataReader): void {} +} + +/** + * Creates a {@code Field} instance representing the field at the given path. + * + * The path can be a simple field name (e.g., "name") or a dot-separated path to a nested field + * (e.g., "address.city"). + * + * ```typescript + * // Create a Field instance for the 'title' field + * const titleField = field("title"); + * + * // Create a Field instance for a nested field 'author.firstName' + * const authorFirstNameField = field("author.firstName"); + * ``` + * + * @param name The path to the field. + * @return A new {@code Field} instance representing the specified field. + */ +export function field(name: string): Field; +export function field(path: FieldPath): Field; +export function field(nameOrPath: string | FieldPath): Field { + if (typeof nameOrPath === 'string') { + if (DOCUMENT_KEY_NAME === nameOrPath) { + return new Field(documentIdFieldPath()._internalPath); + } + return new Field(fieldPathFromArgument('of', nameOrPath)); + } else { + return new Field(nameOrPath._internalPath); } } @@ -2025,158 +2262,25 @@ export class Fields extends Selectable { * * ```typescript * // Create a Constant instance for the number 10 - * const ten = Constant.of(10); + * const ten = constant(10); * * // Create a Constant instance for the string "hello" - * const hello = Constant.of("hello"); + * const hello = constant("hello"); * ``` */ export class Constant extends Expr { - exprType: ExprType = 'Constant'; + readonly exprType: ExprType = 'Constant'; private _protoValue?: ProtoValue; - private constructor(private value: any) { - super(); - } - /** - * Creates a `Constant` instance for a number value. - * - * @param value The number value. - * @return A new `Constant` instance. - */ - static of(value: number): Constant; - - /** - * Creates a `Constant` instance for a string value. - * - * @param value The string value. - * @return A new `Constant` instance. - */ - static of(value: string): Constant; - - /** - * Creates a `Constant` instance for a boolean value. - * - * @param value The boolean value. - * @return A new `Constant` instance. - */ - static of(value: boolean): Constant; - - /** - * Creates a `Constant` instance for a null value. - * - * @param value The null value. - * @return A new `Constant` instance. - */ - static of(value: null): Constant; - - /** - * Creates a `Constant` instance for an undefined value. * @private * @internal - * - * @param value The undefined value. - * @return A new `Constant` instance. + * @hideconstructor + * @param value The value of the constant. */ - static of(value: undefined): Constant; - - /** - * Creates a `Constant` instance for a GeoPoint value. - * - * @param value The GeoPoint value. - * @return A new `Constant` instance. - */ - static of(value: GeoPoint): Constant; - - /** - * Creates a `Constant` instance for a Timestamp value. - * - * @param value The Timestamp value. - * @return A new `Constant` instance. - */ - static of(value: Timestamp): Constant; - - /** - * Creates a `Constant` instance for a Date value. - * - * @param value The Date value. - * @return A new `Constant` instance. - */ - static of(value: Date): Constant; - - /** - * Creates a `Constant` instance for a Bytes value. - * - * @param value The Bytes value. - * @return A new `Constant` instance. - */ - static of(value: Bytes): Constant; - - /** - * Creates a `Constant` instance for a DocumentReference value. - * - * @param value The DocumentReference value. - * @return A new `Constant` instance. - */ - static of(value: DocumentReference): Constant; - - /** - * Creates a `Constant` instance for a Firestore proto value. - * For internal use only. - * @private - * @internal - * @param value The Firestore proto value. - * @return A new `Constant` instance. - */ - static of(value: ProtoValue): Constant; - - /** - * Creates a `Constant` instance for an array value. - * - * @param value The array value. - * @return A new `Constant` instance. - */ - static of(value: any[]): Constant; - - /** - * Creates a `Constant` instance for a map value. - * - * @param value The map value. - * @return A new `Constant` instance. - */ - static of(value: Record): Constant; - - /** - * Creates a `Constant` instance for a VectorValue value. - * - * @param value The VectorValue value. - * @return A new `Constant` instance. - */ - static of(value: VectorValue): Constant; - - static of(value: any): Constant { - return new Constant(value); - } - - /** - * Creates a `Constant` instance for a VectorValue value. - * - * ```typescript - * // Create a Constant instance for a vector value - * const vectorConstant = Constant.ofVector([1, 2, 3]); - * ``` - * - * @param value The VectorValue value. - * @return A new `Constant` instance. - */ - static vector(value: number[] | VectorValue): Constant { - if (value instanceof VectorValue) { - return new Constant(value); - } else { - return new Constant(new VectorValue(value as number[])); - } + constructor(private value: unknown) { + super(); } /** @@ -2205,19 +2309,14 @@ export class Constant extends Expr { * @private * @internal */ - _readUserData(dataReader: UserDataReader): void { - const context = dataReader.createContext( - UserDataSource.Argument, - 'Constant.of' - ); - - if (isFirestoreValue(this.value)) { - // Special case where value is a proto value. - // This can occur when converting a Query to Pipeline. - this._protoValue = this.value; - } else if (this.value === undefined) { - // TODO(pipeline) how should we treat the value of `undefined`? - this._protoValue = parseData(null, context)!; + _readUserData(dataReader: UserDataReader, context?: ParseContext): void { + context = + this._createdFromLiteral && context + ? context + : dataReader.createContext(UserDataSource.Argument, 'constant'); + + if (isFirestoreValue(this._protoValue)) { + return; } else { this._protoValue = parseData(this.value, context)!; } @@ -2225,790 +2324,1208 @@ export class Constant extends Expr { } /** - * @beta + * Creates a `Constant` instance for a number value. * - * This class defines the base class for Firestore {@link Pipeline} functions, which can be evaluated within pipeline - * execution. + * @param value The number value. + * @return A new `Constant` instance. + */ +export function constant(value: number): Constant; + +/** + * Creates a `Constant` instance for a string value. * - * Typically, you would not use this class or its children directly. Use either the functions like {@link and}, {@link eq}, - * or the methods on {@link Expr} ({@link Expr#eq}, {@link Expr#lt}, etc) to construct new Function instances. + * @param value The string value. + * @return A new `Constant` instance. */ -export class FirestoreFunction extends Expr { - exprType: ExprType = 'Function'; - constructor(private name: string, private params: Expr[]) { - super(); - } +export function constant(value: string): Constant; - /** - * @private - * @internal - */ - _toProto(serializer: JsonProtoSerializer): ProtoValue { - return { - functionValue: { - name: this.name, - args: this.params.map(p => p._toProto(serializer)) - } - }; - } +/** + * Creates a `Constant` instance for a boolean value. + * + * @param value The boolean value. + * @return A new `Constant` instance. + */ +export function constant(value: boolean): Constant; - /** - * @private - * @internal - */ - _readUserData(dataReader: UserDataReader): void { - this.params.forEach(expr => expr._readUserData(dataReader)); - } -} +/** + * Creates a `Constant` instance for a null value. + * + * @param value The null value. + * @return A new `Constant` instance. + */ +export function constant(value: null): Constant; /** - * @beta + * Creates a `Constant` instance for a GeoPoint value. + * + * @param value The GeoPoint value. + * @return A new `Constant` instance. */ -export class Add extends FirestoreFunction { - constructor(private left: Expr, private right: Expr) { - super('add', [left, right]); - } -} +export function constant(value: GeoPoint): Constant; /** - * @beta + * Creates a `Constant` instance for a Timestamp value. + * + * @param value The Timestamp value. + * @return A new `Constant` instance. */ -export class Subtract extends FirestoreFunction { - constructor(private left: Expr, private right: Expr) { - super('subtract', [left, right]); - } -} +export function constant(value: Timestamp): Constant; /** - * @beta + * Creates a `Constant` instance for a Date value. + * + * @param value The Date value. + * @return A new `Constant` instance. */ -export class Multiply extends FirestoreFunction { - constructor(private left: Expr, private right: Expr) { - super('multiply', [left, right]); - } +export function constant(value: Date): Constant; + +/** + * Creates a `Constant` instance for a Bytes value. + * + * @param value The Bytes value. + * @return A new `Constant` instance. + */ +export function constant(value: Bytes): Constant; + +/** + * Creates a `Constant` instance for a DocumentReference value. + * + * @param value The DocumentReference value. + * @return A new `Constant` instance. + */ +export function constant(value: DocumentReference): Constant; + +/** + * Creates a `Constant` instance for a Firestore proto value. + * For internal use only. + * @private + * @internal + * @param value The Firestore proto value. + * @return A new `Constant` instance. + */ +export function constant(value: ProtoValue): Constant; + +/** + * Creates a `Constant` instance for a VectorValue value. + * + * @param value The VectorValue value. + * @return A new `Constant` instance. + */ +export function constant(value: VectorValue): Constant; + +export function constant(value: unknown): Constant { + return new Constant(value); } /** - * @beta + * Creates a `Constant` instance for a VectorValue value. + * + * ```typescript + * // Create a Constant instance for a vector value + * const vectorConstant = constantVector([1, 2, 3]); + * ``` + * + * @param value The VectorValue value. + * @return A new `Constant` instance. */ -export class Divide extends FirestoreFunction { - constructor(private left: Expr, private right: Expr) { - super('divide', [left, right]); +export function constantVector(value: number[] | VectorValue): Constant { + if (value instanceof VectorValue) { + return new Constant(value); + } else { + return new Constant(new VectorValue(value as number[])); } } /** - * @beta + * Internal only + * @internal + * @private */ -export class Mod extends FirestoreFunction { - constructor(private left: Expr, private right: Expr) { - super('mod', [left, right]); +export class MapValue extends Expr { + constructor(private plainObject: Map) { + super(); } -} -// /** -// * @beta -// */ -// export class BitAnd extends FirestoreFunction { -// constructor( -// private left: Expr, -// private right: Expr -// ) { -// super('bit_and', [left, right]); -// } -// } -// -// /** -// * @beta -// */ -// export class BitOr extends FirestoreFunction { -// constructor( -// private left: Expr, -// private right: Expr -// ) { -// super('bit_or', [left, right]); -// } -// } -// -// /** -// * @beta -// */ -// export class BitXor extends FirestoreFunction { -// constructor( -// private left: Expr, -// private right: Expr -// ) { -// super('bit_xor', [left, right]); -// } -// } -// -// /** -// * @beta -// */ -// export class BitNot extends FirestoreFunction { -// constructor(private operand: Expr) { -// super('bit_not', [operand]); -// } -// } -// -// /** -// * @beta -// */ -// export class BitLeftShift extends FirestoreFunction { -// constructor( -// private left: Expr, -// private right: Expr -// ) { -// super('bit_left_shift', [left, right]); -// } -// } -// -// /** -// * @beta -// */ -// export class BitRightShift extends FirestoreFunction { -// constructor( -// private left: Expr, -// private right: Expr -// ) { -// super('bit_right_shift', [left, right]); -// } -// } - -/** - * @beta - */ -export class Eq extends FirestoreFunction implements FilterCondition { - constructor(private left: Expr, private right: Expr) { - super('eq', [left, right]); + exprType: ExprType = 'Constant'; + + _readUserData(dataReader: UserDataReader, context?: ParseContext): void { + context = + this._createdFromLiteral && context + ? context + : dataReader.createContext(UserDataSource.Argument, '_map'); + + this.plainObject.forEach(expr => { + expr._readUserData(dataReader, context); + }); + } + + _toProto(serializer: JsonProtoSerializer): ProtoValue { + return toMapValue(serializer, this.plainObject); } - filterable = true as const; } /** * @beta + * + * This class defines the base class for Firestore {@link Pipeline} functions, which can be evaluated within pipeline + * execution. + * + * Typically, you would not use this class or its children directly. Use either the functions like {@link and}, {@link eq}, + * or the methods on {@link Expr} ({@link Expr#eq}, {@link Expr#lt}, etc.) to construct new Function instances. */ -export class Neq extends FirestoreFunction implements FilterCondition { - constructor(private left: Expr, private right: Expr) { - super('neq', [left, right]); +export class FunctionExpr extends Expr { + readonly exprType: ExprType = 'Function'; + + constructor(private name: string, private params: Expr[]) { + super(); } - filterable = true as const; -} -/** - * @beta - */ -export class Lt extends FirestoreFunction implements FilterCondition { - constructor(private left: Expr, private right: Expr) { - super('lt', [left, right]); + /** + * @private + * @internal + */ + _toProto(serializer: JsonProtoSerializer): ProtoValue { + return { + functionValue: { + name: this.name, + args: this.params.map(p => p._toProto(serializer)) + } + }; } - filterable = true as const; -} -/** - * @beta - */ -export class Lte extends FirestoreFunction implements FilterCondition { - constructor(private left: Expr, private right: Expr) { - super('lte', [left, right]); + /** + * @private + * @internal + */ + _readUserData(dataReader: UserDataReader, context?: ParseContext): void { + context = + this._createdFromLiteral && context + ? context + : dataReader.createContext(UserDataSource.Argument, this.name); + this.params.forEach(expr => { + return expr._readUserData(dataReader, context); + }); } - filterable = true as const; } /** * @beta + * + * An interface that represents a filter condition. */ -export class Gt extends FirestoreFunction implements FilterCondition { - constructor(private left: Expr, private right: Expr) { - super('gt', [left, right]); +export class BooleanExpr extends FunctionExpr { + filterable: true = true; + + /** + * Creates an aggregation that finds the count of input documents satisfying + * this boolean expression. + * + * ```typescript + * // Find the count of documents with a score greater than 90 + * field("score").gt(90).countIf().as("highestScore"); + * ``` + * + * @return A new `AggregateFunction` representing the 'countIf' aggregation. + */ + countIf(): AggregateFunction { + return new AggregateFunction('count_if', [this]); } - filterable = true as const; -} -/** - * @beta - */ -export class Gte extends FirestoreFunction implements FilterCondition { - constructor(private left: Expr, private right: Expr) { - super('gte', [left, right]); + /** + * Creates an expression that negates this boolean expression. + * + * ```typescript + * // Find documents where the 'tags' field does not contain 'completed' + * field("tags").arrayContains("completed").not(); + * ``` + * + * @return A new {@code Expr} representing the negated filter condition. + */ + not(): BooleanExpr { + return new BooleanExpr('not', [this]); } - filterable = true as const; } /** * @beta + * Creates an aggregation that counts the number of stage inputs where the provided + * boolean expression evaluates to true. + * + * ```typescript + * // Count the number of documents where 'is_active' field equals true + * countIf(field("is_active").eq(true)).as("numActiveDocuments"); + * ``` + * + * @param booleanExpr - The boolean expression to evaluate on each input. + * @returns A new `AggregateFunction` representing the 'countIf' aggregation. */ -export class ArrayConcat extends FirestoreFunction { - constructor(private array: Expr, private elements: Expr[]) { - super('array_concat', [array, ...elements]); - } +export function countIf(booleanExpr: BooleanExpr): AggregateFunction { + return booleanExpr.countIf(); } /** * @beta + * Creates an expression that return a pseudo-random value of type double in the + * range of [0, 1), inclusive of 0 and exclusive of 1. + * + * @returns A new `Expr` representing the 'rand' function. */ -export class ArrayReverse extends FirestoreFunction { - constructor(private array: Expr) { - super('array_reverse', [array]); - } +export function rand(): FunctionExpr { + return new FunctionExpr('rand', []); } /** * @beta + * + * Creates an expression that applies a bitwise AND operation between a field and a constant. + * + * ```typescript + * // Calculate the bitwise AND of 'field1' and 0xFF. + * bitAnd("field1", 0xFF); + * ``` + * + * @param field The left operand field name. + * @param otherBits A constant representing bits. + * @return A new {@code Expr} representing the bitwise AND operation. */ -export class ArrayContains - extends FirestoreFunction - implements FilterCondition -{ - constructor(private array: Expr, private element: Expr) { - super('array_contains', [array, element]); - } - filterable = true as const; -} - +export function bitAnd(field: string, otherBits: number | Bytes): FunctionExpr; /** * @beta + * + * Creates an expression that applies a bitwise AND operation between a field and an expression. + * + * ```typescript + * // Calculate the bitwise AND of 'field1' and 'field2'. + * bitAnd("field1", field("field2")); + * ``` + * + * @param field The left operand field name. + * @param bitsExpression An expression that returns bits when evaluated. + * @return A new {@code Expr} representing the bitwise AND operation. */ -export class ArrayContainsAll - extends FirestoreFunction - implements FilterCondition -{ - constructor(private array: Expr, private values: Expr[]) { - super('array_contains_all', [array, new ListOfExprs(values)]); - } - filterable = true as const; -} - +export function bitAnd(field: string, bitsExpression: Expr): FunctionExpr; /** * @beta + * + * Creates an expression that applies a bitwise AND operation between an expression and a constant. + * + * ```typescript + * // Calculate the bitwise AND of 'field1' and 0xFF. + * bitAnd(field("field1"), 0xFF); + * ``` + * + * @param bitsExpression An expression returning bits. + * @param otherBits A constant representing bits. + * @return A new {@code Expr} representing the bitwise AND operation. */ -export class ArrayContainsAny - extends FirestoreFunction - implements FilterCondition -{ - constructor(private array: Expr, private values: Expr[]) { - super('array_contains_any', [array, new ListOfExprs(values)]); - } - filterable = true as const; -} - +export function bitAnd( + bitsExpression: Expr, + otherBits: number | Bytes +): FunctionExpr; /** * @beta + * + * Creates an expression that applies a bitwise AND operation between two expressions. + * + * ```typescript + * // Calculate the bitwise AND of 'field1' and 'field2'. + * bitAnd(field("field1"), field("field2")); + * ``` + * + * @param bitsExpression An expression that returns bits when evaluated. + * @param otherBitsExpression An expression that returns bits when evaluated. + * @return A new {@code Expr} representing the bitwise AND operation. */ -export class ArrayLength extends FirestoreFunction { - constructor(private array: Expr) { - super('array_length', [array]); - } +export function bitAnd( + bitsExpression: Expr, + otherBitsExpression: Expr +): FunctionExpr; +export function bitAnd( + bits: string | Expr, + bitsOrExpression: number | Expr | Bytes +): FunctionExpr { + return fieldOrExpression(bits).bitAnd(valueToDefaultExpr(bitsOrExpression)); } /** * @beta + * + * Creates an expression that applies a bitwise OR operation between a field and a constant. + * + * ```typescript + * // Calculate the bitwise OR of 'field1' and 0xFF. + * bitOr("field1", 0xFF); + * ``` + * + * @param field The left operand field name. + * @param otherBits A constant representing bits. + * @return A new {@code Expr} representing the bitwise OR operation. */ -export class ArrayElement extends FirestoreFunction { - constructor() { - super('array_element', []); - } -} - +export function bitOr(field: string, otherBits: number | Bytes): FunctionExpr; /** * @beta + * + * Creates an expression that applies a bitwise OR operation between a field and an expression. + * + * ```typescript + * // Calculate the bitwise OR of 'field1' and 'field2'. + * bitOr("field1", field("field2")); + * ``` + * + * @param field The left operand field name. + * @param bitsExpression An expression that returns bits when evaluated. + * @return A new {@code Expr} representing the bitwise OR operation. */ -export class EqAny extends FirestoreFunction implements FilterCondition { - constructor(private left: Expr, private others: Expr[]) { - super('eq_any', [left, new ListOfExprs(others)]); - } - filterable = true as const; -} - +export function bitOr(field: string, bitsExpression: Expr): FunctionExpr; /** * @beta + * + * Creates an expression that applies a bitwise OR operation between an expression and a constant. + * + * ```typescript + * // Calculate the bitwise OR of 'field1' and 0xFF. + * bitOr(field("field1"), 0xFF); + * ``` + * + * @param bitsExpression An expression returning bits. + * @param otherBits A constant representing bits. + * @return A new {@code Expr} representing the bitwise OR operation. */ -export class NotEqAny extends FirestoreFunction implements FilterCondition { - constructor(private left: Expr, private others: Expr[]) { - super('not_eq_any', [left, new ListOfExprs(others)]); - } - filterable = true as const; -} - +export function bitOr( + bitsExpression: Expr, + otherBits: number | Bytes +): FunctionExpr; /** * @beta + * + * Creates an expression that applies a bitwise OR operation between two expressions. + * + * ```typescript + * // Calculate the bitwise OR of 'field1' and 'field2'. + * bitOr(field("field1"), field("field2")); + * ``` + * + * @param bitsExpression An expression that returns bits when evaluated. + * @param otherBitsExpression An expression that returns bits when evaluated. + * @return A new {@code Expr} representing the bitwise OR operation. */ -export class IsNan extends FirestoreFunction implements FilterCondition { - constructor(private expr: Expr) { - super('is_nan', [expr]); - } - filterable = true as const; +export function bitOr( + bitsExpression: Expr, + otherBitsExpression: Expr +): FunctionExpr; +export function bitOr( + bits: string | Expr, + bitsOrExpression: number | Expr | Bytes +): FunctionExpr { + return fieldOrExpression(bits).bitOr(valueToDefaultExpr(bitsOrExpression)); } /** * @beta + * + * Creates an expression that applies a bitwise XOR operation between a field and a constant. + * + * ```typescript + * // Calculate the bitwise XOR of 'field1' and 0xFF. + * bitXor("field1", 0xFF); + * ``` + * + * @param field The left operand field name. + * @param otherBits A constant representing bits. + * @return A new {@code Expr} representing the bitwise XOR operation. */ -export class Exists extends FirestoreFunction implements FilterCondition { - constructor(private expr: Expr) { - super('exists', [expr]); - } - filterable = true as const; -} - +export function bitXor(field: string, otherBits: number | Bytes): FunctionExpr; /** * @beta + * + * Creates an expression that applies a bitwise XOR operation between a field and an expression. + * + * ```typescript + * // Calculate the bitwise XOR of 'field1' and 'field2'. + * bitXor("field1", field("field2")); + * ``` + * + * @param field The left operand field name. + * @param bitsExpression An expression that returns bits when evaluated. + * @return A new {@code Expr} representing the bitwise XOR operation. */ -export class Not extends FirestoreFunction implements FilterCondition { - constructor(private expr: Expr) { - super('not', [expr]); - } - filterable = true as const; -} - +export function bitXor(field: string, bitsExpression: Expr): FunctionExpr; /** * @beta + * + * Creates an expression that applies a bitwise XOR operation between an expression and a constant. + * + * ```typescript + * // Calculate the bitwise XOR of 'field1' and 0xFF. + * bitXor(field("field1"), 0xFF); + * ``` + * + * @param bitsExpression An expression returning bits. + * @param otherBits A constant representing bits. + * @return A new {@code Expr} representing the bitwise XOR operation. */ -export class And extends FirestoreFunction implements FilterCondition { - constructor(private conditions: FilterCondition[]) { - super('and', conditions); - } - - filterable = true as const; -} - +export function bitXor( + bitsExpression: Expr, + otherBits: number | Bytes +): FunctionExpr; /** * @beta + * + * Creates an expression that applies a bitwise XOR operation between two expressions. + * + * ```typescript + * // Calculate the bitwise XOR of 'field1' and 'field2'. + * bitXor(field("field1"), field("field2")); + * ``` + * + * @param bitsExpression An expression that returns bits when evaluated. + * @param otherBitsExpression An expression that returns bits when evaluated. + * @return A new {@code Expr} representing the bitwise XOR operation. */ -export class Or extends FirestoreFunction implements FilterCondition { - constructor(private conditions: FilterCondition[]) { - super('or', conditions); - } - filterable = true as const; +export function bitXor( + bitsExpression: Expr, + otherBitsExpression: Expr +): FunctionExpr; +export function bitXor( + bits: string | Expr, + bitsOrExpression: number | Expr | Bytes +): FunctionExpr { + return fieldOrExpression(bits).bitXor(valueToDefaultExpr(bitsOrExpression)); } /** * @beta + * + * Creates an expression that applies a bitwise NOT operation to a field. + * + * ```typescript + * // Calculate the bitwise NOT of 'field1'. + * bitNot("field1"); + * ``` + * + * @param field The operand field name. + * @return A new {@code Expr} representing the bitwise NOT operation. */ -export class Xor extends FirestoreFunction implements FilterCondition { - constructor(private conditions: FilterCondition[]) { - super('xor', conditions); - } - filterable = true as const; -} - +export function bitNot(field: string): FunctionExpr; /** * @beta + * + * Creates an expression that applies a bitwise NOT operation to an expression. + * + * ```typescript + * // Calculate the bitwise NOT of 'field1'. + * bitNot(field("field1")); + * ``` + * + * @param bitsValueExpression An expression that returns bits when evaluated. + * @return A new {@code Expr} representing the bitwise NOT operation. */ -export class Cond extends FirestoreFunction { - constructor( - private condition: FilterCondition, - private thenExpr: Expr, - private elseExpr: Expr - ) { - super('cond', [condition, thenExpr, elseExpr]); - } - filterable = true as const; +export function bitNot(bitsValueExpression: Expr): FunctionExpr; +export function bitNot(bits: string | Expr): FunctionExpr { + return fieldOrExpression(bits).bitNot(); } /** * @beta + * + * Creates an expression that applies a bitwise left shift operation between a field and a constant. + * + * ```typescript + * // Calculate the bitwise left shift of 'field1' by 2 bits. + * bitLeftShift("field1", 2); + * ``` + * + * @param field The left operand field name. + * @param y The right operand constant representing the number of bits to shift. + * @return A new {@code Expr} representing the bitwise left shift operation. */ -export class LogicalMaximum extends FirestoreFunction { - constructor(private left: Expr, private right: Expr) { - super('logical_maximum', [left, right]); - } -} - +export function bitLeftShift(field: string, y: number): FunctionExpr; /** * @beta + * + * Creates an expression that applies a bitwise left shift operation between a field and an expression. + * + * ```typescript + * // Calculate the bitwise left shift of 'field1' by 'field2' bits. + * bitLeftShift("field1", field("field2")); + * ``` + * + * @param field The left operand field name. + * @param numberExpr The right operand expression representing the number of bits to shift. + * @return A new {@code Expr} representing the bitwise left shift operation. */ -export class LogicalMinimum extends FirestoreFunction { - constructor(private left: Expr, private right: Expr) { - super('logical_minimum', [left, right]); - } -} - +export function bitLeftShift(field: string, numberExpr: Expr): FunctionExpr; /** * @beta + * + * Creates an expression that applies a bitwise left shift operation between an expression and a constant. + * + * ```typescript + * // Calculate the bitwise left shift of 'field1' by 2 bits. + * bitLeftShift(field("field1"), 2); + * ``` + * + * @param xValue An expression returning bits. + * @param y The right operand constant representing the number of bits to shift. + * @return A new {@code Expr} representing the bitwise left shift operation. */ -export class Reverse extends FirestoreFunction { - constructor(private value: Expr) { - super('reverse', [value]); - } -} - +export function bitLeftShift(xValue: Expr, y: number): FunctionExpr; /** * @beta + * + * Creates an expression that applies a bitwise left shift operation between two expressions. + * + * ```typescript + * // Calculate the bitwise left shift of 'field1' by 'field2' bits. + * bitLeftShift(field("field1"), field("field2")); + * ``` + * + * @param xValue An expression returning bits. + * @param numberExpr The right operand expression representing the number of bits to shift. + * @return A new {@code Expr} representing the bitwise left shift operation. */ -export class ReplaceFirst extends FirestoreFunction { - constructor(private value: Expr, private find: Expr, private replace: Expr) { - super('replace_first', [value, find, replace]); - } +export function bitLeftShift(xValue: Expr, numberExpr: Expr): FunctionExpr; +export function bitLeftShift( + xValue: string | Expr, + numberExpr: number | Expr +): FunctionExpr { + return fieldOrExpression(xValue).bitLeftShift(valueToDefaultExpr(numberExpr)); } /** * @beta + * + * Creates an expression that applies a bitwise right shift operation between a field and a constant. + * + * ```typescript + * // Calculate the bitwise right shift of 'field1' by 2 bits. + * bitRightShift("field1", 2); + * ``` + * + * @param field The left operand field name. + * @param y The right operand constant representing the number of bits to shift. + * @return A new {@code Expr} representing the bitwise right shift operation. */ -export class ReplaceAll extends FirestoreFunction { - constructor(private value: Expr, private find: Expr, private replace: Expr) { - super('replace_all', [value, find, replace]); - } -} - +export function bitRightShift(field: string, y: number): FunctionExpr; /** * @beta + * + * Creates an expression that applies a bitwise right shift operation between a field and an expression. + * + * ```typescript + * // Calculate the bitwise right shift of 'field1' by 'field2' bits. + * bitRightShift("field1", field("field2")); + * ``` + * + * @param field The left operand field name. + * @param numberExpr The right operand expression representing the number of bits to shift. + * @return A new {@code Expr} representing the bitwise right shift operation. */ -export class CharLength extends FirestoreFunction { - constructor(private value: Expr) { - super('char_length', [value]); - } -} - +export function bitRightShift(field: string, numberExpr: Expr): FunctionExpr; /** * @beta + * + * Creates an expression that applies a bitwise right shift operation between an expression and a constant. + * + * ```typescript + * // Calculate the bitwise right shift of 'field1' by 2 bits. + * bitRightShift(field("field1"), 2); + * ``` + * + * @param xValue An expression returning bits. + * @param y The right operand constant representing the number of bits to shift. + * @return A new {@code Expr} representing the bitwise right shift operation. */ -export class ByteLength extends FirestoreFunction { - constructor(private value: Expr) { - super('byte_length', [value]); - } -} - +export function bitRightShift(xValue: Expr, y: number): FunctionExpr; /** * @beta + * + * Creates an expression that applies a bitwise right shift operation between two expressions. + * + * ```typescript + * // Calculate the bitwise right shift of 'field1' by 'field2' bits. + * bitRightShift(field("field1"), field("field2")); + * ``` + * + * @param xValue An expression returning bits. + * @param right The right operand expression representing the number of bits to shift. + * @return A new {@code Expr} representing the bitwise right shift operation. */ -export class Like extends FirestoreFunction implements FilterCondition { - constructor(private expr: Expr, private pattern: Expr) { - super('like', [expr, pattern]); - } - filterable = true as const; +export function bitRightShift(xValue: Expr, numberExpr: Expr): FunctionExpr; +export function bitRightShift( + xValue: string | Expr, + numberExpr: number | Expr +): FunctionExpr { + return fieldOrExpression(xValue).bitRightShift( + valueToDefaultExpr(numberExpr) + ); } /** * @beta + * Creates an expression that indexes into an array from the beginning or end + * and return the element. If the offset exceeds the array length, an error is + * returned. A negative offset, starts from the end. + * + * ```typescript + * // Return the value in the tags field array at index 1. + * arrayOffset('tags', 1); + * ``` + * + * @param arrayField The name of the array field. + * @param offset The index of the element to return. + * @return A new Expr representing the 'arrayOffset' operation. */ -export class RegexContains - extends FirestoreFunction - implements FilterCondition -{ - constructor(private expr: Expr, private pattern: Expr) { - super('regex_contains', [expr, pattern]); - } - filterable = true as const; -} +export function arrayOffset(arrayField: string, offset: number): FunctionExpr; /** * @beta + * Creates an expression that indexes into an array from the beginning or end + * and return the element. If the offset exceeds the array length, an error is + * returned. A negative offset, starts from the end. + * + * ```typescript + * // Return the value in the tags field array at index specified by field + * // 'favoriteTag'. + * arrayOffset('tags', field('favoriteTag')); + * ``` + * + * @param arrayField The name of the array field. + * @param offsetExpr An Expr evaluating to the index of the element to return. + * @return A new Expr representing the 'arrayOffset' operation. */ -export class RegexMatch extends FirestoreFunction implements FilterCondition { - constructor(private expr: Expr, private pattern: Expr) { - super('regex_match', [expr, pattern]); - } - filterable = true as const; -} +export function arrayOffset(arrayField: string, offsetExpr: Expr): FunctionExpr; /** * @beta + * Creates an expression that indexes into an array from the beginning or end + * and return the element. If the offset exceeds the array length, an error is + * returned. A negative offset, starts from the end. + * + * ```typescript + * // Return the value in the tags field array at index 1. + * arrayOffset(field('tags'), 1); + * ``` + * + * @param arrayExpression An Expr evaluating to an array. + * @param offset The index of the element to return. + * @return A new Expr representing the 'arrayOffset' operation. */ -export class StrContains extends FirestoreFunction implements FilterCondition { - constructor(private expr: Expr, private substring: Expr) { - super('str_contains', [expr, substring]); - } - filterable = true as const; -} +export function arrayOffset( + arrayExpression: Expr, + offset: number +): FunctionExpr; /** * @beta + * Creates an expression that indexes into an array from the beginning or end + * and return the element. If the offset exceeds the array length, an error is + * returned. A negative offset, starts from the end. + * + * ```typescript + * // Return the value in the tags field array at index specified by field + * // 'favoriteTag'. + * arrayOffset(field('tags'), field('favoriteTag')); + * ``` + * + * @param arrayExpression An Expr evaluating to an array. + * @param offsetExpr An Expr evaluating to the index of the element to return. + * @return A new Expr representing the 'arrayOffset' operation. */ -export class StartsWith extends FirestoreFunction implements FilterCondition { - constructor(private expr: Expr, private prefix: Expr) { - super('starts_with', [expr, prefix]); - } - filterable = true as const; +export function arrayOffset( + arrayExpression: Expr, + offsetExpr: Expr +): FunctionExpr; +export function arrayOffset( + array: Expr | string, + offset: Expr | number +): FunctionExpr { + return fieldOrExpression(array).arrayOffset(valueToDefaultExpr(offset)); } /** * @beta + * Creates an Expr that returns a map of all values in the current expression context. + * + * @return A new {@code Expr} representing the 'current_context' function. */ -export class EndsWith extends FirestoreFunction implements FilterCondition { - constructor(private expr: Expr, private suffix: Expr) { - super('ends_with', [expr, suffix]); - } - filterable = true as const; +export function currentContext(): FunctionExpr { + return new FunctionExpr('current_context', []); } /** * @beta + * + * Creates an expression that checks if a given expression produces an error. + * + * ```typescript + * // Check if the result of a calculation is an error + * isError(field("title").arrayContains(1)); + * ``` + * + * @param value The expression to check. + * @return A new {@code Expr} representing the 'isError' check. */ -export class ToLower extends FirestoreFunction { - constructor(private expr: Expr) { - super('to_lower', [expr]); - } +export function isError(value: Expr): BooleanExpr { + return value.isError(); } /** * @beta + * + * Creates an expression that returns the `catch` argument if there is an + * error, else return the result of the `try` argument evaluation. + * + * ```typescript + * // Returns the first item in the title field arrays, or returns + * // the entire title field if the array is empty or the field is another type. + * ifError(field("title").arrayOffset(0), field("title")); + * ``` + * + * @param tryExpr The try expression. + * @param catchExpr The catch expression that will be evaluated and + * returned if the tryExpr produces an error. + * @return A new {@code Expr} representing the 'ifError' operation. */ -export class ToUpper extends FirestoreFunction { - constructor(private expr: Expr) { - super('to_upper', [expr]); - } -} +export function ifError(tryExpr: Expr, catchExpr: Expr): FunctionExpr; /** * @beta + * + * Creates an expression that returns the `catch` argument if there is an + * error, else return the result of the `try` argument evaluation. + * + * ```typescript + * // Returns the first item in the title field arrays, or returns + * // "Default Title" + * ifError(field("title").arrayOffset(0), "Default Title"); + * ``` + * + * @param tryExpr The try expression. + * @param catchValue The value that will be returned if the tryExpr produces an + * error. + * @return A new {@code Expr} representing the 'ifError' operation. */ -export class Trim extends FirestoreFunction { - constructor(private expr: Expr) { - super('trim', [expr]); - } +export function ifError(tryExpr: Expr, catchValue: unknown): FunctionExpr; +export function ifError(tryExpr: Expr, catchValue: unknown): FunctionExpr { + return tryExpr.ifError(valueToDefaultExpr(catchValue)); } /** * @beta + * + * Creates an expression that returns `true` if a value is absent. Otherwise, + * returns `false` even if the value is `null`. + * + * ```typescript + * // Check if the field `value` is absent. + * isAbsent(field("value")); + * ``` + * + * @param value The expression to check. + * @return A new {@code Expr} representing the 'isAbsent' check. */ -export class StrConcat extends FirestoreFunction { - constructor(private first: Expr, private rest: Expr[]) { - super('str_concat', [first, ...rest]); - } -} +export function isAbsent(value: Expr): BooleanExpr; /** * @beta + * + * Creates an expression that returns `true` if a field is absent. Otherwise, + * returns `false` even if the field value is `null`. + * + * ```typescript + * // Check if the field `value` is absent. + * isAbsent("value"); + * ``` + * + * @param field The field to check. + * @return A new {@code Expr} representing the 'isAbsent' check. */ -export class MapGet extends FirestoreFunction { - constructor(map: Expr, name: string) { - super('map_get', [map, Constant.of(name)]); - } +export function isAbsent(field: string): BooleanExpr; +export function isAbsent(value: Expr | string): BooleanExpr { + return fieldOrExpression(value).isAbsent(); } /** * @beta + * + * Creates an expression that checks if an expression evaluates to 'NaN' (Not a Number). + * + * ```typescript + * // Check if the result of a calculation is NaN + * isNaN(field("value").divide(0)); + * ``` + * + * @param value The expression to check. + * @return A new {@code Expr} representing the 'isNaN' check. */ -export class Count extends FirestoreFunction implements Accumulator { - accumulator = true as const; - constructor(private value: Expr | undefined, private distinct: boolean) { - super('count', value === undefined ? [] : [value]); - } -} +export function isNull(value: Expr): BooleanExpr; /** * @beta + * + * Creates an expression that checks if a field's value evaluates to 'NaN' (Not a Number). + * + * ```typescript + * // Check if the result of a calculation is NaN + * isNaN("value"); + * ``` + * + * @param value The name of the field to check. + * @return A new {@code Expr} representing the 'isNaN' check. */ -export class Sum extends FirestoreFunction implements Accumulator { - accumulator = true as const; - constructor(private value: Expr, private distinct: boolean) { - super('sum', [value]); - } +export function isNull(value: string): BooleanExpr; +export function isNull(value: Expr | string): BooleanExpr { + return fieldOrExpression(value).isNull(); } /** * @beta + * + * Creates an expression that checks if tbe result of an expression is not null. + * + * ```typescript + * // Check if the value of the 'name' field is not null + * isNotNull(field("name")); + * ``` + * + * @param value The expression to check. + * @return A new {@code Expr} representing the 'isNaN' check. */ -export class Avg extends FirestoreFunction implements Accumulator { - accumulator = true as const; - constructor(private value: Expr, private distinct: boolean) { - super('avg', [value]); - } -} +export function isNotNull(value: Expr): BooleanExpr; /** * @beta + * + * Creates an expression that checks if tbe value of a field is not null. + * + * ```typescript + * // Check if the value of the 'name' field is not null + * isNotNull("name"); + * ``` + * + * @param value The name of the field to check. + * @return A new {@code Expr} representing the 'isNaN' check. */ -export class Minimum extends FirestoreFunction implements Accumulator { - accumulator = true as const; - constructor(private value: Expr, private distinct: boolean) { - super('minimum', [value]); - } +export function isNotNull(value: string): BooleanExpr; +export function isNotNull(value: Expr | string): BooleanExpr { + return fieldOrExpression(value).isNotNull(); } /** * @beta + * + * Creates an expression that checks if the results of this expression is NOT 'NaN' (Not a Number). + * + * ```typescript + * // Check if the result of a calculation is NOT NaN + * isNotNaN(field("value").divide(0)); + * ``` + * + * @param value The expression to check. + * @return A new {@code Expr} representing the 'isNotNaN' check. */ -export class Maximum extends FirestoreFunction implements Accumulator { - accumulator = true as const; - constructor(private value: Expr, private distinct: boolean) { - super('maximum', [value]); - } -} +export function isNotNan(value: Expr): BooleanExpr; /** * @beta + * + * Creates an expression that checks if the results of this expression is NOT 'NaN' (Not a Number). + * + * ```typescript + * // Check if the value of a field is NOT NaN + * isNotNaN("value"); + * ``` + * + * @param value The name of the field to check. + * @return A new {@code Expr} representing the 'isNotNaN' check. */ -export class CosineDistance extends FirestoreFunction { - constructor(private vector1: Expr, private vector2: Expr) { - super('cosine_distance', [vector1, vector2]); - } +export function isNotNan(value: string): BooleanExpr; +export function isNotNan(value: Expr | string): BooleanExpr { + return fieldOrExpression(value).isNotNan(); } /** * @beta + * + * Creates an expression that removes a key from the map at the specified field name. + * + * ``` + * // Removes the key 'city' field from the map in the address field of the input document. + * mapRemove('address', 'city'); + * ``` + * + * @param mapField The name of a field containing a map value. + * @param key The name of the key to remove from the input map. */ -export class DotProduct extends FirestoreFunction { - constructor(private vector1: Expr, private vector2: Expr) { - super('dot_product', [vector1, vector2]); - } -} - +export function mapRemove(mapField: string, key: string): FunctionExpr; /** * @beta + * + * Creates an expression that removes a key from the map produced by evaluating an expression. + * + * ``` + * // Removes the key 'baz' from the input map. + * mapRemove(map({foo: 'bar', baz: true}), 'baz'); + * ``` + * + * @param mapExpr An expression return a map value. + * @param key The name of the key to remove from the input map. */ -export class EuclideanDistance extends FirestoreFunction { - constructor(private vector1: Expr, private vector2: Expr) { - super('euclidean_distance', [vector1, vector2]); - } -} - +export function mapRemove(mapExpr: Expr, key: string): FunctionExpr; /** * @beta + * + * Creates an expression that removes a key from the map at the specified field name. + * + * ``` + * // Removes the key 'city' field from the map in the address field of the input document. + * mapRemove('address', constant('city')); + * ``` + * + * @param mapField The name of a field containing a map value. + * @param keyExpr An expression that produces the name of the key to remove from the input map. */ -export class VectorLength extends FirestoreFunction { - constructor(private value: Expr) { - super('vector_length', [value]); - } -} - +export function mapRemove(mapField: string, keyExpr: Expr): FunctionExpr; /** * @beta + * + * Creates an expression that removes a key from the map produced by evaluating an expression. + * + * ``` + * // Removes the key 'baz' from the input map. + * mapRemove(map({foo: 'bar', baz: true}), constant('baz')); + * ``` + * + * @param mapExpr An expression return a map value. + * @param keyExpr An expression that produces the name of the key to remove from the input map. */ -export class UnixMicrosToTimestamp extends FirestoreFunction { - constructor(private input: Expr) { - super('unix_micros_to_timestamp', [input]); - } -} +export function mapRemove(mapExpr: Expr, keyExpr: Expr): FunctionExpr; -/** - * @beta - */ -export class TimestampToUnixMicros extends FirestoreFunction { - constructor(private input: Expr) { - super('timestamp_to_unix_micros', [input]); - } +export function mapRemove( + mapExpr: Expr | string, + stringExpr: Expr | string +): FunctionExpr { + return fieldOrExpression(mapExpr).mapRemove(valueToDefaultExpr(stringExpr)); } /** * @beta + * + * Creates an expression that merges multiple map values. + * + * ``` + * // Merges the map in the settings field with, a map literal, and a map in + * // that is conditionally returned by another expression + * mapMerge('settings', { enabled: true }, cond(field('isAdmin'), { admin: true}, {}) + * ``` + * + * @param mapField Name of a field containing a map value that will be merged. + * @param secondMap A required second map to merge. Represented as a literal or + * an expression that returns a map. + * @param otherMaps Optional additional maps to merge. Each map is represented + * as a literal or an expression that returns a map. */ -export class UnixMillisToTimestamp extends FirestoreFunction { - constructor(private input: Expr) { - super('unix_millis_to_timestamp', [input]); - } -} +export function mapMerge( + mapField: string, + secondMap: Record | Expr, + ...otherMaps: Array | Expr> +): FunctionExpr; /** * @beta + * + * Creates an expression that merges multiple map values. + * + * ``` + * // Merges the map in the settings field with, a map literal, and a map in + * // that is conditionally returned by another expression + * mapMerge(field('settings'), { enabled: true }, cond(field('isAdmin'), { admin: true}, {}) + * ``` + * + * @param firstMap An expression or literal map value that will be merged. + * @param secondMap A required second map to merge. Represented as a literal or + * an expression that returns a map. + * @param otherMaps Optional additional maps to merge. Each map is represented + * as a literal or an expression that returns a map. */ -export class TimestampToUnixMillis extends FirestoreFunction { - constructor(private input: Expr) { - super('timestamp_to_unix_millis', [input]); - } +export function mapMerge( + firstMap: Record | Expr, + secondMap: Record | Expr, + ...otherMaps: Array | Expr> +): FunctionExpr; + +export function mapMerge( + firstMap: string | Record | Expr, + secondMap: Record | Expr, + ...otherMaps: Array | Expr> +): FunctionExpr { + const secondMapExpr = valueToDefaultExpr(secondMap); + const otherMapExprs = otherMaps.map(valueToDefaultExpr); + return fieldOrExpression(firstMap).mapMerge(secondMapExpr, ...otherMapExprs); } /** * @beta + * + * Creates an expression that returns the document ID from a path. + * + * ```typescript + * // Get the document ID from a path. + * documentId(myDocumentReference); + * ``` + * + * @return A new {@code Expr} representing the documentId operation. */ -export class UnixSecondsToTimestamp extends FirestoreFunction { - constructor(private input: Expr) { - super('unix_seconds_to_timestamp', [input]); - } -} +export function documentId( + documentPath: string | DocumentReference +): FunctionExpr; /** * @beta + * + * Creates an expression that returns the document ID from a path. + * + * ```typescript + * // Get the document ID from a path. + * documentId(field("__path__")); + * ``` + * + * @return A new {@code Expr} representing the documentId operation. */ -export class TimestampToUnixSeconds extends FirestoreFunction { - constructor(private input: Expr) { - super('timestamp_to_unix_seconds', [input]); - } +export function documentId(documentPathExpr: Expr): FunctionExpr; + +export function documentId( + documentPath: Expr | string | DocumentReference +): FunctionExpr { + // @ts-ignore + const documentPathExpr = valueToDefaultExpr(documentPath); + return documentPathExpr.documentId(); } /** * @beta + * + * Creates an expression that returns a substring of a string or byte array. + * + * @param field The name of a field containing a string or byte array to compute the substring from. + * @param position Index of the first character of the substring. + * @param length Length of the substring. */ -export class TimestampAdd extends FirestoreFunction { - constructor( - private timestamp: Expr, - private unit: Expr, - private amount: Expr - ) { - super('timestamp_add', [timestamp, unit, amount]); - } -} +export function substr( + field: string, + position: number, + length?: number +): FunctionExpr; /** * @beta + * + * Creates an expression that returns a substring of a string or byte array. + * + * @param input An expression returning a string or byte array to compute the substring from. + * @param position Index of the first character of the substring. + * @param length Length of the substring. */ -export class TimestampSub extends FirestoreFunction { - constructor( - private timestamp: Expr, - private unit: Expr, - private amount: Expr - ) { - super('timestamp_sub', [timestamp, unit, amount]); - } -} +export function substr( + input: Expr, + position: number, + length?: number +): FunctionExpr; /** * @beta * - * Creates an expression that adds two expressions together. - * - * ```typescript - * // Add the value of the 'quantity' field and the 'reserve' field. - * add(Field.of("quantity"), Field.of("reserve")); - * ``` + * Creates an expression that returns a substring of a string or byte array. * - * @param left The first expression to add. - * @param right The second expression to add. - * @return A new {@code Expr} representing the addition operation. + * @param field The name of a field containing a string or byte array to compute the substring from. + * @param position An expression that returns the index of the first character of the substring. + * @param length An expression that returns the length of the substring. */ -export function add(left: Expr, right: Expr): Add; +export function substr( + field: string, + position: Expr, + length?: Expr +): FunctionExpr; /** * @beta * - * Creates an expression that adds an expression to a constant value. + * Creates an expression that returns a substring of a string or byte array. * - * ```typescript - * // Add 5 to the value of the 'age' field - * add(Field.of("age"), 5); - * ``` - * - * @param left The expression to add to. - * @param right The constant value to add. - * @return A new {@code Expr} representing the addition operation. + * @param input An expression returning a string or byte array to compute the substring from. + * @param position An expression that returns the index of the first character of the substring. + * @param length An expression that returns the length of the substring. */ -export function add(left: Expr, right: any): Add; +export function substr( + input: Expr, + position: Expr, + length?: Expr +): FunctionExpr; + +export function substr( + field: Expr | string, + position: Expr | number, + length?: Expr | number +): FunctionExpr { + const fieldExpr = fieldOrExpression(field); + const positionExpr = valueToDefaultExpr(position); + const lengthExpr = + length === undefined ? undefined : valueToDefaultExpr(length); + return fieldExpr.substr(positionExpr, lengthExpr); +} /** * @beta * - * Creates an expression that adds a field's value to an expression. + * Creates an expression that adds two expressions together. * * ```typescript * // Add the value of the 'quantity' field and the 'reserve' field. - * add("quantity", Field.of("reserve")); + * add(field("quantity"), field("reserve")); * ``` * - * @param left The field name to add to. - * @param right The expression to add. + * @param first The first expression to add. + * @param second The second expression or literal to add. + * @param others Optional other expressions or literals to add. * @return A new {@code Expr} representing the addition operation. */ -export function add(left: string, right: Expr): Add; +export function add( + first: Expr, + second: Expr | unknown, + ...others: Array +): FunctionExpr; /** * @beta * - * Creates an expression that adds a field's value to a constant value. + * Creates an expression that adds a field's value to an expression. * * ```typescript - * // Add 5 to the value of the 'age' field - * add("age", 5); + * // Add the value of the 'quantity' field and the 'reserve' field. + * add("quantity", field("reserve")); * ``` * - * @param left The field name to add to. - * @param right The constant value to add. + * @param fieldName The name of the field containing the value to add. + * @param second The second expression or literal to add. + * @param others Optional other expressions or literals to add. * @return A new {@code Expr} representing the addition operation. */ -export function add(left: string, right: any): Add; -export function add(left: Expr | string, right: Expr | any): Add { - const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; - const normalizedRight = right instanceof Expr ? right : Constant.of(right); - return new Add(normalizedLeft, normalizedRight); +export function add( + fieldName: string, + second: Expr | unknown, + ...others: Array +): FunctionExpr; + +export function add( + first: Expr | string, + second: Expr | unknown, + ...others: Array +): FunctionExpr { + return fieldOrExpression(first).add( + valueToDefaultExpr(second), + ...others.map(value => valueToDefaultExpr(value)) + ); } /** @@ -3018,14 +3535,14 @@ export function add(left: Expr | string, right: Expr | any): Add { * * ```typescript * // Subtract the 'discount' field from the 'price' field - * subtract(Field.of("price"), Field.of("discount")); + * subtract(field("price"), field("discount")); * ``` * * @param left The expression to subtract from. * @param right The expression to subtract. * @return A new {@code Expr} representing the subtraction operation. */ -export function subtract(left: Expr, right: Expr): Subtract; +export function subtract(left: Expr, right: Expr): FunctionExpr; /** * @beta @@ -3034,14 +3551,14 @@ export function subtract(left: Expr, right: Expr): Subtract; * * ```typescript * // Subtract the constant value 2 from the 'value' field - * subtract(Field.of("value"), 2); + * subtract(field("value"), 2); * ``` * - * @param left The expression to subtract from. - * @param right The constant value to subtract. + * @param expression The expression to subtract from. + * @param value The constant value to subtract. * @return A new {@code Expr} representing the subtraction operation. */ -export function subtract(left: Expr, right: any): Subtract; +export function subtract(expression: Expr, value: unknown): FunctionExpr; /** * @beta @@ -3050,14 +3567,14 @@ export function subtract(left: Expr, right: any): Subtract; * * ```typescript * // Subtract the 'discount' field from the 'price' field - * subtract("price", Field.of("discount")); + * subtract("price", field("discount")); * ``` * - * @param left The field name to subtract from. - * @param right The expression to subtract. + * @param fieldName The field name to subtract from. + * @param expression The expression to subtract. * @return A new {@code Expr} representing the subtraction operation. */ -export function subtract(left: string, right: Expr): Subtract; +export function subtract(fieldName: string, expression: Expr): FunctionExpr; /** * @beta @@ -3069,15 +3586,18 @@ export function subtract(left: string, right: Expr): Subtract; * subtract("total", 20); * ``` * - * @param left The field name to subtract from. - * @param right The constant value to subtract. + * @param fieldName The field name to subtract from. + * @param value The constant value to subtract. * @return A new {@code Expr} representing the subtraction operation. */ -export function subtract(left: string, right: any): Subtract; -export function subtract(left: Expr | string, right: Expr | any): Subtract { - const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; - const normalizedRight = right instanceof Expr ? right : Constant.of(right); - return new Subtract(normalizedLeft, normalizedRight); +export function subtract(fieldName: string, value: unknown): FunctionExpr; +export function subtract( + left: Expr | string, + right: Expr | unknown +): FunctionExpr { + const normalizedLeft = typeof left === 'string' ? field(left) : left; + const normalizedRight = valueToDefaultExpr(right); + return normalizedLeft.subtract(normalizedRight); } /** @@ -3087,30 +3607,19 @@ export function subtract(left: Expr | string, right: Expr | any): Subtract { * * ```typescript * // Multiply the 'quantity' field by the 'price' field - * multiply(Field.of("quantity"), Field.of("price")); - * ``` - * - * @param left The first expression to multiply. - * @param right The second expression to multiply. - * @return A new {@code Expr} representing the multiplication operation. - */ -export function multiply(left: Expr, right: Expr): Multiply; - -/** - * @beta - * - * Creates an expression that multiplies an expression by a constant value. - * - * ```typescript - * // Multiply the value of the 'price' field by 2 - * multiply(Field.of("price"), 2); + * multiply(field("quantity"), field("price")); * ``` * - * @param left The expression to multiply. - * @param right The constant value to multiply by. + * @param first The first expression to multiply. + * @param second The second expression or literal to multiply. + * @param others Optional additional expressions or literals to multiply. * @return A new {@code Expr} representing the multiplication operation. */ -export function multiply(left: Expr, right: any): Multiply; +export function multiply( + first: Expr, + second: Expr | unknown, + ...others: Array +): FunctionExpr; /** * @beta @@ -3119,34 +3628,29 @@ export function multiply(left: Expr, right: any): Multiply; * * ```typescript * // Multiply the 'quantity' field by the 'price' field - * multiply("quantity", Field.of("price")); - * ``` - * - * @param left The field name to multiply. - * @param right The expression to multiply by. - * @return A new {@code Expr} representing the multiplication operation. - */ -export function multiply(left: string, right: Expr): Multiply; - -/** - * @beta - * - * Creates an expression that multiplies a field's value by a constant value. - * - * ```typescript - * // Multiply the 'value' field by 2 - * multiply("value", 2); + * multiply("quantity", field("price")); * ``` * - * @param left The field name to multiply. - * @param right The constant value to multiply by. + * @param fieldName The name of the field containing the value to add. + * @param second The second expression or literal to add. + * @param others Optional other expressions or literals to add. * @return A new {@code Expr} representing the multiplication operation. */ -export function multiply(left: string, right: any): Multiply; -export function multiply(left: Expr | string, right: Expr | any): Multiply { - const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; - const normalizedRight = right instanceof Expr ? right : Constant.of(right); - return new Multiply(normalizedLeft, normalizedRight); +export function multiply( + fieldName: string, + second: Expr | unknown, + ...others: Array +): FunctionExpr; + +export function multiply( + first: Expr | string, + second: Expr | unknown, + ...others: Array +): FunctionExpr { + return fieldOrExpression(first).multiply( + valueToDefaultExpr(second), + ...others.map(valueToDefaultExpr) + ); } /** @@ -3156,14 +3660,14 @@ export function multiply(left: Expr | string, right: Expr | any): Multiply { * * ```typescript * // Divide the 'total' field by the 'count' field - * divide(Field.of("total"), Field.of("count")); + * divide(field("total"), field("count")); * ``` * * @param left The expression to be divided. * @param right The expression to divide by. * @return A new {@code Expr} representing the division operation. */ -export function divide(left: Expr, right: Expr): Divide; +export function divide(left: Expr, right: Expr): FunctionExpr; /** * @beta @@ -3172,14 +3676,14 @@ export function divide(left: Expr, right: Expr): Divide; * * ```typescript * // Divide the 'value' field by 10 - * divide(Field.of("value"), 10); + * divide(field("value"), 10); * ``` * - * @param left The expression to be divided. - * @param right The constant value to divide by. + * @param expression The expression to be divided. + * @param value The constant value to divide by. * @return A new {@code Expr} representing the division operation. */ -export function divide(left: Expr, right: any): Divide; +export function divide(expression: Expr, value: unknown): FunctionExpr; /** * @beta @@ -3188,14 +3692,14 @@ export function divide(left: Expr, right: any): Divide; * * ```typescript * // Divide the 'total' field by the 'count' field - * divide("total", Field.of("count")); + * divide("total", field("count")); * ``` * - * @param left The field name to be divided. - * @param right The expression to divide by. + * @param fieldName The field name to be divided. + * @param expressions The expression to divide by. * @return A new {@code Expr} representing the division operation. */ -export function divide(left: string, right: Expr): Divide; +export function divide(fieldName: string, expressions: Expr): FunctionExpr; /** * @beta @@ -3207,15 +3711,18 @@ export function divide(left: string, right: Expr): Divide; * divide("value", 10); * ``` * - * @param left The field name to be divided. - * @param right The constant value to divide by. + * @param fieldName The field name to be divided. + * @param value The constant value to divide by. * @return A new {@code Expr} representing the division operation. */ -export function divide(left: string, right: any): Divide; -export function divide(left: Expr | string, right: Expr | any): Divide { - const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; - const normalizedRight = right instanceof Expr ? right : Constant.of(right); - return new Divide(normalizedLeft, normalizedRight); +export function divide(fieldName: string, value: unknown): FunctionExpr; +export function divide( + left: Expr | string, + right: Expr | unknown +): FunctionExpr { + const normalizedLeft = typeof left === 'string' ? field(left) : left; + const normalizedRight = valueToDefaultExpr(right); + return normalizedLeft.divide(normalizedRight); } /** @@ -3225,14 +3732,14 @@ export function divide(left: Expr | string, right: Expr | any): Divide { * * ```typescript * // Calculate the remainder of dividing 'field1' by 'field2'. - * mod(Field.of("field1"), Field.of("field2")); + * mod(field("field1"), field("field2")); * ``` * * @param left The dividend expression. * @param right The divisor expression. * @return A new {@code Expr} representing the modulo operation. */ -export function mod(left: Expr, right: Expr): Mod; +export function mod(left: Expr, right: Expr): FunctionExpr; /** * @beta @@ -3241,14 +3748,14 @@ export function mod(left: Expr, right: Expr): Mod; * * ```typescript * // Calculate the remainder of dividing 'field1' by 5. - * mod(Field.of("field1"), 5); + * mod(field("field1"), 5); * ``` * - * @param left The dividend expression. - * @param right The divisor constant. + * @param expression The dividend expression. + * @param value The divisor constant. * @return A new {@code Expr} representing the modulo operation. */ -export function mod(left: Expr, right: any): Mod; +export function mod(expression: Expr, value: unknown): FunctionExpr; /** * @beta @@ -3257,14 +3764,14 @@ export function mod(left: Expr, right: any): Mod; * * ```typescript * // Calculate the remainder of dividing 'field1' by 'field2'. - * mod("field1", Field.of("field2")); + * mod("field1", field("field2")); * ``` * - * @param left The dividend field name. - * @param right The divisor expression. + * @param fieldName The dividend field name. + * @param expression The divisor expression. * @return A new {@code Expr} representing the modulo operation. */ -export function mod(left: string, right: Expr): Mod; +export function mod(fieldName: string, expression: Expr): FunctionExpr; /** * @beta @@ -3276,402 +3783,83 @@ export function mod(left: string, right: Expr): Mod; * mod("field1", 5); * ``` * - * @param left The dividend field name. - * @param right The divisor constant. + * @param fieldName The dividend field name. + * @param value The divisor constant. * @return A new {@code Expr} representing the modulo operation. */ -export function mod(left: string, right: any): Mod; -export function mod(left: Expr | string, right: Expr | any): Mod { - const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; - const normalizedRight = right instanceof Expr ? right : Constant.of(right); - return new Mod(normalizedLeft, normalizedRight); +export function mod(fieldName: string, value: unknown): FunctionExpr; +export function mod(left: Expr | string, right: Expr | unknown): FunctionExpr { + const normalizedLeft = typeof left === 'string' ? field(left) : left; + const normalizedRight = valueToDefaultExpr(right); + return normalizedLeft.mod(normalizedRight); +} + +/** + * @beta + * + * Creates an expression that creates a Firestore map value from an input object. + * + * ```typescript + * // Create a map from the input object and reference the 'baz' field value from the input document. + * map({foo: 'bar', baz: Field.of('baz')}).as('data'); + * ``` + * + * @param elements The input map to evaluate in the expression. + * @return A new {@code Expr} representing the map function. + */ +export function map(elements: Record): FunctionExpr { + const result: Expr[] = []; + for (const key in elements) { + if (Object.prototype.hasOwnProperty.call(elements, key)) { + const value = elements[key]; + result.push(constant(key)); + result.push(valueToDefaultExpr(value)); + } + } + return new FunctionExpr('map', result); +} + +/** + * Internal use only + * Converts a plainObject to a mapValue in the proto representation, + * rather than a functionValue+map that is the result of the map(...) function. + * This behaves different from constant(plainObject) because it + * traverses the input object, converts values in the object to expressions, + * and calls _readUserData on each of these expressions. + * @private + * @internal + * @param plainObject + */ +export function _mapValue(plainObject: Record): MapValue { + const result: Map = new Map(); + for (const key in plainObject) { + if (Object.prototype.hasOwnProperty.call(plainObject, key)) { + const value = plainObject[key]; + result.set(key, valueToDefaultExpr(value)); + } + } + return new MapValue(result); } -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise AND operation between two expressions. -// * -// * ```typescript -// * // Calculate the bitwise AND of 'field1' and 'field2'. -// * bitAnd(Field.of("field1"), Field.of("field2")); -// * ``` -// * -// * @param left The left operand expression. -// * @param right The right operand expression. -// * @return A new {@code Expr} representing the bitwise AND operation. -// */ -// export function bitAnd(left: Expr, right: Expr): BitAnd; -// -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise AND operation between an expression and a constant. -// * -// * ```typescript -// * // Calculate the bitwise AND of 'field1' and 0xFF. -// * bitAnd(Field.of("field1"), 0xFF); -// * ``` -// * -// * @param left The left operand expression. -// * @param right The right operand constant. -// * @return A new {@code Expr} representing the bitwise AND operation. -// */ -// export function bitAnd(left: Expr, right: any): BitAnd; -// -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise AND operation between a field and an expression. -// * -// * ```typescript -// * // Calculate the bitwise AND of 'field1' and 'field2'. -// * bitAnd("field1", Field.of("field2")); -// * ``` -// * -// * @param left The left operand field name. -// * @param right The right operand expression. -// * @return A new {@code Expr} representing the bitwise AND operation. -// */ -// export function bitAnd(left: string, right: Expr): BitAnd; -// -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise AND operation between a field and a constant. -// * -// * ```typescript -// * // Calculate the bitwise AND of 'field1' and 0xFF. -// * bitAnd("field1", 0xFF); -// * ``` -// * -// * @param left The left operand field name. -// * @param right The right operand constant. -// * @return A new {@code Expr} representing the bitwise AND operation. -// */ -// export function bitAnd(left: string, right: any): BitAnd; -// export function bitAnd(left: Expr | string, right: Expr | any): BitAnd { -// const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; -// const normalizedRight = right instanceof Expr ? right : Constant.of(right); -// return new BitAnd(normalizedLeft, normalizedRight); -// } -// -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise OR operation between two expressions. -// * -// * ```typescript -// * // Calculate the bitwise OR of 'field1' and 'field2'. -// * bitOr(Field.of("field1"), Field.of("field2")); -// * ``` -// * -// * @param left The left operand expression. -// * @param right The right operand expression. -// * @return A new {@code Expr} representing the bitwise OR operation. -// */ -// export function bitOr(left: Expr, right: Expr): BitOr; -// -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise OR operation between an expression and a constant. -// * -// * ```typescript -// * // Calculate the bitwise OR of 'field1' and 0xFF. -// * bitOr(Field.of("field1"), 0xFF); -// * ``` -// * -// * @param left The left operand expression. -// * @param right The right operand constant. -// * @return A new {@code Expr} representing the bitwise OR operation. -// */ -// export function bitOr(left: Expr, right: any): BitOr; -// -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise OR operation between a field and an expression. -// * -// * ```typescript -// * // Calculate the bitwise OR of 'field1' and 'field2'. -// * bitOr("field1", Field.of("field2")); -// * ``` -// * -// * @param left The left operand field name. -// * @param right The right operand expression. -// * @return A new {@code Expr} representing the bitwise OR operation. -// */ -// export function bitOr(left: string, right: Expr): BitOr; -// -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise OR operation between a field and a constant. -// * -// * ```typescript -// * // Calculate the bitwise OR of 'field1' and 0xFF. -// * bitOr("field1", 0xFF); -// * ``` -// * -// * @param left The left operand field name. -// * @param right The right operand constant. -// * @return A new {@code Expr} representing the bitwise OR operation. -// */ -// export function bitOr(left: string, right: any): BitOr; -// export function bitOr(left: Expr | string, right: Expr | any): BitOr { -// const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; -// const normalizedRight = right instanceof Expr ? right : Constant.of(right); -// return new BitOr(normalizedLeft, normalizedRight); -// } -// -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise XOR operation between two expressions. -// * -// * ```typescript -// * // Calculate the bitwise XOR of 'field1' and 'field2'. -// * bitXor(Field.of("field1"), Field.of("field2")); -// * ``` -// * -// * @param left The left operand expression. -// * @param right The right operand expression. -// * @return A new {@code Expr} representing the bitwise XOR operation. -// */ -// export function bitXor(left: Expr, right: Expr): BitXor; -// -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise XOR operation between an expression and a constant. -// * -// * ```typescript -// * // Calculate the bitwise XOR of 'field1' and 0xFF. -// * bitXor(Field.of("field1"), 0xFF); -// * ``` -// * -// * @param left The left operand expression. -// * @param right The right operand constant. -// * @return A new {@code Expr} representing the bitwise XOR operation. -// */ -// export function bitXor(left: Expr, right: any): BitXor; -// -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise XOR operation between a field and an expression. -// * -// * ```typescript -// * // Calculate the bitwise XOR of 'field1' and 'field2'. -// * bitXor("field1", Field.of("field2")); -// * ``` -// * -// * @param left The left operand field name. -// * @param right The right operand expression. -// * @return A new {@code Expr} representing the bitwise XOR operation. -// */ -// export function bitXor(left: string, right: Expr): BitXor; -// -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise XOR operation between a field and a constant. -// * -// * ```typescript -// * // Calculate the bitwise XOR of 'field1' and 0xFF. -// * bitXor("field1", 0xFF); -// * ``` -// * -// * @param left The left operand field name. -// * @param right The right operand constant. -// * @return A new {@code Expr} representing the bitwise XOR operation. -// */ -// export function bitXor(left: string, right: any): BitXor; -// export function bitXor(left: Expr | string, right: Expr | any): BitXor { -// const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; -// const normalizedRight = right instanceof Expr ? right : Constant.of(right); -// return new BitXor(normalizedLeft, normalizedRight); -// } -// -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise NOT operation to an expression. -// * -// * ```typescript -// * // Calculate the bitwise NOT of 'field1'. -// * bitNot(Field.of("field1")); -// * ``` -// * -// * @param operand The operand expression. -// * @return A new {@code Expr} representing the bitwise NOT operation. -// */ -// export function bitNot(operand: Expr): BitNot; -// -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise NOT operation to a field. -// * -// * ```typescript -// * // Calculate the bitwise NOT of 'field1'. -// * bitNot("field1"); -// * ``` -// * -// * @param operand The operand field name. -// * @return A new {@code Expr} representing the bitwise NOT operation. -// */ -// export function bitNot(operand: string): BitNot; -// export function bitNot(operand: Expr | string): BitNot { -// const normalizedOperand = -// typeof operand === 'string' ? Field.of(operand) : operand; -// return new BitNot(normalizedOperand); -// } -// -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise left shift operation between two expressions. -// * -// * ```typescript -// * // Calculate the bitwise left shift of 'field1' by 'field2' bits. -// * bitLeftShift(Field.of("field1"), Field.of("field2")); -// * ``` -// * -// * @param left The left operand expression. -// * @param right The right operand expression representing the number of bits to shift. -// * @return A new {@code Expr} representing the bitwise left shift operation. -// */ -// export function bitLeftShift(left: Expr, right: Expr): BitLeftShift; -// -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise left shift operation between an expression and a constant. -// * -// * ```typescript -// * // Calculate the bitwise left shift of 'field1' by 2 bits. -// * bitLeftShift(Field.of("field1"), 2); -// * ``` -// * -// * @param left The left operand expression. -// * @param right The right operand constant representing the number of bits to shift. -// * @return A new {@code Expr} representing the bitwise left shift operation. -// */ -// export function bitLeftShift(left: Expr, right: any): BitLeftShift; -// -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise left shift operation between a field and an expression. -// * -// * ```typescript -// * // Calculate the bitwise left shift of 'field1' by 'field2' bits. -// * bitLeftShift("field1", Field.of("field2")); -// * ``` -// * -// * @param left The left operand field name. -// * @param right The right operand expression representing the number of bits to shift. -// * @return A new {@code Expr} representing the bitwise left shift operation. -// */ -// export function bitLeftShift(left: string, right: Expr): BitLeftShift; -// -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise left shift operation between a field and a constant. -// * -// * ```typescript -// * // Calculate the bitwise left shift of 'field1' by 2 bits. -// * bitLeftShift("field1", 2); -// * ``` -// * -// * @param left The left operand field name. -// * @param right The right operand constant representing the number of bits to shift. -// * @return A new {@code Expr} representing the bitwise left shift operation. -// */ -// export function bitLeftShift(left: string, right: any): BitLeftShift; -// export function bitLeftShift( -// left: Expr | string, -// right: Expr | any -// ): BitLeftShift { -// const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; -// const normalizedRight = right instanceof Expr ? right : Constant.of(right); -// return new BitLeftShift(normalizedLeft, normalizedRight); -// } -// -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise right shift operation between two expressions. -// * -// * ```typescript -// * // Calculate the bitwise right shift of 'field1' by 'field2' bits. -// * bitRightShift(Field.of("field1"), Field.of("field2")); -// * ``` -// * -// * @param left The left operand expression. -// * @param right The right operand expression representing the number of bits to shift. -// * @return A new {@code Expr} representing the bitwise right shift operation. -// */ -// export function bitRightShift(left: Expr, right: Expr): BitRightShift; -// -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise right shift operation between an expression and a constant. -// * -// * ```typescript -// * // Calculate the bitwise right shift of 'field1' by 2 bits. -// * bitRightShift(Field.of("field1"), 2); -// * ``` -// * -// * @param left The left operand expression. -// * @param right The right operand constant representing the number of bits to shift. -// * @return A new {@code Expr} representing the bitwise right shift operation. -// */ -// export function bitRightShift(left: Expr, right: any): BitRightShift; -// -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise right shift operation between a field and an expression. -// * -// * ```typescript -// * // Calculate the bitwise right shift of 'field1' by 'field2' bits. -// * bitRightShift("field1", Field.of("field2")); -// * ``` -// * -// * @param left The left operand field name. -// * @param right The right operand expression representing the number of bits to shift. -// * @return A new {@code Expr} representing the bitwise right shift operation. -// */ -// export function bitRightShift(left: string, right: Expr): BitRightShift; -// -// /** -// * @beta -// * -// * Creates an expression that applies a bitwise right shift operation between a field and a constant. -// * -// * ```typescript -// * // Calculate the bitwise right shift of 'field1' by 2 bits. -// * bitRightShift("field1", 2); -// * ``` -// * -// * @param left The left operand field name. -// * @param right The right operand constant representing the number of bits to shift. -// * @return A new {@code Expr} representing the bitwise right shift operation. -// */ -// export function bitRightShift(left: string, right: any): BitRightShift; -// export function bitRightShift( -// left: Expr | string, -// right: Expr | any -// ): BitRightShift { -// const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; -// const normalizedRight = right instanceof Expr ? right : Constant.of(right); -// return new BitRightShift(normalizedLeft, normalizedRight); -// } +/** + * @beta + * + * Creates an expression that creates a Firestore array value from an input array. + * + * ```typescript + * // Create an array value from the input array and reference the 'baz' field value from the input document. + * array(['bar', Field.of('baz')]).as('foo'); + * ``` + * + * @param elements The input array to evaluate in the expression. + * @return A new {@code Expr} representing the array function. + */ +export function array(elements: unknown[]): FunctionExpr { + return new FunctionExpr( + 'array', + elements.map(element => valueToDefaultExpr(element)) + ); +} /** * @beta @@ -3680,14 +3868,14 @@ export function mod(left: Expr | string, right: Expr | any): Mod { * * ```typescript * // Check if the 'age' field is equal to an expression - * eq(Field.of("age"), Field.of("minAge").add(10)); + * eq(field("age"), field("minAge").add(10)); * ``` * * @param left The first expression to compare. * @param right The second expression to compare. * @return A new `Expr` representing the equality comparison. */ -export function eq(left: Expr, right: Expr): Eq; +export function eq(left: Expr, right: Expr): BooleanExpr; /** * @beta @@ -3696,14 +3884,14 @@ export function eq(left: Expr, right: Expr): Eq; * * ```typescript * // Check if the 'age' field is equal to 21 - * eq(Field.of("age"), 21); + * eq(field("age"), 21); * ``` * - * @param left The expression to compare. - * @param right The constant value to compare to. + * @param expression The expression to compare. + * @param value The constant value to compare to. * @return A new `Expr` representing the equality comparison. */ -export function eq(left: Expr, right: any): Eq; +export function eq(expression: Expr, value: unknown): BooleanExpr; /** * @beta @@ -3712,14 +3900,14 @@ export function eq(left: Expr, right: any): Eq; * * ```typescript * // Check if the 'age' field is equal to the 'limit' field - * eq("age", Field.of("limit")); + * eq("age", field("limit")); * ``` * - * @param left The field name to compare. - * @param right The expression to compare to. + * @param fieldName The field name to compare. + * @param expression The expression to compare to. * @return A new `Expr` representing the equality comparison. */ -export function eq(left: string, right: Expr): Eq; +export function eq(fieldName: string, expression: Expr): BooleanExpr; /** * @beta @@ -3731,15 +3919,15 @@ export function eq(left: string, right: Expr): Eq; * eq("city", "London"); * ``` * - * @param left The field name to compare. - * @param right The constant value to compare to. + * @param fieldName The field name to compare. + * @param value The constant value to compare to. * @return A new `Expr` representing the equality comparison. */ -export function eq(left: string, right: any): Eq; -export function eq(left: Expr | string, right: any): Eq { - const leftExpr = left instanceof Expr ? left : Field.of(left); - const rightExpr = right instanceof Expr ? right : Constant.of(right); - return new Eq(leftExpr, rightExpr); +export function eq(fieldName: string, value: unknown): BooleanExpr; +export function eq(left: Expr | string, right: unknown): BooleanExpr { + const leftExpr = left instanceof Expr ? left : field(left); + const rightExpr = valueToDefaultExpr(right); + return leftExpr.eq(rightExpr); } /** @@ -3749,14 +3937,14 @@ export function eq(left: Expr | string, right: any): Eq { * * ```typescript * // Check if the 'status' field is not equal to field 'finalState' - * neq(Field.of("status"), Field.of("finalState")); + * neq(field("status"), field("finalState")); * ``` * * @param left The first expression to compare. * @param right The second expression to compare. * @return A new `Expr` representing the inequality comparison. */ -export function neq(left: Expr, right: Expr): Neq; +export function neq(left: Expr, right: Expr): BooleanExpr; /** * @beta @@ -3765,14 +3953,14 @@ export function neq(left: Expr, right: Expr): Neq; * * ```typescript * // Check if the 'status' field is not equal to "completed" - * neq(Field.of("status"), "completed"); + * neq(field("status"), "completed"); * ``` * - * @param left The expression to compare. - * @param right The constant value to compare to. + * @param expression The expression to compare. + * @param value The constant value to compare to. * @return A new `Expr` representing the inequality comparison. */ -export function neq(left: Expr, right: any): Neq; +export function neq(expression: Expr, value: unknown): BooleanExpr; /** * @beta @@ -3781,14 +3969,14 @@ export function neq(left: Expr, right: any): Neq; * * ```typescript * // Check if the 'status' field is not equal to the value of 'expectedStatus' - * neq("status", Field.of("expectedStatus")); + * neq("status", field("expectedStatus")); * ``` * - * @param left The field name to compare. - * @param right The expression to compare to. + * @param fieldName The field name to compare. + * @param expression The expression to compare to. * @return A new `Expr` representing the inequality comparison. */ -export function neq(left: string, right: Expr): Neq; +export function neq(fieldName: string, expression: Expr): BooleanExpr; /** * @beta @@ -3800,15 +3988,15 @@ export function neq(left: string, right: Expr): Neq; * neq("country", "USA"); * ``` * - * @param left The field name to compare. - * @param right The constant value to compare to. + * @param fieldName The field name to compare. + * @param value The constant value to compare to. * @return A new `Expr` representing the inequality comparison. */ -export function neq(left: string, right: any): Neq; -export function neq(left: Expr | string, right: any): Neq { - const leftExpr = left instanceof Expr ? left : Field.of(left); - const rightExpr = right instanceof Expr ? right : Constant.of(right); - return new Neq(leftExpr, rightExpr); +export function neq(fieldName: string, value: unknown): BooleanExpr; +export function neq(left: Expr | string, right: unknown): BooleanExpr { + const leftExpr = left instanceof Expr ? left : field(left); + const rightExpr = valueToDefaultExpr(right); + return leftExpr.neq(rightExpr); } /** @@ -3818,14 +4006,14 @@ export function neq(left: Expr | string, right: any): Neq { * * ```typescript * // Check if the 'age' field is less than 30 - * lt(Field.of("age"), Field.of("limit")); + * lt(field("age"), field("limit")); * ``` * * @param left The first expression to compare. * @param right The second expression to compare. * @return A new `Expr` representing the less than comparison. */ -export function lt(left: Expr, right: Expr): Lt; +export function lt(left: Expr, right: Expr): BooleanExpr; /** * @beta @@ -3834,14 +4022,14 @@ export function lt(left: Expr, right: Expr): Lt; * * ```typescript * // Check if the 'age' field is less than 30 - * lt(Field.of("age"), 30); + * lt(field("age"), 30); * ``` * - * @param left The expression to compare. - * @param right The constant value to compare to. + * @param expression The expression to compare. + * @param value The constant value to compare to. * @return A new `Expr` representing the less than comparison. */ -export function lt(left: Expr, right: any): Lt; +export function lt(expression: Expr, value: unknown): BooleanExpr; /** * @beta @@ -3850,14 +4038,14 @@ export function lt(left: Expr, right: any): Lt; * * ```typescript * // Check if the 'age' field is less than the 'limit' field - * lt("age", Field.of("limit")); + * lt("age", field("limit")); * ``` * - * @param left The field name to compare. - * @param right The expression to compare to. + * @param fieldName The field name to compare. + * @param expression The expression to compare to. * @return A new `Expr` representing the less than comparison. */ -export function lt(left: string, right: Expr): Lt; +export function lt(fieldName: string, expression: Expr): BooleanExpr; /** * @beta @@ -3869,15 +4057,15 @@ export function lt(left: string, right: Expr): Lt; * lt("price", 50); * ``` * - * @param left The field name to compare. - * @param right The constant value to compare to. + * @param fieldName The field name to compare. + * @param value The constant value to compare to. * @return A new `Expr` representing the less than comparison. */ -export function lt(left: string, right: any): Lt; -export function lt(left: Expr | string, right: any): Lt { - const leftExpr = left instanceof Expr ? left : Field.of(left); - const rightExpr = right instanceof Expr ? right : Constant.of(right); - return new Lt(leftExpr, rightExpr); +export function lt(fieldName: string, value: unknown): BooleanExpr; +export function lt(left: Expr | string, right: unknown): BooleanExpr { + const leftExpr = left instanceof Expr ? left : field(left); + const rightExpr = valueToDefaultExpr(right); + return leftExpr.lt(rightExpr); } /** @@ -3888,14 +4076,14 @@ export function lt(left: Expr | string, right: any): Lt { * * ```typescript * // Check if the 'quantity' field is less than or equal to 20 - * lte(Field.of("quantity"), Field.of("limit")); + * lte(field("quantity"), field("limit")); * ``` * * @param left The first expression to compare. * @param right The second expression to compare. * @return A new `Expr` representing the less than or equal to comparison. */ -export function lte(left: Expr, right: Expr): Lte; +export function lte(left: Expr, right: Expr): BooleanExpr; /** * @beta @@ -3904,28 +4092,28 @@ export function lte(left: Expr, right: Expr): Lte; * * ```typescript * // Check if the 'quantity' field is less than or equal to 20 - * lte(Field.of("quantity"), 20); + * lte(field("quantity"), 20); * ``` * - * @param left The expression to compare. - * @param right The constant value to compare to. + * @param expression The expression to compare. + * @param value The constant value to compare to. * @return A new `Expr` representing the less than or equal to comparison. */ -export function lte(left: Expr, right: any): Lte; +export function lte(expression: Expr, value: unknown): BooleanExpr; /** * Creates an expression that checks if a field's value is less than or equal to an expression. * * ```typescript * // Check if the 'quantity' field is less than or equal to the 'limit' field - * lte("quantity", Field.of("limit")); + * lte("quantity", field("limit")); * ``` * - * @param left The field name to compare. - * @param right The expression to compare to. + * @param fieldName The field name to compare. + * @param expression The expression to compare to. * @return A new `Expr` representing the less than or equal to comparison. */ -export function lte(left: string, right: Expr): Lte; +export function lte(fieldName: string, expression: Expr): BooleanExpr; /** * @beta @@ -3937,15 +4125,15 @@ export function lte(left: string, right: Expr): Lte; * lte("score", 70); * ``` * - * @param left The field name to compare. - * @param right The constant value to compare to. + * @param fieldName The field name to compare. + * @param value The constant value to compare to. * @return A new `Expr` representing the less than or equal to comparison. */ -export function lte(left: string, right: any): Lte; -export function lte(left: Expr | string, right: any): Lte { - const leftExpr = left instanceof Expr ? left : Field.of(left); - const rightExpr = right instanceof Expr ? right : Constant.of(right); - return new Lte(leftExpr, rightExpr); +export function lte(fieldName: string, value: unknown): BooleanExpr; +export function lte(left: Expr | string, right: unknown): BooleanExpr { + const leftExpr = left instanceof Expr ? left : field(left); + const rightExpr = valueToDefaultExpr(right); + return leftExpr.lte(rightExpr); } /** @@ -3956,14 +4144,14 @@ export function lte(left: Expr | string, right: any): Lte { * * ```typescript * // Check if the 'age' field is greater than 18 - * gt(Field.of("age"), Constant(9).add(9)); + * gt(field("age"), Constant(9).add(9)); * ``` * * @param left The first expression to compare. * @param right The second expression to compare. * @return A new `Expr` representing the greater than comparison. */ -export function gt(left: Expr, right: Expr): Gt; +export function gt(left: Expr, right: Expr): BooleanExpr; /** * @beta @@ -3972,14 +4160,14 @@ export function gt(left: Expr, right: Expr): Gt; * * ```typescript * // Check if the 'age' field is greater than 18 - * gt(Field.of("age"), 18); + * gt(field("age"), 18); * ``` * - * @param left The expression to compare. - * @param right The constant value to compare to. + * @param expression The expression to compare. + * @param value The constant value to compare to. * @return A new `Expr` representing the greater than comparison. */ -export function gt(left: Expr, right: any): Gt; +export function gt(expression: Expr, value: unknown): BooleanExpr; /** * @beta @@ -3988,14 +4176,14 @@ export function gt(left: Expr, right: any): Gt; * * ```typescript * // Check if the value of field 'age' is greater than the value of field 'limit' - * gt("age", Field.of("limit")); + * gt("age", field("limit")); * ``` * - * @param left The field name to compare. - * @param right The expression to compare to. + * @param fieldName The field name to compare. + * @param expression The expression to compare to. * @return A new `Expr` representing the greater than comparison. */ -export function gt(left: string, right: Expr): Gt; +export function gt(fieldName: string, expression: Expr): BooleanExpr; /** * @beta @@ -4007,15 +4195,15 @@ export function gt(left: string, right: Expr): Gt; * gt("price", 100); * ``` * - * @param left The field name to compare. - * @param right The constant value to compare to. + * @param fieldName The field name to compare. + * @param value The constant value to compare to. * @return A new `Expr` representing the greater than comparison. */ -export function gt(left: string, right: any): Gt; -export function gt(left: Expr | string, right: any): Gt { - const leftExpr = left instanceof Expr ? left : Field.of(left); - const rightExpr = right instanceof Expr ? right : Constant.of(right); - return new Gt(leftExpr, rightExpr); +export function gt(fieldName: string, value: unknown): BooleanExpr; +export function gt(left: Expr | string, right: unknown): BooleanExpr { + const leftExpr = left instanceof Expr ? left : field(left); + const rightExpr = valueToDefaultExpr(right); + return leftExpr.gt(rightExpr); } /** @@ -4026,14 +4214,14 @@ export function gt(left: Expr | string, right: any): Gt { * * ```typescript * // Check if the 'quantity' field is greater than or equal to the field "threshold" - * gte(Field.of("quantity"), Field.of("threshold")); + * gte(field("quantity"), field("threshold")); * ``` * * @param left The first expression to compare. * @param right The second expression to compare. * @return A new `Expr` representing the greater than or equal to comparison. */ -export function gte(left: Expr, right: Expr): Gte; +export function gte(left: Expr, right: Expr): BooleanExpr; /** * @beta @@ -4043,14 +4231,14 @@ export function gte(left: Expr, right: Expr): Gte; * * ```typescript * // Check if the 'quantity' field is greater than or equal to 10 - * gte(Field.of("quantity"), 10); + * gte(field("quantity"), 10); * ``` * - * @param left The expression to compare. - * @param right The constant value to compare to. + * @param expression The expression to compare. + * @param value The constant value to compare to. * @return A new `Expr` representing the greater than or equal to comparison. */ -export function gte(left: Expr, right: any): Gte; +export function gte(expression: Expr, value: unknown): BooleanExpr; /** * @beta @@ -4059,14 +4247,14 @@ export function gte(left: Expr, right: any): Gte; * * ```typescript * // Check if the value of field 'age' is greater than or equal to the value of field 'limit' - * gte("age", Field.of("limit")); + * gte("age", field("limit")); * ``` * - * @param left The field name to compare. - * @param right The expression to compare to. + * @param fieldName The field name to compare. + * @param value The expression to compare to. * @return A new `Expr` representing the greater than or equal to comparison. */ -export function gte(left: string, right: Expr): Gte; +export function gte(fieldName: string, value: Expr): BooleanExpr; /** * @beta @@ -4079,15 +4267,15 @@ export function gte(left: string, right: Expr): Gte; * gte("score", 80); * ``` * - * @param left The field name to compare. - * @param right The constant value to compare to. + * @param fieldName The field name to compare. + * @param value The constant value to compare to. * @return A new `Expr` representing the greater than or equal to comparison. */ -export function gte(left: string, right: any): Gte; -export function gte(left: Expr | string, right: any): Gte { - const leftExpr = left instanceof Expr ? left : Field.of(left); - const rightExpr = right instanceof Expr ? right : Constant.of(right); - return new Gte(leftExpr, rightExpr); +export function gte(fieldName: string, value: unknown): BooleanExpr; +export function gte(left: Expr | string, right: unknown): BooleanExpr { + const leftExpr = left instanceof Expr ? left : field(left); + const rightExpr = valueToDefaultExpr(right); + return leftExpr.gte(rightExpr); } /** @@ -4097,71 +4285,51 @@ export function gte(left: Expr | string, right: any): Gte { * * ```typescript * // Combine the 'items' array with two new item arrays - * arrayConcat(Field.of("items"), [Field.of("newItems"), Field.of("otherItems")]); - * ``` - * - * @param array The array expression to concatenate to. - * @param elements The array expressions to concatenate. - * @return A new {@code Expr} representing the concatenated array. - */ -export function arrayConcat(array: Expr, elements: Expr[]): ArrayConcat; - -/** - * @beta - * - * Creates an expression that concatenates an array expression with other arrays and/or values. - * - * ```typescript - * // Combine the 'tags' array with a new array - * arrayConcat(Field.of("tags"), ["newTag1", "newTag2"]); - * ``` - * - * @param array The array expression to concatenate to. - * @param elements The array expressions or single values to concatenate. - * @return A new {@code Expr} representing the concatenated array. - */ -export function arrayConcat(array: Expr, elements: any[]): ArrayConcat; - -/** - * @beta - * - * Creates an expression that concatenates a field's array value with other arrays. - * - * ```typescript - * // Combine the 'items' array with two new item arrays - * arrayConcat("items", [Field.of("newItems"), Field.of("otherItems")]); + * arrayConcat(field("items"), [field("newItems"), field("otherItems")]); * ``` * - * @param array The field name containing array values. - * @param elements The array expressions to concatenate. + * @param firstArray The first array expression to concatenate to. + * @param secondArray The second array expression or array literal to concatenate to. + * @param otherArrays Optional additional array expressions or array literals to concatenate. * @return A new {@code Expr} representing the concatenated array. */ -export function arrayConcat(array: string, elements: Expr[]): ArrayConcat; +export function arrayConcat( + firstArray: Expr, + secondArray: Expr | unknown[], + ...otherArrays: Array +): FunctionExpr; /** * @beta * - * Creates an expression that concatenates a field's array value with other arrays and/or values. + * Creates an expression that concatenates a field's array value with other arrays. * * ```typescript - * // Combine the 'tags' array with a new array - * arrayConcat("tags", ["newTag1", "newTag2"]); + * // Combine the 'items' array with two new item arrays + * arrayConcat("items", [field("newItems"), field("otherItems")]); * ``` * - * @param array The field name containing array values. - * @param elements The array expressions or single values to concatenate. + * @param firstArrayField The first array to concatenate to. + * @param secondArray The second array expression or array literal to concatenate to. + * @param otherArrays Optional additional array expressions or array literals to concatenate. * @return A new {@code Expr} representing the concatenated array. */ -export function arrayConcat(array: string, elements: any[]): ArrayConcat; export function arrayConcat( - array: Expr | string, - elements: any[] -): ArrayConcat { - const arrayExpr = array instanceof Expr ? array : Field.of(array); - const exprValues = elements.map(element => - element instanceof Expr ? element : Constant.of(element) + firstArrayField: string, + secondArray: Expr | unknown[], + ...otherArrays: Array +): FunctionExpr; + +export function arrayConcat( + firstArray: Expr | string, + secondArray: Expr | unknown[], + ...otherArrays: Array +): FunctionExpr { + const exprValues = otherArrays.map(element => valueToDefaultExpr(element)); + return fieldOrExpression(firstArray).arrayConcat( + fieldOrExpression(secondArray), + ...exprValues ); - return new ArrayConcat(arrayExpr, exprValues); } /** @@ -4171,14 +4339,14 @@ export function arrayConcat( * * ```typescript * // Check if the 'colors' array contains the value of field 'selectedColor' - * arrayContains(Field.of("colors"), Field.of("selectedColor")); + * arrayContains(field("colors"), field("selectedColor")); * ``` * * @param array The array expression to check. * @param element The element to search for in the array. * @return A new {@code Expr} representing the 'array_contains' comparison. */ -export function arrayContains(array: Expr, element: Expr): ArrayContains; +export function arrayContains(array: Expr, element: Expr): FunctionExpr; /** * @beta @@ -4187,14 +4355,14 @@ export function arrayContains(array: Expr, element: Expr): ArrayContains; * * ```typescript * // Check if the 'colors' array contains "red" - * arrayContains(Field.of("colors"), "red"); + * arrayContains(field("colors"), "red"); * ``` * * @param array The array expression to check. * @param element The element to search for in the array. * @return A new {@code Expr} representing the 'array_contains' comparison. */ -export function arrayContains(array: Expr, element: any): ArrayContains; +export function arrayContains(array: Expr, element: unknown): FunctionExpr; /** * @beta @@ -4203,14 +4371,14 @@ export function arrayContains(array: Expr, element: any): ArrayContains; * * ```typescript * // Check if the 'colors' array contains the value of field 'selectedColor' - * arrayContains("colors", Field.of("selectedColor")); + * arrayContains("colors", field("selectedColor")); * ``` * - * @param array The field name to check. + * @param fieldName The field name to check. * @param element The element to search for in the array. * @return A new {@code Expr} representing the 'array_contains' comparison. */ -export function arrayContains(array: string, element: Expr): ArrayContains; +export function arrayContains(fieldName: string, element: Expr): FunctionExpr; /** * @beta @@ -4222,18 +4390,18 @@ export function arrayContains(array: string, element: Expr): ArrayContains; * arrayContains("colors", "red"); * ``` * - * @param array The field name to check. + * @param fieldName The field name to check. * @param element The element to search for in the array. * @return A new {@code Expr} representing the 'array_contains' comparison. */ -export function arrayContains(array: string, element: any): ArrayContains; +export function arrayContains(fieldName: string, element: unknown): BooleanExpr; export function arrayContains( array: Expr | string, - element: any -): ArrayContains { - const arrayExpr = array instanceof Expr ? array : Field.of(array); - const elementExpr = element instanceof Expr ? element : Constant.of(element); - return new ArrayContains(arrayExpr, elementExpr); + element: unknown +): BooleanExpr { + const arrayExpr = fieldOrExpression(array); + const elementExpr = valueToDefaultExpr(element); + return arrayExpr.arrayContains(elementExpr); } /** @@ -4244,52 +4412,55 @@ export function arrayContains( * * ```typescript * // Check if the 'categories' array contains either values from field "cate1" or "Science" - * arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); + * arrayContainsAny(field("categories"), [field("cate1"), "Science"]); * ``` * * @param array The array expression to check. * @param values The elements to check for in the array. * @return A new {@code Expr} representing the 'array_contains_any' comparison. */ -export function arrayContainsAny(array: Expr, values: Expr[]): ArrayContainsAny; +export function arrayContainsAny( + array: Expr, + values: Array +): BooleanExpr; /** * @beta * - * Creates an expression that checks if an array expression contains any of the specified + * Creates an expression that checks if a field's array value contains any of the specified * elements. * * ```typescript - * // Check if the 'categories' array contains either values from field "cate1" or "Science" - * arrayContainsAny(Field.of("categories"), [Field.of("cate1"), "Science"]); + * // Check if the 'groups' array contains either the value from the 'userGroup' field + * // or the value "guest" + * arrayContainsAny("categories", [field("cate1"), "Science"]); * ``` * - * @param array The array expression to check. + * @param fieldName The field name to check. * @param values The elements to check for in the array. * @return A new {@code Expr} representing the 'array_contains_any' comparison. */ -export function arrayContainsAny(array: Expr, values: any[]): ArrayContainsAny; +export function arrayContainsAny( + fieldName: string, + values: Array +): BooleanExpr; /** * @beta * - * Creates an expression that checks if a field's array value contains any of the specified + * Creates an expression that checks if an array expression contains any of the specified * elements. * * ```typescript - * // Check if the 'groups' array contains either the value from the 'userGroup' field - * // or the value "guest" - * arrayContainsAny("categories", [Field.of("cate1"), "Science"]); + * // Check if the 'categories' array contains either values from field "cate1" or "Science" + * arrayContainsAny(field("categories"), array([field("cate1"), "Science"])); * ``` * - * @param array The field name to check. - * @param values The elements to check for in the array. + * @param array The array expression to check. + * @param values An expression that evaluates to an array, whose elements to check for in the array. * @return A new {@code Expr} representing the 'array_contains_any' comparison. */ -export function arrayContainsAny( - array: string, - values: Expr[] -): ArrayContainsAny; +export function arrayContainsAny(array: Expr, values: Expr): BooleanExpr; /** * @beta @@ -4300,26 +4471,20 @@ export function arrayContainsAny( * ```typescript * // Check if the 'groups' array contains either the value from the 'userGroup' field * // or the value "guest" - * arrayContainsAny("categories", [Field.of("cate1"), "Science"]); + * arrayContainsAny("categories", array([field("cate1"), "Science"])); * ``` * - * @param array The field name to check. - * @param values The elements to check for in the array. + * @param fieldName The field name to check. + * @param values An expression that evaluates to an array, whose elements to check for in the array field. * @return A new {@code Expr} representing the 'array_contains_any' comparison. */ -export function arrayContainsAny( - array: string, - values: any[] -): ArrayContainsAny; +export function arrayContainsAny(fieldName: string, values: Expr): BooleanExpr; export function arrayContainsAny( array: Expr | string, - values: any[] -): ArrayContainsAny { - const arrayExpr = array instanceof Expr ? array : Field.of(array); - const exprValues = values.map(value => - value instanceof Expr ? value : Constant.of(value) - ); - return new ArrayContainsAny(arrayExpr, exprValues); + values: unknown[] | Expr +): BooleanExpr { + // @ts-ignore implementation accepts both types + return fieldOrExpression(array).arrayContainsAny(values); } /** @@ -4329,50 +4494,56 @@ export function arrayContainsAny( * * ```typescript * // Check if the "tags" array contains all of the values: "SciFi", "Adventure", and the value from field "tag1" - * arrayContainsAll(Field.of("tags"), [Field.of("tag1"), Constant.of("SciFi"), Constant.of("Adventure")]); + * arrayContainsAll(field("tags"), [field("tag1"), constant("SciFi"), "Adventure"]); * ``` * * @param array The array expression to check. * @param values The elements to check for in the array. * @return A new {@code Expr} representing the 'array_contains_all' comparison. */ -export function arrayContainsAll(array: Expr, values: Expr[]): ArrayContainsAll; +export function arrayContainsAll( + array: Expr, + values: Array +): BooleanExpr; /** * @beta * - * Creates an expression that checks if an array expression contains all the specified elements. + * Creates an expression that checks if a field's array value contains all the specified values or + * expressions. * * ```typescript - * // Check if the "tags" array contains all of the values: "SciFi", "Adventure", and the value from field "tag1" - * arrayContainsAll(Field.of("tags"), [Field.of("tag1"), "SciFi", "Adventure"]); + * // Check if the 'tags' array contains both of the values from field 'tag1', the value "SciFi", and "Adventure" + * arrayContainsAll("tags", [field("tag1"), "SciFi", "Adventure"]); * ``` * - * @param array The array expression to check. + * @param fieldName The field name to check. * @param values The elements to check for in the array. * @return A new {@code Expr} representing the 'array_contains_all' comparison. */ -export function arrayContainsAll(array: Expr, values: any[]): ArrayContainsAll; +export function arrayContainsAll( + fieldName: string, + values: Array +): BooleanExpr; /** * @beta * - * Creates an expression that checks if a field's array value contains all the specified values or - * expressions. + * Creates an expression that checks if an array expression contains all the specified elements. * * ```typescript - * // Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" - * arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); + * // Check if the "tags" array contains all of the values: "SciFi", "Adventure", and the value from field "tag1" + * arrayContainsAll(field("tags"), [field("tag1"), constant("SciFi"), "Adventure"]); * ``` * - * @param array The field name to check. - * @param values The elements to check for in the array. + * @param array The array expression to check. + * @param arrayExpression The elements to check for in the array. * @return A new {@code Expr} representing the 'array_contains_all' comparison. */ export function arrayContainsAll( - array: string, - values: Expr[] -): ArrayContainsAll; + array: Expr, + arrayExpression: Expr +): BooleanExpr; /** * @beta @@ -4381,29 +4552,41 @@ export function arrayContainsAll( * expressions. * * ```typescript - * // Check if the 'tags' array contains both of the values from field 'tag1' and "tag2" - * arrayContainsAll("tags", [Field.of("tag1"), "SciFi", "Adventure"]); + * // Check if the 'tags' array contains both of the values from field 'tag1', the value "SciFi", and "Adventure" + * arrayContainsAll("tags", [field("tag1"), "SciFi", "Adventure"]); * ``` * - * @param array The field name to check. - * @param values The elements to check for in the array. + * @param fieldName The field name to check. + * @param arrayExpression The elements to check for in the array. * @return A new {@code Expr} representing the 'array_contains_all' comparison. */ export function arrayContainsAll( - array: string, - values: any[] -): ArrayContainsAll; + fieldName: string, + arrayExpression: Expr +): BooleanExpr; export function arrayContainsAll( array: Expr | string, - values: any[] -): ArrayContainsAll { - const arrayExpr = array instanceof Expr ? array : Field.of(array); - const exprValues = values.map(value => - value instanceof Expr ? value : Constant.of(value) - ); - return new ArrayContainsAll(arrayExpr, exprValues); + values: unknown[] | Expr +): BooleanExpr { + // @ts-ignore implementation accepts both types + return fieldOrExpression(array).arrayContainsAll(values); } +/** + * @beta + * + * Creates an expression that calculates the length of an array in a specified field. + * + * ```typescript + * // Get the number of items in field 'cart' + * arrayLength('cart'); + * ``` + * + * @param fieldName The name of the field containing an array to calculate the length of. + * @return A new {@code Expr} representing the length of the array. + */ +export function arrayLength(fieldName: string): FunctionExpr; + /** * @beta * @@ -4411,49 +4594,52 @@ export function arrayContainsAll( * * ```typescript * // Get the number of items in the 'cart' array - * arrayLength(Field.of("cart")); + * arrayLength(field("cart")); * ``` * * @param array The array expression to calculate the length of. * @return A new {@code Expr} representing the length of the array. */ -export function arrayLength(array: Expr): ArrayLength { - return new ArrayLength(array); +export function arrayLength(array: Expr): FunctionExpr; +export function arrayLength(array: Expr | string): FunctionExpr { + return fieldOrExpression(array).arrayLength(); } /** * @beta * - * Creates an expression that checks if an expression is equal to any of the provided values or + * Creates an expression that checks if an expression, when evaluated, is equal to any of the provided values or * expressions. * * ```typescript * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' - * eqAny(Field.of("category"), [Constant.of("Electronics"), Field.of("primaryType")]); + * eqAny(field("category"), [constant("Electronics"), field("primaryType")]); * ``` * - * @param element The expression to compare. - * @param others The values to check against. + * @param expression The expression whose results to compare. + * @param values The values to check against. * @return A new {@code Expr} representing the 'IN' comparison. */ -export function eqAny(element: Expr, others: Expr[]): EqAny; +export function eqAny( + expression: Expr, + values: Array +): BooleanExpr; /** * @beta * - * Creates an expression that checks if an expression is equal to any of the provided values or - * expressions. + * Creates an expression that checks if an expression is equal to any of the provided values. * * ```typescript - * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' - * eqAny(Field.of("category"), ["Electronics", Field.of("primaryType")]); + * // Check if the 'category' field is set to a value in the disabledCategories field + * eqAny(field("category"), field('disabledCategories')); * ``` * - * @param element The expression to compare. - * @param others The values to check against. + * @param expression The expression whose results to compare. + * @param arrayExpression An expression that evaluates to an array, whose elements to check for equality to the input. * @return A new {@code Expr} representing the 'IN' comparison. */ -export function eqAny(element: Expr, others: any[]): EqAny; +export function eqAny(expression: Expr, arrayExpression: Expr): BooleanExpr; /** * @beta @@ -4463,14 +4649,17 @@ export function eqAny(element: Expr, others: any[]): EqAny; * * ```typescript * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' - * eqAny("category", [Constant.of("Electronics"), Field.of("primaryType")]); + * eqAny("category", [constant("Electronics"), field("primaryType")]); * ``` * - * @param element The field to compare. - * @param others The values to check against. + * @param fieldName The field to compare. + * @param values The values to check against. * @return A new {@code Expr} representing the 'IN' comparison. */ -export function eqAny(element: string, others: Expr[]): EqAny; +export function eqAny( + fieldName: string, + values: Array +): BooleanExpr; /** * @beta @@ -4480,20 +4669,20 @@ export function eqAny(element: string, others: Expr[]): EqAny; * * ```typescript * // Check if the 'category' field is either "Electronics" or value of field 'primaryType' - * eqAny("category", ["Electronics", Field.of("primaryType")]); + * eqAny("category", ["Electronics", field("primaryType")]); * ``` * - * @param element The field to compare. - * @param others The values to check against. + * @param fieldName The field to compare. + * @param arrayExpression An expression that evaluates to an array, whose elements to check for equality to the input field. * @return A new {@code Expr} representing the 'IN' comparison. */ -export function eqAny(element: string, others: any[]): EqAny; -export function eqAny(element: Expr | string, others: any[]): EqAny { - const elementExpr = element instanceof Expr ? element : Field.of(element); - const exprOthers = others.map(other => - other instanceof Expr ? other : Constant.of(other) - ); - return new EqAny(elementExpr, exprOthers); +export function eqAny(fieldName: string, arrayExpression: Expr): BooleanExpr; +export function eqAny( + element: Expr | string, + values: unknown[] | Expr +): BooleanExpr { + // @ts-ignore implementation accepts both types + return fieldOrExpression(element).eqAny(values); } /** @@ -4504,78 +4693,83 @@ export function eqAny(element: Expr | string, others: any[]): EqAny { * * ```typescript * // Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' - * notEqAny(Field.of("status"), [Constant.of("pending"), Field.of("rejectedStatus")]); + * notEqAny(field("status"), ["pending", field("rejectedStatus")]); * ``` * * @param element The expression to compare. - * @param others The values to check against. + * @param values The values to check against. * @return A new {@code Expr} representing the 'NOT IN' comparison. */ -export function notEqAny(element: Expr, others: Expr[]): NotEqAny; +export function notEqAny( + element: Expr, + values: Array +): BooleanExpr; /** * @beta * - * Creates an expression that checks if an expression is not equal to any of the provided values + * Creates an expression that checks if a field's value is not equal to any of the provided values * or expressions. * * ```typescript * // Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' - * notEqAny(Field.of("status"), ["pending", Field.of("rejectedStatus")]); + * notEqAny("status", [constant("pending"), field("rejectedStatus")]); * ``` * - * @param element The expression to compare. - * @param others The values to check against. + * @param fieldName The field name to compare. + * @param values The values to check against. * @return A new {@code Expr} representing the 'NOT IN' comparison. */ -export function notEqAny(element: Expr, others: any[]): NotEqAny; +export function notEqAny( + fieldName: string, + values: Array +): BooleanExpr; /** * @beta * - * Creates an expression that checks if a field's value is not equal to any of the provided values + * Creates an expression that checks if an expression is not equal to any of the provided values * or expressions. * * ```typescript - * // Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' - * notEqAny("status", [Constant.of("pending"), Field.of("rejectedStatus")]); + * // Check if the 'status' field is neither "pending" nor the value of the field 'rejectedStatus' + * notEqAny(field("status"), ["pending", field("rejectedStatus")]); * ``` * - * @param element The field name to compare. - * @param others The values to check against. + * @param element The expression to compare. + * @param arrayExpression The values to check against. * @return A new {@code Expr} representing the 'NOT IN' comparison. */ -export function notEqAny(element: string, others: Expr[]): NotEqAny; +export function notEqAny(element: Expr, arrayExpression: Expr): BooleanExpr; /** * @beta * - * Creates an expression that checks if a field's value is not equal to any of the provided values - * or expressions. + * Creates an expression that checks if a field's value is not equal to any of the values in the evaluated expression. * * ```typescript - * // Check if the 'status' field is neither "pending" nor the value of 'rejectedStatus' - * notEqAny("status", ["pending", Field.of("rejectedStatus")]); + * // Check if the 'status' field is not equal to any value in the field 'rejectedStatuses' + * notEqAny("status", field("rejectedStatuses")); * ``` * - * @param element The field name to compare. - * @param others The values to check against. + * @param fieldName The field name to compare. + * @param arrayExpression The values to check against. * @return A new {@code Expr} representing the 'NOT IN' comparison. */ -export function notEqAny(element: string, others: any[]): NotEqAny; -export function notEqAny(element: Expr | string, others: any[]): NotEqAny { - const elementExpr = element instanceof Expr ? element : Field.of(element); - const exprOthers = others.map(other => - other instanceof Expr ? other : Constant.of(other) - ); - return new NotEqAny(elementExpr, exprOthers); +export function notEqAny(fieldName: string, arrayExpression: Expr): BooleanExpr; + +export function notEqAny( + element: Expr | string, + values: unknown[] | Expr +): BooleanExpr { + // @ts-ignore implementation accepts both types + return fieldOrExpression(element).notEqAny(values); } /** * @beta * - * Creates an expression that performs a logical 'XOR' (exclusive OR) operation on multiple filter - * conditions. + * Creates an expression that performs a logical 'XOR' (exclusive OR) operation on multiple BooleanExpressions. * * ```typescript * // Check if only one of the conditions is true: 'age' greater than 18, 'city' is "London", @@ -4586,12 +4780,17 @@ export function notEqAny(element: Expr | string, others: any[]): NotEqAny { * eq("status", "active")); * ``` * - * @param left The first filter condition. - * @param right Additional filter conditions to 'XOR' together. + * @param first The first condition. + * @param second The second condition. + * @param additionalConditions Additional conditions to 'XOR' together. * @return A new {@code Expr} representing the logical 'XOR' operation. */ -export function xor(left: FilterCondition, ...right: FilterCondition[]): Xor { - return new Xor([left, ...right]); +export function xor( + first: BooleanExpr, + second: BooleanExpr, + ...additionalConditions: BooleanExpr[] +): BooleanExpr { + return new BooleanExpr('xor', [first, second, ...additionalConditions]); } /** @@ -4603,7 +4802,7 @@ export function xor(left: FilterCondition, ...right: FilterCondition[]): Xor { * ```typescript * // If 'age' is greater than 18, return "Adult"; otherwise, return "Minor". * cond( - * gt("age", 18), Constant.of("Adult"), Constant.of("Minor")); + * gt("age", 18), constant("Adult"), constant("Minor")); * ``` * * @param condition The condition to evaluate. @@ -4612,11 +4811,11 @@ export function xor(left: FilterCondition, ...right: FilterCondition[]): Xor { * @return A new {@code Expr} representing the conditional expression. */ export function cond( - condition: FilterCondition, + condition: BooleanExpr, thenExpr: Expr, elseExpr: Expr -): Cond { - return new Cond(condition, thenExpr, elseExpr); +): FunctionExpr { + return new FunctionExpr('cond', [condition, thenExpr, elseExpr]); } /** @@ -4629,155 +4828,126 @@ export function cond( * not(eq("completed", true)); * ``` * - * @param filter The filter condition to negate. + * @param booleanExpr The filter condition to negate. * @return A new {@code Expr} representing the negated filter condition. */ -export function not(filter: FilterCondition): Not { - return new Not(filter); +export function not(booleanExpr: BooleanExpr): BooleanExpr { + return booleanExpr.not(); } /** * @beta * - * Creates an expression that returns the larger value between two expressions, based on Firestore's value type ordering. - * - * ```typescript - * // Returns the larger value between the 'field1' field and the 'field2' field. - * logicalMaximum(Field.of("field1"), Field.of("field2")); - * ``` - * - * @param left The left operand expression. - * @param right The right operand expression. - * @return A new {@code Expr} representing the logical max operation. - */ -export function logicalMaximum(left: Expr, right: Expr): LogicalMaximum; - -/** - * @beta - * - * Creates an expression that returns the larger value between an expression and a constant value, based on Firestore's value type ordering. + * Creates an expression that returns the largest value between multiple input + * expressions or literal values. Based on Firestore's value type ordering. * * ```typescript - * // Returns the larger value between the 'value' field and 10. - * logicalMaximum(Field.of("value"), 10); + * // Returns the largest value between the 'field1' field, the 'field2' field, + * // and 1000 + * logicalMaximum(field("field1"), field("field2"), 1000); * ``` * - * @param left The left operand expression. - * @param right The right operand constant. + * @param first The first operand expression. + * @param second The second expression or literal. + * @param others Optional additional expressions or literals. * @return A new {@code Expr} representing the logical max operation. */ -export function logicalMaximum(left: Expr, right: any): LogicalMaximum; +export function logicalMaximum( + first: Expr, + second: Expr | unknown, + ...others: Array +): FunctionExpr; /** * @beta * - * Creates an expression that returns the larger value between a field and an expression, based on Firestore's value type ordering. + * Creates an expression that returns the largest value between multiple input + * expressions or literal values. Based on Firestore's value type ordering. * * ```typescript - * // Returns the larger value between the 'field1' field and the 'field2' field. - * logicalMaximum("field1", Field.of('field2')); + * // Returns the largest value between the 'field1' field, the 'field2' field, + * // and 1000. + * logicalMaximum("field1", field("field2"), 1000); * ``` * - * @param left The left operand field name. - * @param right The right operand expression. + * @param fieldName The first operand field name. + * @param second The second expression or literal. + * @param others Optional additional expressions or literals. * @return A new {@code Expr} representing the logical max operation. */ -export function logicalMaximum(left: string, right: Expr): LogicalMaximum; +export function logicalMaximum( + fieldName: string, + second: Expr | unknown, + ...others: Array +): FunctionExpr; -/** - * @beta - * - * Creates an expression that returns the larger value between a field and a constant value, based on Firestore's value type ordering. - * - * ```typescript - * // Returns the larger value between the 'value' field and 10. - * logicalMaximum("value", 10); - * ``` - * - * @param left The left operand field name. - * @param right The right operand constant. - * @return A new {@code Expr} representing the logical max operation. - */ -export function logicalMaximum(left: string, right: any): LogicalMaximum; export function logicalMaximum( - left: Expr | string, - right: Expr | any -): LogicalMaximum { - const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; - const normalizedRight = right instanceof Expr ? right : Constant.of(right); - return new LogicalMaximum(normalizedLeft, normalizedRight); + first: Expr | string, + second: Expr | unknown, + ...others: Array +): FunctionExpr { + return fieldOrExpression(first).logicalMaximum( + valueToDefaultExpr(second), + ...others.map(value => valueToDefaultExpr(value)) + ); } /** * @beta * - * Creates an expression that returns the smaller value between two expressions, based on Firestore's value type ordering. - * - * ```typescript - * // Returns the smaller value between the 'field1' field and the 'field2' field. - * logicalMinimum(Field.of("field1"), Field.of("field2")); - * ``` - * - * @param left The left operand expression. - * @param right The right operand expression. - * @return A new {@code Expr} representing the logical min operation. - */ -export function logicalMinimum(left: Expr, right: Expr): LogicalMinimum; - -/** - * @beta - * - * Creates an expression that returns the smaller value between an expression and a constant value, based on Firestore's value type ordering. + * Creates an expression that returns the smallest value between multiple input + * expressions and literal values. Based on Firestore's value type ordering. * * ```typescript - * // Returns the smaller value between the 'value' field and 10. - * logicalMinimum(Field.of("value"), 10); + * // Returns the smallest value between the 'field1' field, the 'field2' field, + * // and 1000. + * logicalMinimum(field("field1"), field("field2"), 1000); * ``` * - * @param left The left operand expression. - * @param right The right operand constant. + * @param first The first operand expression. + * @param second The second expression or literal. + * @param others Optional additional expressions or literals. * @return A new {@code Expr} representing the logical min operation. */ -export function logicalMinimum(left: Expr, right: any): LogicalMinimum; +export function logicalMinimum( + first: Expr, + second: Expr | unknown, + ...others: Array +): FunctionExpr; /** * @beta * - * Creates an expression that returns the smaller value between a field and an expression, based on Firestore's value type ordering. + * Creates an expression that returns the smallest value between a field's value + * and other input expressions or literal values. + * Based on Firestore's value type ordering. * * ```typescript - * // Returns the smaller value between the 'field1' field and the 'field2' field. - * logicalMinimum("field1", Field.of("field2")); + * // Returns the smallest value between the 'field1' field, the 'field2' field, + * // and 1000. + * logicalMinimum("field1", field("field2"), 1000); * ``` * - * @param left The left operand field name. - * @param right The right operand expression. + * @param fieldName The first operand field name. + * @param second The second expression or literal. + * @param others Optional additional expressions or literals. * @return A new {@code Expr} representing the logical min operation. */ -export function logicalMinimum(left: string, right: Expr): LogicalMinimum; +export function logicalMinimum( + fieldName: string, + second: Expr | unknown, + ...others: Array +): FunctionExpr; -/** - * @beta - * - * Creates an expression that returns the smaller value between a field and a constant value, based on Firestore's value type ordering. - * - * ```typescript - * // Returns the smaller value between the 'value' field and 10. - * logicalMinimum("value", 10); - * ``` - * - * @param left The left operand field name. - * @param right The right operand constant. - * @return A new {@code Expr} representing the logical min operation. - */ -export function logicalMinimum(left: string, right: any): LogicalMinimum; export function logicalMinimum( - left: Expr | string, - right: Expr | any -): LogicalMinimum { - const normalizedLeft = typeof left === 'string' ? Field.of(left) : left; - const normalizedRight = right instanceof Expr ? right : Constant.of(right); - return new LogicalMinimum(normalizedLeft, normalizedRight); + first: Expr | string, + second: Expr | unknown, + ...others: Array +): FunctionExpr { + return fieldOrExpression(first).logicalMinimum( + valueToDefaultExpr(second), + ...others.map(value => valueToDefaultExpr(value)) + ); } /** @@ -4787,13 +4957,13 @@ export function logicalMinimum( * * ```typescript * // Check if the document has a field named "phoneNumber" - * exists(Field.of("phoneNumber")); + * exists(field("phoneNumber")); * ``` * * @param value An expression evaluates to the name of the field to check. * @return A new {@code Expr} representing the 'exists' check. */ -export function exists(value: Expr): Exists; +export function exists(value: Expr): BooleanExpr; /** * @beta @@ -4805,14 +4975,12 @@ export function exists(value: Expr): Exists; * exists("phoneNumber"); * ``` * - * @param field The field name to check. + * @param fieldName The field name to check. * @return A new {@code Expr} representing the 'exists' check. */ -export function exists(field: string): Exists; -export function exists(valueOrField: Expr | string): Exists { - const valueExpr = - valueOrField instanceof Expr ? valueOrField : Field.of(valueOrField); - return new Exists(valueExpr); +export function exists(fieldName: string): BooleanExpr; +export function exists(valueOrField: Expr | string): BooleanExpr { + return fieldOrExpression(valueOrField).exists(); } /** @@ -4822,13 +4990,13 @@ export function exists(valueOrField: Expr | string): Exists { * * ```typescript * // Check if the result of a calculation is NaN - * isNaN(Field.of("value").divide(0)); + * isNaN(field("value").divide(0)); * ``` * * @param value The expression to check. * @return A new {@code Expr} representing the 'isNaN' check. */ -export function isNan(value: Expr): IsNan; +export function isNan(value: Expr): BooleanExpr; /** * @beta @@ -4840,13 +5008,12 @@ export function isNan(value: Expr): IsNan; * isNaN("value"); * ``` * - * @param value The name of the field to check. + * @param fieldName The name of the field to check. * @return A new {@code Expr} representing the 'isNaN' check. */ -export function isNan(value: string): IsNan; -export function isNan(value: Expr | string): IsNan { - const valueExpr = value instanceof Expr ? value : Field.of(value); - return new IsNan(valueExpr); +export function isNan(fieldName: string): BooleanExpr; +export function isNan(value: Expr | string): BooleanExpr { + return fieldOrExpression(value).isNan(); } /** @@ -4856,18 +5023,18 @@ export function isNan(value: Expr | string): IsNan { * * ```typescript * // Reverse the value of the 'myString' field. - * reverse(Field.of("myString")); + * reverse(field("myString")); * ``` * - * @param expr The expression representing the string to reverse. + * @param stringExpression An expression evaluating to a string value, which will be reversed. * @return A new {@code Expr} representing the reversed string. */ -export function reverse(expr: Expr): Reverse; +export function reverse(stringExpression: Expr): FunctionExpr; /** * @beta * - * Creates an expression that reverses a string represented by a field. + * Creates an expression that reverses a string value in the specified field. * * ```typescript * // Reverse the value of the 'myString' field. @@ -4877,10 +5044,9 @@ export function reverse(expr: Expr): Reverse; * @param field The name of the field representing the string to reverse. * @return A new {@code Expr} representing the reversed string. */ -export function reverse(field: string): Reverse; -export function reverse(expr: Expr | string): Reverse { - const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; - return new Reverse(normalizedExpr); +export function reverse(field: string): FunctionExpr; +export function reverse(expr: Expr | string): FunctionExpr { + return fieldOrExpression(expr).reverse(); } /** @@ -4890,7 +5056,7 @@ export function reverse(expr: Expr | string): Reverse { * * ```typescript * // Replace the first occurrence of "hello" with "hi" in the 'message' field. - * replaceFirst(Field.of("message"), "hello", "hi"); + * replaceFirst(field("message"), "hello", "hi"); * ``` * * @param value The expression representing the string to perform the replacement on. @@ -4902,7 +5068,7 @@ export function replaceFirst( value: Expr, find: string, replace: string -): ReplaceFirst; +): FunctionExpr; /** * @beta @@ -4912,7 +5078,7 @@ export function replaceFirst( * * ```typescript * // Replace the first occurrence of the value in 'findField' with the value in 'replaceField' in the 'message' field. - * replaceFirst(Field.of("message"), Field.of("findField"), Field.of("replaceField")); + * replaceFirst(field("message"), field("findField"), field("replaceField")); * ``` * * @param value The expression representing the string to perform the replacement on. @@ -4924,7 +5090,7 @@ export function replaceFirst( value: Expr, find: Expr, replace: Expr -): ReplaceFirst; +): FunctionExpr; /** * @beta @@ -4936,26 +5102,25 @@ export function replaceFirst( * replaceFirst("message", "hello", "hi"); * ``` * - * @param field The name of the field representing the string to perform the replacement on. + * @param fieldName The name of the field representing the string to perform the replacement on. * @param find The substring to search for. * @param replace The substring to replace the first occurrence of 'find' with. * @return A new {@code Expr} representing the string with the first occurrence replaced. */ export function replaceFirst( - field: string, + fieldName: string, find: string, replace: string -): ReplaceFirst; +): FunctionExpr; export function replaceFirst( value: Expr | string, find: Expr | string, replace: Expr | string -): ReplaceFirst { - const normalizedValue = typeof value === 'string' ? Field.of(value) : value; - const normalizedFind = typeof find === 'string' ? Constant.of(find) : find; - const normalizedReplace = - typeof replace === 'string' ? Constant.of(replace) : replace; - return new ReplaceFirst(normalizedValue, normalizedFind, normalizedReplace); +): FunctionExpr { + const normalizedValue = fieldOrExpression(value); + const normalizedFind = valueToDefaultExpr(find); + const normalizedReplace = valueToDefaultExpr(replace); + return normalizedValue.replaceFirst(normalizedFind, normalizedReplace); } /** @@ -4965,7 +5130,7 @@ export function replaceFirst( * * ```typescript * // Replace all occurrences of "hello" with "hi" in the 'message' field. - * replaceAll(Field.of("message"), "hello", "hi"); + * replaceAll(field("message"), "hello", "hi"); * ``` * * @param value The expression representing the string to perform the replacement on. @@ -4977,7 +5142,7 @@ export function replaceAll( value: Expr, find: string, replace: string -): ReplaceAll; +): FunctionExpr; /** * @beta @@ -4987,7 +5152,7 @@ export function replaceAll( * * ```typescript * // Replace all occurrences of the value in 'findField' with the value in 'replaceField' in the 'message' field. - * replaceAll(Field.of("message"), Field.of("findField"), Field.of("replaceField")); + * replaceAll(field("message"), field("findField"), field("replaceField")); * ``` * * @param value The expression representing the string to perform the replacement on. @@ -4995,7 +5160,11 @@ export function replaceAll( * @param replace The expression representing the substring to replace all occurrences of 'find' with. * @return A new {@code Expr} representing the string with all occurrences replaced. */ -export function replaceAll(value: Expr, find: Expr, replace: Expr): ReplaceAll; +export function replaceAll( + value: Expr, + find: Expr, + replace: Expr +): FunctionExpr; /** * @beta @@ -5007,26 +5176,25 @@ export function replaceAll(value: Expr, find: Expr, replace: Expr): ReplaceAll; * replaceAll("message", "hello", "hi"); * ``` * - * @param field The name of the field representing the string to perform the replacement on. + * @param fieldName The name of the field representing the string to perform the replacement on. * @param find The substring to search for. * @param replace The substring to replace all occurrences of 'find' with. * @return A new {@code Expr} representing the string with all occurrences replaced. */ export function replaceAll( - field: string, + fieldName: string, find: string, replace: string -): ReplaceAll; +): FunctionExpr; export function replaceAll( value: Expr | string, find: Expr | string, replace: Expr | string -): ReplaceAll { - const normalizedValue = typeof value === 'string' ? Field.of(value) : value; - const normalizedFind = typeof find === 'string' ? Constant.of(find) : find; - const normalizedReplace = - typeof replace === 'string' ? Constant.of(replace) : replace; - return new ReplaceAll(normalizedValue, normalizedFind, normalizedReplace); +): FunctionExpr { + const normalizedValue = fieldOrExpression(value); + const normalizedFind = valueToDefaultExpr(find); + const normalizedReplace = valueToDefaultExpr(replace); + return normalizedValue.replaceAll(normalizedFind, normalizedReplace); } /** @@ -5036,13 +5204,13 @@ export function replaceAll( * * ```typescript * // Calculate the length of the 'myString' field in bytes. - * byteLength(Field.of("myString")); + * byteLength(field("myString")); * ``` * * @param expr The expression representing the string. * @return A new {@code Expr} representing the length of the string in bytes. */ -export function byteLength(expr: Expr): ByteLength; +export function byteLength(expr: Expr): FunctionExpr; /** * @beta @@ -5054,13 +5222,13 @@ export function byteLength(expr: Expr): ByteLength; * byteLength("myString"); * ``` * - * @param field The name of the field representing the string. + * @param fieldName The name of the field containing the string. * @return A new {@code Expr} representing the length of the string in bytes. */ -export function byteLength(field: string): ByteLength; -export function byteLength(expr: Expr | string): ByteLength { - const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; - return new ByteLength(normalizedExpr); +export function byteLength(fieldName: string): FunctionExpr; +export function byteLength(expr: Expr | string): FunctionExpr { + const normalizedExpr = fieldOrExpression(expr); + return normalizedExpr.byteLength(); } /** @@ -5073,10 +5241,10 @@ export function byteLength(expr: Expr | string): ByteLength { * strLength("name"); * ``` * - * @param field The name of the field containing the string. + * @param fieldName The name of the field containing the string. * @return A new {@code Expr} representing the length of the string. */ -export function charLength(field: string): CharLength; +export function charLength(fieldName: string): FunctionExpr; /** * @beta @@ -5085,16 +5253,16 @@ export function charLength(field: string): CharLength; * * ```typescript * // Get the character length of the 'name' field in UTF-8. - * strLength(Field.of("name")); + * strLength(field("name")); * ``` * - * @param expr The expression representing the string to calculate the length of. + * @param stringExpression The expression representing the string to calculate the length of. * @return A new {@code Expr} representing the length of the string. */ -export function charLength(expr: Expr): CharLength; -export function charLength(value: Expr | string): CharLength { - const valueExpr = value instanceof Expr ? value : Field.of(value); - return new CharLength(valueExpr); +export function charLength(stringExpression: Expr): FunctionExpr; +export function charLength(value: Expr | string): FunctionExpr { + const valueExpr = fieldOrExpression(value); + return valueExpr.charLength(); } /** @@ -5108,11 +5276,11 @@ export function charLength(value: Expr | string): CharLength { * like("title", "%guide%"); * ``` * - * @param left The name of the field containing the string. + * @param fieldName The name of the field containing the string. * @param pattern The pattern to search for. You can use "%" as a wildcard character. * @return A new {@code Expr} representing the 'like' comparison. */ -export function like(left: string, pattern: string): Like; +export function like(fieldName: string, pattern: string): BooleanExpr; /** * @beta @@ -5122,14 +5290,14 @@ export function like(left: string, pattern: string): Like; * * ```typescript * // Check if the 'title' field contains the string "guide" - * like("title", Field.of("pattern")); + * like("title", field("pattern")); * ``` * - * @param left The name of the field containing the string. + * @param fieldName The name of the field containing the string. * @param pattern The pattern to search for. You can use "%" as a wildcard character. * @return A new {@code Expr} representing the 'like' comparison. */ -export function like(left: string, pattern: Expr): Like; +export function like(fieldName: string, pattern: Expr): BooleanExpr; /** * @beta @@ -5138,14 +5306,14 @@ export function like(left: string, pattern: Expr): Like; * * ```typescript * // Check if the 'title' field contains the string "guide" - * like(Field.of("title"), "%guide%"); + * like(field("title"), "%guide%"); * ``` * - * @param left The expression representing the string to perform the comparison on. + * @param stringExpression The expression representing the string to perform the comparison on. * @param pattern The pattern to search for. You can use "%" as a wildcard character. * @return A new {@code Expr} representing the 'like' comparison. */ -export function like(left: Expr, pattern: string): Like; +export function like(stringExpression: Expr, pattern: string): BooleanExpr; /** * @beta @@ -5154,18 +5322,21 @@ export function like(left: Expr, pattern: string): Like; * * ```typescript * // Check if the 'title' field contains the string "guide" - * like(Field.of("title"), Field.of("pattern")); + * like(field("title"), field("pattern")); * ``` * - * @param left The expression representing the string to perform the comparison on. + * @param stringExpression The expression representing the string to perform the comparison on. * @param pattern The pattern to search for. You can use "%" as a wildcard character. * @return A new {@code Expr} representing the 'like' comparison. */ -export function like(left: Expr, pattern: Expr): Like; -export function like(left: Expr | string, pattern: Expr | string): Like { - const leftExpr = left instanceof Expr ? left : Field.of(left); - const patternExpr = pattern instanceof Expr ? pattern : Constant.of(pattern); - return new Like(leftExpr, patternExpr); +export function like(stringExpression: Expr, pattern: Expr): BooleanExpr; +export function like( + left: Expr | string, + pattern: Expr | string +): FunctionExpr { + const leftExpr = fieldOrExpression(left); + const patternExpr = valueToDefaultExpr(pattern); + return leftExpr.like(patternExpr); } /** @@ -5179,11 +5350,11 @@ export function like(left: Expr | string, pattern: Expr | string): Like { * regexContains("description", "(?i)example"); * ``` * - * @param left The name of the field containing the string. + * @param fieldName The name of the field containing the string. * @param pattern The regular expression to use for the search. * @return A new {@code Expr} representing the 'contains' comparison. */ -export function regexContains(left: string, pattern: string): RegexContains; +export function regexContains(fieldName: string, pattern: string): BooleanExpr; /** * @beta @@ -5193,14 +5364,14 @@ export function regexContains(left: string, pattern: string): RegexContains; * * ```typescript * // Check if the 'description' field contains "example" (case-insensitive) - * regexContains("description", Field.of("pattern")); + * regexContains("description", field("pattern")); * ``` * - * @param left The name of the field containing the string. + * @param fieldName The name of the field containing the string. * @param pattern The regular expression to use for the search. * @return A new {@code Expr} representing the 'contains' comparison. */ -export function regexContains(left: string, pattern: Expr): RegexContains; +export function regexContains(fieldName: string, pattern: Expr): BooleanExpr; /** * @beta @@ -5210,14 +5381,17 @@ export function regexContains(left: string, pattern: Expr): RegexContains; * * ```typescript * // Check if the 'description' field contains "example" (case-insensitive) - * regexContains(Field.of("description"), "(?i)example"); + * regexContains(field("description"), "(?i)example"); * ``` * - * @param left The expression representing the string to perform the comparison on. + * @param stringExpression The expression representing the string to perform the comparison on. * @param pattern The regular expression to use for the search. * @return A new {@code Expr} representing the 'contains' comparison. */ -export function regexContains(left: Expr, pattern: string): RegexContains; +export function regexContains( + stringExpression: Expr, + pattern: string +): BooleanExpr; /** * @beta @@ -5227,21 +5401,24 @@ export function regexContains(left: Expr, pattern: string): RegexContains; * * ```typescript * // Check if the 'description' field contains "example" (case-insensitive) - * regexContains(Field.of("description"), Field.of("pattern")); + * regexContains(field("description"), field("pattern")); * ``` * - * @param left The expression representing the string to perform the comparison on. + * @param stringExpression The expression representing the string to perform the comparison on. * @param pattern The regular expression to use for the search. * @return A new {@code Expr} representing the 'contains' comparison. */ -export function regexContains(left: Expr, pattern: Expr): RegexContains; +export function regexContains( + stringExpression: Expr, + pattern: Expr +): BooleanExpr; export function regexContains( left: Expr | string, pattern: Expr | string -): RegexContains { - const leftExpr = left instanceof Expr ? left : Field.of(left); - const patternExpr = pattern instanceof Expr ? pattern : Constant.of(pattern); - return new RegexContains(leftExpr, patternExpr); +): BooleanExpr { + const leftExpr = fieldOrExpression(left); + const patternExpr = valueToDefaultExpr(pattern); + return leftExpr.regexContains(patternExpr); } /** @@ -5254,11 +5431,11 @@ export function regexContains( * regexMatch("email", "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); * ``` * - * @param left The name of the field containing the string. + * @param fieldName The name of the field containing the string. * @param pattern The regular expression to use for the match. * @return A new {@code Expr} representing the regular expression match. */ -export function regexMatch(left: string, pattern: string): RegexMatch; +export function regexMatch(fieldName: string, pattern: string): BooleanExpr; /** * @beta @@ -5267,14 +5444,14 @@ export function regexMatch(left: string, pattern: string): RegexMatch; * * ```typescript * // Check if the 'email' field matches a valid email pattern - * regexMatch("email", Field.of("pattern")); + * regexMatch("email", field("pattern")); * ``` * - * @param left The name of the field containing the string. + * @param fieldName The name of the field containing the string. * @param pattern The regular expression to use for the match. * @return A new {@code Expr} representing the regular expression match. */ -export function regexMatch(left: string, pattern: Expr): RegexMatch; +export function regexMatch(fieldName: string, pattern: Expr): BooleanExpr; /** * @beta @@ -5284,14 +5461,17 @@ export function regexMatch(left: string, pattern: Expr): RegexMatch; * * ```typescript * // Check if the 'email' field matches a valid email pattern - * regexMatch(Field.of("email"), "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); + * regexMatch(field("email"), "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"); * ``` * - * @param left The expression representing the string to match against. + * @param stringExpression The expression representing the string to match against. * @param pattern The regular expression to use for the match. * @return A new {@code Expr} representing the regular expression match. */ -export function regexMatch(left: Expr, pattern: string): RegexMatch; +export function regexMatch( + stringExpression: Expr, + pattern: string +): BooleanExpr; /** * @beta @@ -5301,21 +5481,21 @@ export function regexMatch(left: Expr, pattern: string): RegexMatch; * * ```typescript * // Check if the 'email' field matches a valid email pattern - * regexMatch(Field.of("email"), Field.of("pattern")); + * regexMatch(field("email"), field("pattern")); * ``` * - * @param left The expression representing the string to match against. + * @param stringExpression The expression representing the string to match against. * @param pattern The regular expression to use for the match. * @return A new {@code Expr} representing the regular expression match. */ -export function regexMatch(left: Expr, pattern: Expr): RegexMatch; +export function regexMatch(stringExpression: Expr, pattern: Expr): BooleanExpr; export function regexMatch( left: Expr | string, pattern: Expr | string -): RegexMatch { - const leftExpr = left instanceof Expr ? left : Field.of(left); - const patternExpr = pattern instanceof Expr ? pattern : Constant.of(pattern); - return new RegexMatch(leftExpr, patternExpr); +): BooleanExpr { + const leftExpr = fieldOrExpression(left); + const patternExpr = valueToDefaultExpr(pattern); + return leftExpr.regexMatch(patternExpr); } /** @@ -5328,11 +5508,11 @@ export function regexMatch( * strContains("description", "example"); * ``` * - * @param left The name of the field containing the string. + * @param fieldName The name of the field containing the string. * @param substring The substring to search for. * @return A new {@code Expr} representing the 'contains' comparison. */ -export function strContains(left: string, substring: string): StrContains; +export function strContains(fieldName: string, substring: string): BooleanExpr; /** * @beta @@ -5341,14 +5521,14 @@ export function strContains(left: string, substring: string): StrContains; * * ```typescript * // Check if the 'description' field contains the value of the 'keyword' field. - * strContains("description", Field.of("keyword")); + * strContains("description", field("keyword")); * ``` * - * @param left The name of the field containing the string. + * @param fieldName The name of the field containing the string. * @param substring The expression representing the substring to search for. * @return A new {@code Expr} representing the 'contains' comparison. */ -export function strContains(left: string, substring: Expr): StrContains; +export function strContains(fieldName: string, substring: Expr): BooleanExpr; /** * @beta @@ -5357,14 +5537,17 @@ export function strContains(left: string, substring: Expr): StrContains; * * ```typescript * // Check if the 'description' field contains "example". - * strContains(Field.of("description"), "example"); + * strContains(field("description"), "example"); * ``` * - * @param left The expression representing the string to perform the comparison on. + * @param stringExpression The expression representing the string to perform the comparison on. * @param substring The substring to search for. * @return A new {@code Expr} representing the 'contains' comparison. */ -export function strContains(left: Expr, substring: string): StrContains; +export function strContains( + stringExpression: Expr, + substring: string +): BooleanExpr; /** * @beta @@ -5373,22 +5556,24 @@ export function strContains(left: Expr, substring: string): StrContains; * * ```typescript * // Check if the 'description' field contains the value of the 'keyword' field. - * strContains(Field.of("description"), Field.of("keyword")); + * strContains(field("description"), field("keyword")); * ``` * - * @param left The expression representing the string to perform the comparison on. + * @param stringExpression The expression representing the string to perform the comparison on. * @param substring The expression representing the substring to search for. * @return A new {@code Expr} representing the 'contains' comparison. */ -export function strContains(left: Expr, substring: Expr): StrContains; +export function strContains( + stringExpression: Expr, + substring: Expr +): BooleanExpr; export function strContains( left: Expr | string, substring: Expr | string -): StrContains { - const leftExpr = left instanceof Expr ? left : Field.of(left); - const substringExpr = - substring instanceof Expr ? substring : Constant.of(substring); - return new StrContains(leftExpr, substringExpr); +): BooleanExpr { + const leftExpr = fieldOrExpression(left); + const substringExpr = valueToDefaultExpr(substring); + return leftExpr.strContains(substringExpr); } /** @@ -5401,11 +5586,11 @@ export function strContains( * startsWith("name", "Mr."); * ``` * - * @param expr The field name to check. + * @param fieldName The field name to check. * @param prefix The prefix to check for. * @return A new {@code Expr} representing the 'starts with' comparison. */ -export function startsWith(expr: string, prefix: string): StartsWith; +export function startsWith(fieldName: string, prefix: string): BooleanExpr; /** * @beta @@ -5414,14 +5599,14 @@ export function startsWith(expr: string, prefix: string): StartsWith; * * ```typescript * // Check if the 'fullName' field starts with the value of the 'firstName' field - * startsWith("fullName", Field.of("firstName")); + * startsWith("fullName", field("firstName")); * ``` * - * @param expr The field name to check. + * @param fieldName The field name to check. * @param prefix The expression representing the prefix. * @return A new {@code Expr} representing the 'starts with' comparison. */ -export function startsWith(expr: string, prefix: Expr): StartsWith; +export function startsWith(fieldName: string, prefix: Expr): BooleanExpr; /** * @beta @@ -5430,14 +5615,14 @@ export function startsWith(expr: string, prefix: Expr): StartsWith; * * ```typescript * // Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." - * startsWith(Field.of("fullName"), "Mr."); + * startsWith(field("fullName"), "Mr."); * ``` * - * @param expr The expression to check. + * @param stringExpression The expression to check. * @param prefix The prefix to check for. * @return A new {@code Expr} representing the 'starts with' comparison. */ -export function startsWith(expr: Expr, prefix: string): StartsWith; +export function startsWith(stringExpression: Expr, prefix: string): BooleanExpr; /** * @beta @@ -5446,21 +5631,19 @@ export function startsWith(expr: Expr, prefix: string): StartsWith; * * ```typescript * // Check if the result of concatenating 'firstName' and 'lastName' fields starts with "Mr." - * startsWith(Field.of("fullName"), Field.of("prefix")); + * startsWith(field("fullName"), field("prefix")); * ``` * - * @param expr The expression to check. + * @param stringExpression The expression to check. * @param prefix The prefix to check for. * @return A new {@code Expr} representing the 'starts with' comparison. */ -export function startsWith(expr: Expr, prefix: Expr): StartsWith; +export function startsWith(stringExpression: Expr, prefix: Expr): BooleanExpr; export function startsWith( expr: Expr | string, prefix: Expr | string -): StartsWith { - const exprLeft = expr instanceof Expr ? expr : Field.of(expr); - const prefixExpr = prefix instanceof Expr ? prefix : Constant.of(prefix); - return new StartsWith(exprLeft, prefixExpr); +): BooleanExpr { + return fieldOrExpression(expr).startsWith(valueToDefaultExpr(prefix)); } /** @@ -5473,11 +5656,11 @@ export function startsWith( * endsWith("filename", ".txt"); * ``` * - * @param expr The field name to check. + * @param fieldName The field name to check. * @param suffix The postfix to check for. * @return A new {@code Expr} representing the 'ends with' comparison. */ -export function endsWith(expr: string, suffix: string): EndsWith; +export function endsWith(fieldName: string, suffix: string): BooleanExpr; /** * @beta @@ -5486,14 +5669,14 @@ export function endsWith(expr: string, suffix: string): EndsWith; * * ```typescript * // Check if the 'url' field ends with the value of the 'extension' field - * endsWith("url", Field.of("extension")); + * endsWith("url", field("extension")); * ``` * - * @param expr The field name to check. + * @param fieldName The field name to check. * @param suffix The expression representing the postfix. * @return A new {@code Expr} representing the 'ends with' comparison. */ -export function endsWith(expr: string, suffix: Expr): EndsWith; +export function endsWith(fieldName: string, suffix: Expr): BooleanExpr; /** * @beta @@ -5502,14 +5685,14 @@ export function endsWith(expr: string, suffix: Expr): EndsWith; * * ```typescript * // Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." - * endsWith(Field.of("fullName"), "Jr."); + * endsWith(field("fullName"), "Jr."); * ``` * - * @param expr The expression to check. + * @param stringExpression The expression to check. * @param suffix The postfix to check for. * @return A new {@code Expr} representing the 'ends with' comparison. */ -export function endsWith(expr: Expr, suffix: string): EndsWith; +export function endsWith(stringExpression: Expr, suffix: string): BooleanExpr; /** * @beta @@ -5518,18 +5701,19 @@ export function endsWith(expr: Expr, suffix: string): EndsWith; * * ```typescript * // Check if the result of concatenating 'firstName' and 'lastName' fields ends with "Jr." - * endsWith(Field.of("fullName"), Constant.of("Jr.")); + * endsWith(field("fullName"), constant("Jr.")); * ``` * - * @param expr The expression to check. + * @param stringExpression The expression to check. * @param suffix The postfix to check for. * @return A new {@code Expr} representing the 'ends with' comparison. */ -export function endsWith(expr: Expr, suffix: Expr): EndsWith; -export function endsWith(expr: Expr | string, suffix: Expr | string): EndsWith { - const exprLeft = expr instanceof Expr ? expr : Field.of(expr); - const suffixExpr = suffix instanceof Expr ? suffix : Constant.of(suffix); - return new EndsWith(exprLeft, suffixExpr); +export function endsWith(stringExpression: Expr, suffix: Expr): BooleanExpr; +export function endsWith( + expr: Expr | string, + suffix: Expr | string +): BooleanExpr { + return fieldOrExpression(expr).endsWith(valueToDefaultExpr(suffix)); } /** @@ -5542,10 +5726,10 @@ export function endsWith(expr: Expr | string, suffix: Expr | string): EndsWith { * toLower("name"); * ``` * - * @param expr The name of the field containing the string. + * @param fieldName The name of the field containing the string. * @return A new {@code Expr} representing the lowercase string. */ -export function toLower(expr: string): ToLower; +export function toLower(fieldName: string): FunctionExpr; /** * @beta @@ -5554,15 +5738,15 @@ export function toLower(expr: string): ToLower; * * ```typescript * // Convert the 'name' field to lowercase - * toLower(Field.of("name")); + * toLower(field("name")); * ``` * - * @param expr The expression representing the string to convert to lowercase. + * @param stringExpression The expression representing the string to convert to lowercase. * @return A new {@code Expr} representing the lowercase string. */ -export function toLower(expr: Expr): ToLower; -export function toLower(expr: Expr | string): ToLower { - return new ToLower(expr instanceof Expr ? expr : Field.of(expr)); +export function toLower(stringExpression: Expr): FunctionExpr; +export function toLower(expr: Expr | string): FunctionExpr { + return fieldOrExpression(expr).toLower(); } /** @@ -5575,10 +5759,10 @@ export function toLower(expr: Expr | string): ToLower { * toUpper("title"); * ``` * - * @param expr The name of the field containing the string. + * @param fieldName The name of the field containing the string. * @return A new {@code Expr} representing the uppercase string. */ -export function toUpper(expr: string): ToUpper; +export function toUpper(fieldName: string): FunctionExpr; /** * @beta @@ -5587,15 +5771,15 @@ export function toUpper(expr: string): ToUpper; * * ```typescript * // Convert the 'title' field to uppercase - * toUppercase(Field.of("title")); + * toUppercase(field("title")); * ``` * - * @param expr The expression representing the string to convert to uppercase. + * @param stringExpression The expression representing the string to convert to uppercase. * @return A new {@code Expr} representing the uppercase string. */ -export function toUpper(expr: Expr): ToUpper; -export function toUpper(expr: Expr | string): ToUpper { - return new ToUpper(expr instanceof Expr ? expr : Field.of(expr)); +export function toUpper(stringExpression: Expr): FunctionExpr; +export function toUpper(expr: Expr | string): FunctionExpr { + return fieldOrExpression(expr).toUpper(); } /** @@ -5608,10 +5792,10 @@ export function toUpper(expr: Expr | string): ToUpper { * trim("userInput"); * ``` * - * @param expr The name of the field containing the string. + * @param fieldName The name of the field containing the string. * @return A new {@code Expr} representing the trimmed string. */ -export function trim(expr: string): Trim; +export function trim(fieldName: string): FunctionExpr; /** * @beta @@ -5620,15 +5804,15 @@ export function trim(expr: string): Trim; * * ```typescript * // Trim whitespace from the 'userInput' field - * trim(Field.of("userInput")); + * trim(field("userInput")); * ``` * - * @param expr The expression representing the string to trim. + * @param stringExpression The expression representing the string to trim. * @return A new {@code Expr} representing the trimmed string. */ -export function trim(expr: Expr): Trim; -export function trim(expr: Expr | string): Trim { - return new Trim(expr instanceof Expr ? expr : Field.of(expr)); +export function trim(stringExpression: Expr): FunctionExpr; +export function trim(expr: Expr | string): FunctionExpr { + return fieldOrExpression(expr).trim(); } /** @@ -5638,17 +5822,19 @@ export function trim(expr: Expr | string): Trim { * * ```typescript * // Combine the 'firstName', " ", and 'lastName' fields into a single string - * strConcat("firstName", " ", Field.of("lastName")); + * strConcat("firstName", " ", field("lastName")); * ``` * - * @param first The field name containing the initial string value. - * @param elements The expressions (typically strings) to concatenate. + * @param fieldName The field name containing the initial string value. + * @param secondString An expression or string literal to concatenate. + * @param otherStrings Optional additional expressions or literals (typically strings) to concatenate. * @return A new {@code Expr} representing the concatenated string. */ export function strConcat( - first: string, - ...elements: Array -): StrConcat; + fieldName: string, + secondString: Expr | string, + ...otherStrings: Array +): FunctionExpr; /** * @beta @@ -5656,23 +5842,28 @@ export function strConcat( * * ```typescript * // Combine the 'firstName', " ", and 'lastName' fields into a single string - * strConcat(Field.of("firstName"), " ", Field.of("lastName")); + * strConcat(field("firstName"), " ", field("lastName")); * ``` * - * @param first The initial string expression to concatenate to. - * @param elements The expressions (typically strings) to concatenate. + * @param firstString The initial string expression to concatenate to. + * @param secondString An expression or string literal to concatenate. + * @param otherStrings Optional additional expressions or literals (typically strings) to concatenate. * @return A new {@code Expr} representing the concatenated string. */ export function strConcat( - first: Expr, - ...elements: Array -): StrConcat; + firstString: Expr, + secondString: Expr | string, + ...otherStrings: Array +): FunctionExpr; export function strConcat( first: string | Expr, + second: string | Expr, ...elements: Array -): StrConcat { - const exprs = elements.map(e => (e instanceof Expr ? e : Constant.of(e))); - return new StrConcat(first instanceof Expr ? first : Field.of(first), exprs); +): FunctionExpr { + return fieldOrExpression(first).strConcat( + valueToDefaultExpr(second), + ...elements.map(valueToDefaultExpr) + ); } /** @@ -5685,11 +5876,11 @@ export function strConcat( * mapGet("address", "city"); * ``` * - * @param mapField The field name of the map field. + * @param fieldName The field name of the map field. * @param subField The key to access in the map. * @return A new {@code Expr} representing the value associated with the given key in the map. */ -export function mapGet(mapField: string, subField: string): MapGet; +export function mapGet(fieldName: string, subField: string): FunctionExpr; /** * @beta @@ -5698,19 +5889,19 @@ export function mapGet(mapField: string, subField: string): MapGet; * * ```typescript * // Get the 'city' value from the 'address' map field - * mapGet(Field.of("address"), "city"); + * mapGet(field("address"), "city"); * ``` * - * @param mapExpr The expression representing the map. + * @param mapExpression The expression representing the map. * @param subField The key to access in the map. * @return A new {@code Expr} representing the value associated with the given key in the map. */ -export function mapGet(mapExpr: Expr, subField: string): MapGet; -export function mapGet(fieldOrExpr: string | Expr, subField: string): MapGet { - return new MapGet( - typeof fieldOrExpr === 'string' ? Field.of(fieldOrExpr) : fieldOrExpr, - subField - ); +export function mapGet(mapExpression: Expr, subField: string): FunctionExpr; +export function mapGet( + fieldOrExpr: string | Expr, + subField: string +): FunctionExpr { + return fieldOrExpression(fieldOrExpr).mapGet(subField); } /** @@ -5719,14 +5910,14 @@ export function mapGet(fieldOrExpr: string | Expr, subField: string): MapGet { * Creates an aggregation that counts the total number of stage inputs. * * ```typescript - * // Count the total number of users - * countAll().as("totalUsers"); + * // Count the total number of input documents + * countAll().as("totalDocument"); * ``` * - * @return A new {@code Accumulator} representing the 'countAll' aggregation. + * @return A new {@code AggregateFunction} representing the 'countAll' aggregation. */ -export function countAll(): Count { - return new Count(undefined, false); +export function countAll(): AggregateFunction { + return new AggregateFunction('count', []); } /** @@ -5737,30 +5928,28 @@ export function countAll(): Count { * * ```typescript * // Count the number of items where the price is greater than 10 - * count(Field.of("price").gt(10)).as("expensiveItemCount"); + * count(field("price").gt(10)).as("expensiveItemCount"); * ``` * - * @param value The expression to count. - * @return A new {@code Accumulator} representing the 'count' aggregation. + * @param expression The expression to count. + * @return A new {@code AggregateFunction} representing the 'count' aggregation. */ -export function countFunction(value: Expr): Count; +export function count(expression: Expr): AggregateFunction; /** - * Creates an aggregation that counts the number of stage inputs with valid evaluations of the - * provided field. + * Creates an aggregation that counts the number of stage inputs where the input field exists. * * ```typescript * // Count the total number of products * count("productId").as("totalProducts"); * ``` * - * @param value The name of the field to count. - * @return A new {@code Accumulator} representing the 'count' aggregation. + * @param fieldName The name of the field to count. + * @return A new {@code AggregateFunction} representing the 'count' aggregation. */ -export function countFunction(value: string): Count; -export function countFunction(value: Expr | string): Count { - const exprValue = value instanceof Expr ? value : Field.of(value); - return new Count(exprValue, false); +export function count(fieldName: string): AggregateFunction; +export function count(value: Expr | string): AggregateFunction { + return fieldOrExpression(value).count(); } /** @@ -5771,13 +5960,13 @@ export function countFunction(value: Expr | string): Count { * * ```typescript * // Calculate the total revenue from a set of orders - * sum(Field.of("orderAmount")).as("totalRevenue"); + * sum(field("orderAmount")).as("totalRevenue"); * ``` * - * @param value The expression to sum up. - * @return A new {@code Accumulator} representing the 'sum' aggregation. + * @param expression The expression to sum up. + * @return A new {@code AggregateFunction} representing the 'sum' aggregation. */ -export function sumFunction(value: Expr): Sum; +export function sum(expression: Expr): AggregateFunction; /** * @beta @@ -5790,13 +5979,12 @@ export function sumFunction(value: Expr): Sum; * sum("orderAmount").as("totalRevenue"); * ``` * - * @param value The name of the field containing numeric values to sum up. - * @return A new {@code Accumulator} representing the 'sum' aggregation. + * @param fieldName The name of the field containing numeric values to sum up. + * @return A new {@code AggregateFunction} representing the 'sum' aggregation. */ -export function sumFunction(value: string): Sum; -export function sumFunction(value: Expr | string): Sum { - const exprValue = value instanceof Expr ? value : Field.of(value); - return new Sum(exprValue, false); +export function sum(fieldName: string): AggregateFunction; +export function sum(value: Expr | string): AggregateFunction { + return fieldOrExpression(value).sum(); } /** @@ -5807,13 +5995,13 @@ export function sumFunction(value: Expr | string): Sum { * * ```typescript * // Calculate the average age of users - * avg(Field.of("age")).as("averageAge"); + * avg(field("age")).as("averageAge"); * ``` * - * @param value The expression representing the values to average. - * @return A new {@code Accumulator} representing the 'avg' aggregation. + * @param expression The expression representing the values to average. + * @return A new {@code AggregateFunction} representing the 'avg' aggregation. */ -export function avgFunction(value: Expr): Avg; +export function avg(expression: Expr): AggregateFunction; /** * @beta @@ -5826,13 +6014,12 @@ export function avgFunction(value: Expr): Avg; * avg("age").as("averageAge"); * ``` * - * @param value The name of the field containing numeric values to average. - * @return A new {@code Accumulator} representing the 'avg' aggregation. + * @param fieldName The name of the field containing numeric values to average. + * @return A new {@code AggregateFunction} representing the 'avg' aggregation. */ -export function avgFunction(value: string): Avg; -export function avgFunction(value: Expr | string): Avg { - const exprValue = value instanceof Expr ? value : Field.of(value); - return new Avg(exprValue, false); +export function avg(fieldName: string): AggregateFunction; +export function avg(value: Expr | string): AggregateFunction { + return fieldOrExpression(value).avg(); } /** @@ -5843,13 +6030,13 @@ export function avgFunction(value: Expr | string): Avg { * * ```typescript * // Find the lowest price of all products - * minimum(Field.of("price")).as("lowestPrice"); + * minimum(field("price")).as("lowestPrice"); * ``` * - * @param value The expression to find the minimum value of. - * @return A new {@code Accumulator} representing the 'min' aggregation. + * @param expression The expression to find the minimum value of. + * @return A new {@code AggregateFunction} representing the 'min' aggregation. */ -export function minimum(value: Expr): Minimum; +export function minimum(expression: Expr): AggregateFunction; /** * @beta @@ -5861,13 +6048,12 @@ export function minimum(value: Expr): Minimum; * minimum("price").as("lowestPrice"); * ``` * - * @param value The name of the field to find the minimum value of. - * @return A new {@code Accumulator} representing the 'min' aggregation. + * @param fieldName The name of the field to find the minimum value of. + * @return A new {@code AggregateFunction} representing the 'min' aggregation. */ -export function minimum(value: string): Minimum; -export function minimum(value: Expr | string): Minimum { - const exprValue = value instanceof Expr ? value : Field.of(value); - return new Minimum(exprValue, false); +export function minimum(fieldName: string): AggregateFunction; +export function minimum(value: Expr | string): AggregateFunction { + return fieldOrExpression(value).minimum(); } /** @@ -5878,13 +6064,13 @@ export function minimum(value: Expr | string): Minimum { * * ```typescript * // Find the highest score in a leaderboard - * maximum(Field.of("score")).as("highestScore"); + * maximum(field("score")).as("highestScore"); * ``` * - * @param value The expression to find the maximum value of. - * @return A new {@code Accumulator} representing the 'max' aggregation. + * @param expression The expression to find the maximum value of. + * @return A new {@code AggregateFunction} representing the 'max' aggregation. */ -export function maximum(value: Expr): Maximum; +export function maximum(expression: Expr): AggregateFunction; /** * @beta @@ -5896,49 +6082,32 @@ export function maximum(value: Expr): Maximum; * maximum("score").as("highestScore"); * ``` * - * @param value The name of the field to find the maximum value of. - * @return A new {@code Accumulator} representing the 'max' aggregation. + * @param fieldName The name of the field to find the maximum value of. + * @return A new {@code AggregateFunction} representing the 'max' aggregation. */ -export function maximum(value: string): Maximum; -export function maximum(value: Expr | string): Maximum { - const exprValue = value instanceof Expr ? value : Field.of(value); - return new Maximum(exprValue, false); +export function maximum(fieldName: string): AggregateFunction; +export function maximum(value: Expr | string): AggregateFunction { + return fieldOrExpression(value).maximum(); } /** * @beta * - * Calculates the Cosine distance between a field's vector value and a double array. + * Calculates the Cosine distance between a field's vector value and a literal vector value. * * ```typescript * // Calculate the Cosine distance between the 'location' field and a target location * cosineDistance("location", [37.7749, -122.4194]); * ``` * - * @param expr The name of the field containing the first vector. - * @param other The other vector (as an array of doubles) to compare against. - * @return A new {@code Expr} representing the Cosine distance between the two vectors. - */ -export function cosineDistance(expr: string, other: number[]): CosineDistance; - -/** - * @beta - * - * Calculates the Cosine distance between a field's vector value and a VectorValue. - * - * ```typescript - * // Calculate the Cosine distance between the 'location' field and a target location - * cosineDistance("location", new VectorValue([37.7749, -122.4194])); - * ``` - * - * @param expr The name of the field containing the first vector. - * @param other The other vector (as a VectorValue) to compare against. + * @param fieldName The name of the field containing the first vector. + * @param vector The other vector (as an array of doubles) or {@link VectorValue} to compare against. * @return A new {@code Expr} representing the Cosine distance between the two vectors. */ export function cosineDistance( - expr: string, - other: VectorValue -): CosineDistance; + fieldName: string, + vector: number[] | VectorValue +): FunctionExpr; /** * @beta @@ -5947,46 +6116,36 @@ export function cosineDistance( * * ```typescript * // Calculate the cosine distance between the 'userVector' field and the 'itemVector' field - * cosineDistance("userVector", Field.of("itemVector")); - * ``` - * - * @param expr The name of the field containing the first vector. - * @param other The other vector (represented as an Expr) to compare against. - * @return A new {@code Expr} representing the cosine distance between the two vectors. - */ -export function cosineDistance(expr: string, other: Expr): CosineDistance; - -/** - * @beta - * - * Calculates the Cosine distance between a vector expression and a double array. - * - * ```typescript - * // Calculate the cosine distance between the 'location' field and a target location - * cosineDistance(Field.of("location"), [37.7749, -122.4194]); + * cosineDistance("userVector", field("itemVector")); * ``` * - * @param expr The first vector (represented as an Expr) to compare against. - * @param other The other vector (as an array of doubles) to compare against. + * @param fieldName The name of the field containing the first vector. + * @param vectorExpression The other vector (represented as an Expr) to compare against. * @return A new {@code Expr} representing the cosine distance between the two vectors. */ -export function cosineDistance(expr: Expr, other: number[]): CosineDistance; +export function cosineDistance( + fieldName: string, + vectorExpression: Expr +): FunctionExpr; /** * @beta * - * Calculates the Cosine distance between a vector expression and a VectorValue. + * Calculates the Cosine distance between a vector expression and a vector literal. * * ```typescript * // Calculate the cosine distance between the 'location' field and a target location - * cosineDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); + * cosineDistance(field("location"), [37.7749, -122.4194]); * ``` * - * @param expr The first vector (represented as an Expr) to compare against. - * @param other The other vector (as a VectorValue) to compare against. + * @param vectorExpression The first vector (represented as an Expr) to compare against. + * @param vector The other vector (as an array of doubles or VectorValue) to compare against. * @return A new {@code Expr} representing the cosine distance between the two vectors. */ -export function cosineDistance(expr: Expr, other: VectorValue): CosineDistance; +export function cosineDistance( + vectorExpression: Expr, + vector: number[] | Expr +): FunctionExpr; /** * @beta @@ -5995,21 +6154,24 @@ export function cosineDistance(expr: Expr, other: VectorValue): CosineDistance; * * ```typescript * // Calculate the cosine distance between the 'userVector' field and the 'itemVector' field - * cosineDistance(Field.of("userVector"), Field.of("itemVector")); + * cosineDistance(field("userVector"), field("itemVector")); * ``` * - * @param expr The first vector (represented as an Expr) to compare against. - * @param other The other vector (represented as an Expr) to compare against. + * @param vectorExpression The first vector (represented as an Expr) to compare against. + * @param otherVectorExpression The other vector (represented as an Expr) to compare against. * @return A new {@code Expr} representing the cosine distance between the two vectors. */ -export function cosineDistance(expr: Expr, other: Expr): CosineDistance; +export function cosineDistance( + vectorExpression: Expr, + otherVectorExpression: Expr +): FunctionExpr; export function cosineDistance( expr: Expr | string, other: Expr | number[] | VectorValue -): CosineDistance { - const expr1 = expr instanceof Expr ? expr : Field.of(expr); - const expr2 = other instanceof Expr ? other : Constant.vector(other); - return new CosineDistance(expr1, expr2); +): FunctionExpr { + const expr1 = fieldOrExpression(expr); + const expr2 = vectorToExpr(other); + return expr1.cosineDistance(expr2); } /** @@ -6022,27 +6184,14 @@ export function cosineDistance( * dotProduct("features", [0.5, 0.8, 0.2]); * ``` * - * @param expr The name of the field containing the first vector. - * @param other The other vector (as an array of doubles) to calculate with. - * @return A new {@code Expr} representing the dot product between the two vectors. - */ -export function dotProduct(expr: string, other: number[]): DotProduct; - -/** - * @beta - * - * Calculates the dot product between a field's vector value and a VectorValue. - * - * ```typescript - * // Calculate the dot product distance between a feature vector and a target vector - * dotProduct("features", new VectorValue([0.5, 0.8, 0.2])); - * ``` - * - * @param expr The name of the field containing the first vector. - * @param other The other vector (as a VectorValue) to calculate with. + * @param fieldName The name of the field containing the first vector. + * @param vector The other vector (as an array of doubles or VectorValue) to calculate with. * @return A new {@code Expr} representing the dot product between the two vectors. */ -export function dotProduct(expr: string, other: VectorValue): DotProduct; +export function dotProduct( + fieldName: string, + vector: number[] | VectorValue +): FunctionExpr; /** * @beta @@ -6051,14 +6200,17 @@ export function dotProduct(expr: string, other: VectorValue): DotProduct; * * ```typescript * // Calculate the dot product distance between two document vectors: 'docVector1' and 'docVector2' - * dotProduct("docVector1", Field.of("docVector2")); + * dotProduct("docVector1", field("docVector2")); * ``` * - * @param expr The name of the field containing the first vector. - * @param other The other vector (represented as an Expr) to calculate with. + * @param fieldName The name of the field containing the first vector. + * @param vectorExpression The other vector (represented as an Expr) to calculate with. * @return A new {@code Expr} representing the dot product between the two vectors. */ -export function dotProduct(expr: string, other: Expr): DotProduct; +export function dotProduct( + fieldName: string, + vectorExpression: Expr +): FunctionExpr; /** * @beta @@ -6067,30 +6219,17 @@ export function dotProduct(expr: string, other: Expr): DotProduct; * * ```typescript * // Calculate the dot product between a feature vector and a target vector - * dotProduct(Field.of("features"), [0.5, 0.8, 0.2]); - * ``` - * - * @param expr The first vector (represented as an Expr) to calculate with. - * @param other The other vector (as an array of doubles) to calculate with. - * @return A new {@code Expr} representing the dot product between the two vectors. - */ -export function dotProduct(expr: Expr, other: number[]): DotProduct; - -/** - * @beta - * - * Calculates the dot product between a vector expression and a VectorValue. - * - * ```typescript - * // Calculate the dot product between a feature vector and a target vector - * dotProduct(Field.of("features"), new VectorValue([0.5, 0.8, 0.2])); + * dotProduct(field("features"), [0.5, 0.8, 0.2]); * ``` * - * @param expr The first vector (represented as an Expr) to calculate with. - * @param other The other vector (as a VectorValue) to calculate with. + * @param vectorExpression The first vector (represented as an Expr) to calculate with. + * @param vector The other vector (as an array of doubles or VectorValue) to calculate with. * @return A new {@code Expr} representing the dot product between the two vectors. */ -export function dotProduct(expr: Expr, other: VectorValue): DotProduct; +export function dotProduct( + vectorExpression: Expr, + vector: number[] | VectorValue +): FunctionExpr; /** * @beta @@ -6099,21 +6238,24 @@ export function dotProduct(expr: Expr, other: VectorValue): DotProduct; * * ```typescript * // Calculate the dot product between two document vectors: 'docVector1' and 'docVector2' - * dotProduct(Field.of("docVector1"), Field.of("docVector2")); + * dotProduct(field("docVector1"), field("docVector2")); * ``` * - * @param expr The first vector (represented as an Expr) to calculate with. - * @param other The other vector (represented as an Expr) to calculate with. + * @param vectorExpression The first vector (represented as an Expr) to calculate with. + * @param otherVectorExpression The other vector (represented as an Expr) to calculate with. * @return A new {@code Expr} representing the dot product between the two vectors. */ -export function dotProduct(expr: Expr, other: Expr): DotProduct; +export function dotProduct( + vectorExpression: Expr, + otherVectorExpression: Expr +): FunctionExpr; export function dotProduct( expr: Expr | string, other: Expr | number[] | VectorValue -): DotProduct { - const expr1 = expr instanceof Expr ? expr : Field.of(expr); - const expr2 = other instanceof Expr ? other : Constant.vector(other); - return new DotProduct(expr1, expr2); +): FunctionExpr { + const expr1 = fieldOrExpression(expr); + const expr2 = vectorToExpr(other); + return expr1.dotProduct(expr2); } /** @@ -6126,33 +6268,14 @@ export function dotProduct( * euclideanDistance("location", [37.7749, -122.4194]); * ``` * - * @param expr The name of the field containing the first vector. - * @param other The other vector (as an array of doubles) to compare against. - * @return A new {@code Expr} representing the Euclidean distance between the two vectors. - */ -export function euclideanDistance( - expr: string, - other: number[] -): EuclideanDistance; - -/** - * @beta - * - * Calculates the Euclidean distance between a field's vector value and a VectorValue. - * - * ```typescript - * // Calculate the Euclidean distance between the 'location' field and a target location - * euclideanDistance("location", new VectorValue([37.7749, -122.4194])); - * ``` - * - * @param expr The name of the field containing the first vector. - * @param other The other vector (as a VectorValue) to compare against. + * @param fieldName The name of the field containing the first vector. + * @param vector The other vector (as an array of doubles or VectorValue) to compare against. * @return A new {@code Expr} representing the Euclidean distance between the two vectors. */ export function euclideanDistance( - expr: string, - other: VectorValue -): EuclideanDistance; + fieldName: string, + vector: number[] | VectorValue +): FunctionExpr; /** * @beta @@ -6161,14 +6284,17 @@ export function euclideanDistance( * * ```typescript * // Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' - * euclideanDistance("pointA", Field.of("pointB")); + * euclideanDistance("pointA", field("pointB")); * ``` * - * @param expr The name of the field containing the first vector. - * @param other The other vector (represented as an Expr) to compare against. + * @param fieldName The name of the field containing the first vector. + * @param vectorExpression The other vector (represented as an Expr) to compare against. * @return A new {@code Expr} representing the Euclidean distance between the two vectors. */ -export function euclideanDistance(expr: string, other: Expr): EuclideanDistance; +export function euclideanDistance( + fieldName: string, + vectorExpression: Expr +): FunctionExpr; /** * @beta @@ -6178,36 +6304,17 @@ export function euclideanDistance(expr: string, other: Expr): EuclideanDistance; * ```typescript * // Calculate the Euclidean distance between the 'location' field and a target location * - * euclideanDistance(Field.of("location"), [37.7749, -122.4194]); - * ``` - * - * @param expr The first vector (represented as an Expr) to compare against. - * @param other The other vector (as an array of doubles) to compare against. - * @return A new {@code Expr} representing the Euclidean distance between the two vectors. - */ -export function euclideanDistance( - expr: Expr, - other: number[] -): EuclideanDistance; - -/** - * @beta - * - * Calculates the Euclidean distance between a vector expression and a VectorValue. - * - * ```typescript - * // Calculate the Euclidean distance between the 'location' field and a target location - * euclideanDistance(Field.of("location"), new VectorValue([37.7749, -122.4194])); + * euclideanDistance(field("location"), [37.7749, -122.4194]); * ``` * - * @param expr The first vector (represented as an Expr) to compare against. - * @param other The other vector (as a VectorValue) to compare against. + * @param vectorExpression The first vector (represented as an Expr) to compare against. + * @param vector The other vector (as an array of doubles or VectorValue) to compare against. * @return A new {@code Expr} representing the Euclidean distance between the two vectors. */ export function euclideanDistance( - expr: Expr, - other: VectorValue -): EuclideanDistance; + vectorExpression: Expr, + vector: number[] | VectorValue +): FunctionExpr; /** * @beta @@ -6216,21 +6323,24 @@ export function euclideanDistance( * * ```typescript * // Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB' - * euclideanDistance(Field.of("pointA"), Field.of("pointB")); + * euclideanDistance(field("pointA"), field("pointB")); * ``` * - * @param expr The first vector (represented as an Expr) to compare against. - * @param other The other vector (represented as an Expr) to compare against. + * @param vectorExpression The first vector (represented as an Expr) to compare against. + * @param otherVectorExpression The other vector (represented as an Expr) to compare against. * @return A new {@code Expr} representing the Euclidean distance between the two vectors. */ -export function euclideanDistance(expr: Expr, other: Expr): EuclideanDistance; +export function euclideanDistance( + vectorExpression: Expr, + otherVectorExpression: Expr +): FunctionExpr; export function euclideanDistance( expr: Expr | string, other: Expr | number[] | VectorValue -): EuclideanDistance { - const expr1 = expr instanceof Expr ? expr : Field.of(expr); - const expr2 = other instanceof Expr ? other : Constant.vector(other); - return new EuclideanDistance(expr1, expr2); +): FunctionExpr { + const expr1 = fieldOrExpression(expr); + const expr2 = vectorToExpr(other); + return expr1.euclideanDistance(expr2); } /** @@ -6240,13 +6350,13 @@ export function euclideanDistance( * * ```typescript * // Get the vector length (dimension) of the field 'embedding'. - * vectorLength(Field.of("embedding")); + * vectorLength(field("embedding")); * ``` * - * @param expr The expression representing the Firestore Vector. + * @param vectorExpression The expression representing the Firestore Vector. * @return A new {@code Expr} representing the length of the array. */ -export function vectorLength(expr: Expr): VectorLength; +export function vectorLength(vectorExpression: Expr): FunctionExpr; /** * @beta @@ -6258,13 +6368,12 @@ export function vectorLength(expr: Expr): VectorLength; * vectorLength("embedding"); * ``` * - * @param field The name of the field representing the Firestore Vector. + * @param fieldName The name of the field representing the Firestore Vector. * @return A new {@code Expr} representing the length of the array. */ -export function vectorLength(field: string): VectorLength; -export function vectorLength(expr: Expr | string): VectorLength { - const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; - return new VectorLength(normalizedExpr); +export function vectorLength(fieldName: string): FunctionExpr; +export function vectorLength(expr: Expr | string): FunctionExpr { + return fieldOrExpression(expr).vectorLength(); } /** @@ -6275,13 +6384,13 @@ export function vectorLength(expr: Expr | string): VectorLength { * * ```typescript * // Interpret the 'microseconds' field as microseconds since epoch. - * unixMicrosToTimestamp(Field.of("microseconds")); + * unixMicrosToTimestamp(field("microseconds")); * ``` * * @param expr The expression representing the number of microseconds since epoch. * @return A new {@code Expr} representing the timestamp. */ -export function unixMicrosToTimestamp(expr: Expr): UnixMicrosToTimestamp; +export function unixMicrosToTimestamp(expr: Expr): FunctionExpr; /** * @beta @@ -6294,15 +6403,12 @@ export function unixMicrosToTimestamp(expr: Expr): UnixMicrosToTimestamp; * unixMicrosToTimestamp("microseconds"); * ``` * - * @param field The name of the field representing the number of microseconds since epoch. + * @param fieldName The name of the field representing the number of microseconds since epoch. * @return A new {@code Expr} representing the timestamp. */ -export function unixMicrosToTimestamp(field: string): UnixMicrosToTimestamp; -export function unixMicrosToTimestamp( - expr: Expr | string -): UnixMicrosToTimestamp { - const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; - return new UnixMicrosToTimestamp(normalizedExpr); +export function unixMicrosToTimestamp(fieldName: string): FunctionExpr; +export function unixMicrosToTimestamp(expr: Expr | string): FunctionExpr { + return fieldOrExpression(expr).unixMicrosToTimestamp(); } /** @@ -6312,13 +6418,13 @@ export function unixMicrosToTimestamp( * * ```typescript * // Convert the 'timestamp' field to microseconds since epoch. - * timestampToUnixMicros(Field.of("timestamp")); + * timestampToUnixMicros(field("timestamp")); * ``` * * @param expr The expression representing the timestamp. * @return A new {@code Expr} representing the number of microseconds since epoch. */ -export function timestampToUnixMicros(expr: Expr): TimestampToUnixMicros; +export function timestampToUnixMicros(expr: Expr): FunctionExpr; /** * @beta @@ -6330,15 +6436,12 @@ export function timestampToUnixMicros(expr: Expr): TimestampToUnixMicros; * timestampToUnixMicros("timestamp"); * ``` * - * @param field The name of the field representing the timestamp. + * @param fieldName The name of the field representing the timestamp. * @return A new {@code Expr} representing the number of microseconds since epoch. */ -export function timestampToUnixMicros(field: string): TimestampToUnixMicros; -export function timestampToUnixMicros( - expr: Expr | string -): TimestampToUnixMicros { - const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; - return new TimestampToUnixMicros(normalizedExpr); +export function timestampToUnixMicros(fieldName: string): FunctionExpr; +export function timestampToUnixMicros(expr: Expr | string): FunctionExpr { + return fieldOrExpression(expr).timestampToUnixMicros(); } /** @@ -6349,13 +6452,13 @@ export function timestampToUnixMicros( * * ```typescript * // Interpret the 'milliseconds' field as milliseconds since epoch. - * unixMillisToTimestamp(Field.of("milliseconds")); + * unixMillisToTimestamp(field("milliseconds")); * ``` * * @param expr The expression representing the number of milliseconds since epoch. * @return A new {@code Expr} representing the timestamp. */ -export function unixMillisToTimestamp(expr: Expr): UnixMillisToTimestamp; +export function unixMillisToTimestamp(expr: Expr): FunctionExpr; /** * @beta @@ -6368,15 +6471,13 @@ export function unixMillisToTimestamp(expr: Expr): UnixMillisToTimestamp; * unixMillisToTimestamp("milliseconds"); * ``` * - * @param field The name of the field representing the number of milliseconds since epoch. + * @param fieldName The name of the field representing the number of milliseconds since epoch. * @return A new {@code Expr} representing the timestamp. */ -export function unixMillisToTimestamp(field: string): UnixMillisToTimestamp; -export function unixMillisToTimestamp( - expr: Expr | string -): UnixMillisToTimestamp { - const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; - return new UnixMillisToTimestamp(normalizedExpr); +export function unixMillisToTimestamp(fieldName: string): FunctionExpr; +export function unixMillisToTimestamp(expr: Expr | string): FunctionExpr { + const normalizedExpr = fieldOrExpression(expr); + return normalizedExpr.unixMillisToTimestamp(); } /** @@ -6386,13 +6487,13 @@ export function unixMillisToTimestamp( * * ```typescript * // Convert the 'timestamp' field to milliseconds since epoch. - * timestampToUnixMillis(Field.of("timestamp")); + * timestampToUnixMillis(field("timestamp")); * ``` * * @param expr The expression representing the timestamp. * @return A new {@code Expr} representing the number of milliseconds since epoch. */ -export function timestampToUnixMillis(expr: Expr): TimestampToUnixMillis; +export function timestampToUnixMillis(expr: Expr): FunctionExpr; /** * @beta @@ -6404,15 +6505,13 @@ export function timestampToUnixMillis(expr: Expr): TimestampToUnixMillis; * timestampToUnixMillis("timestamp"); * ``` * - * @param field The name of the field representing the timestamp. + * @param fieldName The name of the field representing the timestamp. * @return A new {@code Expr} representing the number of milliseconds since epoch. */ -export function timestampToUnixMillis(field: string): TimestampToUnixMillis; -export function timestampToUnixMillis( - expr: Expr | string -): TimestampToUnixMillis { - const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; - return new TimestampToUnixMillis(normalizedExpr); +export function timestampToUnixMillis(fieldName: string): FunctionExpr; +export function timestampToUnixMillis(expr: Expr | string): FunctionExpr { + const normalizedExpr = fieldOrExpression(expr); + return normalizedExpr.timestampToUnixMillis(); } /** @@ -6423,13 +6522,13 @@ export function timestampToUnixMillis( * * ```typescript * // Interpret the 'seconds' field as seconds since epoch. - * unixSecondsToTimestamp(Field.of("seconds")); + * unixSecondsToTimestamp(field("seconds")); * ``` * * @param expr The expression representing the number of seconds since epoch. * @return A new {@code Expr} representing the timestamp. */ -export function unixSecondsToTimestamp(expr: Expr): UnixSecondsToTimestamp; +export function unixSecondsToTimestamp(expr: Expr): FunctionExpr; /** * @beta @@ -6442,15 +6541,13 @@ export function unixSecondsToTimestamp(expr: Expr): UnixSecondsToTimestamp; * unixSecondsToTimestamp("seconds"); * ``` * - * @param field The name of the field representing the number of seconds since epoch. + * @param fieldName The name of the field representing the number of seconds since epoch. * @return A new {@code Expr} representing the timestamp. */ -export function unixSecondsToTimestamp(field: string): UnixSecondsToTimestamp; -export function unixSecondsToTimestamp( - expr: Expr | string -): UnixSecondsToTimestamp { - const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; - return new UnixSecondsToTimestamp(normalizedExpr); +export function unixSecondsToTimestamp(fieldName: string): FunctionExpr; +export function unixSecondsToTimestamp(expr: Expr | string): FunctionExpr { + const normalizedExpr = fieldOrExpression(expr); + return normalizedExpr.unixSecondsToTimestamp(); } /** @@ -6460,13 +6557,13 @@ export function unixSecondsToTimestamp( * * ```typescript * // Convert the 'timestamp' field to seconds since epoch. - * timestampToUnixSeconds(Field.of("timestamp")); + * timestampToUnixSeconds(field("timestamp")); * ``` * * @param expr The expression representing the timestamp. * @return A new {@code Expr} representing the number of seconds since epoch. */ -export function timestampToUnixSeconds(expr: Expr): TimestampToUnixSeconds; +export function timestampToUnixSeconds(expr: Expr): FunctionExpr; /** * @beta @@ -6478,15 +6575,13 @@ export function timestampToUnixSeconds(expr: Expr): TimestampToUnixSeconds; * timestampToUnixSeconds("timestamp"); * ``` * - * @param field The name of the field representing the timestamp. + * @param fieldName The name of the field representing the timestamp. * @return A new {@code Expr} representing the number of seconds since epoch. */ -export function timestampToUnixSeconds(field: string): TimestampToUnixSeconds; -export function timestampToUnixSeconds( - expr: Expr | string -): TimestampToUnixSeconds { - const normalizedExpr = typeof expr === 'string' ? Field.of(expr) : expr; - return new TimestampToUnixSeconds(normalizedExpr); +export function timestampToUnixSeconds(fieldName: string): FunctionExpr; +export function timestampToUnixSeconds(expr: Expr | string): FunctionExpr { + const normalizedExpr = fieldOrExpression(expr); + return normalizedExpr.timestampToUnixSeconds(); } /** @@ -6496,7 +6591,7 @@ export function timestampToUnixSeconds( * * ```typescript * // Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. - * timestampAdd(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); + * timestampAdd(field("timestamp"), field("unit"), field("amount")); * ``` * * @param timestamp The expression representing the timestamp. @@ -6508,7 +6603,7 @@ export function timestampAdd( timestamp: Expr, unit: Expr, amount: Expr -): TimestampAdd; +): FunctionExpr; /** * @beta @@ -6517,7 +6612,7 @@ export function timestampAdd( * * ```typescript * // Add 1 day to the 'timestamp' field. - * timestampAdd(Field.of("timestamp"), "day", 1); + * timestampAdd(field("timestamp"), "day", 1); * ``` * * @param timestamp The expression representing the timestamp. @@ -6529,7 +6624,7 @@ export function timestampAdd( timestamp: Expr, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number -): TimestampAdd; +): FunctionExpr; /** * @beta @@ -6541,16 +6636,16 @@ export function timestampAdd( * timestampAdd("timestamp", "day", 1); * ``` * - * @param field The name of the field representing the timestamp. + * @param fieldName The name of the field representing the timestamp. * @param unit The unit of time to add (e.g., "day", "hour"). * @param amount The amount of time to add. * @return A new {@code Expr} representing the resulting timestamp. */ export function timestampAdd( - field: string, + fieldName: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number -): TimestampAdd; +): FunctionExpr; export function timestampAdd( timestamp: Expr | string, unit: @@ -6562,17 +6657,11 @@ export function timestampAdd( | 'hour' | 'day', amount: Expr | number -): TimestampAdd { - const normalizedTimestamp = - typeof timestamp === 'string' ? Field.of(timestamp) : timestamp; - const normalizedUnit = unit instanceof Expr ? unit : Constant.of(unit); - const normalizedAmount = - typeof amount === 'number' ? Constant.of(amount) : amount; - return new TimestampAdd( - normalizedTimestamp, - normalizedUnit, - normalizedAmount - ); +): FunctionExpr { + const normalizedTimestamp = fieldOrExpression(timestamp); + const normalizedUnit = valueToDefaultExpr(unit); + const normalizedAmount = valueToDefaultExpr(amount); + return normalizedTimestamp.timestampAdd(normalizedUnit, normalizedAmount); } /** @@ -6582,7 +6671,7 @@ export function timestampAdd( * * ```typescript * // Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. - * timestampSub(Field.of("timestamp"), Field.of("unit"), Field.of("amount")); + * timestampSub(field("timestamp"), field("unit"), field("amount")); * ``` * * @param timestamp The expression representing the timestamp. @@ -6594,7 +6683,7 @@ export function timestampSub( timestamp: Expr, unit: Expr, amount: Expr -): TimestampSub; +): FunctionExpr; /** * @beta @@ -6603,7 +6692,7 @@ export function timestampSub( * * ```typescript * // Subtract 1 day from the 'timestamp' field. - * timestampSub(Field.of("timestamp"), "day", 1); + * timestampSub(field("timestamp"), "day", 1); * ``` * * @param timestamp The expression representing the timestamp. @@ -6615,7 +6704,7 @@ export function timestampSub( timestamp: Expr, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number -): TimestampSub; +): FunctionExpr; /** * @beta @@ -6627,16 +6716,16 @@ export function timestampSub( * timestampSub("timestamp", "day", 1); * ``` * - * @param field The name of the field representing the timestamp. + * @param fieldName The name of the field representing the timestamp. * @param unit The unit of time to subtract (e.g., "day", "hour"). * @param amount The amount of time to subtract. * @return A new {@code Expr} representing the resulting timestamp. */ export function timestampSub( - field: string, + fieldName: string, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number -): TimestampSub; +): FunctionExpr; export function timestampSub( timestamp: Expr | string, unit: @@ -6648,39 +6737,11 @@ export function timestampSub( | 'hour' | 'day', amount: Expr | number -): TimestampSub { - const normalizedTimestamp = - typeof timestamp === 'string' ? Field.of(timestamp) : timestamp; - const normalizedUnit = unit instanceof Expr ? unit : Constant.of(unit); - const normalizedAmount = - typeof amount === 'number' ? Constant.of(amount) : amount; - return new TimestampSub( - normalizedTimestamp, - normalizedUnit, - normalizedAmount - ); -} - -/** - * @beta - * - * Creates functions that work on the backend but do not exist in the SDK yet. - * - * ```typescript - * // Call a user defined function named "myFunc" with the arguments 10 and 20 - * // This is the same of the 'sum(Field.of("price"))', if it did not exist - * genericFunction("sum", [Field.of("price")]); - * ``` - * - * @param name The name of the user defined function. - * @param params The arguments to pass to the function. - * @return A new {@code Function} representing the function call. - */ -export function genericFunction( - name: string, - params: Expr[] -): FirestoreFunction { - return new FirestoreFunction(name, params); +): FunctionExpr { + const normalizedTimestamp = fieldOrExpression(timestamp); + const normalizedUnit = valueToDefaultExpr(unit); + const normalizedAmount = valueToDefaultExpr(amount); + return normalizedTimestamp.timestampSub(normalizedUnit, normalizedAmount); } /** @@ -6694,15 +6755,17 @@ export function genericFunction( * const condition = and(gt("age", 18), eq("city", "London"), eq("status", "active")); * ``` * - * @param left The first filter condition. - * @param right Additional filter conditions to 'AND' together. + * @param first The first filter condition. + * @param second The second filter condition. + * @param more Additional filter conditions to 'AND' together. * @return A new {@code Expr} representing the logical 'AND' operation. */ -export function andFunction( - left: FilterCondition, - ...right: FilterCondition[] -): And { - return new And([left, ...right]); +export function and( + first: BooleanExpr, + second: BooleanExpr, + ...more: BooleanExpr[] +): BooleanExpr { + return new BooleanExpr('and', [first, second, ...more]); } /** @@ -6716,51 +6779,87 @@ export function andFunction( * const condition = or(gt("age", 18), eq("city", "London"), eq("status", "active")); * ``` * - * @param left The first filter condition. - * @param right Additional filter conditions to 'OR' together. + * @param first The first filter condition. + * @param second The second filter condition. + * @param more Additional filter conditions to 'OR' together. * @return A new {@code Expr} representing the logical 'OR' operation. */ -export function orFunction( - left: FilterCondition, - ...right: FilterCondition[] -): Or { - return new Or([left, ...right]); +export function or( + first: BooleanExpr, + second: BooleanExpr, + ...more: BooleanExpr[] +): BooleanExpr { + return new BooleanExpr('or', [first, second, ...more]); } /** * @beta * - * Creates an {@link Ordering} that sorts documents in ascending order based on this expression. + * Creates an {@link Ordering} that sorts documents in ascending order based on an expression. * * ```typescript - * // Sort documents by the 'name' field in ascending order + * // Sort documents by the 'name' field in lowercase in ascending order * firestore.pipeline().collection("users") - * .sort(ascending(Field.of("name"))); + * .sort(ascending(field("name").toLower())); * ``` * * @param expr The expression to create an ascending ordering for. * @return A new `Ordering` for ascending sorting. */ -export function ascending(expr: Expr): Ordering { - return new Ordering(expr, 'ascending'); +export function ascending(expr: Expr): Ordering; + +/** + * @beta + * + * Creates an {@link Ordering} that sorts documents in ascending order based on a field. + * + * ```typescript + * // Sort documents by the 'name' field in ascending order + * firestore.pipeline().collection("users") + * .sort(ascending("name")); + * ``` + * + * @param fieldName The field to create an ascending ordering for. + * @return A new `Ordering` for ascending sorting. + */ +export function ascending(fieldName: string): Ordering; +export function ascending(field: Expr | string): Ordering { + return new Ordering(fieldOrExpression(field), 'ascending'); } /** * @beta * - * Creates an {@link Ordering} that sorts documents in descending order based on this expression. + * Creates an {@link Ordering} that sorts documents in descending order based on an expression. * * ```typescript - * // Sort documents by the 'createdAt' field in descending order + * // Sort documents by the 'name' field in lowercase in descending order * firestore.pipeline().collection("users") - * .sort(descending(Field.of("createdAt"))); + * .sort(descending(field("name").toLower())); * ``` * * @param expr The expression to create a descending ordering for. * @return A new `Ordering` for descending sorting. */ -export function descending(expr: Expr): Ordering { - return new Ordering(expr, 'descending'); +export function descending(expr: Expr): Ordering; + +/** + * @beta + * + * Creates an {@link Ordering} that sorts documents in descending order based on a field. + * + * ```typescript + * // Sort documents by the 'name' field in descending order + * firestore.pipeline().collection("users") + * .sort(descending("name")); + * ``` + * + * @param fieldName The field to create a descending ordering for. + * @return A new `Ordering` for descending sorting. + */ +export function descending(fieldName: string): Ordering; +export function descending(field: Expr | string): Ordering { + return new Ordering(fieldOrExpression(field), 'descending'); } /** @@ -6770,12 +6869,20 @@ export function descending(expr: Expr): Ordering { * * You create `Ordering` instances using the `ascending` and `descending` helper functions. */ -export class Ordering { +export class Ordering implements ProtoValueSerializable, UserData { constructor( readonly expr: Expr, readonly direction: 'ascending' | 'descending' ) {} + /** + * @internal + * @private + * Indicates if this expression was created from a literal value passed + * by the caller. + */ + _createdFromLiteral: boolean = false; + /** * @private * @internal @@ -6795,7 +6902,13 @@ export class Ordering { * @private * @internal */ - _readUserData(dataReader: UserDataReader): void { + _readUserData(dataReader: UserDataReader, context?: ParseContext): void { + context = + this._createdFromLiteral && context + ? context + : dataReader.createContext(UserDataSource.Argument, 'constant'); this.expr._readUserData(dataReader); } + + _protoValueType: 'ProtoValue' = 'ProtoValue'; } diff --git a/packages/firestore/src/lite-api/pipeline-result.ts b/packages/firestore/src/lite-api/pipeline-result.ts index dc0a6412481..635636ac46b 100644 --- a/packages/firestore/src/lite-api/pipeline-result.ts +++ b/packages/firestore/src/lite-api/pipeline-result.ts @@ -18,12 +18,58 @@ import { ObjectValue } from '../model/object_value'; import { isOptionalEqual } from '../util/misc'; +import { Field } from './expressions'; import { FieldPath } from './field_path'; +import { Pipeline } from './pipeline'; import { DocumentData, DocumentReference, refEqual } from './reference'; import { fieldPathFromArgument } from './snapshot'; import { Timestamp } from './timestamp'; import { AbstractUserDataWriter } from './user_data_writer'; +export class PipelineSnapshot { + private readonly _pipeline: Pipeline; + private readonly _executionTime: Timestamp | undefined; + private readonly _results: PipelineResult[]; + constructor( + pipeline: Pipeline, + results: PipelineResult[], + executionTime?: Timestamp + ) { + this._pipeline = pipeline; + this._executionTime = executionTime; + this._results = results; + } + + /** + * The Pipeline on which you called `execute()` in order to get this + * `PipelineSnapshot`. + */ + get pipeline(): Pipeline { + return this._pipeline; + } + + /** An array of all the results in the `PipelineSnapshot`. */ + get results(): PipelineResult[] { + return this._results; + } + + /** + * The time at which the pipeline producing this result is executed. + * + * @type {Timestamp} + * @readonly + * + */ + get executionTime(): Timestamp { + if (this._executionTime === undefined) { + throw new Error( + "'executionTime' is expected to exist, but it is undefined" + ); + } + return this._executionTime; + } +} + /** * @beta * @@ -36,7 +82,6 @@ import { AbstractUserDataWriter } from './user_data_writer'; export class PipelineResult { private readonly _userDataWriter: AbstractUserDataWriter; - private readonly _executionTime: Timestamp | undefined; private readonly _createTime: Timestamp | undefined; private readonly _updateTime: Timestamp | undefined; @@ -58,7 +103,7 @@ export class PipelineResult { * * @param userDataWriter The serializer used to encode/decode protobuf. * @param ref The reference to the document. - * @param _fieldsProto The fields of the Firestore `Document` Protobuf backing + * @param fields The fields of the Firestore `Document` Protobuf backing * this document (or undefined if the document does not exist). * @param readTime The time when this result was read (or undefined if * the document exists only locally). @@ -69,13 +114,11 @@ export class PipelineResult { userDataWriter: AbstractUserDataWriter, ref?: DocumentReference, fields?: ObjectValue, - executionTime?: Timestamp, createTime?: Timestamp, updateTime?: Timestamp ) { this._ref = ref; this._userDataWriter = userDataWriter; - this._executionTime = executionTime; this._createTime = createTime; this._updateTime = updateTime; this._fields = fields; @@ -120,22 +163,6 @@ export class PipelineResult { return this._updateTime; } - /** - * The time at which the pipeline producing this result is executed. - * - * @type {Timestamp} - * @readonly - * - */ - get executionTime(): Timestamp { - if (this._executionTime === undefined) { - throw new Error( - "'executionTime' is expected to exist, but it is undefined" - ); - } - return this._executionTime; - } - /** * Retrieves all fields in the result as an object. Returns 'undefined' if * the document doesn't exist. @@ -166,7 +193,7 @@ export class PipelineResult { /** * Retrieves the field specified by `field`. * - * @param {string|FieldPath} field The field path + * @param {string|FieldPath|Field} field The field path * (e.g. 'foo' or 'foo.bar') to a specific field. * @returns {*} The data at the specified field location or undefined if no * such field exists. @@ -184,7 +211,7 @@ export class PipelineResult { // We deliberately use `any` in the external API to not impose type-checking // on end users. // eslint-disable-next-line @typescript-eslint/no-explicit-any - get(fieldPath: string | FieldPath): any { + get(fieldPath: string | FieldPath | Field): any { if (this._fields === undefined) { return undefined; } diff --git a/packages/firestore/src/lite-api/pipeline-source.ts b/packages/firestore/src/lite-api/pipeline-source.ts index 856096037f8..421fc759bfb 100644 --- a/packages/firestore/src/lite-api/pipeline-source.ts +++ b/packages/firestore/src/lite-api/pipeline-source.ts @@ -15,7 +15,12 @@ * limitations under the License. */ -import { DocumentReference } from './reference'; +import { DatabaseId } from '../core/database_info'; +import { toPipeline } from '../core/pipeline-util'; +import { FirestoreError, Code } from '../util/error'; + +import { Pipeline } from './pipeline'; +import { CollectionReference, DocumentReference, Query } from './reference'; import { CollectionGroupSource, CollectionSource, @@ -35,6 +40,7 @@ export class PipelineSource { * @param _createPipeline */ constructor( + private databaseId: DatabaseId, /** * @internal * @private @@ -42,19 +48,89 @@ export class PipelineSource { public _createPipeline: (stages: Stage[]) => PipelineType ) {} - collection(collectionPath: string): PipelineType { - return this._createPipeline([new CollectionSource(collectionPath)]); + /** + * Set the pipeline's source to the collection specified by the given path. + * + * @param collectionPath A path to a collection that will be the source of this pipeline. + */ + collection(collectionPath: string): PipelineType; + + /** + * Set the pipeline's source to the collection specified by the given CollectionReference. + * + * @param collectionReference A CollectionReference for a collection that will be the source of this pipeline. + * The converter for this CollectionReference will be ignored and not have an effect on this pipeline. + * + * @throws {@FirestoreError} Thrown if the provided CollectionReference targets a different project or database than the pipeline. + */ + collection(collectionReference: CollectionReference): PipelineType; + collection(collection: CollectionReference | string): PipelineType { + if (collection instanceof CollectionReference) { + this._validateReference(collection); + return this._createPipeline([new CollectionSource(collection.path)]); + } else { + return this._createPipeline([new CollectionSource(collection)]); + } } + /** + * Set the pipeline's source to the collection group with the given id. + * + * @param collectionid The id of a collection group that will be the source of this pipeline. + */ collectionGroup(collectionId: string): PipelineType { return this._createPipeline([new CollectionGroupSource(collectionId)]); } + /** + * Set the pipeline's source to be all documents in this database. + */ database(): PipelineType { return this._createPipeline([new DatabaseSource()]); } - documents(docs: DocumentReference[]): PipelineType { + /** + * Set the pipeline's source to the documents specified by the given paths and DocumentReferences. + * + * @param docs An array of paths and DocumentReferences specifying the individual documents that will be the source of this pipeline. + * The converters for these DocumentReferences will be ignored and not have an effect on this pipeline. + * + * @throws {@FirestoreError} Thrown if any of the provided DocumentReferences target a different project or database than the pipeline. + */ + documents(docs: Array): PipelineType { + docs.forEach(doc => { + if (doc instanceof DocumentReference) { + this._validateReference(doc); + } + }); + return this._createPipeline([DocumentsSource.of(docs)]); } + + /** + * Convert the given Query into an equivalent Pipeline. + * + * @param query A Query to be converted into a Pipeline. + * + * @throws {@FirestoreError} Thrown if any of the provided DocumentReferences target a different project or database than the pipeline. + */ + createFrom(query: Query): Pipeline { + return toPipeline(query._query, query.firestore); + } + + _validateReference(reference: CollectionReference | DocumentReference): void { + const refDbId = reference.firestore._databaseId; + if (!refDbId.isEqual(this.databaseId)) { + throw new FirestoreError( + Code.INVALID_ARGUMENT, + `Invalid ${ + reference instanceof CollectionReference + ? 'CollectionReference' + : 'DocumentReference' + }. ` + + `The project ID ("${refDbId.projectId}") or the database ("${refDbId.database}") does not match ` + + `the project ID ("${this.databaseId.projectId}") and database ("${this.databaseId.database}") of the target database of this Pipeline.` + ); + } + } } diff --git a/packages/firestore/src/lite-api/pipeline.ts b/packages/firestore/src/lite-api/pipeline.ts index 2145952c004..e07c7a37b9f 100644 --- a/packages/firestore/src/lite-api/pipeline.ts +++ b/packages/firestore/src/lite-api/pipeline.ts @@ -15,36 +15,28 @@ * limitations under the License. */ -/* eslint @typescript-eslint/no-explicit-any: 0 */ - import { ObjectValue } from '../model/object_value'; import { - ExecutePipelineRequest, - StructuredPipeline, + Pipeline as ProtoPipeline, Stage as ProtoStage } from '../protos/firestore_proto_api'; -import { invokeExecutePipeline } from '../remote/datastore'; -import { - getEncodedDatabaseId, - JsonProtoSerializer, - ProtoSerializable -} from '../remote/serializer'; +import { JsonProtoSerializer, ProtoSerializable } from '../remote/serializer'; +import { isPlainObject } from '../util/input_validation'; -import { getDatastore } from './components'; import { Firestore } from './database'; import { - Accumulator, - AccumulatorTarget, + _mapValue, + AggregateFunction, + AggregateWithAlias, Expr, ExprWithAlias, Field, - Fields, - FilterCondition, + BooleanExpr, Ordering, - Selectable + Selectable, + field, + Constant } from './expressions'; -import { PipelineResult } from './pipeline-result'; -import { DocumentReference } from './reference'; import { AddFields, Aggregate, @@ -54,8 +46,13 @@ import { GenericStage, Limit, Offset, + RemoveFields, + Replace, Select, Sort, + Sample, + Union, + Unnest, Stage, Where } from './stage'; @@ -70,7 +67,7 @@ interface ReadableUserData { _readUserData(dataReader: UserDataReader): void; } -function isReadableUserData(value: any): value is ReadableUserData { +function isReadableUserData(value: unknown): value is ReadableUserData { return typeof (value as ReadableUserData)._readUserData === 'function'; } @@ -97,30 +94,27 @@ function isReadableUserData(value: any): value is ReadableUserData { * const db: Firestore; // Assumes a valid firestore instance. * * // Example 1: Select specific fields and rename 'rating' to 'bookRating' - * const results1 = await db.pipeline() + * const results1 = await execute(db.pipeline() * .collection("books") - * .select("title", "author", Field.of("rating").as("bookRating")) - * .execute(); + * .select("title", "author", field("rating").as("bookRating"))); * * // Example 2: Filter documents where 'genre' is "Science Fiction" and 'published' is after 1950 - * const results2 = await db.pipeline() + * const results2 = await execute(db.pipeline() * .collection("books") - * .where(and(Field.of("genre").eq("Science Fiction"), Field.of("published").gt(1950))) - * .execute(); + * .where(and(field("genre").eq("Science Fiction"), field("published").gt(1950)))); * * // Example 3: Calculate the average rating of books published after 1980 - * const results3 = await db.pipeline() + * const results3 = await execute(db.pipeline() * .collection("books") - * .where(Field.of("published").gt(1980)) - * .aggregate(avg(Field.of("rating")).as("averageRating")) - * .execute(); + * .where(field("published").gt(1980)) + * .aggregate(avg(field("rating")).as("averageRating"))); * ``` */ /** * Base-class implementation */ -export class Pipeline implements ProtoSerializable { +export class Pipeline implements ProtoSerializable { /** * @internal * @private @@ -162,27 +156,53 @@ export class Pipeline implements ProtoSerializable { * ```typescript * firestore.pipeline().collection("books") * .addFields( - * Field.of("rating").as("bookRating"), // Rename 'rating' to 'bookRating' - * add(5, Field.of("quantity")).as("totalCost") // Calculate 'totalCost' + * field("rating").as("bookRating"), // Rename 'rating' to 'bookRating' + * add(5, field("quantity")).as("totalCost") // Calculate 'totalCost' * ); * ``` * - * @param fields The fields to add to the documents, specified as {@link Selectable}s. + * @param field The first field to add to the documents, specified as a {@link Selectable}. + * @param additionalFields Optional additional fields to add to the documents, specified as {@link Selectable}s. * @return A new Pipeline object with this stage appended to the stage list. */ - addFields(...fields: Selectable[]): Pipeline { - const copy = this.stages.map(s => s); - copy.push( + addFields(field: Selectable, ...additionalFields: Selectable[]): Pipeline { + return this._addStage( new AddFields( - this.readUserData('addFields', this.selectablesToMap(fields)) + this.readUserData( + 'addFields', + this.selectablesToMap([field, ...additionalFields]) + ) ) ); - return this.newPipeline( - this._db, - this.userDataReader, - this._userDataWriter, - copy + } + + /** + * Remove fields from outputs of previous stages. + * + * Example: + * + * ```typescript + * firestore.pipeline().collection('books') + * // removes field 'rating' and 'cost' from the previous stage outputs. + * .removeFields( + * field('rating'), + * 'cost' + * ); + * ``` + * + * @param fieldValue The first field to remove. + * @param additionalFields Optional additional fields to remove. + * @return A new Pipeline object with this stage appended to the stage list. + */ + removeFields( + fieldValue: Field | string, + ...additionalFields: Array + ): Pipeline { + const fieldExpressions = [fieldValue, ...additionalFields].map(f => + typeof f === 'string' ? field(f) : (f as Field) ); + this.readUserData('removeFields', fieldExpressions); + return this._addStage(new RemoveFields(fieldExpressions)); } /** @@ -198,7 +218,7 @@ export class Pipeline implements ProtoSerializable { * * *

If no selections are provided, the output of this stage is empty. Use {@link - * com.google.cloud.firestore.Pipeline#addFields} instead if only additions are + * Pipeline#addFields} instead if only additions are * desired. * *

Example: @@ -207,101 +227,36 @@ export class Pipeline implements ProtoSerializable { * firestore.pipeline().collection("books") * .select( * "firstName", - * Field.of("lastName"), - * Field.of("address").toUppercase().as("upperAddress"), + * field("lastName"), + * field("address").toUppercase().as("upperAddress"), * ); * ``` * - * @param selections The fields to include in the output documents, specified as {@link + * @param selection The first field to include in the output documents, specified as {@link + * Selectable} expression or string value representing the field name. + * @param additionalSelections Optional additional fields to include in the output documents, specified as {@link * Selectable} expressions or {@code string} values representing field names. * @return A new Pipeline object with this stage appended to the stage list. */ - select(...selections: Array): Pipeline { - const copy = this.stages.map(s => s); - let projections: Map = this.selectablesToMap(selections); - projections = this.readUserData('select', projections); - copy.push(new Select(projections)); - return this.newPipeline( - this._db, - this.userDataReader, - this._userDataWriter, - copy - ); - } - - private selectablesToMap( - selectables: Array - ): Map { - const result = new Map(); - for (const selectable of selectables) { - if (typeof selectable === 'string') { - result.set(selectable as string, Field.of(selectable)); - } else if (selectable instanceof Field) { - result.set((selectable as Field).fieldName(), selectable); - } else if (selectable instanceof Fields) { - const fields = selectable as Fields; - for (const field of fields.fieldList()) { - result.set(field.fieldName(), field); - } - } else if (selectable instanceof ExprWithAlias) { - const expr = selectable as ExprWithAlias; - result.set(expr.alias, expr.expr); - } - } - return result; - } - - /** - * Reads user data for each expression in the expressionMap. - * @param name Name of the calling function. Used for error messages when invalid user data is encountered. - * @param expressionMap - * @return the expressionMap argument. - * @private - */ - private readUserData< - T extends - | Map - | ReadableUserData[] - | ReadableUserData - >(name: string, expressionMap: T): T { - if (isReadableUserData(expressionMap)) { - expressionMap._readUserData(this.userDataReader); - } else if (Array.isArray(expressionMap)) { - expressionMap.forEach(readableData => - readableData._readUserData(this.userDataReader) - ); - } else { - expressionMap.forEach(expr => expr._readUserData(this.userDataReader)); - } - return expressionMap; - } - - /** - * @internal - * @private - * @param db - * @param userDataReader - * @param userDataWriter - * @param stages - * @protected - */ - protected newPipeline( - db: Firestore, - userDataReader: UserDataReader, - userDataWriter: AbstractUserDataWriter, - stages: Stage[], - converter: unknown = {} + select( + selection: Selectable | string, + ...additionalSelections: Array ): Pipeline { - return new Pipeline(db, userDataReader, userDataWriter, stages); + let projections: Map = this.selectablesToMap([ + selection, + ...additionalSelections + ]); + projections = this.readUserData('select', projections); + return this._addStage(new Select(projections)); } /** * Filters the documents from previous stages to only include those matching the specified {@link - * FilterCondition}. + * BooleanExpr}. * *

This stage allows you to apply conditions to the data, similar to a "WHERE" clause in SQL. * You can filter documents based on their field values, using implementations of {@link - * FilterCondition}, typically including but not limited to: + * BooleanExpr}, typically including but not limited to: * *

    *
  • field comparators: {@link Function#eq}, {@link Function#lt} (less than), {@link @@ -317,25 +272,18 @@ export class Pipeline implements ProtoSerializable { * firestore.pipeline().collection("books") * .where( * and( - * gt(Field.of("rating"), 4.0), // Filter for ratings greater than 4.0 - * Field.of("genre").eq("Science Fiction") // Equivalent to gt("genre", "Science Fiction") + * gt(field("rating"), 4.0), // Filter for ratings greater than 4.0 + * field("genre").eq("Science Fiction") // Equivalent to gt("genre", "Science Fiction") * ) * ); * ``` * - * @param condition The {@link FilterCondition} to apply. + * @param condition The {@link BooleanExpr} to apply. * @return A new Pipeline object with this stage appended to the stage list. */ - where(condition: FilterCondition): Pipeline { - const copy = this.stages.map(s => s); + where(condition: BooleanExpr): Pipeline { this.readUserData('where', condition); - copy.push(new Where(condition)); - return this.newPipeline( - this._db, - this.userDataReader, - this._userDataWriter, - copy - ); + return this._addStage(new Where(condition)); } /** @@ -350,7 +298,7 @@ export class Pipeline implements ProtoSerializable { * ```typescript * // Retrieve the second page of 20 results * firestore.pipeline().collection("books") - * .sort(Field.of("published").descending()) + * .sort(field("published").descending()) * .offset(20) // Skip the first 20 results * .limit(20); // Take the next 20 results * ``` @@ -359,14 +307,7 @@ export class Pipeline implements ProtoSerializable { * @return A new Pipeline object with this stage appended to the stage list. */ offset(offset: number): Pipeline { - const copy = this.stages.map(s => s); - copy.push(new Offset(offset)); - return this.newPipeline( - this._db, - this.userDataReader, - this._userDataWriter, - copy - ); + return this._addStage(new Offset(offset)); } /** @@ -387,7 +328,7 @@ export class Pipeline implements ProtoSerializable { * ```typescript * // Limit the results to the top 10 highest-rated books * firestore.pipeline().collection("books") - * .sort(Field.of("rating").descending()) + * .sort(field("rating").descending()) * .limit(10); * ``` * @@ -395,32 +336,28 @@ export class Pipeline implements ProtoSerializable { * @return A new Pipeline object with this stage appended to the stage list. */ limit(limit: number): Pipeline { - const copy = this.stages.map(s => s); - copy.push(new Limit(limit)); - return this.newPipeline( - this._db, - this.userDataReader, - this._userDataWriter, - copy - ); + return this._addStage(new Limit(limit)); } - _limit(limit: number, convertedFromLimitTolast: boolean): Pipeline { - const copy = this.stages.map(s => s); - copy.push(new Limit(limit, convertedFromLimitTolast)); - return this.newPipeline( - this._db, - this.userDataReader, - this._userDataWriter, - copy - ); + /** + * Internal use only. + * Helper to add a limit stage when converting from a Query. + * + * @internal + * @private + * + * @param limit + * @param convertedFromLimitToLast + */ + _limit(limit: number, convertedFromLimitToLast: boolean): Pipeline { + return this._addStage(new Limit(limit, convertedFromLimitToLast)); } /** * Returns a set of distinct {@link Expr} values from the inputs to this stage. * *

    This stage run through the results from previous stages to include only results with unique - * combinations of {@link Expr} values ({@link Field}, {@link Function}, etc). + * combinations of {@link Expr} values ({@link Field}, {@link Function}, etc.). * *

    The parameters to this stage are defined using {@link Selectable} expressions or {@code string}s: * @@ -436,35 +373,36 @@ export class Pipeline implements ProtoSerializable { * ```typescript * // Get a list of unique author names in uppercase and genre combinations. * firestore.pipeline().collection("books") - * .distinct(toUppercase(Field.of("author")).as("authorName"), Field.of("genre"), "publishedAt") + * .distinct(toUppercase(field("author")).as("authorName"), field("genre"), "publishedAt") * .select("authorName"); * ``` * - * @param selectables The {@link Selectable} expressions to consider when determining distinct - * value combinations or {@code string}s representing field names. + * @param group The first {@link Selectable} expression to consider when determining distinct + * value combinations or strings representing field names. + * @param additionalGroups Optional additional {@link Selectable} expressions to consider when determining distinct + * value combinations or strings representing field names. * @return A new {@code Pipeline} object with this stage appended to the stage list. */ - distinct(...groups: Array): Pipeline { - const copy = this.stages.map(s => s); - copy.push( + distinct( + group: string | Selectable, + ...additionalGroups: Array + ): Pipeline { + return this._addStage( new Distinct( - this.readUserData('distinct', this.selectablesToMap(groups || [])) + this.readUserData( + 'distinct', + this.selectablesToMap([group, ...additionalGroups]) + ) ) ); - return this.newPipeline( - this._db, - this.userDataReader, - this._userDataWriter, - copy - ); } /** * Performs aggregation operations on the documents from previous stages. * *

    This stage allows you to calculate aggregate values over a set of documents. You define the - * aggregations to perform using {@link AccumulatorTarget} expressions which are typically results of - * calling {@link Expr#as} on {@link Accumulator} instances. + * aggregations to perform using {@link AggregateWithAlias} expressions which are typically results of + * calling {@link Expr#as} on {@link AggregateFunction} instances. * *

    Example: * @@ -472,16 +410,21 @@ export class Pipeline implements ProtoSerializable { * // Calculate the average rating and the total number of books * firestore.pipeline().collection("books") * .aggregate( - * Field.of("rating").avg().as("averageRating"), + * field("rating").avg().as("averageRating"), * countAll().as("totalBooks") * ); * ``` * - * @param accumulators The {@link AccumulatorTarget} expressions, each wrapping an {@link Accumulator} + * @param accumulator The first {@link AggregateWithAlias}, wrapping an {@link AggregateFunction} + * and provide a name for the accumulated results. + * @param additionalAccumulators Optional additional {@link AggregateWithAlias}, each wrapping an {@link AggregateFunction} * and provide a name for the accumulated results. * @return A new Pipeline object with this stage appended to the stage list. */ - aggregate(...accumulators: AccumulatorTarget[]): Pipeline; + aggregate( + accumulator: AggregateWithAlias, + ...additionalAccumulators: AggregateWithAlias[] + ): Pipeline; /** * Performs optionally grouped aggregation operations on the documents from previous stages. * @@ -494,8 +437,8 @@ export class Pipeline implements ProtoSerializable { * If no grouping fields are provided, a single group containing all documents is used. Not * specifying groups is the same as putting the entire inputs into one group.

  • *
  • **Accumulators:** One or more accumulation operations to perform within each group. These - * are defined using {@link AccumulatorTarget} expressions, which are typically created by - * calling {@link Expr#as} on {@link Accumulator} instances. Each aggregation + * are defined using {@link AggregateWithAlias} expressions, which are typically created by + * calling {@link Expr#as} on {@link AggregateFunction} instances. Each aggregation * calculates a value (e.g., sum, average, count) based on the documents within its group.
  • *
* @@ -505,40 +448,43 @@ export class Pipeline implements ProtoSerializable { * // Calculate the average rating for each genre. * firestore.pipeline().collection("books") * .aggregate({ - * accumulators: [avg(Field.of("rating")).as("avg_rating")] + * accumulators: [avg(field("rating")).as("avg_rating")] * groups: ["genre"] * }); * ``` * - * @param aggregate An {@link Aggregate} object that specifies the grouping fields (if any) and - * the aggregation operations to perform. - * @return A new {@code Pipeline} object with this stage appended to the stage list. + * @param options An object that specifies the accumulators + * and optional grouping fields to perform. + * @return A new {@code Pipeline} object with this stage appended to the stage + * list. */ aggregate(options: { - accumulators: AccumulatorTarget[]; + accumulators: AggregateWithAlias[]; groups?: Array; }): Pipeline; aggregate( optionsOrTarget: - | AccumulatorTarget + | AggregateWithAlias | { - accumulators: AccumulatorTarget[]; + accumulators: AggregateWithAlias[]; groups?: Array; }, - ...rest: AccumulatorTarget[] + ...rest: AggregateWithAlias[] ): Pipeline { - const copy = this.stages.map(s => s); if ('accumulators' in optionsOrTarget) { - copy.push( + return this._addStage( new Aggregate( - new Map( - optionsOrTarget.accumulators.map((target: AccumulatorTarget) => [ - (target as unknown as AccumulatorTarget).alias, + new Map( + optionsOrTarget.accumulators.map((target: AggregateWithAlias) => { this.readUserData( 'aggregate', - (target as unknown as AccumulatorTarget).expr - ) - ]) + target as unknown as AggregateWithAlias + ); + return [ + (target as unknown as AggregateWithAlias).alias, + (target as unknown as AggregateWithAlias).aggregate + ]; + }) ), this.readUserData( 'aggregate', @@ -547,14 +493,14 @@ export class Pipeline implements ProtoSerializable { ) ); } else { - copy.push( + return this._addStage( new Aggregate( - new Map( + new Map( [optionsOrTarget, ...rest].map(target => [ - (target as unknown as AccumulatorTarget).alias, + (target as unknown as AggregateWithAlias).alias, this.readUserData( 'aggregate', - (target as unknown as AccumulatorTarget).expr + (target as unknown as AggregateWithAlias).aggregate ) ]) ), @@ -562,37 +508,24 @@ export class Pipeline implements ProtoSerializable { ) ); } - return this.newPipeline( - this._db, - this.userDataReader, - this._userDataWriter, - copy - ); } findNearest(options: FindNearestOptions): Pipeline { - const copy = this.stages.map(s => s); const parseContext = this.userDataReader.createContext( UserDataSource.Argument, 'findNearest' ); const value = parseVectorValue(options.vectorValue, parseContext); const vectorObjectValue = new ObjectValue(value); - copy.push( + return this._addStage( new FindNearest( - options.field, + options.field instanceof Field ? options.field : field(options.field), vectorObjectValue, options.distanceMeasure, options.limit, options.distanceField ) ); - return this.newPipeline( - this._db, - this.userDataReader, - this._userDataWriter, - copy - ); } /** @@ -611,15 +544,16 @@ export class Pipeline implements ProtoSerializable { * // with the same rating * firestore.pipeline().collection("books") * .sort( - * Ordering.of(Field.of("rating")).descending(), - * Ordering.of(Field.of("title")) // Ascending order is the default + * Ordering.of(field("rating")).descending(), + * Ordering.of(field("title")) // Ascending order is the default * ); * ``` * - * @param orders One or more {@link Ordering} instances specifying the sorting criteria. + * @param ordering The first {@link Ordering} instance specifying the sorting criteria. + * @param additionalOrderings Optional additional {@link Ordering} instances specifying the additional sorting criteria. * @return A new {@code Pipeline} object with this stage appended to the stage list. */ - sort(...orderings: Ordering[]): Pipeline; + sort(ordering: Ordering, ...additionalOrderings: Ordering[]): Pipeline; sort( optionsOrOrderings: | Ordering @@ -628,10 +562,9 @@ export class Pipeline implements ProtoSerializable { }, ...rest: Ordering[] ): Pipeline { - const copy = this.stages.map(s => s); // Option object - if ('orderings' in optionsOrOrderings) { - copy.push( + if (optionsOrOrderings && 'orderings' in optionsOrOrderings) { + return this._addStage( new Sort( this.readUserData( 'sort', @@ -641,17 +574,205 @@ export class Pipeline implements ProtoSerializable { ); } else { // Ordering object - copy.push( + return this._addStage( new Sort(this.readUserData('sort', [optionsOrOrderings, ...rest])) ); } + } - return this.newPipeline( - this._db, - this.userDataReader, - this._userDataWriter, - copy - ); + /** + * Fully overwrites all fields in a document with those coming from a nested map. + * + *

This stage allows you to emit a map value as a document. Each key of the map becomes a field + * on the document that contains the corresponding value. + * + *

Example: + * + * ```typescript + * // Input. + * // { + * // 'name': 'John Doe Jr.', + * // 'parents': { + * // 'father': 'John Doe Sr.', + * // 'mother': 'Jane Doe' + * // } + * // } + * + * // Emit parents as document. + * firestore.pipeline().collection('people').replaceWith('parents'); + * + * // Output + * // { + * // 'father': 'John Doe Sr.', + * // 'mother': 'Jane Doe' + * // } + * ``` + * + * @param fieldName The {@link Field} field containing the nested map. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + replaceWith(fieldName: string): Pipeline; + + /** + * Fully overwrites all fields in a document with those coming from a map. + * + *

This stage allows you to emit a map value as a document. Each key of the map becomes a field + * on the document that contains the corresponding value. + * + *

Example: + * + * ```typescript + * // Input. + * // { + * // 'name': 'John Doe Jr.', + * // 'parents': { + * // 'father': 'John Doe Sr.', + * // 'mother': 'Jane Doe' + * // } + * // } + * + * // Emit parents as document. + * firestore.pipeline().collection('people').replaceWith(map({ + * foo: 'bar', + * info: { + * name: field('name') + * } + * })); + * + * // Output + * // { + * // 'father': 'John Doe Sr.', + * // 'mother': 'Jane Doe' + * // } + * ``` + * + * @param expr An {@link Expr} that when returned evaluates to a map. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + replaceWith(expr: Expr): Pipeline; + replaceWith(value: Expr | string): Pipeline { + const fieldExpr = typeof value === 'string' ? field(value) : value; + this.readUserData('replaceWith', fieldExpr); + return this._addStage(new Replace(fieldExpr, 'full_replace')); + } + + /** + * Performs a pseudo-random sampling of the documents from the previous stage. + * + *

This stage will filter documents pseudo-randomly. The parameter specifies how number of + * documents to be returned. + * + *

Examples: + * + * ```typescript + * // Sample 25 books, if available. + * firestore.pipeline().collection('books') + * .sample(25); + * ``` + * + * @param documents The number of documents to sample. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + sample(documents: number): Pipeline; + + /** + * Performs a pseudo-random sampling of the documents from the previous stage. + * + *

This stage will filter documents pseudo-randomly. The 'options' parameter specifies how + * sampling will be performed. See {@code SampleOptions} for more information. + * + *

Examples: + * + * // Sample 10 books, if available. + * firestore.pipeline().collection("books") + * .sample({ documents: 10 }); + * + * // Sample 50% of books. + * firestore.pipeline().collection("books") + * .sample({ percentage: 0.5 }); + * + * @param options The {@code SampleOptions} specifies how sampling is performed. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + sample(options: { percentage: number } | { documents: number }): Pipeline; + sample( + documentsOrOptions: number | { percentage: number } | { documents: number } + ): Pipeline { + if (typeof documentsOrOptions === 'number') { + return this._addStage(new Sample(documentsOrOptions, 'documents')); + } else if ('percentage' in documentsOrOptions) { + return this._addStage( + new Sample(documentsOrOptions.percentage, 'percent') + ); + } else { + return this._addStage( + new Sample(documentsOrOptions.documents, 'documents') + ); + } + } + + /** + * Performs union of all documents from two pipelines, including duplicates. + * + *

This stage will pass through documents from previous stage, and also pass through documents + * from previous stage of the `other` {@code Pipeline} given in parameter. The order of documents + * emitted from this stage is undefined. + * + *

Example: + * + * ```typescript + * // Emit documents from books collection and magazines collection. + * firestore.pipeline().collection('books') + * .union(firestore.pipeline().collection('magazines')); + * ``` + * + * @param other The other {@code Pipeline} that is part of union. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + union(other: Pipeline): Pipeline { + return this._addStage(new Union(other)); + } + + /** + * Produces a document for each element in array found in previous stage document. + * + * For each previous stage document, this stage will emit zero or more augmented documents. The + * input array found in the previous stage document field specified by the `selectable` parameter, + * will emit an augmented document for each input array element. The input array element will + * augment the previous stage document by setting the `alias` field with the array element value. + * + * When `selectable` evaluates to a non-array value (ex: number, null, absent), then the stage becomes a no-op for + * the current input document, returning it as is with the `alias` field absent. + * + * No documents are emitted when `selectable` evaluates to an empty array. + * + * Example: + * + * ```typescript + * // Input: + * // { "title": "The Hitchhiker's Guide to the Galaxy", "tags": [ "comedy", "space", "adventure" ], ... } + * + * // Emit a book document for each tag of the book. + * firestore.pipeline().collection("books") + * .unnest(field("tags").as('tag'), 'tagIndex'); + * + * // Output: + * // { "title": "The Hitchhiker's Guide to the Galaxy", "tag": "comedy", "tagIndex": 0, ... } + * // { "title": "The Hitchhiker's Guide to the Galaxy", "tag": "space", "tagIndex": 1, ... } + * // { "title": "The Hitchhiker's Guide to the Galaxy", "tag": "adventure", "tagIndex": 2, ... } + * ``` + * + * @param selectable A selectable expression defining the field to unnest and the alias to use for each un-nested element in the output documents. + * @param indexField An optional string value specifying the field path to write the offset (starting at zero) into the array the un-nested element is from + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + unnest(selectable: Selectable, indexField?: string): Pipeline { + this.readUserData('unnest', selectable.expr); + + const alias = field(selectable.alias); + this.readUserData('unnest', alias); + + return this._addStage(new Unnest(selectable.expr, alias, indexField)); } /** @@ -666,7 +787,7 @@ export class Pipeline implements ProtoSerializable { * ```typescript * // Assume we don't have a built-in "where" stage * firestore.pipeline().collection("books") - * .genericStage("where", [Field.of("published").lt(1900)]) // Custom "where" stage + * .genericStage("where", [field("published").lt(1900)]) // Custom "where" stage * .select("title", "author"); * ``` * @@ -674,14 +795,45 @@ export class Pipeline implements ProtoSerializable { * @param params A list of parameters to configure the generic stage's behavior. * @return A new {@code Pipeline} object with this stage appended to the stage list. */ - genericStage(name: string, params: any[]): Pipeline { - const copy = this.stages.map(s => s); - params.forEach(param => { + genericStage(name: string, params: unknown[]): Pipeline { + // Convert input values to Expressions. + // We treat objects as mapValues and arrays as arrayValues, + // this is unlike the default conversion for objects and arrays + // passed to an expression. + const expressionParams = params.map((value: unknown) => { + if (value instanceof Expr) { + return value; + } else if (value instanceof AggregateFunction) { + return value; + } else if (isPlainObject(value)) { + return _mapValue(value as Record); + } else { + return new Constant(value); + } + }); + + expressionParams.forEach(param => { if (isReadableUserData(param)) { param._readUserData(this.userDataReader); } }); - copy.push(new GenericStage(name, params)); + return this._addStage(new GenericStage(name, expressionParams)); + } + + /** + * @internal + * @private + */ + _toProto(jsonProtoSerializer: JsonProtoSerializer): ProtoPipeline { + const stages: ProtoStage[] = this.stages.map(stage => + stage._toProto(jsonProtoSerializer) + ); + return { stages }; + } + + private _addStage(stage: Stage): Pipeline { + const copy = this.stages.map(s => s); + copy.push(stage); return this.newPipeline( this._db, this.userDataReader, @@ -690,74 +842,62 @@ export class Pipeline implements ProtoSerializable { ); } + private selectablesToMap( + selectables: Array + ): Map { + const result = new Map(); + for (const selectable of selectables) { + if (typeof selectable === 'string') { + result.set(selectable as string, field(selectable)); + } else if (selectable instanceof Field) { + result.set(selectable.alias, selectable.expr); + } else if (selectable instanceof ExprWithAlias) { + result.set(selectable.alias, selectable.expr); + } + } + return result; + } + /** - * Executes this pipeline and returns a Promise to represent the asynchronous operation. - * - *

The returned Promise can be used to track the progress of the pipeline execution - * and retrieve the results (or handle any errors) asynchronously. - * - *

The pipeline results are returned as a list of {@link PipelineResult} objects. Each {@link - * PipelineResult} typically represents a single key/value map that has passed through all the - * stages of the pipeline, however this might differ depending on the stages involved in the - * pipeline. For example: - * - *

    - *
  • If there are no stages or only transformation stages, each {@link PipelineResult} - * represents a single document.
  • - *
  • If there is an aggregation, only a single {@link PipelineResult} is returned, - * representing the aggregated results over the entire dataset .
  • - *
  • If there is an aggregation stage with grouping, each {@link PipelineResult} represents a - * distinct group and its associated aggregated values.
  • - *
- * - *

Example: - * - * ```typescript - * const futureResults = await firestore.pipeline().collection("books") - * .where(gt(Field.of("rating"), 4.5)) - * .select("title", "author", "rating") - * .execute(); - * ``` - * - * @return A Promise representing the asynchronous pipeline execution. + * Reads user data for each expression in the expressionMap. + * @param name Name of the calling function. Used for error messages when invalid user data is encountered. + * @param expressionMap + * @return the expressionMap argument. + * @private */ - execute(): Promise { - const datastore = getDatastore(this._db); - return invokeExecutePipeline(datastore, this).then(result => { - const docs = result - // Currently ignore any response from ExecutePipeline that does - // not contain any document data in the `fields` property. - .filter(element => !!element.fields) - .map( - element => - new PipelineResult( - this._userDataWriter, - element.key?.path - ? new DocumentReference(this._db, null, element.key) - : undefined, - element.fields, - element.executionTime?.toTimestamp(), - element.createTime?.toTimestamp(), - element.updateTime?.toTimestamp() - ) - ); - - return docs; - }); + private readUserData< + T extends + | Map + | ReadableUserData[] + | ReadableUserData + >(name: string, expressionMap: T): T { + if (isReadableUserData(expressionMap)) { + expressionMap._readUserData(this.userDataReader); + } else if (Array.isArray(expressionMap)) { + expressionMap.forEach(readableData => + readableData._readUserData(this.userDataReader) + ); + } else { + expressionMap.forEach(expr => expr._readUserData(this.userDataReader)); + } + return expressionMap; } /** * @internal * @private + * @param db + * @param userDataReader + * @param userDataWriter + * @param stages + * @protected */ - _toProto(jsonProtoSerializer: JsonProtoSerializer): ExecutePipelineRequest { - const stages: ProtoStage[] = this.stages.map(stage => - stage._toProto(jsonProtoSerializer) - ); - const structuredPipeline: StructuredPipeline = { pipeline: { stages } }; - return { - database: getEncodedDatabaseId(jsonProtoSerializer), - structuredPipeline - }; + protected newPipeline( + db: Firestore, + userDataReader: UserDataReader, + userDataWriter: AbstractUserDataWriter, + stages: Stage[] + ): Pipeline { + return new Pipeline(db, userDataReader, userDataWriter, stages); } } diff --git a/packages/firestore/src/lite-api/pipeline_impl.ts b/packages/firestore/src/lite-api/pipeline_impl.ts index 98b121ad485..c1ca940a56b 100644 --- a/packages/firestore/src/lite-api/pipeline_impl.ts +++ b/packages/firestore/src/lite-api/pipeline_impl.ts @@ -15,11 +15,14 @@ * limitations under the License. */ +import { invokeExecutePipeline } from '../remote/datastore'; + +import { getDatastore } from './components'; import { Firestore } from './database'; import { Pipeline } from './pipeline'; -import { PipelineResult } from './pipeline-result'; +import { PipelineResult, PipelineSnapshot } from './pipeline-result'; import { PipelineSource } from './pipeline-source'; -import { Query } from './reference'; +import { DocumentReference } from './reference'; import { LiteUserDataWriter } from './reference_impl'; import { Stage } from './stage'; import { newUserDataReader } from './user_data_reader'; @@ -30,67 +33,74 @@ declare module './database' { } } -declare module './reference' { - interface Query { - pipeline(): Pipeline; - } -} - -/** - * Modular API for console experimentation. - * @param pipeline Execute this pipeline. - * @beta - */ -export function execute(pipeline: Pipeline): Promise { - return pipeline.execute(); -} - -/** - * Experimental Modular API for console testing. - * @param firestore - */ -export function pipeline(firestore: Firestore): PipelineSource; - /** - * Experimental Modular API for console testing. - * @param query + * Executes this pipeline and returns a Promise to represent the asynchronous operation. + * + * The returned Promise can be used to track the progress of the pipeline execution + * and retrieve the results (or handle any errors) asynchronously. + * + * The pipeline results are returned as a {@link PipelineSnapshot} that contains + * a list of {@link PipelineResult} objects. Each {@link PipelineResult} typically + * represents a single key/value map that has passed through all the + * stages of the pipeline, however this might differ depending on the stages involved in the + * pipeline. For example: + * + *

    + *
  • If there are no stages or only transformation stages, each {@link PipelineResult} + * represents a single document.
  • + *
  • If there is an aggregation, only a single {@link PipelineResult} is returned, + * representing the aggregated results over the entire dataset .
  • + *
  • If there is an aggregation stage with grouping, each {@link PipelineResult} represents a + * distinct group and its associated aggregated values.
  • + *
+ * + *

Example: + * + * ```typescript + * const snapshot: PipelineSnapshot = await execute(firestore.pipeline().collection("books") + * .where(gt(field("rating"), 4.5)) + * .select("title", "author", "rating")); + * + * const results: PipelineResults = snapshot.results; + * ``` + * + * @param pipeline The pipeline to execute. + * @return A Promise representing the asynchronous pipeline execution. */ -export function pipeline(query: Query): Pipeline; - -export function pipeline( - firestoreOrQuery: Firestore | Query -): PipelineSource | Pipeline { - if (firestoreOrQuery instanceof Firestore) { - const db = firestoreOrQuery; - const userDataWriter = new LiteUserDataWriter(db); - const userDataReader = newUserDataReader(db); - return new PipelineSource((stages: Stage[]) => { - return new Pipeline(db, userDataReader, userDataWriter, stages); - }); - } else { - let pipeline; - const query = firestoreOrQuery; - if (query._query.collectionGroup) { - pipeline = query.firestore - .pipeline() - .collectionGroup(query._query.collectionGroup); - } else { - pipeline = query.firestore - .pipeline() - .collection(query._query.path.canonicalString()); - } +export function execute(pipeline: Pipeline): Promise { + const datastore = getDatastore(pipeline._db); + return invokeExecutePipeline(datastore, pipeline).then(result => { + // Get the execution time from the first result. + // firestoreClientExecutePipeline returns at least one PipelineStreamElement + // even if the returned document set is empty. + const executionTime = + result.length > 0 ? result[0].executionTime?.toTimestamp() : undefined; - // TODO(pipeline) convert existing query filters, limits, etc into - // pipeline stages + const docs = result + // Currently ignore any response from ExecutePipeline that does + // not contain any document data in the `fields` property. + .filter(element => !!element.fields) + .map( + element => + new PipelineResult( + pipeline._userDataWriter, + element.key?.path + ? new DocumentReference(pipeline._db, null, element.key) + : undefined, + element.fields, + element.createTime?.toTimestamp(), + element.updateTime?.toTimestamp() + ) + ); - return pipeline; - } + return new PipelineSnapshot(pipeline, docs, executionTime); + }); } Firestore.prototype.pipeline = function (): PipelineSource { - return pipeline(this); -}; - -Query.prototype.pipeline = function (): Pipeline { - return pipeline(this); + const userDataWriter = new LiteUserDataWriter(this); + const userDataReader = newUserDataReader(this); + return new PipelineSource(this._databaseId, (stages: Stage[]) => { + return new Pipeline(this, userDataReader, userDataWriter, stages); + }); }; diff --git a/packages/firestore/src/lite-api/reference.ts b/packages/firestore/src/lite-api/reference.ts index 26ae2fbd433..e9f5685e2b1 100644 --- a/packages/firestore/src/lite-api/reference.ts +++ b/packages/firestore/src/lite-api/reference.ts @@ -581,7 +581,7 @@ export function doc( ) { throw new FirestoreError( Code.INVALID_ARGUMENT, - 'Expected first argument to collection() to be a CollectionReference, ' + + 'Expected first argument to doc() to be a CollectionReference, ' + 'a DocumentReference or FirebaseFirestore' ); } diff --git a/packages/firestore/src/lite-api/snapshot.ts b/packages/firestore/src/lite-api/snapshot.ts index 3024e2e9db0..66c3a1422e9 100644 --- a/packages/firestore/src/lite-api/snapshot.ts +++ b/packages/firestore/src/lite-api/snapshot.ts @@ -23,6 +23,7 @@ import { FieldPath as InternalFieldPath } from '../model/path'; import { arrayEquals } from '../util/misc'; import { Firestore } from './database'; +import { Field } from './expressions'; import { FieldPath } from './field_path'; import { DocumentData, @@ -515,12 +516,14 @@ export function snapshotEqual( */ export function fieldPathFromArgument( methodName: string, - arg: string | FieldPath | Compat + arg: string | FieldPath | Compat | Field ): InternalFieldPath { if (typeof arg === 'string') { return fieldPathFromDotSeparatedString(methodName, arg); } else if (arg instanceof FieldPath) { return arg._internalPath; + } else if (arg instanceof Field) { + return fieldPathFromDotSeparatedString(methodName, arg.fieldName()); } else { return arg._delegate._internalPath; } diff --git a/packages/firestore/src/lite-api/stage.ts b/packages/firestore/src/lite-api/stage.ts index 46f8fe60654..1d8ae06eaf6 100644 --- a/packages/firestore/src/lite-api/stage.ts +++ b/packages/firestore/src/lite-api/stage.ts @@ -25,17 +25,20 @@ import { JsonProtoSerializer, ProtoSerializable, toMapValue, + toPipelineValue, toStringValue } from '../remote/serializer'; import { hardAssert } from '../util/assert'; import { - Accumulator, + AggregateFunction, Expr, Field, - FilterCondition, - Ordering + BooleanExpr, + Ordering, + field } from './expressions'; +import { Pipeline } from './pipeline'; import { DocumentReference } from './reference'; import { VectorValue } from './vector_value'; @@ -66,6 +69,26 @@ export class AddFields implements Stage { } } +/** + * @beta + */ +export class RemoveFields implements Stage { + name = 'remove_fields'; + + constructor(private fields: Field[]) {} + + /** + * @internal + * @private + */ + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: this.fields.map(f => f._toProto(serializer)) + }; + } +} + /** * @beta */ @@ -73,7 +96,7 @@ export class Aggregate implements Stage { name = 'aggregate'; constructor( - private accumulators: Map, + private accumulators: Map, private groups: Map ) {} @@ -181,8 +204,16 @@ export class DocumentsSource implements Stage { constructor(private docPaths: string[]) {} - static of(refs: DocumentReference[]): DocumentsSource { - return new DocumentsSource(refs.map(ref => '/' + ref.path)); + static of(refs: Array): DocumentsSource { + return new DocumentsSource( + refs.map(ref => + ref instanceof DocumentReference + ? '/' + ref.path + : ref.startsWith('/') + ? ref + : '/' + ref + ) + ); } /** @@ -205,7 +236,7 @@ export class DocumentsSource implements Stage { export class Where implements Stage { name = 'where'; - constructor(private condition: FilterCondition) {} + constructor(private condition: BooleanExpr) {} /** * @internal @@ -223,7 +254,7 @@ export class Where implements Stage { * @beta */ export interface FindNearestOptions { - field: Field; + field: Field | string; vectorValue: VectorValue | number[]; distanceMeasure: 'euclidean' | 'cosine' | 'dot_product'; limit?: number; @@ -267,9 +298,7 @@ export class FindNearest implements Stage { if (this._distanceField) { // eslint-disable-next-line camelcase - options.distance_field = Field.of(this._distanceField)._toProto( - serializer - ); + options.distance_field = field(this._distanceField)._toProto(serializer); } return { @@ -372,18 +401,108 @@ export class Sort implements Stage { } } +/** + * @beta + */ +export class Sample implements Stage { + name = 'sample'; + + constructor(private limit: number, private mode: string) {} + + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: [toNumber(serializer, this.limit)!, toStringValue(this.mode)!] + }; + } +} + +/** + * @beta + */ +export class Union implements Stage { + name = 'union'; + + constructor(private _other: Pipeline) {} + + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: [toPipelineValue(this._other._toProto(serializer))] + }; + } +} + +/** + * @beta + */ +export class Unnest implements Stage { + name = 'unnest'; + constructor( + private expr: Expr, + private alias: Field, + private indexField?: string + ) {} + + _toProto(serializer: JsonProtoSerializer): ProtoStage { + const stageProto: ProtoStage = { + name: this.name, + args: [this.expr._toProto(serializer), this.alias._toProto(serializer)] + }; + + if (this.indexField) { + stageProto.options = { + indexField: toStringValue(this.indexField) + }; + } + + return stageProto; + } +} + +/** + * @beta + */ +export class Replace implements Stage { + name = 'replace_with'; + + constructor( + private field: Expr, + private mode: + | 'full_replace' + | 'merge_prefer_nest' + | 'merge_prefer_parent' = 'full_replace' + ) {} + + _toProto(serializer: JsonProtoSerializer): ProtoStage { + return { + name: this.name, + args: [this.field._toProto(serializer), toStringValue(this.mode)] + }; + } +} + /** * @beta */ export class GenericStage implements Stage { - constructor(public name: string, params: unknown[]) {} + /** + * @private + * @internal + */ + constructor( + public name: string, + private params: Array + ) {} /** * @internal * @private */ _toProto(serializer: JsonProtoSerializer): ProtoStage { - // TODO support generic stage - return {}; + return { + name: this.name, + args: this.params.map(o => o._toProto(serializer)) + }; } } diff --git a/packages/firestore/src/lite-api/user_data_reader.ts b/packages/firestore/src/lite-api/user_data_reader.ts index 42f905d5cab..e3e0deaa479 100644 --- a/packages/firestore/src/lite-api/user_data_reader.ts +++ b/packages/firestore/src/lite-api/user_data_reader.ts @@ -22,7 +22,7 @@ import { } from '@firebase/firestore-types'; import { Compat, deepEqual, getModularInstance } from '@firebase/util'; -import { ParseContext } from '../api/parse_context'; +import { ContextSettings, ParseContext } from '../api/parse_context'; import { DatabaseId } from '../core/database_info'; import { DocumentKey } from '../model/document_key'; import { FieldMask } from '../model/field_mask'; @@ -56,7 +56,8 @@ import { JsonProtoSerializer, toBytes, toResourceName, - toTimestamp + toTimestamp, + isProtoValueSerializable } from '../remote/serializer'; import { debugAssert, fail } from '../util/assert'; import { Code, FirestoreError } from '../util/error'; @@ -179,33 +180,6 @@ function isWrite(dataSource: UserDataSource): boolean { } } -/** Contains the settings that are mutated as we parse user data. */ -interface ContextSettings { - /** Indicates what kind of API method this data came from. */ - readonly dataSource: UserDataSource; - /** The name of the method the user called to create the ParseContext. */ - readonly methodName: string; - /** The document the user is attempting to modify, if that applies. */ - readonly targetDoc?: DocumentKey; - /** - * A path within the object being parsed. This could be an empty path (in - * which case the context represents the root of the data being parsed), or a - * nonempty path (indicating the context represents a nested location within - * the data). - */ - readonly path?: InternalFieldPath; - /** - * Whether or not this context corresponds to an element of an array. - * If not set, elements are treated as if they were outside of arrays. - */ - readonly arrayElement?: boolean; - /** - * Whether or not a converter was specified in this context. If true, error - * messages will reference the converter when invalid data is provided. - */ - readonly hasConverter?: boolean; -} - /** A "context" object passed around while parsing user data. */ class ParseContextImpl implements ParseContext { readonly fieldTransforms: FieldTransform[]; @@ -729,7 +703,7 @@ export function parseQueryValue( */ export function parseData( input: unknown, - context: ParseContextImpl + context: ParseContext ): ProtoValue | null { // Unwrap the API type from the Compat SDK. This will return the API type // from firestore-exp. @@ -780,7 +754,7 @@ export function parseData( function parseObject( obj: Dict, - context: ParseContextImpl + context: ParseContext ): { mapValue: ProtoMapValue } { const fields: Dict = {}; @@ -802,7 +776,7 @@ function parseObject( return { mapValue: { fields } }; } -function parseArray(array: unknown[], context: ParseContextImpl): ProtoValue { +function parseArray(array: unknown[], context: ParseContext): ProtoValue { const values: ProtoValue[] = []; let entryIndex = 0; for (const entry of array) { @@ -827,7 +801,7 @@ function parseArray(array: unknown[], context: ParseContextImpl): ProtoValue { */ function parseSentinelFieldValue( value: FieldValue, - context: ParseContextImpl + context: ParseContext ): void { // Sentinels are only supported with writes, and not within arrays. if (!isWrite(context.dataSource)) { @@ -854,7 +828,7 @@ function parseSentinelFieldValue( */ export function parseScalarValue( value: unknown, - context: ParseContextImpl + context: ParseContext ): ProtoValue | null { value = getModularInstance(value); @@ -909,6 +883,8 @@ export function parseScalarValue( }; } else if (value instanceof VectorValue) { return parseVectorValue(value, context); + } else if (isProtoValueSerializable(value)) { + return value._toProto(context.serializer); } else { throw context.createError( `Unsupported field value: ${valueDescription(value)}` @@ -921,7 +897,7 @@ export function parseScalarValue( */ export function parseVectorValue( value: VectorValue | number[], - context: ParseContextImpl + context: ParseContext ): { mapValue: ProtoMapValue } { const values = value instanceof VectorValue ? value.toArray() : value; const mapValue: ProtoMapValue = { @@ -955,7 +931,7 @@ export function parseVectorValue( * GeoPoints, etc. are not considered to look like JSON objects since they map * to specific FieldValue types other than ObjectValue. */ -function looksLikeJsonObject(input: unknown): boolean { +export function looksLikeJsonObject(input: unknown): boolean { return ( typeof input === 'object' && input !== null && @@ -966,13 +942,14 @@ function looksLikeJsonObject(input: unknown): boolean { !(input instanceof Bytes) && !(input instanceof DocumentReference) && !(input instanceof FieldValue) && - !(input instanceof VectorValue) + !(input instanceof VectorValue) && + !isProtoValueSerializable(input) ); } function validatePlainObject( message: string, - context: ParseContextImpl, + context: ParseContext, input: unknown ): asserts input is Dict { if (!looksLikeJsonObject(input) || !isPlainObject(input)) { diff --git a/packages/firestore/src/remote/datastore.ts b/packages/firestore/src/remote/datastore.ts index 00c1e7fca9e..32666feeea1 100644 --- a/packages/firestore/src/remote/datastore.ts +++ b/packages/firestore/src/remote/datastore.ts @@ -59,7 +59,8 @@ import { toQueryTarget, toResourcePath, toRunAggregationQueryRequest, - fromPipelineResponse + fromPipelineResponse, + getEncodedDatabaseId } from './serializer'; /** @@ -244,7 +245,12 @@ export async function invokeExecutePipeline( pipeline: Pipeline ): Promise { const datastoreImpl = debugCast(datastore, DatastoreImpl); - const executePipelineRequest = pipeline._toProto(datastoreImpl.serializer); + const executePipelineRequest: ProtoExecutePipelineRequest = { + database: getEncodedDatabaseId(datastoreImpl.serializer), + structuredPipeline: { + pipeline: pipeline._toProto(datastoreImpl.serializer) + } + }; const response = await datastoreImpl.invokeStreamingRPC< ProtoExecutePipelineRequest, diff --git a/packages/firestore/src/remote/serializer.ts b/packages/firestore/src/remote/serializer.ts index 4759571b4a5..1ed2c7cd381 100644 --- a/packages/firestore/src/remote/serializer.ts +++ b/packages/firestore/src/remote/serializer.ts @@ -15,6 +15,7 @@ * limitations under the License. */ +import { ParseContext } from '../api/parse_context'; import { Aggregate } from '../core/aggregate'; import { Bound } from '../core/bound'; import { DatabaseId } from '../core/database_info'; @@ -94,7 +95,8 @@ import { WriteResult as ProtoWriteResult, Value as ProtoValue, MapValue as ProtoMapValue, - ExecutePipelineResponse as ProtoExecutePipelineResponse + ExecutePipelineResponse as ProtoExecutePipelineResponse, + Pipeline } from '../protos/firestore_proto_api'; import { debugAssert, fail, hardAssert } from '../util/assert'; import { ByteString } from '../util/byte_string'; @@ -1433,8 +1435,24 @@ export interface ProtoSerializable { _toProto(serializer: JsonProtoSerializer): ProtoType; } +export interface ProtoValueSerializable extends ProtoSerializable { + // Supports runtime identification of the ProtoSerializable type. + _protoValueType: 'ProtoValue'; +} + +export function isProtoValueSerializable( + // eslint-disable-next-line @typescript-eslint/no-explicit-any + value: any +): value is ProtoValueSerializable { + return ( + !!value && + typeof value._toProto === 'function' && + value._protoValueType === 'ProtoValue' + ); +} + export interface UserData { - _readUserData(dataReader: UserDataReader): void; + _readUserData(dataReader: UserDataReader, context?: ParseContext): void; } export function toMapValue( @@ -1466,6 +1484,10 @@ export function toStringValue(value: string): ProtoValue { return { stringValue: value }; } +export function toPipelineValue(value: Pipeline): ProtoValue { + return { pipelineValue: value }; +} + export function dateToTimestampValue( serializer: JsonProtoSerializer, value: Date diff --git a/packages/firestore/src/util/types.ts b/packages/firestore/src/util/types.ts index c298bfe2131..361ebda1935 100644 --- a/packages/firestore/src/util/types.ts +++ b/packages/firestore/src/util/types.ts @@ -51,6 +51,10 @@ export function isSafeInteger(value: unknown): boolean { ); } +export function isString(value: unknown): value is string { + return typeof value === 'string'; +} + /** The subset of the browser's Window interface used by the SDK. */ export interface WindowLike { readonly localStorage: Storage; diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index 48441c26065..7fc26ce58cd 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -18,312 +18,914 @@ import { expect, use } from 'chai'; import chaiAsPromised from 'chai-as-promised'; -import { Bytes, vector } from '../../../src/api'; -import { GeoPoint } from '../../../src/lite-api/geo_point'; -import { Timestamp } from '../../../src/lite-api/timestamp'; +import { + AggregateFunction, + ascending, + BooleanExpr, + byteLength, + constantVector, + FunctionExpr, + timestampAdd, + timestampToUnixMicros, + timestampToUnixMillis, + timestampToUnixSeconds, + toLower, + unixMicrosToTimestamp, + unixMillisToTimestamp, + vectorLength +} from '../../../src/lite-api/expressions'; +import { PipelineSnapshot } from '../../../src/lite-api/pipeline-result'; import { addEqualityMatcher } from '../../util/equality_matcher'; import { Deferred } from '../../util/promise'; import { - pipeline, + GeoPoint, + Timestamp, + Bytes, + getFirestore, + terminate, + vector, + CollectionReference, + doc, + DocumentData, + Firestore, + setDoc, + setLogLevel, + collection, + documentId as documentIdFieldPath, + writeBatch, + addDoc +} from '../util/firebase_export'; +import { apiDescribe, withTestCollection, itIf } from '../util/helpers'; +import { + array, + mod, + pipelineResultEqual, + sum, + replaceFirst, + replaceAll, + descending, + isNan, + map, execute, - _internalPipelineToExecutePipelineRequestProto, add, - andFunction, + arrayContainsAll, + unixSecondsToTimestamp, + and, arrayContains, arrayContainsAny, - avgFunction, - CollectionReference, - Constant, + count, + avg, cosineDistance, + not, countAll, - doc, - DocumentData, dotProduct, endsWith, eq, + reverse, + toUpper, euclideanDistance, - Field, - Firestore, gt, like, lt, + strContains, + divide, lte, + arrayLength, + arrayConcat, mapGet, neq, - not, - orFunction, - PipelineResult, + or, regexContains, regexMatch, - setDoc, startsWith, + strConcat, subtract, - setLogLevel, cond, eqAny, logicalMaximum, - logicalMinimum, notEqAny, - query, - where, - FieldPath, - orderBy, - limit, - limitToLast, - startAt, - startAfter, - endAt, - endBefore, - collectionGroup, - collection, - and, + multiply, + countIf, + bitAnd, + bitOr, + bitXor, + bitNot, + exists, + bitLeftShift, + charLength, + bitRightShift, + rand, + arrayOffset, + minimum, + maximum, + currentContext, + isError, + ifError, + trim, + isAbsent, + isNull, + isNotNull, + isNotNan, + timestampSub, + mapRemove, + mapMerge, documentId, - addDoc, - getDoc -} from '../util/firebase_export'; -import { - apiDescribe, - PERSISTENCE_MODE_UNSPECIFIED, - withTestCollection -} from '../util/helpers'; + substr, + logicalMinimum, + xor, + field, + constant, + _internalPipelineToExecutePipelineRequestProto, + FindNearestOptions +} from '../util/pipeline_export'; use(chaiAsPromised); setLogLevel('debug'); +const testUnsupportedFeatures = false; + apiDescribe.only('Pipelines', persistence => { addEqualityMatcher(); - describe('books tests', () => { - let firestore: Firestore; - let randomCol: CollectionReference; - - async function testCollectionWithDocs(docs: { - [id: string]: DocumentData; - }): Promise> { - for (const id in docs) { - if (docs.hasOwnProperty(id)) { - const ref = doc(randomCol, id); - await setDoc(ref, docs[id]); - } + let firestore: Firestore; + let randomCol: CollectionReference; + let beginDocCreation: number = 0; + let endDocCreation: number = 0; + + const timestampDeltaMS = 1000; + + async function testCollectionWithDocs(docs: { + [id: string]: DocumentData; + }): Promise> { + beginDocCreation = new Date().valueOf(); + for (const id in docs) { + if (docs.hasOwnProperty(id)) { + const ref = doc(randomCol, id); + await setDoc(ref, docs[id]); } - return randomCol; } - - function expectResults( - result: Array>, - ...docs: string[] - ): void; - function expectResults( - result: Array>, - ...data: DocumentData[] - ): void; - - function expectResults( - result: Array>, - ...data: DocumentData[] | string[] - ): void { - expect(result.length).to.equal(data.length); - - if (data.length > 0) { - if (typeof data[0] === 'string') { - const actualIds = result.map(result => result.ref?.id); - expect(actualIds).to.deep.equal(data); - } else { - result.forEach(r => { - expect(r.data()).to.deep.equal(data.shift()); - }); - } + endDocCreation = new Date().valueOf(); + return randomCol; + } + + function expectResults(snapshot: PipelineSnapshot, ...docs: string[]): void; + function expectResults( + snapshot: PipelineSnapshot, + ...data: DocumentData[] + ): void; + + function expectResults( + snapshot: PipelineSnapshot, + ...data: DocumentData[] | string[] + ): void { + const docs = snapshot.results; + + expect(docs.length).to.equal(data.length); + + if (data.length > 0) { + if (typeof data[0] === 'string') { + const actualIds = docs.map(doc => doc.id); + expect(actualIds).to.deep.equal(data); + } else { + docs.forEach(r => { + expect(r.data()).to.deep.equal(data.shift()); + }); } } - - async function setupBookDocs(): Promise> { - const bookDocs: { [id: string]: DocumentData } = { - book1: { - title: "The Hitchhiker's Guide to the Galaxy", - author: 'Douglas Adams', - genre: 'Science Fiction', - published: 1979, - rating: 4.2, - tags: ['comedy', 'space', 'adventure'], - awards: { - hugo: true, - nebula: false, - others: { unknown: { year: 1980 } } - }, - nestedField: { 'level.1': { 'level.2': true } } - }, - book2: { - title: 'Pride and Prejudice', - author: 'Jane Austen', - genre: 'Romance', - published: 1813, - rating: 4.5, - tags: ['classic', 'social commentary', 'love'], - awards: { none: true } - }, - book3: { - title: 'One Hundred Years of Solitude', - author: 'Gabriel García Márquez', - genre: 'Magical Realism', - published: 1967, - rating: 4.3, - tags: ['family', 'history', 'fantasy'], - awards: { nobel: true, nebula: false } - }, - book4: { - title: 'The Lord of the Rings', - author: 'J.R.R. Tolkien', - genre: 'Fantasy', - published: 1954, - rating: 4.7, - tags: ['adventure', 'magic', 'epic'], - awards: { hugo: false, nebula: false } - }, - book5: { - title: "The Handmaid's Tale", - author: 'Margaret Atwood', - genre: 'Dystopian', - published: 1985, - rating: 4.1, - tags: ['feminism', 'totalitarianism', 'resistance'], - awards: { 'arthur c. clarke': true, 'booker prize': false } - }, - book6: { - title: 'Crime and Punishment', - author: 'Fyodor Dostoevsky', - genre: 'Psychological Thriller', - published: 1866, - rating: 4.3, - tags: ['philosophy', 'crime', 'redemption'], - awards: { none: true } - }, - book7: { - title: 'To Kill a Mockingbird', - author: 'Harper Lee', - genre: 'Southern Gothic', - published: 1960, - rating: 4.2, - tags: ['racism', 'injustice', 'coming-of-age'], - awards: { pulitzer: true } - }, - book8: { - title: '1984', - author: 'George Orwell', - genre: 'Dystopian', - published: 1949, - rating: 4.2, - tags: ['surveillance', 'totalitarianism', 'propaganda'], - awards: { prometheus: true } - }, - book9: { - title: 'The Great Gatsby', - author: 'F. Scott Fitzgerald', - genre: 'Modernist', - published: 1925, - rating: 4.0, - tags: ['wealth', 'american dream', 'love'], - awards: { none: true } + } + + async function setupBookDocs(): Promise> { + const bookDocs: { [id: string]: DocumentData } = { + book1: { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams', + genre: 'Science Fiction', + published: 1979, + rating: 4.2, + tags: ['comedy', 'space', 'adventure'], + awards: { + hugo: true, + nebula: false, + others: { unknown: { year: 1980 } } }, - book10: { - title: 'Dune', - author: 'Frank Herbert', - genre: 'Science Fiction', - published: 1965, - rating: 4.6, - tags: ['politics', 'desert', 'ecology'], - awards: { hugo: true, nebula: true } - } - }; - return testCollectionWithDocs(bookDocs); - } + nestedField: { 'level.1': { 'level.2': true } }, + embedding: vector([10, 1, 1, 1, 1, 1, 1, 1, 1, 1]) + }, + book2: { + title: 'Pride and Prejudice', + author: 'Jane Austen', + genre: 'Romance', + published: 1813, + rating: 4.5, + tags: ['classic', 'social commentary', 'love'], + awards: { none: true }, + embedding: vector([1, 10, 1, 1, 1, 1, 1, 1, 1, 1]) + }, + book3: { + title: 'One Hundred Years of Solitude', + author: 'Gabriel García Márquez', + genre: 'Magical Realism', + published: 1967, + rating: 4.3, + tags: ['family', 'history', 'fantasy'], + awards: { nobel: true, nebula: false }, + embedding: vector([1, 1, 10, 1, 1, 1, 1, 1, 1, 1]) + }, + book4: { + title: 'The Lord of the Rings', + author: 'J.R.R. Tolkien', + genre: 'Fantasy', + published: 1954, + rating: 4.7, + tags: ['adventure', 'magic', 'epic'], + awards: { hugo: false, nebula: false }, + remarks: null, + cost: NaN, + embedding: vector([1, 1, 1, 10, 1, 1, 1, 1, 1, 1]) + }, + book5: { + title: "The Handmaid's Tale", + author: 'Margaret Atwood', + genre: 'Dystopian', + published: 1985, + rating: 4.1, + tags: ['feminism', 'totalitarianism', 'resistance'], + awards: { 'arthur c. clarke': true, 'booker prize': false }, + embedding: vector([1, 1, 1, 1, 10, 1, 1, 1, 1, 1]) + }, + book6: { + title: 'Crime and Punishment', + author: 'Fyodor Dostoevsky', + genre: 'Psychological Thriller', + published: 1866, + rating: 4.3, + tags: ['philosophy', 'crime', 'redemption'], + awards: { none: true }, + embedding: vector([1, 1, 1, 1, 1, 10, 1, 1, 1, 1]) + }, + book7: { + title: 'To Kill a Mockingbird', + author: 'Harper Lee', + genre: 'Southern Gothic', + published: 1960, + rating: 4.2, + tags: ['racism', 'injustice', 'coming-of-age'], + awards: { pulitzer: true }, + embedding: vector([1, 1, 1, 1, 1, 1, 10, 1, 1, 1]) + }, + book8: { + title: '1984', + author: 'George Orwell', + genre: 'Dystopian', + published: 1949, + rating: 4.2, + tags: ['surveillance', 'totalitarianism', 'propaganda'], + awards: { prometheus: true }, + embedding: vector([1, 1, 1, 1, 1, 1, 1, 10, 1, 1]) + }, + book9: { + title: 'The Great Gatsby', + author: 'F. Scott Fitzgerald', + genre: 'Modernist', + published: 1925, + rating: 4.0, + tags: ['wealth', 'american dream', 'love'], + awards: { none: true }, + embedding: vector([1, 1, 1, 1, 1, 1, 1, 1, 10, 1]) + }, + book10: { + title: 'Dune', + author: 'Frank Herbert', + genre: 'Science Fiction', + published: 1965, + rating: 4.6, + tags: ['politics', 'desert', 'ecology'], + awards: { hugo: true, nebula: true }, + embedding: vector([1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) + } + }; + return testCollectionWithDocs(bookDocs); + } + + let testDeferred: Deferred | undefined; + let withTestCollectionPromise: Promise | undefined; + + beforeEach(async () => { + const setupDeferred = new Deferred(); + testDeferred = new Deferred(); + withTestCollectionPromise = withTestCollection( + persistence, + {}, + async (collectionRef, firestoreInstance) => { + randomCol = collectionRef; + firestore = firestoreInstance; + await setupBookDocs(); + setupDeferred.resolve(); + + return testDeferred?.promise; + } + ); - let testDeferred: Deferred | undefined; - let withTestCollectionPromise: Promise | undefined; - - beforeEach(async () => { - const setupDeferred = new Deferred(); - testDeferred = new Deferred(); - withTestCollectionPromise = withTestCollection( - persistence, - {}, - async (collectionRef, firestoreInstance) => { - randomCol = collectionRef; - firestore = firestoreInstance; - await setupBookDocs(); - setupDeferred.resolve(); - - return testDeferred?.promise; - } + await setupDeferred.promise; + }); + + afterEach(async () => { + testDeferred?.resolve(); + await withTestCollectionPromise; + }); + + describe('pipeline results', () => { + it('empty snapshot as expected', async () => { + const snapshot = await execute( + firestore.pipeline().collection(randomCol.path).limit(0) + ); + expect(snapshot.results.length).to.equal(0); + }); + + // Skipping because __name__ is not currently working in DBE + itIf(testUnsupportedFeatures)('full snapshot as expected', async () => { + const ppl = firestore + .pipeline() + .collection(randomCol.path) + .sort(ascending('__name__')); + const snapshot = await execute(ppl); + expect(snapshot.results.length).to.equal(10); + expect(snapshot.pipeline).to.equal(ppl); + expectResults( + snapshot, + 'book1', + 'book10', + 'book2', + 'book3', + 'book4', + 'book5', + 'book6', + 'book7', + 'book8', + 'book9' + ); + }); + + it('result equals works', async () => { + const ppl = firestore + .pipeline() + .collection(randomCol.path) + .sort(ascending('title')) + .limit(1); + const snapshot1 = await execute(ppl); + const snapshot2 = await execute(ppl); + expect(snapshot1.results.length).to.equal(1); + expect(snapshot2.results.length).to.equal(1); + expect(pipelineResultEqual(snapshot1.results[0], snapshot2.results[0])).to + .be.true; + }); + + it('returns execution time', async () => { + const start = new Date().valueOf(); + const pipeline = firestore.pipeline().collection(randomCol.path); + + const snapshot = await execute(pipeline); + const end = new Date().valueOf(); + + expect(snapshot.executionTime.toDate().valueOf()).to.approximately( + (start + end) / 2, + timestampDeltaMS + ); + }); + + it('returns execution time for an empty query', async () => { + const start = new Date().valueOf(); + const pipeline = firestore.pipeline().collection(randomCol.path).limit(0); + + const snapshot = await execute(pipeline); + const end = new Date().valueOf(); + + expect(snapshot.results.length).to.equal(0); + + expect(snapshot.executionTime.toDate().valueOf()).to.approximately( + (start + end) / 2, + timestampDeltaMS + ); + }); + + it('returns create and update time for each document', async () => { + const pipeline = firestore.pipeline().collection(randomCol.path); + + let snapshot = await execute(pipeline); + expect(snapshot.results.length).to.equal(10); + snapshot.results.forEach(doc => { + expect(doc.createTime).to.not.be.null; + expect(doc.updateTime).to.not.be.null; + + expect(doc.createTime!.toDate().valueOf()).to.approximately( + (beginDocCreation + endDocCreation) / 2, + timestampDeltaMS + ); + expect(doc.updateTime!.toDate().valueOf()).to.approximately( + (beginDocCreation + endDocCreation) / 2, + timestampDeltaMS + ); + expect(doc.createTime?.valueOf()).to.equal(doc.updateTime?.valueOf()); + }); + + const wb = writeBatch(firestore); + snapshot.results.forEach(doc => { + wb.update(doc.ref!, { newField: 'value' }); + }); + await wb.commit(); + + snapshot = await execute(pipeline); + expect(snapshot.results.length).to.equal(10); + snapshot.results.forEach(doc => { + expect(doc.createTime).to.not.be.null; + expect(doc.updateTime).to.not.be.null; + expect(doc.createTime!.toDate().valueOf()).to.be.lessThan( + doc.updateTime!.toDate().valueOf() + ); + }); + }); + + it('returns execution time for an aggregate query', async () => { + const start = new Date().valueOf(); + const pipeline = firestore + .pipeline() + .collection(randomCol.path) + .aggregate(avg('rating').as('avgRating')); + + const snapshot = await execute(pipeline); + const end = new Date().valueOf(); + + expect(snapshot.results.length).to.equal(1); + + expect(snapshot.executionTime.toDate().valueOf()).to.approximately( + (start + end) / 2, + timestampDeltaMS ); + }); + + it('returns undefined create and update time for each result in an aggregate query', async () => { + const pipeline = firestore + .pipeline() + .collection(randomCol.path) + .aggregate({ + accumulators: [avg('rating').as('avgRating')], + groups: ['genre'] + }); + + const snapshot = await execute(pipeline); - await setupDeferred.promise; + expect(snapshot.results.length).to.equal(8); + + snapshot.results.forEach(doc => { + expect(doc.updateTime).to.be.undefined; + expect(doc.createTime).to.be.undefined; + }); }); + }); - afterEach(async () => { - testDeferred?.resolve(); - await withTestCollectionPromise; + describe('pipeline sources', () => { + it('supports CollectionReference as source', async () => { + const snapshot = await execute( + firestore.pipeline().collection(randomCol) + ); + expect(snapshot.results.length).to.equal(10); }); - describe('fluent API', () => { - it('empty results as expected', async () => { - const result = await firestore + it('supports list of documents as source', async () => { + const collName = randomCol.id; + + const snapshot = await execute( + firestore .pipeline() - .collection(randomCol.path) - .limit(0) - .execute(); - expect(result.length).to.equal(0); + .documents([ + `${collName}/book1`, + doc(randomCol, 'book2'), + doc(randomCol, 'book3').path + ]) + ); + expect(snapshot.results.length).to.equal(3); + }); + + it('reject CollectionReference for another DB', async () => { + const db2 = getFirestore(firestore.app, 'notDefault'); + + expect(() => { + firestore.pipeline().collection(collection(db2, 'foo')); + }).to.throw(/Invalid CollectionReference/); + + await terminate(db2); + }); + + it('reject DocumentReference for another DB', async () => { + const db2 = getFirestore(firestore.app, 'notDefault'); + + expect(() => { + firestore.pipeline().documents([doc(db2, 'foo/bar')]); + }).to.throw(/Invalid DocumentReference/); + + await terminate(db2); + }); + + // Subcollections not currently supported in DBE + itIf(testUnsupportedFeatures)( + 'supports collection group as source', + async () => { + const randomSubCollectionId = Math.random().toString(16).slice(2); + const doc1 = await addDoc( + collection(randomCol, 'book1', randomSubCollectionId), + { order: 1 } + ); + const doc2 = await addDoc( + collection(randomCol, 'book2', randomSubCollectionId), + { order: 2 } + ); + const snapshot = await execute( + firestore + .pipeline() + .collectionGroup(randomSubCollectionId) + .sort(ascending('order')) + ); + expectResults(snapshot, doc1.id, doc2.id); + } + ); + + // subcollections not currently supported in dbe + itIf(testUnsupportedFeatures)('supports database as source', async () => { + const randomId = Math.random().toString(16).slice(2); + const doc1 = await addDoc(collection(randomCol, 'book1', 'sub'), { + order: 1, + randomId }); + const doc2 = await addDoc(collection(randomCol, 'book2', 'sub'), { + order: 2, + randomId + }); + const snapshot = await execute( + firestore + .pipeline() + .database() + .where(eq('randomId', randomId)) + .sort(ascending('order')) + ); + expectResults(snapshot, doc1.id, doc2.id); + }); + }); + + describe('supported data types', () => { + it('accepts and returns all data types', async () => { + const refDate = new Date(); + const refTimestamp = Timestamp.now(); + const constants = [ + constant(1).as('number'), + constant('a string').as('string'), + constant(true).as('boolean'), + constant(null).as('null'), + constant(new GeoPoint(0.1, 0.2)).as('geoPoint'), + constant(refTimestamp).as('timestamp'), + constant(refDate).as('date'), + constant( + Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])) + ).as('bytes'), + constant(doc(firestore, 'foo', 'bar')).as('documentReference'), + constantVector(vector([1, 2, 3])).as('vectorValue'), + constantVector([1, 2, 3]).as('vectorValue2'), + map({ + 'number': 1, + 'string': 'a string', + 'boolean': true, + 'null': null, + 'geoPoint': new GeoPoint(0.1, 0.2), + 'timestamp': refTimestamp, + 'date': refDate, + 'uint8Array': Bytes.fromUint8Array( + new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0]) + ), + 'documentReference': doc(firestore, 'foo', 'bar'), + 'vectorValue': vector([1, 2, 3]), + 'map': { + 'number': 2, + 'string': 'b string' + }, + 'array': [1, 'c string'] + }).as('map'), + array([ + 1, + 'a string', + true, + null, + new GeoPoint(0.1, 0.2), + refTimestamp, + refDate, + Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])), + doc(firestore, 'foo', 'bar'), + vector([1, 2, 3]), + { + 'number': 2, + 'string': 'b string' + } + ]).as('array') + ]; - it('full results as expected', async () => { - const result = await firestore + const snapshots = await execute( + firestore .pipeline() .collection(randomCol.path) - .execute(); - expect(result.length).to.equal(10); + .limit(1) + .select(constants[0], ...constants.slice(1)) + ); + + expectResults(snapshots, { + 'number': 1, + 'string': 'a string', + 'boolean': true, + 'null': null, + 'geoPoint': new GeoPoint(0.1, 0.2), + 'timestamp': refTimestamp, + 'date': Timestamp.fromDate(refDate), + 'bytes': Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])), + 'documentReference': doc(firestore, 'foo', 'bar'), + 'vectorValue': vector([1, 2, 3]), + 'vectorValue2': vector([1, 2, 3]), + 'map': { + 'number': 1, + 'string': 'a string', + 'boolean': true, + 'null': null, + 'geoPoint': new GeoPoint(0.1, 0.2), + 'timestamp': refTimestamp, + 'date': Timestamp.fromDate(refDate), + 'uint8Array': Bytes.fromUint8Array( + new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0]) + ), + 'documentReference': doc(firestore, 'foo', 'bar'), + 'vectorValue': vector([1, 2, 3]), + 'map': { + 'number': 2, + 'string': 'b string' + }, + 'array': [1, 'c string'] + }, + 'array': [ + 1, + 'a string', + true, + null, + new GeoPoint(0.1, 0.2), + refTimestamp, + Timestamp.fromDate(refDate), + Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])), + doc(firestore, 'foo', 'bar'), + vector([1, 2, 3]), + { + 'number': 2, + 'string': 'b string' + } + ] }); + }); + + it('throws on undefined in a map', async () => { + expect(() => { + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + map({ + 'number': 1, + undefined + }).as('foo') + ); + }).to.throw( + 'Function map() called with invalid data. Unsupported field value: undefined' + ); + }); - it('returns aggregate results as expected', async () => { - let result = await firestore + it('throws on undefined in an array', async () => { + expect(() => { + firestore .pipeline() .collection(randomCol.path) - .aggregate(countAll().as('count')) - .execute(); - expectResults(result, { count: 10 }); + .limit(1) + .select(array([1, undefined]).as('foo')); + }).to.throw( + 'Function array() called with invalid data. Unsupported field value: undefined' + ); + }); - result = await randomCol + it('converts arrays and plain objects to functionValues if the customer intent is unspecified', async () => { + const snapshot = await execute( + firestore .pipeline() - .where(eq('genre', 'Science Fiction')) - .aggregate( - countAll().as('count'), - avgFunction('rating').as('avgRating'), - Field.of('rating').maximum().as('maxRating') + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select( + 'title', + 'author', + 'genre', + 'rating', + 'published', + 'tags', + 'awards' + ) + .addFields( + array([ + 1, + 2, + field('genre'), + multiply('rating', 10), + [field('title')], + { + published: field('published') + } + ]).as('metadataArray'), + map({ + genre: field('genre'), + rating: multiply('rating', 10), + nestedArray: [field('title')], + nestedMap: { + published: field('published') + } + }).as('metadata') ) - .execute(); - expectResults(result, { count: 2, avgRating: 4.4, maxRating: 4.6 }); + .where( + and( + eq('metadataArray', [ + 1, + 2, + field('genre'), + multiply('rating', 10), + [field('title')], + { + published: field('published') + } + ]), + eq('metadata', { + genre: field('genre'), + rating: multiply('rating', 10), + nestedArray: [field('title')], + nestedMap: { + published: field('published') + } + }) + ) + ) + ); + + expect(snapshot.results.length).to.equal(1); + + expectResults(snapshot, { + title: 'The Lord of the Rings', + author: 'J.R.R. Tolkien', + genre: 'Fantasy', + published: 1954, + rating: 4.7, + tags: ['adventure', 'magic', 'epic'], + awards: { hugo: false, nebula: false }, + metadataArray: [ + 1, + 2, + 'Fantasy', + 47, + ['The Lord of the Rings'], + { + published: 1954 + } + ], + metadata: { + genre: 'Fantasy', + rating: 47, + nestedArray: ['The Lord of the Rings'], + nestedMap: { + published: 1954 + } + } + }); + }); + }); + + describe('stages', () => { + describe('aggregate stage', () => { + it('supports aggregate', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .aggregate(countAll().as('count')) + ); + expectResults(snapshot, { count: 10 }); + + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('genre', 'Science Fiction')) + .aggregate( + countAll().as('count'), + avg('rating').as('avgRating'), + maximum('rating').as('maxRating'), + sum('rating').as('sumRating') + ) + ); + expectResults(snapshot, { + count: 2, + avgRating: 4.4, + maxRating: 4.6, + sumRating: 8.8 + }); }); it('rejects groups without accumulators', async () => { await expect( - randomCol + execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(lt('published', 1900)) + .aggregate({ + accumulators: [], + groups: ['genre'] + }) + ) + ).to.be.rejected; + }); + + it('returns group and accumulate results', async () => { + const snapshot = await execute( + firestore .pipeline() - .where(lt('published', 1900)) + .collection(randomCol.path) + .where(lt(field('published'), 1984)) .aggregate({ - accumulators: [], + accumulators: [avg('rating').as('avgRating')], groups: ['genre'] }) - .execute() - ).to.be.rejected; + .where(gt('avgRating', 4.3)) + .sort(field('avgRating').descending()) + ); + expectResults( + snapshot, + { avgRating: 4.7, genre: 'Fantasy' }, + { avgRating: 4.5, genre: 'Romance' }, + { avgRating: 4.4, genre: 'Science Fiction' } + ); + }); + + it('returns min, max, count, and countAll accumulations', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .aggregate( + count('cost').as('booksWithCost'), + countAll().as('count'), + maximum('rating').as('maxRating'), + minimum('published').as('minPublished') + ) + ); + expectResults(snapshot, { + booksWithCost: 1, + count: 10, + maxRating: 4.7, + minPublished: 1813 + }); + }); + + it('returns countif accumulation', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .aggregate(countIf(field('rating').gt(4.3)).as('count')) + ); + const expectedResults = { + count: 3 + }; + expectResults(snapshot, expectedResults); + + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .aggregate(field('rating').gt(4.3).countIf().as('count')) + ); + expectResults(snapshot, expectedResults); }); + }); + describe('distinct stage', () => { it('returns distinct values as expected', async () => { - const results = await randomCol - .pipeline() - .distinct('genre', 'author') - .sort(Field.of('genre').ascending(), Field.of('author').ascending()) - .execute(); + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .distinct('genre', 'author') + .sort(field('genre').ascending(), field('author').ascending()) + ); expectResults( - results, + snapshot, { genre: 'Dystopian', author: 'George Orwell' }, { genre: 'Dystopian', author: 'Margaret Atwood' }, { genre: 'Fantasy', author: 'J.R.R. Tolkien' }, @@ -336,51 +938,19 @@ apiDescribe.only('Pipelines', persistence => { { genre: 'Southern Gothic', author: 'Harper Lee' } ); }); + }); - it('returns group and accumulate results', async () => { - const results = await randomCol - .pipeline() - .where(lt(Field.of('published'), 1984)) - .aggregate({ - accumulators: [avgFunction('rating').as('avgRating')], - groups: ['genre'] - }) - .where(gt('avgRating', 4.3)) - .sort(Field.of('avgRating').descending()) - .execute(); - expectResults( - results, - { avgRating: 4.7, genre: 'Fantasy' }, - { avgRating: 4.5, genre: 'Romance' }, - { avgRating: 4.4, genre: 'Science Fiction' } - ); - }); - - it('returns min and max accumulations', async () => { - const results = await randomCol - .pipeline() - .aggregate( - countAll().as('count'), - Field.of('rating').maximum().as('maxRating'), - Field.of('published').minimum().as('minPublished') - ) - .execute(); - expectResults(results, { - count: 10, - maxRating: 4.7, - minPublished: 1813 - }); - }); - + describe('select stage', () => { it('can select fields', async () => { - const results = await firestore - .pipeline() - .collection(randomCol.path) - .select('title', 'author') - .sort(Field.of('author').ascending()) - .execute(); + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'author') + .sort(field('author').ascending()) + ); expectResults( - results, + snapshot, { title: "The Hitchhiker's Guide to the Galaxy", author: 'Douglas Adams' @@ -399,1331 +969,2116 @@ apiDescribe.only('Pipelines', persistence => { { title: "The Handmaid's Tale", author: 'Margaret Atwood' } ); }); + }); - it('where with and', async () => { - const results = await randomCol - .pipeline() - .where(andFunction(gt('rating', 4.5), eq('genre', 'Science Fiction'))) - .execute(); - expectResults(results, 'book10'); - }); - - it('where with or', async () => { - const results = await randomCol - .pipeline() - .where(orFunction(eq('genre', 'Romance'), eq('genre', 'Dystopian'))) - .select('title') - .execute(); + describe('addField stage', () => { + it('can add fields', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'author') + .addFields(constant('bar').as('foo')) + .sort(field('author').ascending()) + ); expectResults( - results, - { title: 'Pride and Prejudice' }, - { title: "The Handmaid's Tale" }, - { title: '1984' } + snapshot, + { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams', + foo: 'bar' + }, + { + title: 'The Great Gatsby', + author: 'F. Scott Fitzgerald', + foo: 'bar' + }, + { title: 'Dune', author: 'Frank Herbert', foo: 'bar' }, + { + title: 'Crime and Punishment', + author: 'Fyodor Dostoevsky', + foo: 'bar' + }, + { + title: 'One Hundred Years of Solitude', + author: 'Gabriel García Márquez', + foo: 'bar' + }, + { title: '1984', author: 'George Orwell', foo: 'bar' }, + { + title: 'To Kill a Mockingbird', + author: 'Harper Lee', + foo: 'bar' + }, + { + title: 'The Lord of the Rings', + author: 'J.R.R. Tolkien', + foo: 'bar' + }, + { title: 'Pride and Prejudice', author: 'Jane Austen', foo: 'bar' }, + { + title: "The Handmaid's Tale", + author: 'Margaret Atwood', + foo: 'bar' + } ); }); + }); - it('offset and limits', async () => { - const results = await firestore - .pipeline() - .collection(randomCol.path) - .sort(Field.of('author').ascending()) - .offset(5) - .limit(3) - .select('title', 'author') - .execute(); + describe('removeFields stage', () => { + it('can remove fields', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'author') + .sort(field('author').ascending()) + .removeFields(field('author')) + .sort(field('author').ascending()) + ); expectResults( - results, - { title: '1984', author: 'George Orwell' }, - { title: 'To Kill a Mockingbird', author: 'Harper Lee' }, - { title: 'The Lord of the Rings', author: 'J.R.R. Tolkien' } + snapshot, + { + title: "The Hitchhiker's Guide to the Galaxy" + }, + { + title: 'The Great Gatsby' + }, + { title: 'Dune' }, + { + title: 'Crime and Punishment' + }, + { + title: 'One Hundred Years of Solitude' + }, + { title: '1984' }, + { + title: 'To Kill a Mockingbird' + }, + { + title: 'The Lord of the Rings' + }, + { title: 'Pride and Prejudice' }, + { + title: "The Handmaid's Tale" + } ); }); + }); - it('logical min works', async () => { - const results = await randomCol - .pipeline() - .select( - 'title', - logicalMinimum(Constant.of(1960), Field.of('published')).as( - 'published-safe' + describe('where stage', () => { + it('where with and (2 conditions)', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where( + and( + gt('rating', 4.5), + eqAny('genre', ['Science Fiction', 'Romance', 'Fantasy']) + ) ) - ) - .sort(Field.of('title').ascending()) - .limit(3) - .execute(); - expectResults( - results, - { title: '1984', 'published-safe': 1949 }, - { title: 'Crime and Punishment', 'published-safe': 1866 }, - { title: 'Dune', 'published-safe': 1960 } ); + expectResults(snapshot, 'book10', 'book4'); }); - - it('logical max works', async () => { - const results = await randomCol - .pipeline() - .select( - 'title', - logicalMaximum(Constant.of(1960), Field.of('published')).as( - 'published-safe' + it('where with and (3 conditions)', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where( + and( + gt('rating', 4.5), + eqAny('genre', ['Science Fiction', 'Romance', 'Fantasy']), + lt('published', 1965) + ) ) - ) - .sort(Field.of('title').ascending()) - .limit(3) - .execute(); - expectResults( - results, - { title: '1984', 'published-safe': 1960 }, - { title: 'Crime and Punishment', 'published-safe': 1960 }, - { title: 'Dune', 'published-safe': 1965 } - ); - }); - - it('accepts and returns all data types', async () => { - const refDate = new Date(); - const refTimestamp = Timestamp.now(); - const constants = [ - Constant.of(1).as('number'), - Constant.of('a string').as('string'), - Constant.of(true).as('boolean'), - Constant.of(null).as('null'), - Constant.of(new GeoPoint(0.1, 0.2)).as('geoPoint'), - Constant.of(refTimestamp).as('timestamp'), - Constant.of(refDate).as('date'), - Constant.of( - Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])) - ).as('bytes'), - Constant.of(doc(firestore, 'foo', 'bar')).as('documentReference'), - Constant.of(vector([1, 2, 3])).as('vectorValue'), - Constant.of({ - 'number': 1, - 'string': 'a string', - 'boolean': true, - 'null': null, - 'geoPoint': new GeoPoint(0.1, 0.2), - 'timestamp': refTimestamp, - 'date': refDate, - 'uint8Array': Bytes.fromUint8Array( - new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0]) - ), - 'documentReference': doc(firestore, 'foo', 'bar'), - 'vectorValue': vector([1, 2, 3]), - 'map': { - 'number': 2, - 'string': 'b string' - }, - 'array': [1, 'c string'] - }).as('map'), - Constant.of([ - 1, - 'a string', - true, - null, - new GeoPoint(0.1, 0.2), - refTimestamp, - refDate, - Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])), - doc(firestore, 'foo', 'bar'), - vector([1, 2, 3]), - { - 'number': 2, - 'string': 'b string' - } - ]).as('array') - ]; - - const results = await randomCol - .pipeline() - .limit(1) - .select(...constants) - .execute(); - - expectResults(results, { - 'number': 1, - 'string': 'a string', - 'boolean': true, - 'null': null, - 'geoPoint': new GeoPoint(0.1, 0.2), - 'timestamp': refTimestamp, - 'date': Timestamp.fromDate(refDate), - 'bytes': Bytes.fromUint8Array( - new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0]) - ), - 'documentReference': doc(firestore, 'foo', 'bar'), - 'vectorValue': vector([1, 2, 3]), - 'map': { - 'number': 1, - 'string': 'a string', - 'boolean': true, - 'null': null, - 'geoPoint': new GeoPoint(0.1, 0.2), - 'timestamp': refTimestamp, - 'date': Timestamp.fromDate(refDate), - 'uint8Array': Bytes.fromUint8Array( - new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0]) - ), - 'documentReference': doc(firestore, 'foo', 'bar'), - 'vectorValue': vector([1, 2, 3]), - 'map': { - 'number': 2, - 'string': 'b string' - }, - 'array': [1, 'c string'] - }, - 'array': [ - 1, - 'a string', - true, - null, - new GeoPoint(0.1, 0.2), - refTimestamp, - Timestamp.fromDate(refDate), - Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])), - doc(firestore, 'foo', 'bar'), - vector([1, 2, 3]), - { - 'number': 2, - 'string': 'b string' - } - ] - }); + ); + expectResults(snapshot, 'book4'); }); - - it('cond works', async () => { - const results = await randomCol - .pipeline() - .select( - 'title', - cond( - lt(Field.of('published'), 1960), - Constant.of(1960), - Field.of('published') - ).as('published-safe') - ) - .sort(Field.of('title').ascending()) - .limit(3) - .execute(); + it('where with or', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where( + or( + eq('genre', 'Romance'), + eq('genre', 'Dystopian'), + eq('genre', 'Fantasy') + ) + ) + .sort(ascending('title')) + .select('title') + ); expectResults( - results, - { title: '1984', 'published-safe': 1960 }, - { title: 'Crime and Punishment', 'published-safe': 1960 }, - { title: 'Dune', 'published-safe': 1965 } + snapshot, + { title: '1984' }, + { title: 'Pride and Prejudice' }, + { title: "The Handmaid's Tale" }, + { title: 'The Lord of the Rings' } ); }); - it('eqAny works', async () => { - const results = await randomCol - .pipeline() - .where(eqAny('published', [1979, 1999, 1967])) - .select('title') - .execute(); + it('where with xor', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where( + xor( + eq('genre', 'Romance'), + eq('genre', 'Dystopian'), + eq('genre', 'Fantasy'), + eq('published', 1949) + ) + ) + .select('title') + ); expectResults( - results, - { title: "The Hitchhiker's Guide to the Galaxy" }, - { title: 'One Hundred Years of Solitude' } + snapshot, + { title: 'Pride and Prejudice' }, + { title: 'The Lord of the Rings' }, + { title: "The Handmaid's Tale" } ); }); + }); - it('notEqAny works', async () => { - const results = await randomCol - .pipeline() - .where( - notEqAny( - 'published', - [1965, 1925, 1949, 1960, 1866, 1985, 1954, 1967, 1979] - ) - ) - .select('title') - .execute(); - expectResults(results, { title: 'Pride and Prejudice' }); + describe('sort, offset, and limit stages', () => { + it('supports sort, offset, and limits', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('author').ascending()) + .offset(5) + .limit(3) + .select('title', 'author') + ); + expectResults( + snapshot, + { title: '1984', author: 'George Orwell' }, + { title: 'To Kill a Mockingbird', author: 'Harper Lee' }, + { title: 'The Lord of the Rings', author: 'J.R.R. Tolkien' } + ); }); + }); - it('arrayContains works', async () => { - const results = await randomCol - .pipeline() - .where(arrayContains('tags', 'comedy')) - .select('title') - .execute(); - expectResults(results, { - title: "The Hitchhiker's Guide to the Galaxy" + describe('generic stage', () => { + it('can select fields', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .genericStage('select', [ + { + title: field('title'), + metadata: { + 'author': field('author') + } + } + ]) + .sort(field('author').ascending()) + .limit(1) + ); + expectResults(snapshot, { + metadata: { + author: 'Frank Herbert' + }, + title: 'Dune' }); }); - it('arrayContainsAny works', async () => { - const results = await randomCol - .pipeline() - .where(arrayContainsAny('tags', ['comedy', 'classic'])) - .select('title') - .execute(); - expectResults( - results, - { title: "The Hitchhiker's Guide to the Galaxy" }, - { title: 'Pride and Prejudice' } + it('can add fields', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('author').ascending()) + .limit(1) + .select('title', 'author') + .genericStage('add_fields', [ + { + display: strConcat('title', ' - ', field('author')) + } + ]) ); + expectResults(snapshot, { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams', + display: "The Hitchhiker's Guide to the Galaxy - Douglas Adams" + }); }); - it('arrayContainsAll works', async () => { - const results = await randomCol - .pipeline() - .where(Field.of('tags').arrayContainsAll('adventure', 'magic')) - .select('title') - .execute(); - expectResults(results, { title: 'The Lord of the Rings' }); - }); - - it('arrayLength works', async () => { - const results = await randomCol - .pipeline() - .select(Field.of('tags').arrayLength().as('tagsCount')) - .where(eq('tagsCount', 3)) - .execute(); - expect(results.length).to.equal(10); - }); - - // skip: arrayConcat not supported - // it.skip('arrayConcat works', async () => { - // const results = await randomCol - // .pipeline() - // .select( - // Field.of('tags').arrayConcat(['newTag1', 'newTag2']).as('modifiedTags') - // ) - // .limit(1) - // .execute(); - // expectResults(results, { - // modifiedTags: ['comedy', 'space', 'adventure', 'newTag1', 'newTag2'] - // }); - // }); - - it('testStrConcat', async () => { - const results = await randomCol - .pipeline() - .select( - Field.of('author') - .strConcat(' - ', Field.of('title')) - .as('bookInfo') - ) - .limit(1) - .execute(); - expectResults(results, { - bookInfo: "Douglas Adams - The Hitchhiker's Guide to the Galaxy" + it('can filter with where', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'author') + .genericStage('where', [field('author').eq('Douglas Adams')]) + ); + expectResults(snapshot, { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams' }); }); - it('testStartsWith', async () => { - const results = await randomCol - .pipeline() - .where(startsWith('title', 'The')) - .select('title') - .sort(Field.of('title').ascending()) - .execute(); - expectResults( - results, - { title: 'The Great Gatsby' }, - { title: "The Handmaid's Tale" }, - { title: "The Hitchhiker's Guide to the Galaxy" }, - { title: 'The Lord of the Rings' } + it('can limit, offset, and sort', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'author') + .genericStage('sort', [ + { + direction: 'ascending', + expression: field('author') + } + ]) + .genericStage('offset', [3]) + .genericStage('limit', [1]) ); + expectResults(snapshot, { + author: 'Fyodor Dostoevsky', + title: 'Crime and Punishment' + }); }); - it('testEndsWith', async () => { - const results = await randomCol - .pipeline() - .where(endsWith('title', 'y')) - .select('title') - .sort(Field.of('title').descending()) - .execute(); - expectResults( - results, - { title: "The Hitchhiker's Guide to the Galaxy" }, - { title: 'The Great Gatsby' } + it('can perform aggregate query', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'author', 'rating') + .genericStage('aggregate', [ + { averageRating: field('rating').avg() }, + {} + ]) ); + expectResults(snapshot, { + averageRating: 4.3100000000000005 + }); }); - it('testLength', async () => { - const results = await randomCol - .pipeline() - .select( - Field.of('title').charLength().as('titleLength'), - Field.of('title') - ) - .where(gt('titleLength', 20)) - .sort(Field.of('title').ascending()) - .execute(); - + it('can perform distinct query', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'author', 'rating') + .genericStage('distinct', [{ rating: field('rating') }]) + .sort(field('rating').descending()) + ); expectResults( - results, - + snapshot, { - titleLength: 29, - title: 'One Hundred Years of Solitude' + rating: 4.7 }, { - titleLength: 36, - title: "The Hitchhiker's Guide to the Galaxy" + rating: 4.6 }, { - titleLength: 21, - title: 'The Lord of the Rings' + rating: 4.5 }, { - titleLength: 21, - title: 'To Kill a Mockingbird' + rating: 4.3 + }, + { + rating: 4.2 + }, + { + rating: 4.1 + }, + { + rating: 4.0 } ); }); + }); - // skip: toLower not supported - // it.skip('testToLowercase', async () => { - // const results = await randomCol - // .pipeline() - // .select(Field.of('title').toLower().as('lowercaseTitle')) - // .limit(1) - // .execute(); - // expectResults(results, { - // lowercaseTitle: "the hitchhiker's guide to the galaxy" - // }); - // }); - - // skip: toUpper not supported - // it.skip('testToUppercase', async () => { - // const results = await randomCol - // .pipeline() - // .select(Field.of('author').toUpper().as('uppercaseAuthor')) - // .limit(1) - // .execute(); - // expectResults(results, { uppercaseAuthor: 'DOUGLAS ADAMS' }); - // }); - - // skip: trim not supported - // it.skip('testTrim', async () => { - // const results = await randomCol - // .pipeline() - // .addFields(strConcat(' ', Field.of('title'), ' ').as('spacedTitle')) - // .select( - // Field.of('spacedTitle').trim().as('trimmedTitle'), - // Field.of('spacedTitle') - // ) - // .limit(1) - // .execute(); - // expectResults(results, { - // spacedTitle: " The Hitchhiker's Guide to the Galaxy ", - // trimmedTitle: "The Hitchhiker's Guide to the Galaxy" - // }); - // }); - - it('testLike', async () => { - const results = await randomCol - .pipeline() - .where(like('title', '%Guide%')) - .select('title') - .execute(); - expectResults(results, { - title: "The Hitchhiker's Guide to the Galaxy" + describe('replaceWith stage', () => { + it('run pipeline with replaceWith field name', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('title', "The Hitchhiker's Guide to the Galaxy")) + .replaceWith('awards') + ); + expectResults(snapshot, { + hugo: true, + nebula: false, + others: { unknown: { year: 1980 } } }); }); - it('testRegexContains', async () => { - const results = await randomCol - .pipeline() - .where(regexContains('title', '(?i)(the|of)')) - .execute(); - expect(results.length).to.equal(5); + it('run pipeline with replaceWith Expr result', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('title', "The Hitchhiker's Guide to the Galaxy")) + .replaceWith( + map({ + foo: 'bar', + baz: { + title: field('title') + } + }) + ) + ); + expectResults(snapshot, { + foo: 'bar', + baz: { title: "The Hitchhiker's Guide to the Galaxy" } + }); }); + }); - it('testRegexMatches', async () => { - const results = await randomCol - .pipeline() - .where(regexMatch('title', '.*(?i)(the|of).*')) - .execute(); - expect(results.length).to.equal(5); + describe('sample stage', () => { + it('run pipeline with sample limit of 3', async () => { + const snapshot = await execute( + firestore.pipeline().collection(randomCol.path).sample(3) + ); + expect(snapshot.results.length).to.equal(3); }); - it('testArithmeticOperations', async () => { - const results = await randomCol - .pipeline() - .select( - add(Field.of('rating'), 1).as('ratingPlusOne'), - subtract(Field.of('published'), 1900).as('yearsSince1900'), - Field.of('rating').multiply(10).as('ratingTimesTen'), - Field.of('rating').divide(2).as('ratingDividedByTwo') - ) - .limit(1) - .execute(); - expectResults(results, { - ratingPlusOne: 5.2, - yearsSince1900: 79, - ratingTimesTen: 42, - ratingDividedByTwo: 2.1 - }); + it('run pipeline with sample limit of {documents: 3}', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sample({ documents: 3 }) + ); + expect(snapshot.results.length).to.equal(3); }); - it('testComparisonOperators', async () => { - const results = await randomCol - .pipeline() - .where( - andFunction( - gt('rating', 4.2), - lte(Field.of('rating'), 4.5), - neq('genre', 'Science Fiction') - ) - ) - .select('rating', 'title') - .sort(Field.of('title').ascending()) - .execute(); - expectResults( - results, - { rating: 4.3, title: 'Crime and Punishment' }, - { - rating: 4.3, - title: 'One Hundred Years of Solitude' - }, - { rating: 4.5, title: 'Pride and Prejudice' } - ); + it('run pipeline with sample limit of {percentage: 0.6}', async () => { + let avgSize = 0; + const numIterations = 20; + for (let i = 0; i < numIterations; i++) { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sample({ percentage: 0.6 }) + ); + + avgSize += snapshot.results.length; + } + avgSize /= numIterations; + expect(avgSize).to.be.closeTo(6, 1); }); + }); - it('testLogicalOperators', async () => { - const results = await randomCol - .pipeline() - .where( - orFunction( - andFunction(gt('rating', 4.5), eq('genre', 'Science Fiction')), - lt('published', 1900) - ) - ) - .select('title') - .sort(Field.of('title').ascending()) - .execute(); + describe('union stage', () => { + // __name__ not currently supported by dbe + itIf(testUnsupportedFeatures)('run pipeline with union', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .union(firestore.pipeline().collection(randomCol.path)) + .sort(field(documentIdFieldPath()).ascending()) + ); expectResults( - results, - { title: 'Crime and Punishment' }, - { title: 'Dune' }, - { title: 'Pride and Prejudice' } + snapshot, + 'book1', + 'book1', + 'book10', + 'book10', + 'book2', + 'book2', + 'book3', + 'book3', + 'book4', + 'book4', + 'book5', + 'book5', + 'book6', + 'book6', + 'book7', + 'book7', + 'book8', + 'book8', + 'book9', + 'book9' ); }); + }); - it('testChecks', async () => { - const results = await randomCol - .pipeline() - .where(not(Field.of('rating').isNaN())) - .select( - Field.of('rating').eq(null).as('ratingIsNull'), - not(Field.of('rating').isNaN()).as('ratingIsNotNaN') - ) - .limit(1) - .execute(); - expectResults(results, { ratingIsNull: false, ratingIsNotNaN: true }); - }); - - it('testMapGet', async () => { - const results = await randomCol - .pipeline() - .select( - Field.of('awards').mapGet('hugo').as('hugoAward'), - Field.of('awards').mapGet('others').as('others'), - Field.of('title') - ) - .where(eq('hugoAward', true)) - .execute(); + describe('unnest stage', () => { + it('run pipeline with unnest', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('title', "The Hitchhiker's Guide to the Galaxy")) + .unnest(field('tags').as('tag')) + .select( + 'title', + 'author', + 'genre', + 'published', + 'rating', + 'tags', + 'tag', + 'awards', + 'nestedField' + ) + ); expectResults( - results, + snapshot, { - hugoAward: true, title: "The Hitchhiker's Guide to the Galaxy", - others: { unknown: { year: 1980 } } + author: 'Douglas Adams', + genre: 'Science Fiction', + published: 1979, + rating: 4.2, + tags: ['comedy', 'space', 'adventure'], + tag: 'comedy', + awards: { + hugo: true, + nebula: false, + others: { unknown: { year: 1980 } } + }, + nestedField: { 'level.1': { 'level.2': true } } }, - { hugoAward: true, title: 'Dune', others: null } - ); - }); - - // it('testParent', async () => { - // const results = await randomCol - // .pipeline() - // .select( - // parent(randomCol.doc('chile').collection('subCollection').path).as( - // 'parent' - // ) - // ) - // .limit(1) - // .execute(); - // expect(results[0].data().parent.endsWith('/books')).to.be.true; - // }); - // - // it('testCollectionId', async () => { - // const results = await randomCol - // .pipeline() - // .select(collectionId(randomCol.doc('chile')).as('collectionId')) - // .limit(1) - // .execute(); - // expectResults(results, {collectionId: 'books'}); - // }); - - it('testDistanceFunctions', async () => { - const sourceVector = [0.1, 0.1]; - const targetVector = [0.5, 0.8]; - const results = await randomCol - .pipeline() - .select( - cosineDistance(Constant.vector(sourceVector), targetVector).as( - 'cosineDistance' - ), - dotProduct(Constant.vector(sourceVector), targetVector).as( - 'dotProductDistance' - ), - euclideanDistance(Constant.vector(sourceVector), targetVector).as( - 'euclideanDistance' - ) - ) - .limit(1) - .execute(); - - expectResults(results, { - cosineDistance: 0.02560880430538015, - dotProductDistance: 0.13, - euclideanDistance: 0.806225774829855 - }); - }); - - it('testNestedFields', async () => { - const results = await randomCol - .pipeline() - .where(eq('awards.hugo', true)) - .select('title', 'awards.hugo') - .execute(); - expectResults( - results, { title: "The Hitchhiker's Guide to the Galaxy", - 'awards.hugo': true + author: 'Douglas Adams', + genre: 'Science Fiction', + published: 1979, + rating: 4.2, + tags: ['comedy', 'space', 'adventure'], + tag: 'space', + awards: { + hugo: true, + nebula: false, + others: { unknown: { year: 1980 } } + }, + nestedField: { 'level.1': { 'level.2': true } } }, - { title: 'Dune', 'awards.hugo': true } + { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams', + genre: 'Science Fiction', + published: 1979, + rating: 4.2, + tags: ['comedy', 'space', 'adventure'], + tag: 'adventure', + awards: { + hugo: true, + nebula: false, + others: { unknown: { year: 1980 } } + }, + nestedField: { 'level.1': { 'level.2': true } } + } ); }); - - it('test mapGet with field name including . notation', async () => { - const results = await randomCol - .pipeline() - .where(eq('awards.hugo', true)) - .select( - 'title', - Field.of('nestedField.level.1'), - mapGet('nestedField', 'level.1').mapGet('level.2').as('nested') - ) - .execute(); + it('unnest an expr', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('title', "The Hitchhiker's Guide to the Galaxy")) + .unnest(array([1, 2, 3]).as('copy')) + .select( + 'title', + 'author', + 'genre', + 'published', + 'rating', + 'tags', + 'copy', + 'awards', + 'nestedField' + ) + ); expectResults( - results, + snapshot, + { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams', + genre: 'Science Fiction', + published: 1979, + rating: 4.2, + tags: ['comedy', 'space', 'adventure'], + copy: 1, + awards: { + hugo: true, + nebula: false, + others: { unknown: { year: 1980 } } + }, + nestedField: { 'level.1': { 'level.2': true } } + }, { title: "The Hitchhiker's Guide to the Galaxy", - 'nestedField.level.`1`': null, - nested: true + author: 'Douglas Adams', + genre: 'Science Fiction', + published: 1979, + rating: 4.2, + tags: ['comedy', 'space', 'adventure'], + copy: 2, + awards: { + hugo: true, + nebula: false, + others: { unknown: { year: 1980 } } + }, + nestedField: { 'level.1': { 'level.2': true } } }, - { title: 'Dune', 'nestedField.level.`1`': null, nested: null } + { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams', + genre: 'Science Fiction', + published: 1979, + rating: 4.2, + tags: ['comedy', 'space', 'adventure'], + copy: 3, + awards: { + hugo: true, + nebula: false, + others: { unknown: { year: 1980 } } + }, + nestedField: { 'level.1': { 'level.2': true } } + } ); }); + }); - it('supports internal serialization to proto', async () => { - const pipeline = firestore - .pipeline() - .collection('books') - .where(eq('awards.hugo', true)) - .select( - 'title', - Field.of('nestedField.level.1'), - mapGet('nestedField', 'level.1').mapGet('level.2').as('nested') - ); - - const proto = _internalPipelineToExecutePipelineRequestProto(pipeline); - expect(proto).not.to.be.null; - }); - - describe('pagination', () => { - async function addBooks( - collection: CollectionReference - ): Promise { - await setDoc(doc(randomCol, 'book11'), { - title: 'Jonathan Strange & Mr Norrell', - author: 'Susanna Clarke', - genre: 'Fantasy', - published: 2004, - rating: 4.6, - tags: [ - 'historical fantasy', - 'magic', - 'alternate history', - 'england' - ], - awards: { hugo: false, nebula: false } - }); - await setDoc(doc(randomCol, 'book12'), { - title: 'The Master and Margarita', - author: 'Mikhail Bulgakov', - genre: 'Satire', - published: 1967, // Though written much earlier - rating: 4.6, - tags: [ - 'russian literature', - 'supernatural', - 'philosophy', - 'dark comedy' - ], - awards: {} - }); - await setDoc(doc(randomCol, 'book13'), { - title: 'A Long Way to a Small, Angry Planet', - author: 'Becky Chambers', - genre: 'Science Fiction', - published: 2014, - rating: 4.6, - tags: [ - 'space opera', - 'found family', - 'character-driven', - 'optimistic' - ], - awards: { hugo: false, nebula: false, kitschies: true } - }); - } - - it('supports pagination with filters', async () => { - await addBooks(randomCol); - const pageSize = 2; - const pipeline = randomCol - .pipeline() - .select('title', 'rating', '__name__') - .sort( - Field.of('rating').descending(), - Field.of('__name__').ascending() - ); - - let results = await pipeline.limit(pageSize).execute(); - expectResults( - results, - { title: 'The Lord of the Rings', rating: 4.7 }, - { title: 'Jonathan Strange & Mr Norrell', rating: 4.6 } - ); - - const lastDoc = results[results.length - 1]; - - results = await pipeline - .where( - orFunction( - andFunction( - Field.of('rating').eq(lastDoc.get('rating')), - Field.of('__path__').gt(lastDoc.ref?.path) - ), - Field.of('rating').lt(lastDoc.get('rating')) - ) - ) - .limit(pageSize) - .execute(); - expectResults( - results, - { title: 'Pride and Prejudice', rating: 4.5 }, - { title: 'Crime and Punishment', rating: 4.3 } - ); - }); - - it('supports pagination with offsets', async () => { - await addBooks(randomCol); - - const secondFilterField = '__path__'; - - const pipeline = randomCol - .pipeline() - .select('title', 'rating', secondFilterField) - .sort( - Field.of('rating').descending(), - Field.of(secondFilterField).ascending() - ); - - const pageSize = 2; - let currPage = 0; - - let results = await pipeline - .offset(currPage++ * pageSize) - .limit(pageSize) - .execute(); - - expectResults( - results, - { - title: 'The Lord of the Rings', - rating: 4.7 - }, - { title: 'Dune', rating: 4.6 } + describe('findNearest stage', () => { + it('run pipeline with findNearest', async () => { + const measures: Array = [ + 'euclidean', + 'dot_product', + 'cosine' + ]; + for (const measure of measures) { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol) + .findNearest({ + field: 'embedding', + vectorValue: vector([10, 1, 3, 1, 2, 1, 1, 1, 1, 1]), + limit: 3, + distanceMeasure: measure + }) + .select('title') ); - - results = await pipeline - .offset(currPage++ * pageSize) - .limit(pageSize) - .execute(); expectResults( - results, + snapshot, { - title: 'Jonathan Strange & Mr Norrell', - rating: 4.6 + title: "The Hitchhiker's Guide to the Galaxy" }, - { title: 'The Master and Margarita', rating: 4.6 } - ); - - results = await pipeline - .offset(currPage++ * pageSize) - .limit(pageSize) - .execute(); - expectResults( - results, { - title: 'A Long Way to a Small, Angry Planet', - rating: 4.6 + title: 'One Hundred Years of Solitude' }, { - title: 'Pride and Prejudice', - rating: 4.5 + title: "The Handmaid's Tale" } ); - }); + } }); - }); - describe('modular API', () => { - it('works when creating a pipeline from a Firestore instance', async () => { - const myPipeline = pipeline(firestore) - .collection(randomCol.path) - .where(lt(Field.of('published'), 1984)) - .aggregate({ - accumulators: [avgFunction('rating').as('avgRating')], - groups: ['genre'] - }) - .where(gt('avgRating', 4.3)) - .sort(Field.of('avgRating').descending()); - - const results = await execute(myPipeline); - - expectResults( - results, - { avgRating: 4.7, genre: 'Fantasy' }, - { avgRating: 4.5, genre: 'Romance' }, - { avgRating: 4.4, genre: 'Science Fiction' } + it('optionally returns the computed distance', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol) + .findNearest({ + field: 'embedding', + vectorValue: vector([10, 1, 2, 1, 1, 1, 1, 1, 1, 1]), + limit: 2, + distanceMeasure: 'euclidean', + distanceField: 'computedDistance' + }) + .select('title', 'computedDistance') ); - }); - - it('works when creating a pipeline from a collection', async () => { - const myPipeline = pipeline(randomCol) - .where(lt(Field.of('published'), 1984)) - .aggregate({ - accumulators: [avgFunction('rating').as('avgRating')], - groups: ['genre'] - }) - .where(gt('avgRating', 4.3)) - .sort(Field.of('avgRating').descending()); - - const results = await execute(myPipeline); - expectResults( - results, - { avgRating: 4.7, genre: 'Fantasy' }, - { avgRating: 4.5, genre: 'Romance' }, - { avgRating: 4.4, genre: 'Science Fiction' } + snapshot, + { + title: "The Hitchhiker's Guide to the Galaxy", + computedDistance: 1 + }, + { + title: 'One Hundred Years of Solitude', + computedDistance: 12.041594578792296 + } ); }); }); }); - // This is the Query integration tests from the lite API (no cache support) - // with some additional test cases added for more complete coverage. - describe('Query to Pipeline', () => { - function verifyResults( - actual: Array>, - ...expected: DocumentData[] - ): void { - expect(actual.length).to.equal(expected.length); - - for (let i = 0; i < expected.length; ++i) { - expect(actual[i].data()).to.deep.equal(expected[i]); - } - } - - it('supports default query', () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, - { 1: { foo: 1 } }, - async collRef => { - const result = await collRef.pipeline().execute(); - verifyResults(result, { foo: 1 }); - } + describe('function expressions', () => { + it('logical max works', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select( + 'title', + logicalMaximum(constant(1960), field('published'), 1961).as( + 'published-safe' + ) + ) + .sort(field('title').ascending()) + .limit(3) + ); + expectResults( + snapshot, + { title: '1984', 'published-safe': 1961 }, + { title: 'Crime and Punishment', 'published-safe': 1961 }, + { title: 'Dune', 'published-safe': 1965 } ); }); - it('supports filtered query', () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, - { - 1: { foo: 1 }, - 2: { foo: 2 } - }, - async collRef => { - const query1 = query(collRef, where('foo', '==', 1)); - const result = await query1.pipeline().execute(); - verifyResults(result, { foo: 1 }); - } + it('logical min works', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select( + 'title', + logicalMinimum(constant(1960), field('published'), 1961).as( + 'published-safe' + ) + ) + .sort(field('title').ascending()) + .limit(3) + ); + expectResults( + snapshot, + { title: '1984', 'published-safe': 1949 }, + { title: 'Crime and Punishment', 'published-safe': 1866 }, + { title: 'Dune', 'published-safe': 1960 } ); }); - it('supports filtered query (with FieldPath)', () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, - { - 1: { foo: 1 }, - 2: { foo: 2 } - }, - async collRef => { - const query1 = query(collRef, where(new FieldPath('foo'), '==', 1)); - const result = await query1.pipeline().execute(); - verifyResults(result, { foo: 1 }); - } + it('cond works', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select( + 'title', + cond( + lt(field('published'), 1960), + constant(1960), + field('published') + ).as('published-safe') + ) + .sort(field('title').ascending()) + .limit(3) + ); + expectResults( + snapshot, + { title: '1984', 'published-safe': 1960 }, + { title: 'Crime and Punishment', 'published-safe': 1960 }, + { title: 'Dune', 'published-safe': 1965 } ); }); - it('supports ordered query (with default order)', () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, - { - 1: { foo: 1 }, - 2: { foo: 2 } - }, - async collRef => { - const query1 = query(collRef, orderBy('foo')); - const result = await query1.pipeline().execute(); - verifyResults(result, { foo: 1 }, { foo: 2 }); - } + it('eqAny works', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eqAny('published', [1979, 1999, 1967])) + .sort(descending('title')) + .select('title') + ); + expectResults( + snapshot, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'One Hundred Years of Solitude' } ); }); - it('supports ordered query (with asc)', () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, - { - 1: { foo: 1 }, - 2: { foo: 2 } - }, - async collRef => { - const query1 = query(collRef, orderBy('foo', 'asc')); - const result = await query1.pipeline().execute(); - verifyResults(result, { foo: 1 }, { foo: 2 }); - } + it('notEqAny works', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where( + notEqAny( + 'published', + [1965, 1925, 1949, 1960, 1866, 1985, 1954, 1967, 1979] + ) + ) + .select('title') ); + expectResults(snapshot, { title: 'Pride and Prejudice' }); }); - it('supports ordered query (with desc)', () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, - { - 1: { foo: 1 }, - 2: { foo: 2 } - }, - async collRef => { - const query1 = query(collRef, orderBy('foo', 'desc')); - const result = await query1.pipeline().execute(); - verifyResults(result, { foo: 2 }, { foo: 1 }); - } + it('arrayContains works', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(arrayContains('tags', 'comedy')) + .select('title') ); + expectResults(snapshot, { + title: "The Hitchhiker's Guide to the Galaxy" + }); }); - it('supports limit query', () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, - { - 1: { foo: 1 }, - 2: { foo: 2 } - }, - async collRef => { - const query1 = query(collRef, orderBy('foo'), limit(1)); - const result = await query1.pipeline().execute(); - verifyResults(result, { foo: 1 }); - } + it('arrayContainsAny works', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(arrayContainsAny('tags', ['comedy', 'classic'])) + .sort(descending('title')) + .select('title') + ); + expectResults( + snapshot, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'Pride and Prejudice' } ); }); - it('supports limitToLast query', () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, - { - 1: { foo: 1 }, - 2: { foo: 2 }, - 3: { foo: 3 } - }, - async collRef => { - const query1 = query(collRef, orderBy('foo'), limitToLast(2)); - const result = await query1.pipeline().execute(); - verifyResults(result, { foo: 2 }, { foo: 3 }); - } + it('arrayContainsAll works', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(arrayContainsAll('tags', ['adventure', 'magic'])) + .select('title') ); + expectResults(snapshot, { title: 'The Lord of the Rings' }); }); - it('supports startAt', () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, - { - 1: { foo: 1 }, - 2: { foo: 2 } - }, - async collRef => { - const query1 = query(collRef, orderBy('foo'), startAt(2)); - const result = await query1.pipeline().execute(); - verifyResults(result, { foo: 2 }); - } + it('arrayLength works', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select(arrayLength('tags').as('tagsCount')) + .where(eq('tagsCount', 3)) ); + expect(snapshot.results.length).to.equal(10); }); - it('supports startAfter (with DocumentReference)', () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, - { - 1: { id: 1, foo: 1, bar: 1, baz: 1 }, - 2: { id: 2, foo: 1, bar: 1, baz: 2 }, - 3: { id: 3, foo: 1, bar: 1, baz: 2 }, - 4: { id: 4, foo: 1, bar: 2, baz: 1 }, - 5: { id: 5, foo: 1, bar: 2, baz: 2 }, - 6: { id: 6, foo: 1, bar: 2, baz: 2 }, - 7: { id: 7, foo: 2, bar: 1, baz: 1 }, - 8: { id: 8, foo: 2, bar: 1, baz: 2 }, - 9: { id: 9, foo: 2, bar: 1, baz: 2 }, - 10: { id: 10, foo: 2, bar: 2, baz: 1 }, - 11: { id: 11, foo: 2, bar: 2, baz: 2 }, - 12: { id: 12, foo: 2, bar: 2, baz: 2 } - }, - async collRef => { - let docRef = await getDoc(doc(collRef, '2')); - let query1 = query( - collRef, - orderBy('foo'), - orderBy('bar'), - orderBy('baz'), - startAfter(docRef) - ); - let result = await query1.pipeline().execute(); - verifyResults( - result, - { id: 3, foo: 1, bar: 1, baz: 2 }, - { id: 4, foo: 1, bar: 2, baz: 1 }, - { id: 5, foo: 1, bar: 2, baz: 2 }, - { id: 6, foo: 1, bar: 2, baz: 2 }, - { id: 7, foo: 2, bar: 1, baz: 1 }, - { id: 8, foo: 2, bar: 1, baz: 2 }, - { id: 9, foo: 2, bar: 1, baz: 2 }, - { id: 10, foo: 2, bar: 2, baz: 1 }, - { id: 11, foo: 2, bar: 2, baz: 2 }, - { id: 12, foo: 2, bar: 2, baz: 2 } - ); - - docRef = await getDoc(doc(collRef, '3')); - query1 = query( - collRef, - orderBy('foo'), - orderBy('bar'), - orderBy('baz'), - startAfter(docRef) - ); - result = await query1.pipeline().execute(); - verifyResults( - result, - { id: 4, foo: 1, bar: 2, baz: 1 }, - { id: 5, foo: 1, bar: 2, baz: 2 }, - { id: 6, foo: 1, bar: 2, baz: 2 }, - { id: 7, foo: 2, bar: 1, baz: 1 }, - { id: 8, foo: 2, bar: 1, baz: 2 }, - { id: 9, foo: 2, bar: 1, baz: 2 }, - { id: 10, foo: 2, bar: 2, baz: 1 }, - { id: 11, foo: 2, bar: 2, baz: 2 }, - { id: 12, foo: 2, bar: 2, baz: 2 } - ); - } + it('testStrConcat', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(ascending('author')) + .select( + field('author').strConcat(' - ', field('title')).as('bookInfo') + ) + .limit(1) ); + expectResults(snapshot, { + bookInfo: "Douglas Adams - The Hitchhiker's Guide to the Galaxy" + }); }); - it('supports startAt (with DocumentReference)', () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, - { - 1: { id: 1, foo: 1, bar: 1, baz: 1 }, - 2: { id: 2, foo: 1, bar: 1, baz: 2 }, - 3: { id: 3, foo: 1, bar: 1, baz: 2 }, - 4: { id: 4, foo: 1, bar: 2, baz: 1 }, - 5: { id: 5, foo: 1, bar: 2, baz: 2 }, - 6: { id: 6, foo: 1, bar: 2, baz: 2 }, - 7: { id: 7, foo: 2, bar: 1, baz: 1 }, - 8: { id: 8, foo: 2, bar: 1, baz: 2 }, - 9: { id: 9, foo: 2, bar: 1, baz: 2 }, - 10: { id: 10, foo: 2, bar: 2, baz: 1 }, - 11: { id: 11, foo: 2, bar: 2, baz: 2 }, - 12: { id: 12, foo: 2, bar: 2, baz: 2 } - }, - async collRef => { - let docRef = await getDoc(doc(collRef, '2')); - let query1 = query( - collRef, - orderBy('foo'), - orderBy('bar'), - orderBy('baz'), - startAt(docRef) - ); - let result = await query1.pipeline().execute(); - verifyResults( - result, - { id: 2, foo: 1, bar: 1, baz: 2 }, - { id: 3, foo: 1, bar: 1, baz: 2 }, - { id: 4, foo: 1, bar: 2, baz: 1 }, - { id: 5, foo: 1, bar: 2, baz: 2 }, - { id: 6, foo: 1, bar: 2, baz: 2 }, - { id: 7, foo: 2, bar: 1, baz: 1 }, - { id: 8, foo: 2, bar: 1, baz: 2 }, - { id: 9, foo: 2, bar: 1, baz: 2 }, - { id: 10, foo: 2, bar: 2, baz: 1 }, - { id: 11, foo: 2, bar: 2, baz: 2 }, - { id: 12, foo: 2, bar: 2, baz: 2 } - ); - - docRef = await getDoc(doc(collRef, '3')); - query1 = query( - collRef, - orderBy('foo'), - orderBy('bar'), - orderBy('baz'), - startAt(docRef) - ); - result = await query1.pipeline().execute(); - verifyResults( - result, - { id: 3, foo: 1, bar: 1, baz: 2 }, - { id: 4, foo: 1, bar: 2, baz: 1 }, - { id: 5, foo: 1, bar: 2, baz: 2 }, - { id: 6, foo: 1, bar: 2, baz: 2 }, - { id: 7, foo: 2, bar: 1, baz: 1 }, - { id: 8, foo: 2, bar: 1, baz: 2 }, - { id: 9, foo: 2, bar: 1, baz: 2 }, - { id: 10, foo: 2, bar: 2, baz: 1 }, - { id: 11, foo: 2, bar: 2, baz: 2 }, - { id: 12, foo: 2, bar: 2, baz: 2 } - ); - } + it('testStartsWith', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(startsWith('title', 'The')) + .select('title') + .sort(field('title').ascending()) + ); + expectResults( + snapshot, + { title: 'The Great Gatsby' }, + { title: "The Handmaid's Tale" }, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'The Lord of the Rings' } ); }); - it('supports startAfter', () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, - { - 1: { foo: 1 }, - 2: { foo: 2 } - }, - async collRef => { - const query1 = query(collRef, orderBy('foo'), startAfter(1)); - const result = await query1.pipeline().execute(); - verifyResults(result, { foo: 2 }); - } + it('testEndsWith', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(endsWith('title', 'y')) + .select('title') + .sort(field('title').descending()) + ); + expectResults( + snapshot, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'The Great Gatsby' } ); }); - it('supports endAt', () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, - { - 1: { foo: 1 }, - 2: { foo: 2 } - }, - async collRef => { - const query1 = query(collRef, orderBy('foo'), endAt(1)); - const result = await query1.pipeline().execute(); - verifyResults(result, { foo: 1 }); - } + it('testStrContains', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(strContains('title', "'s")) + .select('title') + .sort(field('title').ascending()) + ); + expectResults( + snapshot, + { title: "The Handmaid's Tale" }, + { title: "The Hitchhiker's Guide to the Galaxy" } ); }); - it('supports endBefore', () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, + it('testLength', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select(charLength('title').as('titleLength'), field('title')) + .where(gt('titleLength', 20)) + .sort(field('title').ascending()) + ); + + expectResults( + snapshot, + + { + titleLength: 29, + title: 'One Hundred Years of Solitude' + }, + { + titleLength: 36, + title: "The Hitchhiker's Guide to the Galaxy" + }, { - 1: { foo: 1 }, - 2: { foo: 2 } + titleLength: 21, + title: 'The Lord of the Rings' }, - async collRef => { - const query1 = query(collRef, orderBy('foo'), endBefore(2)); - const result = await query1.pipeline().execute(); - verifyResults(result, { foo: 1 }); + { + titleLength: 21, + title: 'To Kill a Mockingbird' } ); }); - it('supports pagination', () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, - { - 1: { foo: 1 }, - 2: { foo: 2 } - }, - async collRef => { - let query1 = query(collRef, orderBy('foo'), limit(1)); - const pipeline1 = query1.pipeline(); - let result = await pipeline1.execute(); - verifyResults(result, { foo: 1 }); - - // Pass the document snapshot from the previous result - query1 = query(query1, startAfter(result[0].get('foo'))); - result = await query1.pipeline().execute(); - verifyResults(result, { foo: 2 }); - } + it('testLike', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(like('title', '%Guide%')) + .select('title') + ); + expectResults(snapshot, { + title: "The Hitchhiker's Guide to the Galaxy" + }); + }); + + it('testRegexContains', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(regexContains('title', '(?i)(the|of)')) + ); + expect(snapshot.results.length).to.equal(5); + }); + + it('testRegexMatches', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(regexMatch('title', '.*(?i)(the|of).*')) + ); + expect(snapshot.results.length).to.equal(5); + }); + + it('testArithmeticOperations', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('title', 'To Kill a Mockingbird')) + .select( + add(field('rating'), 1).as('ratingPlusOne'), + subtract(field('published'), 1900).as('yearsSince1900'), + field('rating').multiply(10).as('ratingTimesTen'), + divide('rating', 2).as('ratingDividedByTwo'), + multiply('rating', 10, 2).as('ratingTimes20'), + add('rating', 1, 2).as('ratingPlus3'), + mod('rating', 2).as('ratingMod2') + ) + .limit(1) ); + expectResults(snapshot, { + ratingPlusOne: 5.2, + yearsSince1900: 60, + ratingTimesTen: 42, + ratingDividedByTwo: 2.1, + ratingTimes20: 84, + ratingPlus3: 7.2, + ratingMod2: 0.20000000000000018 + }); }); - it('supports pagination on DocumentIds', () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, + it('testComparisonOperators', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where( + and( + gt('rating', 4.2), + lte(field('rating'), 4.5), + neq('genre', 'Science Fiction') + ) + ) + .select('rating', 'title') + .sort(field('title').ascending()) + ); + expectResults( + snapshot, + { rating: 4.3, title: 'Crime and Punishment' }, { - 1: { foo: 1 }, - 2: { foo: 2 } + rating: 4.3, + title: 'One Hundred Years of Solitude' }, - async collRef => { - let query1 = query( - collRef, - orderBy('foo'), - orderBy(documentId(), 'asc'), - limit(1) - ); - const pipeline1 = query1.pipeline(); - let result = await pipeline1.execute(); - verifyResults(result, { foo: 1 }); - - // Pass the document snapshot from the previous result - query1 = query( - query1, - startAfter(result[0].get('foo'), result[0].ref?.id) - ); - result = await query1.pipeline().execute(); - verifyResults(result, { foo: 2 }); - } + { rating: 4.5, title: 'Pride and Prejudice' } ); }); - it('supports collection groups', () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, - {}, - async collRef => { - const collectionGroupId = `${collRef.id}group`; + it('testLogicalOperators', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where( + or( + and(gt('rating', 4.5), eq('genre', 'Science Fiction')), + lt('published', 1900) + ) + ) + .select('title') + .sort(field('title').ascending()) + ); + expectResults( + snapshot, + { title: 'Crime and Punishment' }, + { title: 'Dune' }, + { title: 'Pride and Prejudice' } + ); + }); - const fooDoc = doc( - collRef.firestore, - `${collRef.id}/foo/${collectionGroupId}/doc1` - ); - const barDoc = doc( - collRef.firestore, - `${collRef.id}/bar/baz/boo/${collectionGroupId}/doc2` - ); - await setDoc(fooDoc, { foo: 1 }); - await setDoc(barDoc, { bar: 1 }); + it('testChecks', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select( + isNull('rating').as('ratingIsNull'), + isNan('rating').as('ratingIsNaN'), + isError(arrayOffset('title', 0)).as('isError'), + ifError(arrayOffset('title', 0), constant('was error')).as( + 'ifError' + ), + isAbsent('foo').as('isAbsent'), + isNotNull('title').as('titleIsNotNull'), + isNotNan('cost').as('costIsNotNan'), + exists('fooBarBaz').as('fooBarBazExists'), + field('title').exists().as('titleExists') + ) + ); + expectResults(snapshot, { + ratingIsNull: false, + ratingIsNaN: false, + isError: true, + ifError: 'was error', + isAbsent: true, + titleIsNotNull: true, + costIsNotNan: false, + fooBarBazExists: false, + titleExists: true + }); - const query1 = collectionGroup(collRef.firestore, collectionGroupId); - const result = await query1.pipeline().execute(); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select( + field('rating').isNull().as('ratingIsNull'), + field('rating').isNan().as('ratingIsNaN'), + arrayOffset('title', 0).isError().as('isError'), + arrayOffset('title', 0) + .ifError(constant('was error')) + .as('ifError'), + field('foo').isAbsent().as('isAbsent'), + field('title').isNotNull().as('titleIsNotNull'), + field('cost').isNotNan().as('costIsNotNan') + ) + ); + expectResults(snapshot, { + ratingIsNull: false, + ratingIsNaN: false, + isError: true, + ifError: 'was error', + isAbsent: true, + titleIsNotNull: true, + costIsNotNan: false + }); + }); - verifyResults(result, { bar: 1 }, { foo: 1 }); - } + it('testMapGet', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('published').descending()) + .select( + field('awards').mapGet('hugo').as('hugoAward'), + field('awards').mapGet('others').as('others'), + field('title') + ) + .where(eq('hugoAward', true)) + ); + expectResults( + snapshot, + { + hugoAward: true, + title: "The Hitchhiker's Guide to the Galaxy", + others: { unknown: { year: 1980 } } + }, + { hugoAward: true, title: 'Dune', others: null } ); }); - it('supports query over collection path with special characters', () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, - {}, - async collRef => { - const docWithSpecials = doc(collRef, 'so!@#$%^&*()_+special'); + it('testDistanceFunctions', async () => { + const sourceVector = [0.1, 0.1]; + const targetVector = [0.5, 0.8]; + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select( + cosineDistance(constantVector(sourceVector), targetVector).as( + 'cosineDistance' + ), + dotProduct(constantVector(sourceVector), targetVector).as( + 'dotProductDistance' + ), + euclideanDistance(constantVector(sourceVector), targetVector).as( + 'euclideanDistance' + ) + ) + .limit(1) + ); - const collectionWithSpecials = collection( - docWithSpecials, - 'so!@#$%^&*()_+special' - ); - await addDoc(collectionWithSpecials, { foo: 1 }); - await addDoc(collectionWithSpecials, { foo: 2 }); + expectResults(snapshot, { + cosineDistance: 0.02560880430538015, + dotProductDistance: 0.13, + euclideanDistance: 0.806225774829855 + }); - const result = await query( - collectionWithSpecials, - orderBy('foo', 'asc') + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select( + constantVector(sourceVector) + .cosineDistance(targetVector) + .as('cosineDistance'), + constantVector(sourceVector) + .dotProduct(targetVector) + .as('dotProductDistance'), + constantVector(sourceVector) + .euclideanDistance(targetVector) + .as('euclideanDistance') ) - .pipeline() - .execute(); + .limit(1) + ); - verifyResults(result, { foo: 1 }, { foo: 2 }); - } + expectResults(snapshot, { + cosineDistance: 0.02560880430538015, + dotProductDistance: 0.13, + euclideanDistance: 0.806225774829855 + }); + }); + + it('testVectorLength', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(vectorLength(constantVector([1, 2, 3])).as('vectorLength')) + ); + expectResults(snapshot, { + vectorLength: 3 + }); + }); + + it('testNestedFields', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('awards.hugo', true)) + .sort(descending('title')) + .select('title', 'awards.hugo') + ); + expectResults( + snapshot, + { + title: "The Hitchhiker's Guide to the Galaxy", + 'awards.hugo': true + }, + { title: 'Dune', 'awards.hugo': true } ); }); - it('supports multiple inequality on same field', () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, + it('test mapGet with field name including . notation', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('awards.hugo', true)) + .select( + 'title', + field('nestedField.level.1'), + mapGet('nestedField', 'level.1').mapGet('level.2').as('nested') + ) + .sort(descending('title')) + ); + expectResults( + snapshot, { - '01': { id: 1, foo: 1, bar: 1, baz: 1 }, - '02': { id: 2, foo: 1, bar: 1, baz: 2 }, - '03': { id: 3, foo: 1, bar: 1, baz: 2 }, - '04': { id: 4, foo: 1, bar: 2, baz: 1 }, - '05': { id: 5, foo: 1, bar: 2, baz: 2 }, - '06': { id: 6, foo: 1, bar: 2, baz: 2 }, - '07': { id: 7, foo: 2, bar: 1, baz: 1 }, - '08': { id: 8, foo: 2, bar: 1, baz: 2 }, - '09': { id: 9, foo: 2, bar: 1, baz: 2 }, - '10': { id: 10, foo: 2, bar: 2, baz: 1 }, - '11': { id: 11, foo: 2, bar: 2, baz: 2 }, - '12': { id: 12, foo: 2, bar: 2, baz: 2 } + title: "The Hitchhiker's Guide to the Galaxy", + 'nestedField.level.`1`': null, + nested: true }, - async collRef => { - const query1 = query( - collRef, - and(where('id', '>', 2), where('id', '<=', 10)) - ); - const result = await query1.pipeline().execute(); - verifyResults( - result, - { id: 3, foo: 1, bar: 1, baz: 2 }, - { id: 4, foo: 1, bar: 2, baz: 1 }, - { id: 5, foo: 1, bar: 2, baz: 2 }, - { id: 6, foo: 1, bar: 2, baz: 2 }, - { id: 7, foo: 2, bar: 1, baz: 1 }, - { id: 8, foo: 2, bar: 1, baz: 2 }, - { id: 9, foo: 2, bar: 1, baz: 2 }, - { id: 10, foo: 2, bar: 2, baz: 1 } - ); - } + { title: 'Dune', 'nestedField.level.`1`': null, nested: null } + ); + }); + + describe('genericFunction', () => { + it('add selectable', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(descending('rating')) + .limit(1) + .select( + new FunctionExpr('add', [field('rating'), constant(1)]).as( + 'rating' + ) + ) + ); + expectResults(snapshot, { + rating: 5.7 + }); + }); + + it('and (variadic) selectable', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where( + new BooleanExpr('and', [ + field('rating').gt(0), + field('title').charLength().lt(5), + field('tags').arrayContains('propaganda') + ]) + ) + .select('title') + ); + expectResults(snapshot, { + title: '1984' + }); + }); + + it('array contains any', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where( + new BooleanExpr('array_contains_any', [ + field('tags'), + array(['politics']) + ]) + ) + .select('title') + ); + expectResults(snapshot, { + title: 'Dune' + }); + }); + + it('countif aggregate', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .aggregate( + new AggregateFunction('count_if', [field('rating').gte(4.5)]).as( + 'countOfBest' + ) + ) + ); + expectResults(snapshot, { + countOfBest: 3 + }); + }); + + it('sort by char_len', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort( + new FunctionExpr('char_length', [field('title')]).ascending(), + descending('__name__') + ) + .limit(3) + .select('title') + ); + expectResults( + snapshot, + { + title: '1984' + }, + { + title: 'Dune' + }, + { + title: 'The Great Gatsby' + } + ); + }); + }); + + itIf(testUnsupportedFeatures)('testReplaceFirst', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('title', 'The Lord of the Rings')) + .limit(1) + .select(replaceFirst('title', 'o', '0').as('newName')) + ); + expectResults(snapshot, { newName: 'The L0rd of the Rings' }); + }); + + itIf(testUnsupportedFeatures)('testReplaceAll', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('title', 'The Lord of the Rings')) + .limit(1) + .select(replaceAll('title', 'o', '0').as('newName')) + ); + expectResults(snapshot, { newName: 'The L0rd 0f the Rings' }); + }); + + it('supports Rand', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(10) + .select(rand().as('result')) + ); + expect(snapshot.results.length).to.equal(10); + snapshot.results.forEach(d => { + expect(d.get('result')).to.be.lt(1); + expect(d.get('result')).to.be.gte(0); + }); + }); + + it('supports array', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(array([1, 2, 3, 4]).as('metadata')) + ); + expect(snapshot.results.length).to.equal(1); + expectResults(snapshot, { + metadata: [1, 2, 3, 4] + }); + }); + + it('evaluates expression in array', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select( + array([1, 2, field('genre'), multiply('rating', 10)]).as('metadata') + ) ); + expect(snapshot.results.length).to.equal(1); + expectResults(snapshot, { + metadata: [1, 2, 'Fantasy', 47] + }); }); - it('supports multiple inequality on different fields', () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, + it('supports arrayOffset', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(3) + .select(arrayOffset('tags', 0).as('firstTag')) + ); + const expectedResults = [ { - '01': { id: 1, foo: 1, bar: 1, baz: 1 }, - '02': { id: 2, foo: 1, bar: 1, baz: 2 }, - '03': { id: 3, foo: 1, bar: 1, baz: 2 }, - '04': { id: 4, foo: 1, bar: 2, baz: 1 }, - '05': { id: 5, foo: 1, bar: 2, baz: 2 }, - '06': { id: 6, foo: 1, bar: 2, baz: 2 }, - '07': { id: 7, foo: 2, bar: 1, baz: 1 }, - '08': { id: 8, foo: 2, bar: 1, baz: 2 }, - '09': { id: 9, foo: 2, bar: 1, baz: 2 }, - '10': { id: 10, foo: 2, bar: 2, baz: 1 }, - '11': { id: 11, foo: 2, bar: 2, baz: 2 }, - '12': { id: 12, foo: 2, bar: 2, baz: 2 } + firstTag: 'adventure' }, - async collRef => { - const query1 = query( - collRef, - and(where('id', '>=', 2), where('baz', '<', 2)) - ); - const result = await query1.pipeline().execute(); - verifyResults( - result, - { id: 4, foo: 1, bar: 2, baz: 1 }, - { id: 7, foo: 2, bar: 1, baz: 1 }, - { id: 10, foo: 2, bar: 2, baz: 1 } - ); + { + firstTag: 'politics' + }, + { + firstTag: 'classic' } + ]; + expectResults(snapshot, ...expectedResults); + + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(3) + .select(field('tags').arrayOffset(0).as('firstTag')) + ); + expectResults(snapshot, ...expectedResults); + }); + + // TODO: current_context tests with are failing because of b/395937453 + itIf(testUnsupportedFeatures)('supports currentContext', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(currentContext().as('currentContext')) + ); + expectResults(snapshot, { + currentContext: 'TODO' + }); + }); + + it('supports map', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select( + map({ + foo: 'bar' + }).as('metadata') + ) ); + + expect(snapshot.results.length).to.equal(1); + expectResults(snapshot, { + metadata: { + foo: 'bar' + } + }); + }); + + it('evaluates expression in map', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select( + map({ + genre: field('genre'), + rating: field('rating').multiply(10) + }).as('metadata') + ) + ); + + expect(snapshot.results.length).to.equal(1); + expectResults(snapshot, { + metadata: { + genre: 'Fantasy', + rating: 47 + } + }); + }); + + it('supports mapRemove', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(mapRemove('awards', 'hugo').as('awards')) + ); + expectResults(snapshot, { + awards: { nebula: false } + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(field('awards').mapRemove('hugo').as('awards')) + ); + expectResults(snapshot, { + awards: { nebula: false } + }); + }); + + it('supports mapMerge', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(mapMerge('awards', { fakeAward: true }).as('awards')) + ); + expectResults(snapshot, { + awards: { nebula: false, hugo: false, fakeAward: true } + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(field('awards').mapMerge({ fakeAward: true }).as('awards')) + ); + expectResults(snapshot, { + awards: { nebula: false, hugo: false, fakeAward: true } + }); + }); + + it('supports timestamp conversions', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + unixSecondsToTimestamp(constant(1741380235)).as( + 'unixSecondsToTimestamp' + ), + unixMillisToTimestamp(constant(1741380235123)).as( + 'unixMillisToTimestamp' + ), + unixMicrosToTimestamp(constant(1741380235123456)).as( + 'unixMicrosToTimestamp' + ), + timestampToUnixSeconds( + constant(new Timestamp(1741380235, 123456789)) + ).as('timestampToUnixSeconds'), + timestampToUnixMicros( + constant(new Timestamp(1741380235, 123456789)) + ).as('timestampToUnixMicros'), + timestampToUnixMillis( + constant(new Timestamp(1741380235, 123456789)) + ).as('timestampToUnixMillis') + ) + ); + expectResults(snapshot, { + unixMicrosToTimestamp: new Timestamp(1741380235, 123456000), + unixMillisToTimestamp: new Timestamp(1741380235, 123000000), + unixSecondsToTimestamp: new Timestamp(1741380235, 0), + timestampToUnixSeconds: 1741380235, + timestampToUnixMicros: 1741380235123456, + timestampToUnixMillis: 1741380235123 + }); + }); + + it('supports timestamp math', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(constant(new Timestamp(1741380235, 0)).as('timestamp')) + .select( + timestampAdd('timestamp', 'day', 10).as('plus10days'), + timestampAdd('timestamp', 'hour', 10).as('plus10hours'), + timestampAdd('timestamp', 'minute', 10).as('plus10minutes'), + timestampAdd('timestamp', 'second', 10).as('plus10seconds'), + timestampAdd('timestamp', 'microsecond', 10).as('plus10micros'), + timestampAdd('timestamp', 'millisecond', 10).as('plus10millis'), + timestampSub('timestamp', 'day', 10).as('minus10days'), + timestampSub('timestamp', 'hour', 10).as('minus10hours'), + timestampSub('timestamp', 'minute', 10).as('minus10minutes'), + timestampSub('timestamp', 'second', 10).as('minus10seconds'), + timestampSub('timestamp', 'microsecond', 10).as('minus10micros'), + timestampSub('timestamp', 'millisecond', 10).as('minus10millis') + ) + ); + expectResults(snapshot, { + plus10days: new Timestamp(1742244235, 0), + plus10hours: new Timestamp(1741416235, 0), + plus10minutes: new Timestamp(1741380835, 0), + plus10seconds: new Timestamp(1741380245, 0), + plus10micros: new Timestamp(1741380235, 10000), + plus10millis: new Timestamp(1741380235, 10000000), + minus10days: new Timestamp(1740516235, 0), + minus10hours: new Timestamp(1741344235, 0), + minus10minutes: new Timestamp(1741379635, 0), + minus10seconds: new Timestamp(1741380225, 0), + minus10micros: new Timestamp(1741380234, 999990000), + minus10millis: new Timestamp(1741380234, 990000000) + }); + }); + + it('supports byteLength', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol) + .limit(1) + .select( + constant( + Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])) + ).as('bytes') + ) + .select(byteLength('bytes').as('byteLength')) + ); + + expectResults(snapshot, { + byteLength: 8 + }); + }); + + it('supports not', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol) + .limit(1) + .select(constant(true).as('trueField')) + .select('trueField', not(eq('trueField', true)).as('falseField')) + ); + + expectResults(snapshot, { + trueField: true, + falseField: false + }); + }); + }); + + describe('not yet implemented in backend', () => { + itIf(testUnsupportedFeatures)('supports Bit_and', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(bitAnd(constant(5), 12).as('result')) + ); + expectResults(snapshot, { + result: 4 + }); + }); + + itIf(testUnsupportedFeatures)('supports Bit_and', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(constant(5).bitAnd(12).as('result')) + ); + expectResults(snapshot, { + result: 4 + }); + }); + + itIf(testUnsupportedFeatures)('supports Bit_or', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(bitOr(constant(5), 12).as('result')) + ); + expectResults(snapshot, { + result: 13 + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(constant(5).bitOr(12).as('result')) + ); + expectResults(snapshot, { + result: 13 + }); + }); + + itIf(testUnsupportedFeatures)('supports Bit_xor', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(bitXor(constant(5), 12).as('result')) + ); + expectResults(snapshot, { + result: 9 + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(constant(5).bitXor(12).as('result')) + ); + expectResults(snapshot, { + result: 9 + }); + }); + + itIf(testUnsupportedFeatures)('supports Bit_not', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + bitNot(constant(Bytes.fromUint8Array(Uint8Array.of(0xfd)))).as( + 'result' + ) + ) + ); + expectResults(snapshot, { + result: Bytes.fromUint8Array(Uint8Array.of(0x02)) + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + constant(Bytes.fromUint8Array(Uint8Array.of(0xfd))) + .bitNot() + .as('result') + ) + ); + expectResults(snapshot, { + result: Bytes.fromUint8Array(Uint8Array.of(0x02)) + }); + }); + + itIf(testUnsupportedFeatures)('supports Bit_left_shift', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + bitLeftShift( + constant(Bytes.fromUint8Array(Uint8Array.of(0x02))), + 2 + ).as('result') + ) + ); + expectResults(snapshot, { + result: Bytes.fromUint8Array(Uint8Array.of(0x04)) + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + constant(Bytes.fromUint8Array(Uint8Array.of(0x02))) + .bitLeftShift(2) + .as('result') + ) + ); + expectResults(snapshot, { + result: Bytes.fromUint8Array(Uint8Array.of(0x04)) + }); + }); + + itIf(testUnsupportedFeatures)('supports Bit_right_shift', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + bitRightShift( + constant(Bytes.fromUint8Array(Uint8Array.of(0x02))), + 2 + ).as('result') + ) + ); + expectResults(snapshot, { + result: Bytes.fromUint8Array(Uint8Array.of(0x01)) + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + constant(Bytes.fromUint8Array(Uint8Array.of(0x02))) + .bitRightShift(2) + .as('result') + ) + ); + expectResults(snapshot, { + result: Bytes.fromUint8Array(Uint8Array.of(0x01)) + }); + }); + + itIf(testUnsupportedFeatures)('supports Document_id', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(documentId(field('__path__')).as('docId')) + ); + expectResults(snapshot, { + docId: 'book4' + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(field('__path__').documentId().as('docId')) + ); + expectResults(snapshot, { + docId: 'book4' + }); + }); + + itIf(testUnsupportedFeatures)('supports Substr', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(substr('title', 9, 2).as('of')) + ); + expectResults(snapshot, { + of: 'of' + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(field('title').substr(9, 2).as('of')) + ); + expectResults(snapshot, { + of: 'of' + }); + }); + + itIf(testUnsupportedFeatures)( + 'supports Substr without length', + async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(substr('title', 9).as('of')) + ); + expectResults(snapshot, { + of: 'of the Rings' + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(field('title').substr(9).as('of')) + ); + expectResults(snapshot, { + of: 'of the Rings' + }); + } + ); + + itIf(testUnsupportedFeatures)('arrayConcat works', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select( + arrayConcat('tags', ['newTag1', 'newTag2'], field('tags'), [ + null + ]).as('modifiedTags') + ) + .limit(1) + ); + expectResults(snapshot, { + modifiedTags: [ + 'comedy', + 'space', + 'adventure', + 'newTag1', + 'newTag2', + 'comedy', + 'space', + 'adventure', + null + ] + }); + }); + + itIf(testUnsupportedFeatures)('testToLowercase', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select(toLower('title').as('lowercaseTitle')) + .limit(1) + ); + expectResults(snapshot, { + lowercaseTitle: "the hitchhiker's guide to the galaxy" + }); + }); + + itIf(testUnsupportedFeatures)('testToUppercase', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select(toUpper('author').as('uppercaseAuthor')) + .limit(1) + ); + expectResults(snapshot, { uppercaseAuthor: 'DOUGLAS ADAMS' }); + }); + + itIf(testUnsupportedFeatures)('testTrim', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .addFields( + constant(" The Hitchhiker's Guide to the Galaxy ").as('spacedTitle') + ) + .select(trim('spacedTitle').as('trimmedTitle'), field('spacedTitle')) + .limit(1) + ); + expectResults(snapshot, { + spacedTitle: " The Hitchhiker's Guide to the Galaxy ", + trimmedTitle: "The Hitchhiker's Guide to the Galaxy" + }); + }); + + itIf(testUnsupportedFeatures)('test reverse', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('title', '1984')) + .limit(1) + .select(reverse('title').as('reverseTitle')) + ); + expectResults(snapshot, { title: '4891' }); + }); + }); + + describe('pagination', () => { + /** + * Adds several books to the test collection. These + * additional books support pagination test scenarios + * that would otherwise not be possible with the original + * set of books. + * @param collectionReference + */ + async function addBooks( + collectionReference: CollectionReference + ): Promise { + await setDoc(doc(collectionReference, 'book11'), { + title: 'Jonathan Strange & Mr Norrell', + author: 'Susanna Clarke', + genre: 'Fantasy', + published: 2004, + rating: 4.6, + tags: ['historical fantasy', 'magic', 'alternate history', 'england'], + awards: { hugo: false, nebula: false } + }); + await setDoc(doc(collectionReference, 'book12'), { + title: 'The Master and Margarita', + author: 'Mikhail Bulgakov', + genre: 'Satire', + published: 1967, // Though written much earlier + rating: 4.6, + tags: [ + 'russian literature', + 'supernatural', + 'philosophy', + 'dark comedy' + ], + awards: {} + }); + await setDoc(doc(collectionReference, 'book13'), { + title: 'A Long Way to a Small, Angry Planet', + author: 'Becky Chambers', + genre: 'Science Fiction', + published: 2014, + rating: 4.6, + tags: ['space opera', 'found family', 'character-driven', 'optimistic'], + awards: { hugo: false, nebula: false, kitschies: true } + }); + } + + // sort on __name__ is not working + itIf(testUnsupportedFeatures)( + 'supports pagination with filters', + async () => { + await addBooks(randomCol); + const pageSize = 2; + const pipeline = firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'rating', '__name__') + .sort(field('rating').descending(), field('__name__').ascending()); + + let snapshot = await execute(pipeline.limit(pageSize)); + expectResults( + snapshot, + { title: 'The Lord of the Rings', rating: 4.7 }, + { title: 'Jonathan Strange & Mr Norrell', rating: 4.6 } + ); + + const lastDoc = snapshot.results[snapshot.results.length - 1]; + + snapshot = await execute( + pipeline + .where( + or( + and( + field('rating').eq(lastDoc.get('rating')), + field('__path__').gt(lastDoc.ref?.id) + ), + field('rating').lt(lastDoc.get('rating')) + ) + ) + .limit(pageSize) + ); + expectResults( + snapshot, + { title: 'Pride and Prejudice', rating: 4.5 }, + { title: 'Crime and Punishment', rating: 4.3 } + ); + } + ); + + // sort on __name__ is not working + itIf(testUnsupportedFeatures)( + 'supports pagination with offsets', + async () => { + await addBooks(randomCol); + + const secondFilterField = '__path__'; + + const pipeline = firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'rating', secondFilterField) + .sort( + field('rating').descending(), + field(secondFilterField).ascending() + ); + + const pageSize = 2; + let currPage = 0; + + let snapshot = await execute( + pipeline.offset(currPage++ * pageSize).limit(pageSize) + ); + + expectResults( + snapshot, + { + title: 'The Lord of the Rings', + rating: 4.7 + }, + { title: 'Dune', rating: 4.6 } + ); + + snapshot = await execute( + pipeline.offset(currPage++ * pageSize).limit(pageSize) + ); + expectResults( + snapshot, + { + title: 'Jonathan Strange & Mr Norrell', + rating: 4.6 + }, + { title: 'The Master and Margarita', rating: 4.6 } + ); + + snapshot = await execute( + pipeline.offset(currPage++ * pageSize).limit(pageSize) + ); + expectResults( + snapshot, + { + title: 'A Long Way to a Small, Angry Planet', + rating: 4.6 + }, + { + title: 'Pride and Prejudice', + rating: 4.5 + } + ); + } + ); + }); + + describe('console support', () => { + it('supports internal serialization to proto', async () => { + const pipeline = firestore + .pipeline() + .collection('books') + .where(eq('awards.hugo', true)) + .select( + 'title', + field('nestedField.level.1'), + mapGet('nestedField', 'level.1').mapGet('level.2').as('nested') + ); + + const proto = _internalPipelineToExecutePipelineRequestProto(pipeline); + expect(proto).not.to.be.null; }); }); }); diff --git a/packages/firestore/test/integration/api/query_to_pipeline.test.ts b/packages/firestore/test/integration/api/query_to_pipeline.test.ts new file mode 100644 index 00000000000..8eac50a5afa --- /dev/null +++ b/packages/firestore/test/integration/api/query_to_pipeline.test.ts @@ -0,0 +1,827 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { expect, use } from 'chai'; +import chaiAsPromised from 'chai-as-promised'; + +import { PipelineSnapshot } from '../../../src/lite-api/pipeline-result'; +import { addEqualityMatcher } from '../../util/equality_matcher'; +import { + doc, + DocumentData, + setDoc, + setLogLevel, + query, + where, + FieldPath, + orderBy, + limit, + limitToLast, + startAt, + startAfter, + endAt, + endBefore, + collectionGroup, + collection, + and, + documentId, + addDoc, + getDoc, + or +} from '../util/firebase_export'; +import { + apiDescribe, + PERSISTENCE_MODE_UNSPECIFIED, + withTestCollection, + itIf +} from '../util/helpers'; +import { execute } from '../util/pipeline_export'; + +use(chaiAsPromised); + +setLogLevel('debug'); + +const testUnsupportedFeatures = false; + +// This is the Query integration tests from the lite API (no cache support) +// with some additional test cases added for more complete coverage. +apiDescribe.only('Query to Pipeline', persistence => { + addEqualityMatcher(); + + function verifyResults( + actual: PipelineSnapshot, + ...expected: DocumentData[] + ): void { + const results = actual.results; + expect(results.length).to.equal(expected.length); + + for (let i = 0; i < expected.length; ++i) { + expect(results[i].data()).to.deep.equal(expected[i]); + } + } + + it('supports default query', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { 1: { foo: 1 } }, + async (collRef, db) => { + const snapshot = await execute(db.pipeline().createFrom(collRef)); + verifyResults(snapshot, { foo: 1 }); + } + ); + }); + + it('supports filtered query', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 } + }, + async (collRef, db) => { + const query1 = query(collRef, where('foo', '==', 1)); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 1 }); + } + ); + }); + + it('supports filtered query (with FieldPath)', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 } + }, + async (collRef, db) => { + const query1 = query(collRef, where(new FieldPath('foo'), '==', 1)); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 1 }); + } + ); + }); + + it('supports ordered query (with default order)', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 } + }, + async (collRef, db) => { + const query1 = query(collRef, orderBy('foo')); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 1 }, { foo: 2 }); + } + ); + }); + + it('supports ordered query (with asc)', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 } + }, + async (collRef, db) => { + const query1 = query(collRef, orderBy('foo', 'asc')); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 1 }, { foo: 2 }); + } + ); + }); + + it('supports ordered query (with desc)', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 } + }, + async (collRef, db) => { + const query1 = query(collRef, orderBy('foo', 'desc')); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 2 }, { foo: 1 }); + } + ); + }); + + it('supports limit query', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 } + }, + async (collRef, db) => { + const query1 = query(collRef, orderBy('foo'), limit(1)); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 1 }); + } + ); + }); + + it('supports limitToLast query', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 }, + 3: { foo: 3 } + }, + async (collRef, db) => { + const query1 = query(collRef, orderBy('foo'), limitToLast(2)); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 2 }, { foo: 3 }); + } + ); + }); + + it('supports startAt', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 } + }, + async (collRef, db) => { + const query1 = query(collRef, orderBy('foo'), startAt(2)); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 2 }); + } + ); + }); + + it('supports startAt with limitToLast', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 }, + 3: { foo: 3 }, + 4: { foo: 4 }, + 5: { foo: 5 } + }, + async (collRef, db) => { + const query1 = query( + collRef, + orderBy('foo'), + startAt(3), + limitToLast(4) + ); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 3 }, { foo: 4 }, { foo: 5 }); + } + ); + }); + + it('supports endAt with limitToLast', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 }, + 3: { foo: 3 }, + 4: { foo: 4 }, + 5: { foo: 5 } + }, + async (collRef, db) => { + const query1 = query(collRef, orderBy('foo'), endAt(3), limitToLast(2)); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 2 }, { foo: 3 }); + } + ); + }); + + // sort on __name__ is not working + itIf(testUnsupportedFeatures)( + 'supports startAfter (with DocumentSnapshot)', + () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { id: 1, foo: 1, bar: 1, baz: 1 }, + 2: { id: 2, foo: 1, bar: 1, baz: 2 }, + 3: { id: 3, foo: 1, bar: 1, baz: 2 }, + 4: { id: 4, foo: 1, bar: 2, baz: 1 }, + 5: { id: 5, foo: 1, bar: 2, baz: 2 }, + 6: { id: 6, foo: 1, bar: 2, baz: 2 }, + 7: { id: 7, foo: 2, bar: 1, baz: 1 }, + 8: { id: 8, foo: 2, bar: 1, baz: 2 }, + 9: { id: 9, foo: 2, bar: 1, baz: 2 }, + 10: { id: 10, foo: 2, bar: 2, baz: 1 }, + 11: { id: 11, foo: 2, bar: 2, baz: 2 }, + 12: { id: 12, foo: 2, bar: 2, baz: 2 } + }, + async (collRef, db) => { + let docRef = await getDoc(doc(collRef, '2')); + let query1 = query( + collRef, + orderBy('foo'), + orderBy('bar'), + orderBy('baz'), + startAfter(docRef) + ); + let snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults( + snapshot, + { id: 3, foo: 1, bar: 1, baz: 2 }, + { id: 4, foo: 1, bar: 2, baz: 1 }, + { id: 5, foo: 1, bar: 2, baz: 2 }, + { id: 6, foo: 1, bar: 2, baz: 2 }, + { id: 7, foo: 2, bar: 1, baz: 1 }, + { id: 8, foo: 2, bar: 1, baz: 2 }, + { id: 9, foo: 2, bar: 1, baz: 2 }, + { id: 10, foo: 2, bar: 2, baz: 1 }, + { id: 11, foo: 2, bar: 2, baz: 2 }, + { id: 12, foo: 2, bar: 2, baz: 2 } + ); + + docRef = await getDoc(doc(collRef, '3')); + query1 = query( + collRef, + orderBy('foo'), + orderBy('bar'), + orderBy('baz'), + startAfter(docRef) + ); + snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults( + snapshot, + { id: 4, foo: 1, bar: 2, baz: 1 }, + { id: 5, foo: 1, bar: 2, baz: 2 }, + { id: 6, foo: 1, bar: 2, baz: 2 }, + { id: 7, foo: 2, bar: 1, baz: 1 }, + { id: 8, foo: 2, bar: 1, baz: 2 }, + { id: 9, foo: 2, bar: 1, baz: 2 }, + { id: 10, foo: 2, bar: 2, baz: 1 }, + { id: 11, foo: 2, bar: 2, baz: 2 }, + { id: 12, foo: 2, bar: 2, baz: 2 } + ); + } + ); + } + ); + + // sort on __name__ is not working + itIf(testUnsupportedFeatures)( + 'supports startAt (with DocumentSnapshot)', + () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { id: 1, foo: 1, bar: 1, baz: 1 }, + 2: { id: 2, foo: 1, bar: 1, baz: 2 }, + 3: { id: 3, foo: 1, bar: 1, baz: 2 }, + 4: { id: 4, foo: 1, bar: 2, baz: 1 }, + 5: { id: 5, foo: 1, bar: 2, baz: 2 }, + 6: { id: 6, foo: 1, bar: 2, baz: 2 }, + 7: { id: 7, foo: 2, bar: 1, baz: 1 }, + 8: { id: 8, foo: 2, bar: 1, baz: 2 }, + 9: { id: 9, foo: 2, bar: 1, baz: 2 }, + 10: { id: 10, foo: 2, bar: 2, baz: 1 }, + 11: { id: 11, foo: 2, bar: 2, baz: 2 }, + 12: { id: 12, foo: 2, bar: 2, baz: 2 } + }, + async (collRef, db) => { + let docRef = await getDoc(doc(collRef, '2')); + let query1 = query( + collRef, + orderBy('foo'), + orderBy('bar'), + orderBy('baz'), + startAt(docRef) + ); + let snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults( + snapshot, + { id: 2, foo: 1, bar: 1, baz: 2 }, + { id: 3, foo: 1, bar: 1, baz: 2 }, + { id: 4, foo: 1, bar: 2, baz: 1 }, + { id: 5, foo: 1, bar: 2, baz: 2 }, + { id: 6, foo: 1, bar: 2, baz: 2 }, + { id: 7, foo: 2, bar: 1, baz: 1 }, + { id: 8, foo: 2, bar: 1, baz: 2 }, + { id: 9, foo: 2, bar: 1, baz: 2 }, + { id: 10, foo: 2, bar: 2, baz: 1 }, + { id: 11, foo: 2, bar: 2, baz: 2 }, + { id: 12, foo: 2, bar: 2, baz: 2 } + ); + + docRef = await getDoc(doc(collRef, '3')); + query1 = query( + collRef, + orderBy('foo'), + orderBy('bar'), + orderBy('baz'), + startAt(docRef) + ); + snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults( + snapshot, + { id: 3, foo: 1, bar: 1, baz: 2 }, + { id: 4, foo: 1, bar: 2, baz: 1 }, + { id: 5, foo: 1, bar: 2, baz: 2 }, + { id: 6, foo: 1, bar: 2, baz: 2 }, + { id: 7, foo: 2, bar: 1, baz: 1 }, + { id: 8, foo: 2, bar: 1, baz: 2 }, + { id: 9, foo: 2, bar: 1, baz: 2 }, + { id: 10, foo: 2, bar: 2, baz: 1 }, + { id: 11, foo: 2, bar: 2, baz: 2 }, + { id: 12, foo: 2, bar: 2, baz: 2 } + ); + } + ); + } + ); + + it('supports startAfter', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 } + }, + async (collRef, db) => { + const query1 = query(collRef, orderBy('foo'), startAfter(1)); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 2 }); + } + ); + }); + + it('supports endAt', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 } + }, + async (collRef, db) => { + const query1 = query(collRef, orderBy('foo'), endAt(1)); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 1 }); + } + ); + }); + + it('supports endBefore', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 } + }, + async (collRef, db) => { + const query1 = query(collRef, orderBy('foo'), endBefore(2)); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 1 }); + } + ); + }); + + it('supports pagination', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 } + }, + async (collRef, db) => { + let query1 = query(collRef, orderBy('foo'), limit(1)); + const pipeline1 = db.pipeline().createFrom(query1); + let snapshot = await execute(pipeline1); + verifyResults(snapshot, { foo: 1 }); + + // Pass the document snapshot from the previous snapshot + query1 = query(query1, startAfter(snapshot.results[0].get('foo'))); + snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 2 }); + } + ); + }); + + it('supports pagination on DocumentIds', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1 }, + 2: { foo: 2 } + }, + async (collRef, db) => { + let query1 = query( + collRef, + orderBy('foo'), + orderBy(documentId(), 'asc'), + limit(1) + ); + const pipeline1 = db.pipeline().createFrom(query1); + let snapshot = await execute(pipeline1); + verifyResults(snapshot, { foo: 1 }); + + // Pass the document snapshot from the previous snapshot + query1 = query( + query1, + startAfter( + snapshot.results[0].get('foo'), + snapshot.results[0].ref?.id + ) + ); + snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 2 }); + } + ); + }); + + // needs subcollection support + itIf(testUnsupportedFeatures)('supports collection groups', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + {}, + async (collRef, db) => { + const collectionGroupId = `${collRef.id}group`; + + const fooDoc = doc( + collRef.firestore, + `${collRef.id}/foo/${collectionGroupId}/doc1` + ); + const barDoc = doc( + collRef.firestore, + `${collRef.id}/bar/baz/boo/${collectionGroupId}/doc2` + ); + await setDoc(fooDoc, { foo: 1 }); + await setDoc(barDoc, { bar: 1 }); + + const query1 = collectionGroup(collRef.firestore, collectionGroupId); + const snapshot = await execute(db.pipeline().createFrom(query1)); + + verifyResults(snapshot, { bar: 1 }, { foo: 1 }); + } + ); + }); + + // needs subcollection support + itIf(testUnsupportedFeatures)( + 'supports query over collection path with special characters', + () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + {}, + async (collRef, db) => { + const docWithSpecials = doc(collRef, 'so!@#$%^&*()_+special'); + + const collectionWithSpecials = collection( + docWithSpecials, + 'so!@#$%^&*()_+special' + ); + await addDoc(collectionWithSpecials, { foo: 1 }); + await addDoc(collectionWithSpecials, { foo: 2 }); + + const snapshot = await execute( + db + .pipeline() + .createFrom(query(collectionWithSpecials, orderBy('foo', 'asc'))) + ); + + verifyResults(snapshot, { foo: 1 }, { foo: 2 }); + } + ); + } + ); + + it('supports multiple inequality on same field', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + '01': { id: 1, foo: 1, bar: 1, baz: 1 }, + '02': { id: 2, foo: 1, bar: 1, baz: 2 }, + '03': { id: 3, foo: 1, bar: 1, baz: 2 }, + '04': { id: 4, foo: 1, bar: 2, baz: 1 }, + '05': { id: 5, foo: 1, bar: 2, baz: 2 }, + '06': { id: 6, foo: 1, bar: 2, baz: 2 }, + '07': { id: 7, foo: 2, bar: 1, baz: 1 }, + '08': { id: 8, foo: 2, bar: 1, baz: 2 }, + '09': { id: 9, foo: 2, bar: 1, baz: 2 }, + '10': { id: 10, foo: 2, bar: 2, baz: 1 }, + '11': { id: 11, foo: 2, bar: 2, baz: 2 }, + '12': { id: 12, foo: 2, bar: 2, baz: 2 } + }, + async (collRef, db) => { + const query1 = query( + collRef, + and(where('id', '>', 2), where('id', '<=', 10)) + ); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults( + snapshot, + { id: 3, foo: 1, bar: 1, baz: 2 }, + { id: 4, foo: 1, bar: 2, baz: 1 }, + { id: 5, foo: 1, bar: 2, baz: 2 }, + { id: 6, foo: 1, bar: 2, baz: 2 }, + { id: 7, foo: 2, bar: 1, baz: 1 }, + { id: 8, foo: 2, bar: 1, baz: 2 }, + { id: 9, foo: 2, bar: 1, baz: 2 }, + { id: 10, foo: 2, bar: 2, baz: 1 } + ); + } + ); + }); + + it('supports multiple inequality on different fields', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + '01': { id: 1, foo: 1, bar: 1, baz: 1 }, + '02': { id: 2, foo: 1, bar: 1, baz: 2 }, + '03': { id: 3, foo: 1, bar: 1, baz: 2 }, + '04': { id: 4, foo: 1, bar: 2, baz: 1 }, + '05': { id: 5, foo: 1, bar: 2, baz: 2 }, + '06': { id: 6, foo: 1, bar: 2, baz: 2 }, + '07': { id: 7, foo: 2, bar: 1, baz: 1 }, + '08': { id: 8, foo: 2, bar: 1, baz: 2 }, + '09': { id: 9, foo: 2, bar: 1, baz: 2 }, + '10': { id: 10, foo: 2, bar: 2, baz: 1 }, + '11': { id: 11, foo: 2, bar: 2, baz: 2 }, + '12': { id: 12, foo: 2, bar: 2, baz: 2 } + }, + async (collRef, db) => { + const query1 = query( + collRef, + and(where('id', '>=', 2), where('baz', '<', 2)) + ); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults( + snapshot, + { id: 4, foo: 1, bar: 2, baz: 1 }, + { id: 7, foo: 2, bar: 1, baz: 1 }, + { id: 10, foo: 2, bar: 2, baz: 1 } + ); + } + ); + }); + + it('supports collectionGroup query', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { 1: { foo: 1 } }, + async (collRef, db) => { + const snapshot = await execute( + db.pipeline().createFrom(collectionGroup(db, collRef.id)) + ); + verifyResults(snapshot, { foo: 1 }); + } + ); + }); + + it('supports eq nan', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1, bar: NaN }, + 2: { foo: 2, bar: 1 } + }, + async (collRef, db) => { + const query1 = query(collRef, where('bar', '==', NaN)); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 1, bar: NaN }); + } + ); + }); + + it('supports neq nan', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1, bar: NaN }, + 2: { foo: 2, bar: 1 } + }, + async (collRef, db) => { + const query1 = query(collRef, where('bar', '!=', NaN)); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 2, bar: 1 }); + } + ); + }); + + it('supports eq null', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1, bar: null }, + 2: { foo: 2, bar: 1 } + }, + async (collRef, db) => { + const query1 = query(collRef, where('bar', '==', null)); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 1, bar: null }); + } + ); + }); + + it('supports neq null', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1, bar: null }, + 2: { foo: 2, bar: 1 } + }, + async (collRef, db) => { + const query1 = query(collRef, where('bar', '!=', null)); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 2, bar: 1 }); + } + ); + }); + + it('supports neq', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1, bar: 0 }, + 2: { foo: 2, bar: 1 } + }, + async (collRef, db) => { + const query1 = query(collRef, where('bar', '!=', 0)); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 2, bar: 1 }); + } + ); + }); + + it('supports array contains', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1, bar: [0, 2, 4, 6] }, + 2: { foo: 2, bar: [1, 3, 5, 7] } + }, + async (collRef, db) => { + const query1 = query(collRef, where('bar', 'array-contains', 4)); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 1, bar: [0, 2, 4, 6] }); + } + ); + }); + + // sorting on name required + itIf(testUnsupportedFeatures)('supports array contains any', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1, bar: [0, 2, 4, 6] }, + 2: { foo: 2, bar: [1, 3, 5, 7] }, + 3: { foo: 3, bar: [10, 20, 30, 40] } + }, + async (collRef, db) => { + const query1 = query( + collRef, + where('bar', 'array-contains-any', [4, 5]) + ); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults( + snapshot, + { foo: 1, bar: [0, 2, 4, 6] }, + { foo: 2, bar: [1, 3, 5, 7] } + ); + } + ); + }); + + it('supports in', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1, bar: 2 }, + 2: { foo: 2 }, + 3: { foo: 3, bar: 10 } + }, + async (collRef, db) => { + const query1 = query(collRef, where('bar', 'in', [0, 10, 20])); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 3, bar: 10 }); + } + ); + }); + + it('supports in with 1', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1, bar: 2 }, + 2: { foo: 2 }, + 3: { foo: 3, bar: 10 } + }, + async (collRef, db) => { + const query1 = query(collRef, where('bar', 'in', [2])); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 1, bar: 2 }); + } + ); + }); + + itIf(testUnsupportedFeatures)('supports not in', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1, bar: 2 }, + 2: { foo: 2, bar: 1 }, + 3: { foo: 3, bar: 10 } + }, + async (collRef, db) => { + const query1 = query(collRef, where('bar', 'not-in', [0, 10, 20])); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 1, bar: 2 }, { foo: 2, bar: 1 }); + } + ); + }); + + it('supports not in with 1', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1, bar: 2 }, + 2: { foo: 2 }, + 3: { foo: 3, bar: 10 } + }, + async (collRef, db) => { + const query1 = query(collRef, where('bar', 'not-in', [2])); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 3, bar: 10 }); + } + ); + }); + + it('supports or operator', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { foo: 1, bar: 2 }, + 2: { foo: 2, bar: 0 }, + 3: { foo: 3, bar: 10 } + }, + async (collRef, db) => { + const query1 = query( + collRef, + or(where('bar', '==', 2), where('foo', '==', 3)), + orderBy('foo') + ); + const snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults(snapshot, { foo: 1, bar: 2 }, { foo: 3, bar: 10 }); + } + ); + }); +}); diff --git a/packages/firestore/test/integration/util/firebase_export.ts b/packages/firestore/test/integration/util/firebase_export.ts index a6739dfe72f..f58b3ce045b 100644 --- a/packages/firestore/test/integration/util/firebase_export.ts +++ b/packages/firestore/test/integration/util/firebase_export.ts @@ -51,5 +51,4 @@ export function newTestFirestore( } export * from '../../../src'; -export * from '../../../pipelines/pipelines'; export { PrivateSettings }; diff --git a/packages/firestore/test/integration/util/helpers.ts b/packages/firestore/test/integration/util/helpers.ts index 465bc8edd61..81d97867d09 100644 --- a/packages/firestore/test/integration/util/helpers.ts +++ b/packages/firestore/test/integration/util/helpers.ts @@ -557,3 +557,10 @@ export async function checkOnlineAndOfflineResultsMatch( const docsFromCache = await getDocsFromCache(query); expect(toIds(docsFromServer)).to.deep.equal(toIds(docsFromCache)); } + +export function itIf( + condition: boolean | 'only' +): Mocha.TestFunction | Mocha.PendingTestFunction { + // eslint-disable-next-line no-restricted-properties + return condition === 'only' ? it.only : condition ? it : it.skip; +} diff --git a/packages/firestore/src/all_packages.ts b/packages/firestore/test/integration/util/pipeline_export.ts similarity index 61% rename from packages/firestore/src/all_packages.ts rename to packages/firestore/test/integration/util/pipeline_export.ts index 82babeea706..d2495d772a5 100644 --- a/packages/firestore/src/all_packages.ts +++ b/packages/firestore/test/integration/util/pipeline_export.ts @@ -1,12 +1,6 @@ -/** - * Cloud Firestore - * - * @packageDocumentation - */ - /** * @license - * Copyright 2024 Google LLC + * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,5 +15,9 @@ * limitations under the License. */ -export * from './api'; -export * from './api_pipelines'; +// Imports firebase via the raw sources and re-exports it. The +// "/integration/firestore" test suite replaces this file with a +// reference to the minified sources. If you change any exports in this file, +// you need to also adjust "integration/firestore/pipeline_export.ts". + +export * from '../../../pipelines/pipelines'; diff --git a/packages/firestore/test/lite/pipeline.test.ts b/packages/firestore/test/lite/pipeline.test.ts new file mode 100644 index 00000000000..e3e5083a811 --- /dev/null +++ b/packages/firestore/test/lite/pipeline.test.ts @@ -0,0 +1,2919 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// eslint-disable-next-line import/no-extraneous-dependencies +import { expect, use } from 'chai'; +import chaiAsPromised from 'chai-as-promised'; + +import { Bytes } from '../../src/lite-api/bytes'; +import { + Firestore, + getFirestore, + terminate +} from '../../src/lite-api/database'; +import { + field, + and, + array, + arrayOffset, + constant, + add, + subtract, + multiply, + avg, + bitAnd, + substr, + constantVector, + bitLeftShift, + bitNot, + count, + mapMerge, + mapRemove, + bitOr, + ifError, + isAbsent, + isError, + or, + rand, + bitRightShift, + bitXor, + isNotNan, + map, + isNotNull, + isNull, + mod, + documentId, + eq, + neq, + lt, + countIf, + currentContext, + lte, + gt, + arrayConcat, + arrayContains, + arrayContainsAny, + eqAny, + notEqAny, + xor, + cond, + logicalMaximum, + logicalMinimum, + exists, + isNan, + reverse, + like, + regexContains, + regexMatch, + strContains, + startsWith, + endsWith, + mapGet, + countAll, + minimum, + maximum, + cosineDistance, + dotProduct, + euclideanDistance, + vectorLength, + unixMicrosToTimestamp, + timestampToUnixMicros, + unixMillisToTimestamp, + timestampToUnixMillis, + unixSecondsToTimestamp, + timestampToUnixSeconds, + timestampAdd, + timestampSub, + ascending, + descending, + FunctionExpr, + BooleanExpr, + AggregateFunction +} from '../../src/lite-api/expressions'; +import { documentId as documentIdFieldPath } from '../../src/lite-api/field_path'; +import { vector } from '../../src/lite-api/field_value_impl'; +import { GeoPoint } from '../../src/lite-api/geo_point'; +import { PipelineSnapshot } from '../../src/lite-api/pipeline-result'; +import { execute } from '../../src/lite-api/pipeline_impl'; +import { + DocumentData, + CollectionReference, + collection, + doc +} from '../../src/lite-api/reference'; +import { addDoc, setDoc } from '../../src/lite-api/reference_impl'; +import { FindNearestOptions } from '../../src/lite-api/stage'; +import { Timestamp } from '../../src/lite-api/timestamp'; +import { writeBatch } from '../../src/lite-api/write_batch'; +import { addEqualityMatcher } from '../util/equality_matcher'; +import { Deferred } from '../util/promise'; + +import { withTestCollection } from './helpers'; + +use(chaiAsPromised); + +describe('Firestore Pipelines', () => { + addEqualityMatcher(); + + let firestore: Firestore; + let randomCol: CollectionReference; + let beginDocCreation: number = 0; + let endDocCreation: number = 0; + + async function testCollectionWithDocs(docs: { + [id: string]: DocumentData; + }): Promise> { + beginDocCreation = new Date().valueOf(); + for (const id in docs) { + if (docs.hasOwnProperty(id)) { + const ref = doc(randomCol, id); + await setDoc(ref, docs[id]); + } + } + endDocCreation = new Date().valueOf(); + return randomCol; + } + + function expectResults(snapshot: PipelineSnapshot, ...docs: string[]): void; + function expectResults( + snapshot: PipelineSnapshot, + ...data: DocumentData[] + ): void; + + function expectResults( + snapshot: PipelineSnapshot, + ...data: DocumentData[] | string[] + ): void { + const docs = snapshot.results; + + expect(docs.length).to.equal(data.length); + + if (data.length > 0) { + if (typeof data[0] === 'string') { + const actualIds = docs.map(doc => doc.id); + expect(actualIds).to.deep.equal(data); + } else { + docs.forEach(r => { + expect(r.data()).to.deep.equal(data.shift()); + }); + } + } + } + + async function setupBookDocs(): Promise> { + const bookDocs: { [id: string]: DocumentData } = { + book1: { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams', + genre: 'Science Fiction', + published: 1979, + rating: 4.2, + tags: ['comedy', 'space', 'adventure'], + awards: { + hugo: true, + nebula: false, + others: { unknown: { year: 1980 } } + }, + nestedField: { 'level.1': { 'level.2': true } }, + embedding: vector([10, 1, 1, 1, 1, 1, 1, 1, 1, 1]) + }, + book2: { + title: 'Pride and Prejudice', + author: 'Jane Austen', + genre: 'Romance', + published: 1813, + rating: 4.5, + tags: ['classic', 'social commentary', 'love'], + awards: { none: true }, + embedding: vector([1, 10, 1, 1, 1, 1, 1, 1, 1, 1]) + }, + book3: { + title: 'One Hundred Years of Solitude', + author: 'Gabriel García Márquez', + genre: 'Magical Realism', + published: 1967, + rating: 4.3, + tags: ['family', 'history', 'fantasy'], + awards: { nobel: true, nebula: false }, + embedding: vector([1, 1, 10, 1, 1, 1, 1, 1, 1, 1]) + }, + book4: { + title: 'The Lord of the Rings', + author: 'J.R.R. Tolkien', + genre: 'Fantasy', + published: 1954, + rating: 4.7, + tags: ['adventure', 'magic', 'epic'], + awards: { hugo: false, nebula: false }, + remarks: null, + cost: NaN, + embedding: vector([1, 1, 1, 10, 1, 1, 1, 1, 1, 1]) + }, + book5: { + title: "The Handmaid's Tale", + author: 'Margaret Atwood', + genre: 'Dystopian', + published: 1985, + rating: 4.1, + tags: ['feminism', 'totalitarianism', 'resistance'], + awards: { 'arthur c. clarke': true, 'booker prize': false }, + embedding: vector([1, 1, 1, 1, 10, 1, 1, 1, 1, 1]) + }, + book6: { + title: 'Crime and Punishment', + author: 'Fyodor Dostoevsky', + genre: 'Psychological Thriller', + published: 1866, + rating: 4.3, + tags: ['philosophy', 'crime', 'redemption'], + awards: { none: true }, + embedding: vector([1, 1, 1, 1, 1, 10, 1, 1, 1, 1]) + }, + book7: { + title: 'To Kill a Mockingbird', + author: 'Harper Lee', + genre: 'Southern Gothic', + published: 1960, + rating: 4.2, + tags: ['racism', 'injustice', 'coming-of-age'], + awards: { pulitzer: true }, + embedding: vector([1, 1, 1, 1, 1, 1, 10, 1, 1, 1]) + }, + book8: { + title: '1984', + author: 'George Orwell', + genre: 'Dystopian', + published: 1949, + rating: 4.2, + tags: ['surveillance', 'totalitarianism', 'propaganda'], + awards: { prometheus: true }, + embedding: vector([1, 1, 1, 1, 1, 1, 1, 10, 1, 1]) + }, + book9: { + title: 'The Great Gatsby', + author: 'F. Scott Fitzgerald', + genre: 'Modernist', + published: 1925, + rating: 4.0, + tags: ['wealth', 'american dream', 'love'], + awards: { none: true }, + embedding: vector([1, 1, 1, 1, 1, 1, 1, 1, 10, 1]) + }, + book10: { + title: 'Dune', + author: 'Frank Herbert', + genre: 'Science Fiction', + published: 1965, + rating: 4.6, + tags: ['politics', 'desert', 'ecology'], + awards: { hugo: true, nebula: true }, + embedding: vector([1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) + } + }; + return testCollectionWithDocs(bookDocs); + } + + let testDeferred: Deferred | undefined; + let withTestCollectionPromise: Promise | undefined; + + beforeEach(async () => { + const setupDeferred = new Deferred(); + testDeferred = new Deferred(); + withTestCollectionPromise = withTestCollection(async collectionRef => { + randomCol = collectionRef; + firestore = collectionRef.firestore; + await setupBookDocs(); + setupDeferred.resolve(); + + return testDeferred?.promise; + }); + + await setupDeferred.promise; + }); + + afterEach(async () => { + testDeferred?.resolve(); + await withTestCollectionPromise; + }); + + describe('pipeline results', () => { + it('empty snapshot as expected', async () => { + const snapshot = await execute( + firestore.pipeline().collection(randomCol.path).limit(0) + ); + expect(snapshot.results.length).to.equal(0); + }); + + it('full snapshot as expected', async () => { + const ppl = firestore.pipeline().collection(randomCol.path); + const snapshot = await execute(ppl); + expect(snapshot.results.length).to.equal(10); + expect(snapshot.pipeline).to.equal(ppl); + expectResults( + snapshot, + 'book1', + 'book10', + 'book2', + 'book3', + 'book4', + 'book5', + 'book6', + 'book7', + 'book8', + 'book9' + ); + }); + + it('returns execution time', async () => { + const start = new Date().valueOf(); + const pipeline = firestore.pipeline().collection(randomCol.path); + + const snapshot = await execute(pipeline); + const end = new Date().valueOf(); + + expect(snapshot.executionTime.toDate().valueOf()).to.approximately( + (start + end) / 2, + end - start + ); + }); + + it('returns execution time for an empty query', async () => { + const start = new Date().valueOf(); + const pipeline = firestore.pipeline().collection(randomCol.path).limit(0); + + const snapshot = await execute(pipeline); + const end = new Date().valueOf(); + + expect(snapshot.results.length).to.equal(0); + + expect(snapshot.executionTime.toDate().valueOf()).to.approximately( + (start + end) / 2, + end - start + ); + }); + + it('returns create and update time for each document', async () => { + const pipeline = firestore.pipeline().collection(randomCol.path); + + let snapshot = await execute(pipeline); + expect(snapshot.results.length).to.equal(10); + snapshot.results.forEach(doc => { + expect(doc.createTime).to.not.be.null; + expect(doc.updateTime).to.not.be.null; + + expect(doc.createTime!.toDate().valueOf()).to.approximately( + (beginDocCreation + endDocCreation) / 2, + endDocCreation - beginDocCreation + ); + expect(doc.updateTime!.toDate().valueOf()).to.approximately( + (beginDocCreation + endDocCreation) / 2, + endDocCreation - beginDocCreation + ); + expect(doc.createTime?.valueOf()).to.equal(doc.updateTime?.valueOf()); + }); + + const wb = writeBatch(firestore); + snapshot.results.forEach(doc => { + wb.update(doc.ref!, { newField: 'value' }); + }); + await wb.commit(); + + snapshot = await execute(pipeline); + expect(snapshot.results.length).to.equal(10); + snapshot.results.forEach(doc => { + expect(doc.createTime).to.not.be.null; + expect(doc.updateTime).to.not.be.null; + expect(doc.createTime!.toDate().valueOf()).to.be.lessThan( + doc.updateTime!.toDate().valueOf() + ); + }); + }); + + it('returns execution time for an aggregate query', async () => { + const start = new Date().valueOf(); + const pipeline = firestore + .pipeline() + .collection(randomCol.path) + .aggregate(avg('rating').as('avgRating')); + + const snapshot = await execute(pipeline); + const end = new Date().valueOf(); + + expect(snapshot.results.length).to.equal(1); + + expect(snapshot.executionTime.toDate().valueOf()).to.approximately( + (start + end) / 2, + end - start + ); + }); + + it('returns undefined create and update time for each result in an aggregate query', async () => { + const pipeline = firestore + .pipeline() + .collection(randomCol.path) + .aggregate({ + accumulators: [avg('rating').as('avgRating')], + groups: ['genre'] + }); + + const snapshot = await execute(pipeline); + + expect(snapshot.results.length).to.equal(8); + + snapshot.results.forEach(doc => { + expect(doc.updateTime).to.be.undefined; + expect(doc.createTime).to.be.undefined; + }); + }); + }); + + describe('pipeline sources', () => { + it('supports CollectionReference as source', async () => { + const snapshot = await execute( + firestore.pipeline().collection(randomCol) + ); + expect(snapshot.results.length).to.equal(10); + }); + + it('supports list of documents as source', async () => { + const collName = randomCol.id; + + const snapshot = await execute( + firestore + .pipeline() + .documents([ + `${collName}/book1`, + doc(randomCol, 'book2'), + doc(randomCol, 'book3').path + ]) + ); + expect(snapshot.results.length).to.equal(3); + }); + + it('reject CollectionReference for another DB', async () => { + const db2 = getFirestore(firestore.app, 'notDefault'); + + expect(() => { + firestore.pipeline().collection(collection(db2, 'foo')); + }).to.throw(/Invalid CollectionReference/); + + await terminate(db2); + }); + + it('reject DocumentReference for another DB', async () => { + const db2 = getFirestore(firestore.app, 'notDefault'); + + expect(() => { + firestore.pipeline().documents([doc(db2, 'foo/bar')]); + }).to.throw(/Invalid DocumentReference/); + + await terminate(db2); + }); + + it('supports collection group as source', async () => { + const randomSubCollectionId = Math.random().toString(16).slice(2); + const doc1 = await addDoc( + collection(randomCol, 'book1', randomSubCollectionId), + { order: 1 } + ); + const doc2 = await addDoc( + collection(randomCol, 'book2', randomSubCollectionId), + { order: 2 } + ); + const snapshot = await execute( + firestore + .pipeline() + .collectionGroup(randomSubCollectionId) + .sort(ascending('order')) + ); + expectResults(snapshot, doc1.id, doc2.id); + }); + + it('supports database as source', async () => { + const randomId = Math.random().toString(16).slice(2); + const doc1 = await addDoc(collection(randomCol, 'book1', 'sub'), { + order: 1, + randomId + }); + const doc2 = await addDoc(collection(randomCol, 'book2', 'sub'), { + order: 2, + randomId + }); + const snapshot = await execute( + firestore + .pipeline() + .database() + .where(eq('randomId', randomId)) + .sort(ascending('order')) + ); + expectResults(snapshot, doc1.id, doc2.id); + }); + }); + + describe('supported data types', () => { + it('accepts and returns all data types', async () => { + const refDate = new Date(); + const refTimestamp = Timestamp.now(); + const constants = [ + constant(1).as('number'), + constant('a string').as('string'), + constant(true).as('boolean'), + constant(null).as('null'), + constant(new GeoPoint(0.1, 0.2)).as('geoPoint'), + constant(refTimestamp).as('timestamp'), + constant(refDate).as('date'), + constant( + Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])) + ).as('bytes'), + constant(doc(firestore, 'foo', 'bar')).as('documentReference'), + constantVector(vector([1, 2, 3])).as('vectorValue'), + constantVector([1, 2, 3]).as('vectorValue2'), + map({ + 'number': 1, + 'string': 'a string', + 'boolean': true, + 'null': null, + 'geoPoint': new GeoPoint(0.1, 0.2), + 'timestamp': refTimestamp, + 'date': refDate, + 'uint8Array': Bytes.fromUint8Array( + new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0]) + ), + 'documentReference': doc(firestore, 'foo', 'bar'), + 'vectorValue': vector([1, 2, 3]), + 'map': { + 'number': 2, + 'string': 'b string' + }, + 'array': [1, 'c string'] + }).as('map'), + array([ + 1, + 'a string', + true, + null, + new GeoPoint(0.1, 0.2), + refTimestamp, + refDate, + Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])), + doc(firestore, 'foo', 'bar'), + vector([1, 2, 3]), + { + 'number': 2, + 'string': 'b string' + } + ]).as('array') + ]; + + const snapshots = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(constants[0], ...constants.slice(1)) + ); + + expectResults(snapshots, { + 'number': 1, + 'string': 'a string', + 'boolean': true, + 'null': null, + 'geoPoint': new GeoPoint(0.1, 0.2), + 'timestamp': refTimestamp, + 'date': Timestamp.fromDate(refDate), + 'bytes': Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])), + 'documentReference': doc(firestore, 'foo', 'bar'), + 'vectorValue': vector([1, 2, 3]), + 'vectorValue2': vector([1, 2, 3]), + 'map': { + 'number': 1, + 'string': 'a string', + 'boolean': true, + 'null': null, + 'geoPoint': new GeoPoint(0.1, 0.2), + 'timestamp': refTimestamp, + 'date': Timestamp.fromDate(refDate), + 'uint8Array': Bytes.fromUint8Array( + new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0]) + ), + 'documentReference': doc(firestore, 'foo', 'bar'), + 'vectorValue': vector([1, 2, 3]), + 'map': { + 'number': 2, + 'string': 'b string' + }, + 'array': [1, 'c string'] + }, + 'array': [ + 1, + 'a string', + true, + null, + new GeoPoint(0.1, 0.2), + refTimestamp, + Timestamp.fromDate(refDate), + Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])), + doc(firestore, 'foo', 'bar'), + vector([1, 2, 3]), + { + 'number': 2, + 'string': 'b string' + } + ] + }); + }); + + it('throws on undefined in a map', async () => { + expect(() => { + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + map({ + 'number': 1, + 'undefined': array([undefined]) + }).as('foo') + ); + }).to.throw( + 'Function constant() called with invalid data. Unsupported field value: undefined' + ); + }); + + it('throws on undefined in an array', async () => { + expect(() => { + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(array([1, undefined]).as('foo')); + }).to.throw( + 'Function constant() called with invalid data. Unsupported field value: undefined' + ); + }); + + it('converts arrays and plain objects to functionValues if the customer intent is unspecified', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select( + 'title', + 'author', + 'genre', + 'rating', + 'published', + 'tags', + 'awards' + ) + .addFields( + array([ + 1, + 2, + field('genre'), + multiply('rating', 10), + [field('title')], + { + published: field('published') + } + ]).as('metadataArray'), + map({ + genre: field('genre'), + rating: multiply('rating', 10), + nestedArray: [field('title')], + nestedMap: { + published: field('published') + } + }).as('metadata') + ) + .where( + and( + eq('metadataArray', [ + 1, + 2, + field('genre'), + multiply('rating', 10), + [field('title')], + { + published: field('published') + } + ]), + eq('metadata', { + genre: field('genre'), + rating: multiply('rating', 10), + nestedArray: [field('title')], + nestedMap: { + published: field('published') + } + }) + ) + ) + ); + + expect(snapshot.results.length).to.equal(1); + + expectResults(snapshot, { + title: 'The Lord of the Rings', + author: 'J.R.R. Tolkien', + genre: 'Fantasy', + published: 1954, + rating: 4.7, + tags: ['adventure', 'magic', 'epic'], + awards: { hugo: false, nebula: false }, + metadataArray: [ + 1, + 2, + 'Fantasy', + 47, + ['The Lord of the Rings'], + { + published: 1954 + } + ], + metadata: { + genre: 'Fantasy', + rating: 47, + nestedArray: ['The Lord of the Rings'], + nestedMap: { + published: 1954 + } + } + }); + }); + }); + + describe('stages', () => { + describe('aggregate stage', () => { + it('supports aggregate', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .aggregate(countAll().as('count')) + ); + expectResults(snapshot, { count: 10 }); + + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('genre', 'Science Fiction')) + .aggregate( + countAll().as('count'), + avg('rating').as('avgRating'), + field('rating').maximum().as('maxRating') + ) + ); + expectResults(snapshot, { count: 2, avgRating: 4.4, maxRating: 4.6 }); + }); + + it('rejects groups without accumulators', async () => { + await expect( + execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(lt('published', 1900)) + .aggregate({ + accumulators: [], + groups: ['genre'] + }) + ) + ).to.be.rejected; + }); + + it('returns group and accumulate results', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(lt(field('published'), 1984)) + .aggregate({ + accumulators: [avg('rating').as('avgRating')], + groups: ['genre'] + }) + .where(gt('avgRating', 4.3)) + .sort(field('avgRating').descending()) + ); + expectResults( + snapshot, + { avgRating: 4.7, genre: 'Fantasy' }, + { avgRating: 4.5, genre: 'Romance' }, + { avgRating: 4.4, genre: 'Science Fiction' } + ); + }); + + it('returns min, max, count, and countAll accumulations', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .aggregate( + count('cost').as('booksWithCost'), + countAll().as('count'), + maximum('rating').as('maxRating'), + minimum('published').as('minPublished') + ) + ); + expectResults(snapshot, { + booksWithCost: 1, + count: 10, + maxRating: 4.7, + minPublished: 1813 + }); + }); + + it('returns countif accumulation', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .aggregate(countIf(field('rating').gt(4.3)).as('count')) + ); + const expectedResults = { + count: 3 + }; + expectResults(snapshot, expectedResults); + + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .aggregate(field('rating').gt(4.3).countIf().as('count')) + ); + expectResults(snapshot, expectedResults); + }); + }); + + describe('distinct stage', () => { + it('returns distinct values as expected', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .distinct('genre', 'author') + .sort(field('genre').ascending(), field('author').ascending()) + ); + expectResults( + snapshot, + { genre: 'Dystopian', author: 'George Orwell' }, + { genre: 'Dystopian', author: 'Margaret Atwood' }, + { genre: 'Fantasy', author: 'J.R.R. Tolkien' }, + { genre: 'Magical Realism', author: 'Gabriel García Márquez' }, + { genre: 'Modernist', author: 'F. Scott Fitzgerald' }, + { genre: 'Psychological Thriller', author: 'Fyodor Dostoevsky' }, + { genre: 'Romance', author: 'Jane Austen' }, + { genre: 'Science Fiction', author: 'Douglas Adams' }, + { genre: 'Science Fiction', author: 'Frank Herbert' }, + { genre: 'Southern Gothic', author: 'Harper Lee' } + ); + }); + }); + + describe('select stage', () => { + it('can select fields', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'author') + .sort(field('author').ascending()) + ); + expectResults( + snapshot, + { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams' + }, + { title: 'The Great Gatsby', author: 'F. Scott Fitzgerald' }, + { title: 'Dune', author: 'Frank Herbert' }, + { title: 'Crime and Punishment', author: 'Fyodor Dostoevsky' }, + { + title: 'One Hundred Years of Solitude', + author: 'Gabriel García Márquez' + }, + { title: '1984', author: 'George Orwell' }, + { title: 'To Kill a Mockingbird', author: 'Harper Lee' }, + { title: 'The Lord of the Rings', author: 'J.R.R. Tolkien' }, + { title: 'Pride and Prejudice', author: 'Jane Austen' }, + { title: "The Handmaid's Tale", author: 'Margaret Atwood' } + ); + }); + }); + + describe('addField stage', () => { + it('can add fields', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'author') + .addFields(constant('bar').as('foo')) + .sort(field('author').ascending()) + ); + expectResults( + snapshot, + { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams', + foo: 'bar' + }, + { + title: 'The Great Gatsby', + author: 'F. Scott Fitzgerald', + foo: 'bar' + }, + { title: 'Dune', author: 'Frank Herbert', foo: 'bar' }, + { + title: 'Crime and Punishment', + author: 'Fyodor Dostoevsky', + foo: 'bar' + }, + { + title: 'One Hundred Years of Solitude', + author: 'Gabriel García Márquez', + foo: 'bar' + }, + { title: '1984', author: 'George Orwell', foo: 'bar' }, + { + title: 'To Kill a Mockingbird', + author: 'Harper Lee', + foo: 'bar' + }, + { + title: 'The Lord of the Rings', + author: 'J.R.R. Tolkien', + foo: 'bar' + }, + { title: 'Pride and Prejudice', author: 'Jane Austen', foo: 'bar' }, + { + title: "The Handmaid's Tale", + author: 'Margaret Atwood', + foo: 'bar' + } + ); + }); + }); + + describe('removeFields stage', () => { + it('can remove fields', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'author') + .sort(field('author').ascending()) + .removeFields(field('author')) + .sort(field('author').ascending()) + ); + expectResults( + snapshot, + { + title: "The Hitchhiker's Guide to the Galaxy" + }, + { + title: 'The Great Gatsby' + }, + { title: 'Dune' }, + { + title: 'Crime and Punishment' + }, + { + title: 'One Hundred Years of Solitude' + }, + { title: '1984' }, + { + title: 'To Kill a Mockingbird' + }, + { + title: 'The Lord of the Rings' + }, + { title: 'Pride and Prejudice' }, + { + title: "The Handmaid's Tale" + } + ); + }); + }); + + describe('where stage', () => { + it('where with and (2 conditions)', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where( + and( + gt('rating', 4.5), + eqAny('genre', ['Science Fiction', 'Romance', 'Fantasy']) + ) + ) + ); + expectResults(snapshot, 'book10', 'book4'); + }); + it('where with and (3 conditions)', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where( + and( + gt('rating', 4.5), + eqAny('genre', ['Science Fiction', 'Romance', 'Fantasy']), + lt('published', 1965) + ) + ) + ); + expectResults(snapshot, 'book4'); + }); + it('where with or', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where( + or( + eq('genre', 'Romance'), + eq('genre', 'Dystopian'), + eq('genre', 'Fantasy') + ) + ) + .select('title') + ); + expectResults( + snapshot, + { title: 'Pride and Prejudice' }, + { title: 'The Lord of the Rings' }, + { title: "The Handmaid's Tale" }, + { title: '1984' } + ); + }); + + it('where with xor', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where( + xor( + eq('genre', 'Romance'), + eq('genre', 'Dystopian'), + eq('genre', 'Fantasy'), + eq('published', 1949) + ) + ) + .select('title') + ); + expectResults( + snapshot, + { title: 'Pride and Prejudice' }, + { title: 'The Lord of the Rings' }, + { title: "The Handmaid's Tale" } + ); + }); + }); + + describe('sort, offset, and limit stages', () => { + it('supports sort, offset, and limits', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('author').ascending()) + .offset(5) + .limit(3) + .select('title', 'author') + ); + expectResults( + snapshot, + { title: '1984', author: 'George Orwell' }, + { title: 'To Kill a Mockingbird', author: 'Harper Lee' }, + { title: 'The Lord of the Rings', author: 'J.R.R. Tolkien' } + ); + }); + }); + + describe('generic stage', () => { + it('can select fields', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .genericStage('select', [ + { + title: field('title'), + metadata: { + 'author': field('author') + } + } + ]) + .sort(field('author').ascending()) + .limit(1) + ); + expectResults(snapshot, { + title: "The Hitchhiker's Guide to the Galaxy", + metadata: { + author: 'Douglas Adams' + } + }); + }); + + it('can add fields', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('author').ascending()) + .limit(1) + .select('title', 'author') + .genericStage('add_fields', [ + { + display: field('title').strConcat(' - ', field('author')) + } + ]) + ); + expectResults(snapshot, { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams', + display: "The Hitchhiker's Guide to the Galaxy - Douglas Adams" + }); + }); + + it('can filter with where', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'author') + .genericStage('where', [field('author').eq('Douglas Adams')]) + ); + expectResults(snapshot, { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams' + }); + }); + + it('can limit, offset, and sort', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'author') + .genericStage('sort', [ + { + direction: 'ascending', + expression: field('author') + } + ]) + .genericStage('offset', [3]) + .genericStage('limit', [1]) + ); + expectResults(snapshot, { + author: 'Fyodor Dostoevsky', + title: 'Crime and Punishment' + }); + }); + + it('can perform aggregate query', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'author', 'rating') + .genericStage('aggregate', [ + { averageRating: field('rating').avg() }, + {} + ]) + ); + expectResults(snapshot, { + averageRating: 4.3100000000000005 + }); + }); + + it('can perform distinct query', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'author', 'rating') + .genericStage('distinct', [{ rating: field('rating') }]) + .sort(field('rating').descending()) + ); + expectResults( + snapshot, + { + rating: 4.7 + }, + { + rating: 4.6 + }, + { + rating: 4.5 + }, + { + rating: 4.3 + }, + { + rating: 4.2 + }, + { + rating: 4.1 + }, + { + rating: 4.0 + } + ); + }); + }); + + describe('replace stage', () => { + it('run pipleine with replace', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('title', "The Hitchhiker's Guide to the Galaxy")) + .replaceWith('awards') + ); + expectResults(snapshot, { + hugo: true, + nebula: false, + others: { unknown: { year: 1980 } } + }); + }); + }); + + describe('sample stage', () => { + it('run pipeline with sample limit of 3', async () => { + const snapshot = await execute( + firestore.pipeline().collection(randomCol.path).sample(3) + ); + expect(snapshot.results.length).to.equal(3); + }); + + it('run pipeline with sample limit of {documents: 3}', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sample({ documents: 3 }) + ); + expect(snapshot.results.length).to.equal(3); + }); + + it('run pipeline with sample limit of {percentage: 0.6}', async () => { + let avgSize = 0; + const numIterations = 20; + for (let i = 0; i < numIterations; i++) { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sample({ percentage: 0.6 }) + ); + + avgSize += snapshot.results.length; + } + avgSize /= numIterations; + expect(avgSize).to.be.closeTo(6, 1); + }); + }); + + describe('union stage', () => { + it('run pipeline with union', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .union(firestore.pipeline().collection(randomCol.path)) + .sort(field(documentIdFieldPath()).ascending()) + ); + expectResults( + snapshot, + 'book1', + 'book1', + 'book10', + 'book10', + 'book2', + 'book2', + 'book3', + 'book3', + 'book4', + 'book4', + 'book5', + 'book5', + 'book6', + 'book6', + 'book7', + 'book7', + 'book8', + 'book8', + 'book9', + 'book9' + ); + }); + }); + + describe('unnest stage', () => { + it('run pipeline with unnest', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('title', "The Hitchhiker's Guide to the Galaxy")) + .unnest(field('tags').as('tag')) + .select( + 'title', + 'author', + 'genre', + 'published', + 'rating', + 'tags', + 'tag', + 'awards', + 'nestedField' + ) + ); + expectResults( + snapshot, + { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams', + genre: 'Science Fiction', + published: 1979, + rating: 4.2, + tags: ['comedy', 'space', 'adventure'], + tag: 'comedy', + awards: { + hugo: true, + nebula: false, + others: { unknown: { year: 1980 } } + }, + nestedField: { 'level.1': { 'level.2': true } } + }, + { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams', + genre: 'Science Fiction', + published: 1979, + rating: 4.2, + tags: ['comedy', 'space', 'adventure'], + tag: 'space', + awards: { + hugo: true, + nebula: false, + others: { unknown: { year: 1980 } } + }, + nestedField: { 'level.1': { 'level.2': true } } + }, + { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams', + genre: 'Science Fiction', + published: 1979, + rating: 4.2, + tags: ['comedy', 'space', 'adventure'], + tag: 'adventure', + awards: { + hugo: true, + nebula: false, + others: { unknown: { year: 1980 } } + }, + nestedField: { 'level.1': { 'level.2': true } } + } + ); + }); + it('unnest an expr', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('title', "The Hitchhiker's Guide to the Galaxy")) + .unnest(array([1, 2, 3]).as('copy')) + .select( + 'title', + 'author', + 'genre', + 'published', + 'rating', + 'tags', + 'copy', + 'awards', + 'nestedField' + ) + ); + expectResults( + snapshot, + { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams', + genre: 'Science Fiction', + published: 1979, + rating: 4.2, + tags: ['comedy', 'space', 'adventure'], + copy: 1, + awards: { + hugo: true, + nebula: false, + others: { unknown: { year: 1980 } } + }, + nestedField: { 'level.1': { 'level.2': true } } + }, + { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams', + genre: 'Science Fiction', + published: 1979, + rating: 4.2, + tags: ['comedy', 'space', 'adventure'], + copy: 2, + awards: { + hugo: true, + nebula: false, + others: { unknown: { year: 1980 } } + }, + nestedField: { 'level.1': { 'level.2': true } } + }, + { + title: "The Hitchhiker's Guide to the Galaxy", + author: 'Douglas Adams', + genre: 'Science Fiction', + published: 1979, + rating: 4.2, + tags: ['comedy', 'space', 'adventure'], + copy: 3, + awards: { + hugo: true, + nebula: false, + others: { unknown: { year: 1980 } } + }, + nestedField: { 'level.1': { 'level.2': true } } + } + ); + }); + }); + + describe('findNearest stage', () => { + it('run pipeline with findNearest', async () => { + const measures: Array = [ + 'euclidean', + 'dot_product', + 'cosine' + ]; + for (const measure of measures) { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol) + .findNearest({ + field: 'embedding', + vectorValue: vector([10, 1, 3, 1, 2, 1, 1, 1, 1, 1]), + limit: 3, + distanceMeasure: measure + }) + .select('title') + ); + expectResults( + snapshot, + { + title: "The Hitchhiker's Guide to the Galaxy" + }, + { + title: 'One Hundred Years of Solitude' + }, + { + title: "The Handmaid's Tale" + } + ); + } + }); + + it('optionally returns the computed distance', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol) + .findNearest({ + field: 'embedding', + vectorValue: vector([10, 1, 2, 1, 1, 1, 1, 1, 1, 1]), + limit: 2, + distanceMeasure: 'euclidean', + distanceField: 'computedDistance' + }) + .select('title', 'computedDistance') + ); + expectResults( + snapshot, + { + title: "The Hitchhiker's Guide to the Galaxy", + computedDistance: 1 + }, + { + title: 'One Hundred Years of Solitude', + computedDistance: 12.041594578792296 + } + ); + }); + }); + }); + + describe('function expressions', () => { + it('logical max works', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select( + 'title', + logicalMaximum(constant(1960), field('published'), 1961).as( + 'published-safe' + ) + ) + .sort(field('title').ascending()) + .limit(3) + ); + expectResults( + snapshot, + { title: '1984', 'published-safe': 1961 }, + { title: 'Crime and Punishment', 'published-safe': 1961 }, + { title: 'Dune', 'published-safe': 1965 } + ); + }); + + it('logical min works', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select( + 'title', + logicalMinimum(constant(1960), field('published'), 1961).as( + 'published-safe' + ) + ) + .sort(field('title').ascending()) + .limit(3) + ); + expectResults( + snapshot, + { title: '1984', 'published-safe': 1949 }, + { title: 'Crime and Punishment', 'published-safe': 1866 }, + { title: 'Dune', 'published-safe': 1960 } + ); + }); + + it('cond works', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select( + 'title', + cond( + lt(field('published'), 1960), + constant(1960), + field('published') + ).as('published-safe') + ) + .sort(field('title').ascending()) + .limit(3) + ); + expectResults( + snapshot, + { title: '1984', 'published-safe': 1960 }, + { title: 'Crime and Punishment', 'published-safe': 1960 }, + { title: 'Dune', 'published-safe': 1965 } + ); + }); + + it('eqAny works', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eqAny('published', [1979, 1999, 1967])) + .select('title') + ); + expectResults( + snapshot, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'One Hundred Years of Solitude' } + ); + }); + + it('notEqAny works', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where( + notEqAny( + 'published', + [1965, 1925, 1949, 1960, 1866, 1985, 1954, 1967, 1979] + ) + ) + .select('title') + ); + expectResults(snapshot, { title: 'Pride and Prejudice' }); + }); + + it('arrayContains works', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(arrayContains('tags', 'comedy')) + .select('title') + ); + expectResults(snapshot, { + title: "The Hitchhiker's Guide to the Galaxy" + }); + }); + + it('arrayContainsAny works', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(arrayContainsAny('tags', ['comedy', 'classic'])) + .select('title') + ); + expectResults( + snapshot, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'Pride and Prejudice' } + ); + }); + + it('arrayContainsAll works', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(field('tags').arrayContainsAll(['adventure', 'magic'])) + .select('title') + ); + expectResults(snapshot, { title: 'The Lord of the Rings' }); + }); + + it('arrayLength works', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select(field('tags').arrayLength().as('tagsCount')) + .where(eq('tagsCount', 3)) + ); + expect(snapshot.results.length).to.equal(10); + }); + + it('testStrConcat', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select( + field('author').strConcat(' - ', field('title')).as('bookInfo') + ) + .limit(1) + ); + expectResults(snapshot, { + bookInfo: "Douglas Adams - The Hitchhiker's Guide to the Galaxy" + }); + }); + + it('testStartsWith', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(startsWith('title', 'The')) + .select('title') + .sort(field('title').ascending()) + ); + expectResults( + snapshot, + { title: 'The Great Gatsby' }, + { title: "The Handmaid's Tale" }, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'The Lord of the Rings' } + ); + }); + + it('testEndsWith', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(endsWith('title', 'y')) + .select('title') + .sort(field('title').descending()) + ); + expectResults( + snapshot, + { title: "The Hitchhiker's Guide to the Galaxy" }, + { title: 'The Great Gatsby' } + ); + }); + + it('testStrContains', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(strContains('title', "'s")) + .select('title') + .sort(field('title').ascending()) + ); + expectResults( + snapshot, + { title: "The Handmaid's Tale" }, + { title: "The Hitchhiker's Guide to the Galaxy" } + ); + }); + + it('testLength', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select(field('title').charLength().as('titleLength'), field('title')) + .where(gt('titleLength', 20)) + .sort(field('title').ascending()) + ); + + expectResults( + snapshot, + + { + titleLength: 29, + title: 'One Hundred Years of Solitude' + }, + { + titleLength: 36, + title: "The Hitchhiker's Guide to the Galaxy" + }, + { + titleLength: 21, + title: 'The Lord of the Rings' + }, + { + titleLength: 21, + title: 'To Kill a Mockingbird' + } + ); + }); + + it('testLike', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(like('title', '%Guide%')) + .select('title') + ); + expectResults(snapshot, { + title: "The Hitchhiker's Guide to the Galaxy" + }); + }); + + it('testRegexContains', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(regexContains('title', '(?i)(the|of)')) + ); + expect(snapshot.results.length).to.equal(5); + }); + + it('testRegexMatches', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(regexMatch('title', '.*(?i)(the|of).*')) + ); + expect(snapshot.results.length).to.equal(5); + }); + + it('testArithmeticOperations', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select( + add(field('rating'), 1).as('ratingPlusOne'), + subtract(field('published'), 1900).as('yearsSince1900'), + field('rating').multiply(10).as('ratingTimesTen'), + field('rating').divide(2).as('ratingDividedByTwo'), + multiply('rating', 10, 2).as('ratingTimes20'), + add('rating', 1, 2).as('ratingPlus3'), + mod('rating', 2).as('ratingMod2') + ) + .limit(1) + ); + expectResults(snapshot, { + ratingPlusOne: 5.2, + yearsSince1900: 79, + ratingTimesTen: 42, + ratingDividedByTwo: 2.1, + ratingTimes20: 84, + ratingPlus3: 7.2, + ratingMod2: 0.2 + }); + }); + + it('testComparisonOperators', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where( + and( + gt('rating', 4.2), + lte(field('rating'), 4.5), + neq('genre', 'Science Fiction') + ) + ) + .select('rating', 'title') + .sort(field('title').ascending()) + ); + expectResults( + snapshot, + { rating: 4.3, title: 'Crime and Punishment' }, + { + rating: 4.3, + title: 'One Hundred Years of Solitude' + }, + { rating: 4.5, title: 'Pride and Prejudice' } + ); + }); + + it('testLogicalOperators', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where( + or( + and(gt('rating', 4.5), eq('genre', 'Science Fiction')), + lt('published', 1900) + ) + ) + .select('title') + .sort(field('title').ascending()) + ); + expectResults( + snapshot, + { title: 'Crime and Punishment' }, + { title: 'Dune' }, + { title: 'Pride and Prejudice' } + ); + }); + + it('testChecks', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select( + isNull('rating').as('ratingIsNull'), + isNan('rating').as('ratingIsNaN'), + isError(arrayOffset('title', 0)).as('isError'), + ifError(arrayOffset('title', 0), constant('was error')).as( + 'ifError' + ), + isAbsent('foo').as('isAbsent'), + isNotNull('title').as('titleIsNotNull'), + isNotNan('cost').as('costIsNotNan'), + exists('fooBarBaz').as('fooBarBazExists'), + field('title').as('titleExists') + ) + ); + expectResults(snapshot, { + ratingIsNull: false, + ratingIsNaN: false, + isError: true, + ifError: 'was error', + isAbsent: true, + titleIsNotNull: true, + costIsNotNan: false, + fooBarBazExists: false, + titleExists: true + }); + + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select( + field('rating').isNull().as('ratingIsNull'), + field('rating').isNan().as('ratingIsNaN'), + arrayOffset('title', 0).isError().as('isError'), + arrayOffset('title', 0) + .ifError(constant('was error')) + .as('ifError'), + field('foo').isAbsent().as('isAbsent'), + field('title').isNotNull().as('titleIsNotNull'), + field('cost').isNotNan().as('costIsNotNan') + ) + ); + expectResults(snapshot, { + ratingIsNull: false, + ratingIsNaN: false, + isError: true, + ifError: 'was error', + isAbsent: true, + titleIsNotNull: true, + costIsNotNan: false + }); + }); + + it('testMapGet', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('published').descending()) + .select( + field('awards').mapGet('hugo').as('hugoAward'), + field('awards').mapGet('others').as('others'), + field('title') + ) + .where(eq('hugoAward', true)) + ); + expectResults( + snapshot, + { + hugoAward: true, + title: "The Hitchhiker's Guide to the Galaxy", + others: { unknown: { year: 1980 } } + }, + { hugoAward: true, title: 'Dune', others: null } + ); + }); + + it('testDistanceFunctions', async () => { + const sourceVector = [0.1, 0.1]; + const targetVector = [0.5, 0.8]; + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select( + cosineDistance(constantVector(sourceVector), targetVector).as( + 'cosineDistance' + ), + dotProduct(constantVector(sourceVector), targetVector).as( + 'dotProductDistance' + ), + euclideanDistance(constantVector(sourceVector), targetVector).as( + 'euclideanDistance' + ) + ) + .limit(1) + ); + + expectResults(snapshot, { + cosineDistance: 0.02560880430538015, + dotProductDistance: 0.13, + euclideanDistance: 0.806225774829855 + }); + + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select( + constantVector(sourceVector) + .cosineDistance(targetVector) + .as('cosineDistance'), + constantVector(sourceVector) + .dotProduct(targetVector) + .as('dotProductDistance'), + constantVector(sourceVector) + .euclideanDistance(targetVector) + .as('euclideanDistance') + ) + .limit(1) + ); + + expectResults(snapshot, { + cosineDistance: 0.02560880430538015, + dotProductDistance: 0.13, + euclideanDistance: 0.806225774829855 + }); + }); + + it('testVectorLength', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(vectorLength(constantVector([1, 2, 3])).as('vectorLength')) + ); + expectResults(snapshot, { + vectorLength: 3 + }); + }); + + it('testNestedFields', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('awards.hugo', true)) + .select('title', 'awards.hugo') + ); + expectResults( + snapshot, + { + title: "The Hitchhiker's Guide to the Galaxy", + 'awards.hugo': true + }, + { title: 'Dune', 'awards.hugo': true } + ); + }); + + it('test mapGet with field name including . notation', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('awards.hugo', true)) + .select( + 'title', + field('nestedField.level.1'), + mapGet('nestedField', 'level.1').mapGet('level.2').as('nested') + ) + ); + expectResults( + snapshot, + { + title: "The Hitchhiker's Guide to the Galaxy", + 'nestedField.level.`1`': null, + nested: true + }, + { title: 'Dune', 'nestedField.level.`1`': null, nested: null } + ); + }); + + describe('genericFunction', () => { + it('add selectable', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(descending('rating')) + .limit(1) + .select( + new FunctionExpr('add', [field('rating'), constant(1)]).as( + 'rating' + ) + ) + ); + expectResults(snapshot, { + rating: 5.7 + }); + }); + + it('and (variadic) selectable', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where( + new BooleanExpr('and', [ + field('rating').gt(0), + field('title').charLength().lt(5), + field('tags').arrayContains('propaganda') + ]) + ) + .select('title') + ); + expectResults(snapshot, { + title: '1984' + }); + }); + + it('array contains any', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where( + new BooleanExpr('array_contains_any', [ + field('tags'), + array(['politics']) + ]) + ) + .select('title') + ); + expectResults(snapshot, { + title: 'Dune' + }); + }); + + it('countif aggregate', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .aggregate( + new AggregateFunction('count_if', [field('rating').gte(4.5)]).as( + 'countOfBest' + ) + ) + ); + expectResults(snapshot, { + countOfBest: 3 + }); + }); + + it('sort by char_len', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort( + new FunctionExpr('char_length', [field('title')]).ascending(), + descending('__name__') + ) + .limit(3) + .select('title') + ); + expectResults( + snapshot, + { + title: '1984' + }, + { + title: 'Dune' + }, + { + title: 'The Great Gatsby' + } + ); + }); + }); + + describe('not implemented in backend', () => { + it('supports Bit_and', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(bitAnd(constant(5), 12).as('result')) + ); + expectResults(snapshot, { + result: 4 + }); + }); + + it('supports Bit_and', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(constant(5).bitAnd(12).as('result')) + ); + expectResults(snapshot, { + result: 4 + }); + }); + + it('supports Bit_or', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(bitOr(constant(5), 12).as('result')) + ); + expectResults(snapshot, { + result: 13 + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(constant(5).bitOr(12).as('result')) + ); + expectResults(snapshot, { + result: 13 + }); + }); + + it('supports Bit_xor', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(bitXor(constant(5), 12).as('result')) + ); + expectResults(snapshot, { + result: 9 + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(constant(5).bitXor(12).as('result')) + ); + expectResults(snapshot, { + result: 9 + }); + }); + + it('supports Bit_not', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + bitNot(constant(Bytes.fromUint8Array(Uint8Array.of(0xfd)))).as( + 'result' + ) + ) + ); + expectResults(snapshot, { + result: Bytes.fromUint8Array(Uint8Array.of(0x02)) + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + constant(Bytes.fromUint8Array(Uint8Array.of(0xfd))) + .bitNot() + .as('result') + ) + ); + expectResults(snapshot, { + result: Bytes.fromUint8Array(Uint8Array.of(0x02)) + }); + }); + + it('supports Bit_left_shift', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + bitLeftShift( + constant(Bytes.fromUint8Array(Uint8Array.of(0x02))), + 2 + ).as('result') + ) + ); + expectResults(snapshot, { + result: Bytes.fromUint8Array(Uint8Array.of(0x04)) + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + constant(Bytes.fromUint8Array(Uint8Array.of(0x02))) + .bitLeftShift(2) + .as('result') + ) + ); + expectResults(snapshot, { + result: Bytes.fromUint8Array(Uint8Array.of(0x04)) + }); + }); + + it('supports Bit_right_shift', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + bitRightShift( + constant(Bytes.fromUint8Array(Uint8Array.of(0x02))), + 2 + ).as('result') + ) + ); + expectResults(snapshot, { + result: Bytes.fromUint8Array(Uint8Array.of(0x01)) + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + constant(Bytes.fromUint8Array(Uint8Array.of(0x02))) + .bitRightShift(2) + .as('result') + ) + ); + expectResults(snapshot, { + result: Bytes.fromUint8Array(Uint8Array.of(0x01)) + }); + }); + + it('supports Document_id', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(documentId(field('__path__')).as('docId')) + ); + expectResults(snapshot, { + docId: 'book4' + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(field('__path__').documentId().as('docId')) + ); + expectResults(snapshot, { + docId: 'book4' + }); + }); + + it('supports Substr', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(substr('title', 9, 2).as('of')) + ); + expectResults(snapshot, { + of: 'of' + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(field('title').substr(9, 2).as('of')) + ); + expectResults(snapshot, { + of: 'of' + }); + }); + + it('supports Substr without length', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(substr('title', 9).as('of')) + ); + expectResults(snapshot, { + of: 'of the Rings' + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(field('title').substr(9).as('of')) + ); + expectResults(snapshot, { + of: 'of the Rings' + }); + }); + + it('arrayConcat works', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select( + arrayConcat('tags', ['newTag1', 'newTag2'], field('tags'), [ + null + ]).as('modifiedTags') + ) + .limit(1) + ); + expectResults(snapshot, { + modifiedTags: [ + 'comedy', + 'space', + 'adventure', + 'newTag1', + 'newTag2', + 'comedy', + 'space', + 'adventure', + null + ] + }); + }); + + it('testToLowercase', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select(field('title').toLower().as('lowercaseTitle')) + .limit(1) + ); + expectResults(snapshot, { + lowercaseTitle: "the hitchhiker's guide to the galaxy" + }); + }); + + it('testToUppercase', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select(field('author').toUpper().as('uppercaseAuthor')) + .limit(1) + ); + expectResults(snapshot, { uppercaseAuthor: 'DOUGLAS ADAMS' }); + }); + + it('testTrim', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .addFields( + constant(" The Hitchhiker's Guide to the Galaxy ").as( + 'spacedTitle' + ) + ) + .select( + field('spacedTitle').trim().as('trimmedTitle'), + field('spacedTitle') + ) + .limit(1) + ); + expectResults(snapshot, { + spacedTitle: " The Hitchhiker's Guide to the Galaxy ", + trimmedTitle: "The Hitchhiker's Guide to the Galaxy" + }); + }); + + it('test reverse', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('title', '1984')) + .limit(1) + .select(reverse('title').as('reverseTitle')) + ); + expectResults(snapshot, { title: '4891' }); + }); + }); + + it('supports Rand', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(10) + .select(rand().as('result')) + ); + expect(snapshot.results.length).to.equal(10); + snapshot.results.forEach(d => { + expect(d.get('result')).to.be.lt(1); + expect(d.get('result')).to.be.gte(0); + }); + }); + + it('supports array', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(array([1, 2, 3, 4]).as('metadata')) + ); + expect(snapshot.results.length).to.equal(1); + expectResults(snapshot, { + metadata: [1, 2, 3, 4] + }); + }); + + it('evaluates expression in array', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select( + array([1, 2, field('genre'), multiply('rating', 10)]).as('metadata') + ) + ); + expect(snapshot.results.length).to.equal(1); + expectResults(snapshot, { + metadata: [1, 2, 'Fantasy', 47] + }); + }); + + it('supports arrayOffset', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(3) + .select(arrayOffset('tags', 0).as('firstTag')) + ); + const expectedResults = [ + { + firstTag: 'adventure' + }, + { + firstTag: 'politics' + }, + { + firstTag: 'classic' + } + ]; + expectResults(snapshot, ...expectedResults); + + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(3) + .select(field('tags').arrayOffset(0).as('firstTag')) + ); + expectResults(snapshot, ...expectedResults); + }); + + // TODO: current_context tests with are failing because of b/395937453 + it('supports currentContext', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(currentContext().as('currentContext')) + ); + expectResults(snapshot, { + currentContext: 'TODO' + }); + }); + + it('supports map', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select( + map({ + foo: 'bar' + }).as('metadata') + ) + ); + + expect(snapshot.results.length).to.equal(1); + expectResults(snapshot, { + metadata: { + foo: 'bar' + } + }); + }); + + it('evaluates expression in map', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select( + map({ + genre: field('genre'), + rating: field('rating').multiply(10) + }).as('metadata') + ) + ); + + expect(snapshot.results.length).to.equal(1); + expectResults(snapshot, { + metadata: { + genre: 'Fantasy', + rating: 47 + } + }); + }); + + it('supports mapRemove', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(mapRemove('awards', 'hugo').as('awards')) + ); + expectResults(snapshot, { + awards: { nebula: false } + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(field('awards').mapRemove('hugo').as('awards')) + ); + expectResults(snapshot, { + awards: { nebula: false } + }); + }); + + it('supports mapMerge', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(mapMerge('awards', { fakeAward: true }).as('awards')) + ); + expectResults(snapshot, { + awards: { nebula: false, hugo: false, fakeAward: true } + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(field('awards').mapMerge({ fakeAward: true }).as('awards')) + ); + expectResults(snapshot, { + awards: { nebula: false, hugo: false, fakeAward: true } + }); + }); + + it('supports timestamp conversions', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + unixSecondsToTimestamp(constant(1741380235)).as( + 'unixSecondsToTimestamp' + ), + unixMillisToTimestamp(constant(1741380235123)).as( + 'unixMillisToTimestamp' + ), + unixMicrosToTimestamp(constant(1741380235123456)).as( + 'unixMicrosToTimestamp' + ), + timestampToUnixSeconds( + constant(new Timestamp(1741380235, 123456789)) + ).as('timestampToUnixSeconds'), + timestampToUnixMicros( + constant(new Timestamp(1741380235, 123456789)) + ).as('timestampToUnixMicros'), + timestampToUnixMillis( + constant(new Timestamp(1741380235, 123456789)) + ).as('timestampToUnixMillis') + ) + ); + expectResults(snapshot, { + unixMicrosToTimestamp: new Timestamp(1741380235, 123456000), + unixMillisToTimestamp: new Timestamp(1741380235, 123000000), + unixSecondsToTimestamp: new Timestamp(1741380235, 0), + timestampToUnixSeconds: 1741380235, + timestampToUnixMicros: 1741380235123456, + timestampToUnixMillis: 1741380235123 + }); + }); + + it('supports timestamp math', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(constant(new Timestamp(1741380235, 0)).as('timestamp')) + .select( + timestampAdd('timestamp', 'day', 10).as('plus10days'), + timestampAdd('timestamp', 'hour', 10).as('plus10hours'), + timestampAdd('timestamp', 'minute', 10).as('plus10minutes'), + timestampAdd('timestamp', 'second', 10).as('plus10seconds'), + timestampAdd('timestamp', 'microsecond', 10).as('plus10micros'), + timestampAdd('timestamp', 'millisecond', 10).as('plus10millis'), + timestampSub('timestamp', 'day', 10).as('minus10days'), + timestampSub('timestamp', 'hour', 10).as('minus10hours'), + timestampSub('timestamp', 'minute', 10).as('minus10minutes'), + timestampSub('timestamp', 'second', 10).as('minus10seconds'), + timestampSub('timestamp', 'microsecond', 10).as('minus10micros'), + timestampSub('timestamp', 'millisecond', 10).as('minus10millis') + ) + ); + expectResults(snapshot, { + plus10days: new Timestamp(1742244235, 0), + plus10hours: new Timestamp(1741416235, 0), + plus10minutes: new Timestamp(1741380835, 0), + plus10seconds: new Timestamp(1741380245, 0), + plus10micros: new Timestamp(1741380235, 10000), + plus10millis: new Timestamp(1741380235, 10000000), + minus10days: new Timestamp(1740516235, 0), + minus10hours: new Timestamp(1741344235, 0), + minus10minutes: new Timestamp(1741379635, 0), + minus10seconds: new Timestamp(1741380225, 0), + minus10micros: new Timestamp(1741380234, 999990000), + minus10millis: new Timestamp(1741380234, 990000000) + }); + }); + }); + + describe('pagination', () => { + /** + * Adds several books to the test collection. These + * additional books support pagination test scenarios + * that would otherwise not be possible with the original + * set of books. + * @param collectionReference + */ + async function addBooks( + collectionReference: CollectionReference + ): Promise { + await setDoc(doc(collectionReference, 'book11'), { + title: 'Jonathan Strange & Mr Norrell', + author: 'Susanna Clarke', + genre: 'Fantasy', + published: 2004, + rating: 4.6, + tags: ['historical fantasy', 'magic', 'alternate history', 'england'], + awards: { hugo: false, nebula: false } + }); + await setDoc(doc(collectionReference, 'book12'), { + title: 'The Master and Margarita', + author: 'Mikhail Bulgakov', + genre: 'Satire', + published: 1967, // Though written much earlier + rating: 4.6, + tags: [ + 'russian literature', + 'supernatural', + 'philosophy', + 'dark comedy' + ], + awards: {} + }); + await setDoc(doc(collectionReference, 'book13'), { + title: 'A Long Way to a Small, Angry Planet', + author: 'Becky Chambers', + genre: 'Science Fiction', + published: 2014, + rating: 4.6, + tags: ['space opera', 'found family', 'character-driven', 'optimistic'], + awards: { hugo: false, nebula: false, kitschies: true } + }); + } + + it('supports pagination with filters', async () => { + await addBooks(randomCol); + const pageSize = 2; + const pipeline = firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'rating', '__name__') + .sort(field('rating').descending(), field('__name__').ascending()); + + let snapshot = await execute(pipeline.limit(pageSize)); + expectResults( + snapshot, + { title: 'The Lord of the Rings', rating: 4.7 }, + { title: 'Jonathan Strange & Mr Norrell', rating: 4.6 } + ); + + const lastDoc = snapshot.results[snapshot.results.length - 1]; + + snapshot = await execute( + pipeline + .where( + or( + and( + field('rating').eq(lastDoc.get('rating')), + field('__path__').gt(lastDoc.ref?.id) + ), + field('rating').lt(lastDoc.get('rating')) + ) + ) + .limit(pageSize) + ); + expectResults( + snapshot, + { title: 'Pride and Prejudice', rating: 4.5 }, + { title: 'Crime and Punishment', rating: 4.3 } + ); + }); + + it('supports pagination with offsets', async () => { + await addBooks(randomCol); + + const secondFilterField = '__name__'; + + const pipeline = firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'rating', secondFilterField) + .sort( + field('rating').descending(), + field(secondFilterField).ascending() + ); + + const pageSize = 2; + let currPage = 0; + + let snapshot = await execute( + pipeline.offset(currPage++ * pageSize).limit(pageSize) + ); + + expectResults( + snapshot, + { + title: 'The Lord of the Rings', + rating: 4.7 + }, + { title: 'Dune', rating: 4.6 } + ); + + snapshot = await execute( + pipeline.offset(currPage++ * pageSize).limit(pageSize) + ); + expectResults( + snapshot, + { + title: 'Jonathan Strange & Mr Norrell', + rating: 4.6 + }, + { title: 'The Master and Margarita', rating: 4.6 } + ); + + snapshot = await execute( + pipeline.offset(currPage++ * pageSize).limit(pageSize) + ); + expectResults( + snapshot, + { + title: 'A Long Way to a Small, Angry Planet', + rating: 4.6 + }, + { + title: 'Pride and Prejudice', + rating: 4.5 + } + ); + }); + }); +}); From b1808981a74c5858edeb25ea948868649784d1df Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 26 Mar 2025 09:33:03 -0600 Subject: [PATCH 51/59] Port improved whereConditionsFromCursor from Android --- packages/firestore/src/core/pipeline-util.ts | 55 +++++++++----------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/packages/firestore/src/core/pipeline-util.ts b/packages/firestore/src/core/pipeline-util.ts index 4409daffc2e..10f0cb47da6 100644 --- a/packages/firestore/src/core/pipeline-util.ts +++ b/packages/firestore/src/core/pipeline-util.ts @@ -18,16 +18,12 @@ import { Firestore } from '../lite-api/database'; import { Constant, - Field, BooleanExpr, and, or, Ordering, lt, gt, - lte, - gte, - eq, field } from '../lite-api/expressions'; import { Pipeline } from '../lite-api/pipeline'; @@ -254,36 +250,35 @@ function whereConditionsFromCursor( orderings: Ordering[], position: 'before' | 'after' ): BooleanExpr { - const cursors = bound.position.map(value => Constant._fromProto(value)); + // The filterFunc is either greater than or less than const filterFunc = position === 'before' ? lt : gt; - const filterInclusiveFunc = position === 'before' ? lte : gte; - - const orConditions: BooleanExpr[] = []; - for (let i = 1; i <= orderings.length; i++) { - const cursorSubset = cursors.slice(0, i); + const cursors = bound.position.map(value => Constant._fromProto(value)); + const size = cursors.length; - const conditions: BooleanExpr[] = cursorSubset.map((cursor, index) => { - if (index < cursorSubset.length - 1) { - return eq(orderings[index].expr as Field, cursor); - } else if (bound.inclusive && i === orderings.length - 1) { - return filterInclusiveFunc(orderings[index].expr as Field, cursor); - } else { - return filterFunc(orderings[index].expr as Field, cursor); - } - }); + let field = orderings[size-1].expr; + let value = cursors[size-1]; - if (conditions.length === 1) { - orConditions.push(conditions[0]); - } else { - orConditions.push( - and(conditions[0], conditions[1], ...conditions.slice(2)) - ); - } + // Add condition for last bound + let condition: BooleanExpr = filterFunc(field, value); + if (bound.inclusive) { + // When the cursor bound is inclusive, then the last bound + // can be equal to the value, otherwise it's not equal + condition = or(condition, field.eq(value)); } - if (orConditions.length === 1) { - return orConditions[0]; - } else { - return or(orConditions[0], orConditions[1], ...orConditions.slice(2)); + // Iterate backwards over the remaining bounds, adding + // a condition for each one + for (let i = size - 2; i >= 0; i--) { + field = orderings[i].expr; + value = cursors[i]; + + // For each field in the orderings, the condition is either + // a) lt|gt the cursor value, + // b) or equal the cursor value and lt|gt the cursor values for other fields + condition = or( + filterFunc(field, value), + and(field.eq(value), condition)); } + + return condition; } From 6cc2ee6a8069ddb859ff7b1a42d36ccb3cb3a5ce Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Wed, 26 Mar 2025 10:03:49 -0600 Subject: [PATCH 52/59] Port improved whereConditionsFromCursor from Android (#8867) --- packages/firestore/src/core/pipeline-util.ts | 55 +++++++++----------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/packages/firestore/src/core/pipeline-util.ts b/packages/firestore/src/core/pipeline-util.ts index 4409daffc2e..10f0cb47da6 100644 --- a/packages/firestore/src/core/pipeline-util.ts +++ b/packages/firestore/src/core/pipeline-util.ts @@ -18,16 +18,12 @@ import { Firestore } from '../lite-api/database'; import { Constant, - Field, BooleanExpr, and, or, Ordering, lt, gt, - lte, - gte, - eq, field } from '../lite-api/expressions'; import { Pipeline } from '../lite-api/pipeline'; @@ -254,36 +250,35 @@ function whereConditionsFromCursor( orderings: Ordering[], position: 'before' | 'after' ): BooleanExpr { - const cursors = bound.position.map(value => Constant._fromProto(value)); + // The filterFunc is either greater than or less than const filterFunc = position === 'before' ? lt : gt; - const filterInclusiveFunc = position === 'before' ? lte : gte; - - const orConditions: BooleanExpr[] = []; - for (let i = 1; i <= orderings.length; i++) { - const cursorSubset = cursors.slice(0, i); + const cursors = bound.position.map(value => Constant._fromProto(value)); + const size = cursors.length; - const conditions: BooleanExpr[] = cursorSubset.map((cursor, index) => { - if (index < cursorSubset.length - 1) { - return eq(orderings[index].expr as Field, cursor); - } else if (bound.inclusive && i === orderings.length - 1) { - return filterInclusiveFunc(orderings[index].expr as Field, cursor); - } else { - return filterFunc(orderings[index].expr as Field, cursor); - } - }); + let field = orderings[size-1].expr; + let value = cursors[size-1]; - if (conditions.length === 1) { - orConditions.push(conditions[0]); - } else { - orConditions.push( - and(conditions[0], conditions[1], ...conditions.slice(2)) - ); - } + // Add condition for last bound + let condition: BooleanExpr = filterFunc(field, value); + if (bound.inclusive) { + // When the cursor bound is inclusive, then the last bound + // can be equal to the value, otherwise it's not equal + condition = or(condition, field.eq(value)); } - if (orConditions.length === 1) { - return orConditions[0]; - } else { - return or(orConditions[0], orConditions[1], ...orConditions.slice(2)); + // Iterate backwards over the remaining bounds, adding + // a condition for each one + for (let i = size - 2; i >= 0; i--) { + field = orderings[i].expr; + value = cursors[i]; + + // For each field in the orderings, the condition is either + // a) lt|gt the cursor value, + // b) or equal the cursor value and lt|gt the cursor values for other fields + condition = or( + filterFunc(field, value), + and(field.eq(value), condition)); } + + return condition; } From 609d0828ad5372253e976f0149a08f6ddfed9e7a Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Tue, 8 Apr 2025 10:03:53 -0600 Subject: [PATCH 53/59] Pipeline and test cleanup --- packages/firestore/src/core/pipeline-util.ts | 8 +- .../firestore/src/lite-api/expressions.ts | 2 +- .../test/integration/api/pipeline.test.ts | 10 +- .../integration/api/query_to_pipeline.test.ts | 8 +- packages/firestore/test/lite/pipeline.test.ts | 1277 +++++++++-------- 5 files changed, 724 insertions(+), 581 deletions(-) diff --git a/packages/firestore/src/core/pipeline-util.ts b/packages/firestore/src/core/pipeline-util.ts index 10f0cb47da6..ec25e258834 100644 --- a/packages/firestore/src/core/pipeline-util.ts +++ b/packages/firestore/src/core/pipeline-util.ts @@ -255,8 +255,8 @@ function whereConditionsFromCursor( const cursors = bound.position.map(value => Constant._fromProto(value)); const size = cursors.length; - let field = orderings[size-1].expr; - let value = cursors[size-1]; + let field = orderings[size - 1].expr; + let value = cursors[size - 1]; // Add condition for last bound let condition: BooleanExpr = filterFunc(field, value); @@ -275,9 +275,7 @@ function whereConditionsFromCursor( // For each field in the orderings, the condition is either // a) lt|gt the cursor value, // b) or equal the cursor value and lt|gt the cursor values for other fields - condition = or( - filterFunc(field, value), - and(field.eq(value), condition)); + condition = or(filterFunc(field, value), and(field.eq(value), condition)); } return condition; diff --git a/packages/firestore/src/lite-api/expressions.ts b/packages/firestore/src/lite-api/expressions.ts index 6eaebf2c4f0..43e44b7577d 100644 --- a/packages/firestore/src/lite-api/expressions.ts +++ b/packages/firestore/src/lite-api/expressions.ts @@ -2247,7 +2247,7 @@ export function field(nameOrPath: string | FieldPath): Field { if (DOCUMENT_KEY_NAME === nameOrPath) { return new Field(documentIdFieldPath()._internalPath); } - return new Field(fieldPathFromArgument('of', nameOrPath)); + return new Field(fieldPathFromArgument('field', nameOrPath)); } else { return new Field(nameOrPath._internalPath); } diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index 7fc26ce58cd..f8a5cc28bce 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -53,7 +53,8 @@ import { collection, documentId as documentIdFieldPath, writeBatch, - addDoc + addDoc, + increment } from '../util/firebase_export'; import { apiDescribe, withTestCollection, itIf } from '../util/helpers'; import { @@ -144,8 +145,9 @@ use(chaiAsPromised); setLogLevel('debug'); const testUnsupportedFeatures = false; +const timestampDeltaMS = 1000; -apiDescribe.only('Pipelines', persistence => { +apiDescribe('Pipelines', persistence => { addEqualityMatcher(); let firestore: Firestore; @@ -153,8 +155,6 @@ apiDescribe.only('Pipelines', persistence => { let beginDocCreation: number = 0; let endDocCreation: number = 0; - const timestampDeltaMS = 1000; - async function testCollectionWithDocs(docs: { [id: string]: DocumentData; }): Promise> { @@ -2388,7 +2388,7 @@ apiDescribe.only('Pipelines', persistence => { .collection(randomCol.path) .sort(field('rating').descending()) .limit(1) - .select( + .addFields( map({ foo: 'bar' }).as('metadata') diff --git a/packages/firestore/test/integration/api/query_to_pipeline.test.ts b/packages/firestore/test/integration/api/query_to_pipeline.test.ts index 8eac50a5afa..a0ad0e93bc9 100644 --- a/packages/firestore/test/integration/api/query_to_pipeline.test.ts +++ b/packages/firestore/test/integration/api/query_to_pipeline.test.ts @@ -59,7 +59,7 @@ const testUnsupportedFeatures = false; // This is the Query integration tests from the lite API (no cache support) // with some additional test cases added for more complete coverage. -apiDescribe.only('Query to Pipeline', persistence => { +apiDescribe('Query to Pipeline', persistence => { addEqualityMatcher(); function verifyResults( @@ -632,7 +632,8 @@ apiDescribe.only('Query to Pipeline', persistence => { PERSISTENCE_MODE_UNSPECIFIED, { 1: { foo: 1, bar: NaN }, - 2: { foo: 2, bar: 1 } + 2: { foo: 2, bar: 1 }, + 3: { foo: 3, bar: 'bar' } }, async (collRef, db) => { const query1 = query(collRef, where('bar', '==', NaN)); @@ -647,7 +648,8 @@ apiDescribe.only('Query to Pipeline', persistence => { PERSISTENCE_MODE_UNSPECIFIED, { 1: { foo: 1, bar: NaN }, - 2: { foo: 2, bar: 1 } + 2: { foo: 2, bar: 1 }, + 3: { foo: 3, bar: 'bar' } }, async (collRef, db) => { const query1 = query(collRef, where('bar', '!=', NaN)); diff --git a/packages/firestore/test/lite/pipeline.test.ts b/packages/firestore/test/lite/pipeline.test.ts index e3e5083a811..cedc6b4dcf9 100644 --- a/packages/firestore/test/lite/pipeline.test.ts +++ b/packages/firestore/test/lite/pipeline.test.ts @@ -102,12 +102,28 @@ import { descending, FunctionExpr, BooleanExpr, - AggregateFunction + AggregateFunction, + sum, + strConcat, + arrayContainsAll, + arrayLength, + charLength, + divide, + replaceFirst, + replaceAll, + byteLength, + not, + toLower, + toUpper, + trim } from '../../src/lite-api/expressions'; import { documentId as documentIdFieldPath } from '../../src/lite-api/field_path'; import { vector } from '../../src/lite-api/field_value_impl'; import { GeoPoint } from '../../src/lite-api/geo_point'; -import { PipelineSnapshot } from '../../src/lite-api/pipeline-result'; +import { + pipelineResultEqual, + PipelineSnapshot +} from '../../src/lite-api/pipeline-result'; import { execute } from '../../src/lite-api/pipeline_impl'; import { DocumentData, @@ -119,6 +135,7 @@ import { addDoc, setDoc } from '../../src/lite-api/reference_impl'; import { FindNearestOptions } from '../../src/lite-api/stage'; import { Timestamp } from '../../src/lite-api/timestamp'; import { writeBatch } from '../../src/lite-api/write_batch'; +import { itIf } from '../integration/util/helpers'; import { addEqualityMatcher } from '../util/equality_matcher'; import { Deferred } from '../util/promise'; @@ -126,6 +143,9 @@ import { withTestCollection } from './helpers'; use(chaiAsPromised); +const testUnsupportedFeatures = false; +const timestampDeltaMS = 1000; + describe('Firestore Pipelines', () => { addEqualityMatcher(); @@ -318,8 +338,12 @@ describe('Firestore Pipelines', () => { expect(snapshot.results.length).to.equal(0); }); - it('full snapshot as expected', async () => { - const ppl = firestore.pipeline().collection(randomCol.path); + // Skipping because __name__ is not currently working in DBE + itIf(testUnsupportedFeatures)('full snapshot as expected', async () => { + const ppl = firestore + .pipeline() + .collection(randomCol.path) + .sort(ascending('__name__')); const snapshot = await execute(ppl); expect(snapshot.results.length).to.equal(10); expect(snapshot.pipeline).to.equal(ppl); @@ -338,6 +362,20 @@ describe('Firestore Pipelines', () => { ); }); + it('result equals works', async () => { + const ppl = firestore + .pipeline() + .collection(randomCol.path) + .sort(ascending('title')) + .limit(1); + const snapshot1 = await execute(ppl); + const snapshot2 = await execute(ppl); + expect(snapshot1.results.length).to.equal(1); + expect(snapshot2.results.length).to.equal(1); + expect(pipelineResultEqual(snapshot1.results[0], snapshot2.results[0])).to + .be.true; + }); + it('returns execution time', async () => { const start = new Date().valueOf(); const pipeline = firestore.pipeline().collection(randomCol.path); @@ -347,11 +385,11 @@ describe('Firestore Pipelines', () => { expect(snapshot.executionTime.toDate().valueOf()).to.approximately( (start + end) / 2, - end - start + timestampDeltaMS ); }); - it('returns execution time for an empty query', async () => { + it.only('returns execution time for an empty query', async () => { const start = new Date().valueOf(); const pipeline = firestore.pipeline().collection(randomCol.path).limit(0); @@ -362,7 +400,7 @@ describe('Firestore Pipelines', () => { expect(snapshot.executionTime.toDate().valueOf()).to.approximately( (start + end) / 2, - end - start + timestampDeltaMS ); }); @@ -377,11 +415,11 @@ describe('Firestore Pipelines', () => { expect(doc.createTime!.toDate().valueOf()).to.approximately( (beginDocCreation + endDocCreation) / 2, - endDocCreation - beginDocCreation + timestampDeltaMS ); expect(doc.updateTime!.toDate().valueOf()).to.approximately( (beginDocCreation + endDocCreation) / 2, - endDocCreation - beginDocCreation + timestampDeltaMS ); expect(doc.createTime?.valueOf()).to.equal(doc.updateTime?.valueOf()); }); @@ -417,7 +455,7 @@ describe('Firestore Pipelines', () => { expect(snapshot.executionTime.toDate().valueOf()).to.approximately( (start + end) / 2, - end - start + timestampDeltaMS ); }); @@ -484,26 +522,31 @@ describe('Firestore Pipelines', () => { await terminate(db2); }); - it('supports collection group as source', async () => { - const randomSubCollectionId = Math.random().toString(16).slice(2); - const doc1 = await addDoc( - collection(randomCol, 'book1', randomSubCollectionId), - { order: 1 } - ); - const doc2 = await addDoc( - collection(randomCol, 'book2', randomSubCollectionId), - { order: 2 } - ); - const snapshot = await execute( - firestore - .pipeline() - .collectionGroup(randomSubCollectionId) - .sort(ascending('order')) - ); - expectResults(snapshot, doc1.id, doc2.id); - }); + // Subcollections not currently supported in DBE + itIf(testUnsupportedFeatures)( + 'supports collection group as source', + async () => { + const randomSubCollectionId = Math.random().toString(16).slice(2); + const doc1 = await addDoc( + collection(randomCol, 'book1', randomSubCollectionId), + { order: 1 } + ); + const doc2 = await addDoc( + collection(randomCol, 'book2', randomSubCollectionId), + { order: 2 } + ); + const snapshot = await execute( + firestore + .pipeline() + .collectionGroup(randomSubCollectionId) + .sort(ascending('order')) + ); + expectResults(snapshot, doc1.id, doc2.id); + } + ); - it('supports database as source', async () => { + // subcollections not currently supported in dbe + itIf(testUnsupportedFeatures)('supports database as source', async () => { const randomId = Math.random().toString(16).slice(2); const doc1 = await addDoc(collection(randomCol, 'book1', 'sub'), { order: 1, @@ -646,11 +689,11 @@ describe('Firestore Pipelines', () => { .select( map({ 'number': 1, - 'undefined': array([undefined]) + undefined }).as('foo') ); }).to.throw( - 'Function constant() called with invalid data. Unsupported field value: undefined' + 'Function map() called with invalid data. Unsupported field value: undefined' ); }); @@ -662,7 +705,7 @@ describe('Firestore Pipelines', () => { .limit(1) .select(array([1, undefined]).as('foo')); }).to.throw( - 'Function constant() called with invalid data. Unsupported field value: undefined' + 'Function array() called with invalid data. Unsupported field value: undefined' ); }); @@ -777,10 +820,16 @@ describe('Firestore Pipelines', () => { .aggregate( countAll().as('count'), avg('rating').as('avgRating'), - field('rating').maximum().as('maxRating') + maximum('rating').as('maxRating'), + sum('rating').as('sumRating') ) ); - expectResults(snapshot, { count: 2, avgRating: 4.4, maxRating: 4.6 }); + expectResults(snapshot, { + count: 2, + avgRating: 4.4, + maxRating: 4.6, + sumRating: 8.8 + }); }); it('rejects groups without accumulators', async () => { @@ -1054,14 +1103,15 @@ describe('Firestore Pipelines', () => { eq('genre', 'Fantasy') ) ) + .sort(ascending('title')) .select('title') ); expectResults( snapshot, + { title: '1984' }, { title: 'Pride and Prejudice' }, - { title: 'The Lord of the Rings' }, { title: "The Handmaid's Tale" }, - { title: '1984' } + { title: 'The Lord of the Rings' } ); }); @@ -1127,10 +1177,10 @@ describe('Firestore Pipelines', () => { .limit(1) ); expectResults(snapshot, { - title: "The Hitchhiker's Guide to the Galaxy", metadata: { - author: 'Douglas Adams' - } + author: 'Frank Herbert' + }, + title: 'Dune' }); }); @@ -1144,7 +1194,7 @@ describe('Firestore Pipelines', () => { .select('title', 'author') .genericStage('add_fields', [ { - display: field('title').strConcat(' - ', field('author')) + display: strConcat('title', ' - ', field('author')) } ]) ); @@ -1242,8 +1292,8 @@ describe('Firestore Pipelines', () => { }); }); - describe('replace stage', () => { - it('run pipleine with replace', async () => { + describe('replaceWith stage', () => { + it('run pipeline with replaceWith field name', async () => { const snapshot = await execute( firestore .pipeline() @@ -1257,6 +1307,27 @@ describe('Firestore Pipelines', () => { others: { unknown: { year: 1980 } } }); }); + + it('run pipeline with replaceWith Expr result', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('title', "The Hitchhiker's Guide to the Galaxy")) + .replaceWith( + map({ + foo: 'bar', + baz: { + title: field('title') + } + }) + ) + ); + expectResults(snapshot, { + foo: 'bar', + baz: { title: "The Hitchhiker's Guide to the Galaxy" } + }); + }); }); describe('sample stage', () => { @@ -1296,7 +1367,8 @@ describe('Firestore Pipelines', () => { }); describe('union stage', () => { - it('run pipeline with union', async () => { + // __name__ not currently supported by dbe + itIf(testUnsupportedFeatures)('run pipeline with union', async () => { const snapshot = await execute( firestore .pipeline() @@ -1608,6 +1680,7 @@ describe('Firestore Pipelines', () => { .pipeline() .collection(randomCol.path) .where(eqAny('published', [1979, 1999, 1967])) + .sort(descending('title')) .select('title') ); expectResults( @@ -1652,6 +1725,7 @@ describe('Firestore Pipelines', () => { .pipeline() .collection(randomCol.path) .where(arrayContainsAny('tags', ['comedy', 'classic'])) + .sort(descending('title')) .select('title') ); expectResults( @@ -1666,7 +1740,7 @@ describe('Firestore Pipelines', () => { firestore .pipeline() .collection(randomCol.path) - .where(field('tags').arrayContainsAll(['adventure', 'magic'])) + .where(arrayContainsAll('tags', ['adventure', 'magic'])) .select('title') ); expectResults(snapshot, { title: 'The Lord of the Rings' }); @@ -1677,7 +1751,7 @@ describe('Firestore Pipelines', () => { firestore .pipeline() .collection(randomCol.path) - .select(field('tags').arrayLength().as('tagsCount')) + .select(arrayLength('tags').as('tagsCount')) .where(eq('tagsCount', 3)) ); expect(snapshot.results.length).to.equal(10); @@ -1688,6 +1762,7 @@ describe('Firestore Pipelines', () => { firestore .pipeline() .collection(randomCol.path) + .sort(ascending('author')) .select( field('author').strConcat(' - ', field('title')).as('bookInfo') ) @@ -1753,7 +1828,7 @@ describe('Firestore Pipelines', () => { firestore .pipeline() .collection(randomCol.path) - .select(field('title').charLength().as('titleLength'), field('title')) + .select(charLength('title').as('titleLength'), field('title')) .where(gt('titleLength', 20)) .sort(field('title').ascending()) ); @@ -1818,11 +1893,12 @@ describe('Firestore Pipelines', () => { firestore .pipeline() .collection(randomCol.path) + .where(eq('title', 'To Kill a Mockingbird')) .select( add(field('rating'), 1).as('ratingPlusOne'), subtract(field('published'), 1900).as('yearsSince1900'), field('rating').multiply(10).as('ratingTimesTen'), - field('rating').divide(2).as('ratingDividedByTwo'), + divide('rating', 2).as('ratingDividedByTwo'), multiply('rating', 10, 2).as('ratingTimes20'), add('rating', 1, 2).as('ratingPlus3'), mod('rating', 2).as('ratingMod2') @@ -1831,12 +1907,12 @@ describe('Firestore Pipelines', () => { ); expectResults(snapshot, { ratingPlusOne: 5.2, - yearsSince1900: 79, + yearsSince1900: 60, ratingTimesTen: 42, ratingDividedByTwo: 2.1, ratingTimes20: 84, ratingPlus3: 7.2, - ratingMod2: 0.2 + ratingMod2: 0.20000000000000018 }); }); @@ -1888,7 +1964,7 @@ describe('Firestore Pipelines', () => { ); }); - it('testChecks', async () => { + it.only('testChecks', async () => { let snapshot = await execute( firestore .pipeline() @@ -1906,7 +1982,7 @@ describe('Firestore Pipelines', () => { isNotNull('title').as('titleIsNotNull'), isNotNan('cost').as('costIsNotNan'), exists('fooBarBaz').as('fooBarBazExists'), - field('title').as('titleExists') + field('title').exists().as('titleExists') ) ); expectResults(snapshot, { @@ -2045,6 +2121,7 @@ describe('Firestore Pipelines', () => { .pipeline() .collection(randomCol.path) .where(eq('awards.hugo', true)) + .sort(descending('title')) .select('title', 'awards.hugo') ); expectResults( @@ -2068,6 +2145,7 @@ describe('Firestore Pipelines', () => { field('nestedField.level.1'), mapGet('nestedField', 'level.1').mapGet('level.2').as('nested') ) + .sort(descending('title')) ); expectResults( snapshot, @@ -2179,417 +2257,112 @@ describe('Firestore Pipelines', () => { }); }); - describe('not implemented in backend', () => { - it('supports Bit_and', async () => { - const snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .limit(1) - .select(bitAnd(constant(5), 12).as('result')) - ); - expectResults(snapshot, { - result: 4 - }); - }); + itIf(testUnsupportedFeatures)('testReplaceFirst', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('title', 'The Lord of the Rings')) + .limit(1) + .select(replaceFirst('title', 'o', '0').as('newName')) + ); + expectResults(snapshot, { newName: 'The L0rd of the Rings' }); + }); - it('supports Bit_and', async () => { - const snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .limit(1) - .select(constant(5).bitAnd(12).as('result')) - ); - expectResults(snapshot, { - result: 4 - }); - }); + itIf(testUnsupportedFeatures)('testReplaceAll', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('title', 'The Lord of the Rings')) + .limit(1) + .select(replaceAll('title', 'o', '0').as('newName')) + ); + expectResults(snapshot, { newName: 'The L0rd 0f the Rings' }); + }); - it('supports Bit_or', async () => { - let snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .limit(1) - .select(bitOr(constant(5), 12).as('result')) - ); - expectResults(snapshot, { - result: 13 - }); - snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .limit(1) - .select(constant(5).bitOr(12).as('result')) - ); - expectResults(snapshot, { - result: 13 - }); + it('supports Rand', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(10) + .select(rand().as('result')) + ); + expect(snapshot.results.length).to.equal(10); + snapshot.results.forEach(d => { + expect(d.get('result')).to.be.lt(1); + expect(d.get('result')).to.be.gte(0); }); + }); - it('supports Bit_xor', async () => { - let snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .limit(1) - .select(bitXor(constant(5), 12).as('result')) - ); - expectResults(snapshot, { - result: 9 - }); - snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .limit(1) - .select(constant(5).bitXor(12).as('result')) - ); - expectResults(snapshot, { - result: 9 - }); + it('supports array', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(array([1, 2, 3, 4]).as('metadata')) + ); + expect(snapshot.results.length).to.equal(1); + expectResults(snapshot, { + metadata: [1, 2, 3, 4] }); + }); - it('supports Bit_not', async () => { - let snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .limit(1) - .select( - bitNot(constant(Bytes.fromUint8Array(Uint8Array.of(0xfd)))).as( - 'result' - ) - ) - ); - expectResults(snapshot, { - result: Bytes.fromUint8Array(Uint8Array.of(0x02)) - }); - snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .limit(1) - .select( - constant(Bytes.fromUint8Array(Uint8Array.of(0xfd))) - .bitNot() - .as('result') - ) - ); - expectResults(snapshot, { - result: Bytes.fromUint8Array(Uint8Array.of(0x02)) - }); + it('evaluates expression in array', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select( + array([1, 2, field('genre'), multiply('rating', 10)]).as('metadata') + ) + ); + expect(snapshot.results.length).to.equal(1); + expectResults(snapshot, { + metadata: [1, 2, 'Fantasy', 47] }); + }); - it('supports Bit_left_shift', async () => { - let snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .limit(1) - .select( - bitLeftShift( - constant(Bytes.fromUint8Array(Uint8Array.of(0x02))), - 2 - ).as('result') - ) - ); - expectResults(snapshot, { - result: Bytes.fromUint8Array(Uint8Array.of(0x04)) - }); - snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .limit(1) - .select( - constant(Bytes.fromUint8Array(Uint8Array.of(0x02))) - .bitLeftShift(2) - .as('result') - ) - ); - expectResults(snapshot, { - result: Bytes.fromUint8Array(Uint8Array.of(0x04)) - }); - }); + it('supports arrayOffset', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(3) + .select(arrayOffset('tags', 0).as('firstTag')) + ); + const expectedResults = [ + { + firstTag: 'adventure' + }, + { + firstTag: 'politics' + }, + { + firstTag: 'classic' + } + ]; + expectResults(snapshot, ...expectedResults); - it('supports Bit_right_shift', async () => { - let snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .limit(1) - .select( - bitRightShift( - constant(Bytes.fromUint8Array(Uint8Array.of(0x02))), - 2 - ).as('result') - ) - ); - expectResults(snapshot, { - result: Bytes.fromUint8Array(Uint8Array.of(0x01)) - }); - snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .limit(1) - .select( - constant(Bytes.fromUint8Array(Uint8Array.of(0x02))) - .bitRightShift(2) - .as('result') - ) - ); - expectResults(snapshot, { - result: Bytes.fromUint8Array(Uint8Array.of(0x01)) - }); - }); - - it('supports Document_id', async () => { - let snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .sort(field('rating').descending()) - .limit(1) - .select(documentId(field('__path__')).as('docId')) - ); - expectResults(snapshot, { - docId: 'book4' - }); - snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .sort(field('rating').descending()) - .limit(1) - .select(field('__path__').documentId().as('docId')) - ); - expectResults(snapshot, { - docId: 'book4' - }); - }); - - it('supports Substr', async () => { - let snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .sort(field('rating').descending()) - .limit(1) - .select(substr('title', 9, 2).as('of')) - ); - expectResults(snapshot, { - of: 'of' - }); - snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .sort(field('rating').descending()) - .limit(1) - .select(field('title').substr(9, 2).as('of')) - ); - expectResults(snapshot, { - of: 'of' - }); - }); - - it('supports Substr without length', async () => { - let snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .sort(field('rating').descending()) - .limit(1) - .select(substr('title', 9).as('of')) - ); - expectResults(snapshot, { - of: 'of the Rings' - }); - snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .sort(field('rating').descending()) - .limit(1) - .select(field('title').substr(9).as('of')) - ); - expectResults(snapshot, { - of: 'of the Rings' - }); - }); - - it('arrayConcat works', async () => { - const snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .select( - arrayConcat('tags', ['newTag1', 'newTag2'], field('tags'), [ - null - ]).as('modifiedTags') - ) - .limit(1) - ); - expectResults(snapshot, { - modifiedTags: [ - 'comedy', - 'space', - 'adventure', - 'newTag1', - 'newTag2', - 'comedy', - 'space', - 'adventure', - null - ] - }); - }); - - it('testToLowercase', async () => { - const snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .select(field('title').toLower().as('lowercaseTitle')) - .limit(1) - ); - expectResults(snapshot, { - lowercaseTitle: "the hitchhiker's guide to the galaxy" - }); - }); - - it('testToUppercase', async () => { - const snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .select(field('author').toUpper().as('uppercaseAuthor')) - .limit(1) - ); - expectResults(snapshot, { uppercaseAuthor: 'DOUGLAS ADAMS' }); - }); - - it('testTrim', async () => { - const snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .addFields( - constant(" The Hitchhiker's Guide to the Galaxy ").as( - 'spacedTitle' - ) - ) - .select( - field('spacedTitle').trim().as('trimmedTitle'), - field('spacedTitle') - ) - .limit(1) - ); - expectResults(snapshot, { - spacedTitle: " The Hitchhiker's Guide to the Galaxy ", - trimmedTitle: "The Hitchhiker's Guide to the Galaxy" - }); - }); - - it('test reverse', async () => { - const snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .where(eq('title', '1984')) - .limit(1) - .select(reverse('title').as('reverseTitle')) - ); - expectResults(snapshot, { title: '4891' }); - }); - }); - - it('supports Rand', async () => { - const snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .limit(10) - .select(rand().as('result')) - ); - expect(snapshot.results.length).to.equal(10); - snapshot.results.forEach(d => { - expect(d.get('result')).to.be.lt(1); - expect(d.get('result')).to.be.gte(0); - }); - }); - - it('supports array', async () => { - const snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .sort(field('rating').descending()) - .limit(1) - .select(array([1, 2, 3, 4]).as('metadata')) - ); - expect(snapshot.results.length).to.equal(1); - expectResults(snapshot, { - metadata: [1, 2, 3, 4] - }); - }); - - it('evaluates expression in array', async () => { - const snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .sort(field('rating').descending()) - .limit(1) - .select( - array([1, 2, field('genre'), multiply('rating', 10)]).as('metadata') - ) - ); - expect(snapshot.results.length).to.equal(1); - expectResults(snapshot, { - metadata: [1, 2, 'Fantasy', 47] - }); - }); - - it('supports arrayOffset', async () => { - let snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .sort(field('rating').descending()) - .limit(3) - .select(arrayOffset('tags', 0).as('firstTag')) - ); - const expectedResults = [ - { - firstTag: 'adventure' - }, - { - firstTag: 'politics' - }, - { - firstTag: 'classic' - } - ]; - expectResults(snapshot, ...expectedResults); - - snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .sort(field('rating').descending()) - .limit(3) - .select(field('tags').arrayOffset(0).as('firstTag')) - ); - expectResults(snapshot, ...expectedResults); - }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(3) + .select(field('tags').arrayOffset(0).as('firstTag')) + ); + expectResults(snapshot, ...expectedResults); + }); // TODO: current_context tests with are failing because of b/395937453 - it('supports currentContext', async () => { + itIf(testUnsupportedFeatures)('supports currentContext', async () => { const snapshot = await execute( firestore .pipeline() @@ -2773,147 +2546,517 @@ describe('Firestore Pipelines', () => { minus10millis: new Timestamp(1741380234, 990000000) }); }); - }); - describe('pagination', () => { - /** - * Adds several books to the test collection. These - * additional books support pagination test scenarios - * that would otherwise not be possible with the original - * set of books. - * @param collectionReference - */ - async function addBooks( - collectionReference: CollectionReference - ): Promise { - await setDoc(doc(collectionReference, 'book11'), { - title: 'Jonathan Strange & Mr Norrell', - author: 'Susanna Clarke', - genre: 'Fantasy', - published: 2004, - rating: 4.6, - tags: ['historical fantasy', 'magic', 'alternate history', 'england'], - awards: { hugo: false, nebula: false } - }); - await setDoc(doc(collectionReference, 'book12'), { - title: 'The Master and Margarita', - author: 'Mikhail Bulgakov', - genre: 'Satire', - published: 1967, // Though written much earlier - rating: 4.6, - tags: [ - 'russian literature', - 'supernatural', - 'philosophy', - 'dark comedy' - ], - awards: {} - }); - await setDoc(doc(collectionReference, 'book13'), { - title: 'A Long Way to a Small, Angry Planet', - author: 'Becky Chambers', - genre: 'Science Fiction', - published: 2014, - rating: 4.6, - tags: ['space opera', 'found family', 'character-driven', 'optimistic'], - awards: { hugo: false, nebula: false, kitschies: true } - }); - } + it('supports byteLength', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol) + .limit(1) + .select( + constant( + Bytes.fromUint8Array(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 0])) + ).as('bytes') + ) + .select(byteLength('bytes').as('byteLength')) + ); - it('supports pagination with filters', async () => { - await addBooks(randomCol); - const pageSize = 2; - const pipeline = firestore - .pipeline() - .collection(randomCol.path) - .select('title', 'rating', '__name__') - .sort(field('rating').descending(), field('__name__').ascending()); + expectResults(snapshot, { + byteLength: 8 + }); + }); - let snapshot = await execute(pipeline.limit(pageSize)); - expectResults( - snapshot, - { title: 'The Lord of the Rings', rating: 4.7 }, - { title: 'Jonathan Strange & Mr Norrell', rating: 4.6 } + it('supports not', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol) + .limit(1) + .select(constant(true).as('trueField')) + .select('trueField', not(eq('trueField', true)).as('falseField')) ); - const lastDoc = snapshot.results[snapshot.results.length - 1]; + expectResults(snapshot, { + trueField: true, + falseField: false + }); + }); + }); - snapshot = await execute( - pipeline - .where( - or( - and( - field('rating').eq(lastDoc.get('rating')), - field('__path__').gt(lastDoc.ref?.id) - ), - field('rating').lt(lastDoc.get('rating')) - ) - ) - .limit(pageSize) + describe('not yet implemented in backend', () => { + itIf(testUnsupportedFeatures)('supports Bit_and', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(bitAnd(constant(5), 12).as('result')) ); - expectResults( - snapshot, - { title: 'Pride and Prejudice', rating: 4.5 }, - { title: 'Crime and Punishment', rating: 4.3 } + expectResults(snapshot, { + result: 4 + }); + }); + + itIf(testUnsupportedFeatures)('supports Bit_and', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(constant(5).bitAnd(12).as('result')) ); + expectResults(snapshot, { + result: 4 + }); }); - it('supports pagination with offsets', async () => { - await addBooks(randomCol); + itIf(testUnsupportedFeatures)('supports Bit_or', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(bitOr(constant(5), 12).as('result')) + ); + expectResults(snapshot, { + result: 13 + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(constant(5).bitOr(12).as('result')) + ); + expectResults(snapshot, { + result: 13 + }); + }); - const secondFilterField = '__name__'; + itIf(testUnsupportedFeatures)('supports Bit_xor', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(bitXor(constant(5), 12).as('result')) + ); + expectResults(snapshot, { + result: 9 + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select(constant(5).bitXor(12).as('result')) + ); + expectResults(snapshot, { + result: 9 + }); + }); - const pipeline = firestore - .pipeline() - .collection(randomCol.path) - .select('title', 'rating', secondFilterField) - .sort( - field('rating').descending(), - field(secondFilterField).ascending() - ); + itIf(testUnsupportedFeatures)('supports Bit_not', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + bitNot(constant(Bytes.fromUint8Array(Uint8Array.of(0xfd)))).as( + 'result' + ) + ) + ); + expectResults(snapshot, { + result: Bytes.fromUint8Array(Uint8Array.of(0x02)) + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + constant(Bytes.fromUint8Array(Uint8Array.of(0xfd))) + .bitNot() + .as('result') + ) + ); + expectResults(snapshot, { + result: Bytes.fromUint8Array(Uint8Array.of(0x02)) + }); + }); - const pageSize = 2; - let currPage = 0; + itIf(testUnsupportedFeatures)('supports Bit_left_shift', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + bitLeftShift( + constant(Bytes.fromUint8Array(Uint8Array.of(0x02))), + 2 + ).as('result') + ) + ); + expectResults(snapshot, { + result: Bytes.fromUint8Array(Uint8Array.of(0x04)) + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + constant(Bytes.fromUint8Array(Uint8Array.of(0x02))) + .bitLeftShift(2) + .as('result') + ) + ); + expectResults(snapshot, { + result: Bytes.fromUint8Array(Uint8Array.of(0x04)) + }); + }); + itIf(testUnsupportedFeatures)('supports Bit_right_shift', async () => { let snapshot = await execute( - pipeline.offset(currPage++ * pageSize).limit(pageSize) + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + bitRightShift( + constant(Bytes.fromUint8Array(Uint8Array.of(0x02))), + 2 + ).as('result') + ) + ); + expectResults(snapshot, { + result: Bytes.fromUint8Array(Uint8Array.of(0x01)) + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .limit(1) + .select( + constant(Bytes.fromUint8Array(Uint8Array.of(0x02))) + .bitRightShift(2) + .as('result') + ) ); + expectResults(snapshot, { + result: Bytes.fromUint8Array(Uint8Array.of(0x01)) + }); + }); - expectResults( - snapshot, - { - title: 'The Lord of the Rings', - rating: 4.7 - }, - { title: 'Dune', rating: 4.6 } + itIf(testUnsupportedFeatures)('supports Document_id', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(documentId(field('__path__')).as('docId')) + ); + expectResults(snapshot, { + docId: 'book4' + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(field('__path__').documentId().as('docId')) ); + expectResults(snapshot, { + docId: 'book4' + }); + }); + itIf(testUnsupportedFeatures)('supports Substr', async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(substr('title', 9, 2).as('of')) + ); + expectResults(snapshot, { + of: 'of' + }); snapshot = await execute( - pipeline.offset(currPage++ * pageSize).limit(pageSize) + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(field('title').substr(9, 2).as('of')) ); - expectResults( - snapshot, - { - title: 'Jonathan Strange & Mr Norrell', - rating: 4.6 - }, - { title: 'The Master and Margarita', rating: 4.6 } + expectResults(snapshot, { + of: 'of' + }); + }); + + itIf(testUnsupportedFeatures)( + 'supports Substr without length', + async () => { + let snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(substr('title', 9).as('of')) + ); + expectResults(snapshot, { + of: 'of the Rings' + }); + snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .sort(field('rating').descending()) + .limit(1) + .select(field('title').substr(9).as('of')) + ); + expectResults(snapshot, { + of: 'of the Rings' + }); + } + ); + + itIf(testUnsupportedFeatures)('arrayConcat works', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select( + arrayConcat('tags', ['newTag1', 'newTag2'], field('tags'), [ + null + ]).as('modifiedTags') + ) + .limit(1) ); + expectResults(snapshot, { + modifiedTags: [ + 'comedy', + 'space', + 'adventure', + 'newTag1', + 'newTag2', + 'comedy', + 'space', + 'adventure', + null + ] + }); + }); - snapshot = await execute( - pipeline.offset(currPage++ * pageSize).limit(pageSize) + itIf(testUnsupportedFeatures)('testToLowercase', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select(toLower('title').as('lowercaseTitle')) + .limit(1) ); - expectResults( - snapshot, - { - title: 'A Long Way to a Small, Angry Planet', - rating: 4.6 - }, - { - title: 'Pride and Prejudice', - rating: 4.5 - } + expectResults(snapshot, { + lowercaseTitle: "the hitchhiker's guide to the galaxy" + }); + }); + + itIf(testUnsupportedFeatures)('testToUppercase', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .select(toUpper('author').as('uppercaseAuthor')) + .limit(1) + ); + expectResults(snapshot, { uppercaseAuthor: 'DOUGLAS ADAMS' }); + }); + + itIf(testUnsupportedFeatures)('testTrim', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .addFields( + constant(" The Hitchhiker's Guide to the Galaxy ").as('spacedTitle') + ) + .select(trim('spacedTitle').as('trimmedTitle'), field('spacedTitle')) + .limit(1) ); + expectResults(snapshot, { + spacedTitle: " The Hitchhiker's Guide to the Galaxy ", + trimmedTitle: "The Hitchhiker's Guide to the Galaxy" + }); }); + + itIf(testUnsupportedFeatures)('test reverse', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(eq('title', '1984')) + .limit(1) + .select(reverse('title').as('reverseTitle')) + ); + expectResults(snapshot, { title: '4891' }); + }); + }); + + describe('pagination', () => { + /** + * Adds several books to the test collection. These + * additional books support pagination test scenarios + * that would otherwise not be possible with the original + * set of books. + * @param collectionReference + */ + async function addBooks( + collectionReference: CollectionReference + ): Promise { + await setDoc(doc(collectionReference, 'book11'), { + title: 'Jonathan Strange & Mr Norrell', + author: 'Susanna Clarke', + genre: 'Fantasy', + published: 2004, + rating: 4.6, + tags: ['historical fantasy', 'magic', 'alternate history', 'england'], + awards: { hugo: false, nebula: false } + }); + await setDoc(doc(collectionReference, 'book12'), { + title: 'The Master and Margarita', + author: 'Mikhail Bulgakov', + genre: 'Satire', + published: 1967, // Though written much earlier + rating: 4.6, + tags: [ + 'russian literature', + 'supernatural', + 'philosophy', + 'dark comedy' + ], + awards: {} + }); + await setDoc(doc(collectionReference, 'book13'), { + title: 'A Long Way to a Small, Angry Planet', + author: 'Becky Chambers', + genre: 'Science Fiction', + published: 2014, + rating: 4.6, + tags: ['space opera', 'found family', 'character-driven', 'optimistic'], + awards: { hugo: false, nebula: false, kitschies: true } + }); + } + + // sort on __name__ is not working + itIf(testUnsupportedFeatures)( + 'supports pagination with filters', + async () => { + await addBooks(randomCol); + const pageSize = 2; + const pipeline = firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'rating', '__name__') + .sort(field('rating').descending(), field('__name__').ascending()); + + let snapshot = await execute(pipeline.limit(pageSize)); + expectResults( + snapshot, + { title: 'The Lord of the Rings', rating: 4.7 }, + { title: 'Jonathan Strange & Mr Norrell', rating: 4.6 } + ); + + const lastDoc = snapshot.results[snapshot.results.length - 1]; + + snapshot = await execute( + pipeline + .where( + or( + and( + field('rating').eq(lastDoc.get('rating')), + field('__path__').gt(lastDoc.ref?.id) + ), + field('rating').lt(lastDoc.get('rating')) + ) + ) + .limit(pageSize) + ); + expectResults( + snapshot, + { title: 'Pride and Prejudice', rating: 4.5 }, + { title: 'Crime and Punishment', rating: 4.3 } + ); + } + ); + + // sort on __name__ is not working + itIf(testUnsupportedFeatures)( + 'supports pagination with offsets', + async () => { + await addBooks(randomCol); + + const secondFilterField = '__path__'; + + const pipeline = firestore + .pipeline() + .collection(randomCol.path) + .select('title', 'rating', secondFilterField) + .sort( + field('rating').descending(), + field(secondFilterField).ascending() + ); + + const pageSize = 2; + let currPage = 0; + + let snapshot = await execute( + pipeline.offset(currPage++ * pageSize).limit(pageSize) + ); + + expectResults( + snapshot, + { + title: 'The Lord of the Rings', + rating: 4.7 + }, + { title: 'Dune', rating: 4.6 } + ); + + snapshot = await execute( + pipeline.offset(currPage++ * pageSize).limit(pageSize) + ); + expectResults( + snapshot, + { + title: 'Jonathan Strange & Mr Norrell', + rating: 4.6 + }, + { title: 'The Master and Margarita', rating: 4.6 } + ); + + snapshot = await execute( + pipeline.offset(currPage++ * pageSize).limit(pageSize) + ); + expectResults( + snapshot, + { + title: 'A Long Way to a Small, Angry Planet', + rating: 4.6 + }, + { + title: 'Pride and Prejudice', + rating: 4.5 + } + ); + } + ); }); }); From 3d6bbf36fa0045d7a19d74eea7282717c39dabfb Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Tue, 8 Apr 2025 13:46:31 -0600 Subject: [PATCH 54/59] Test fixes and re-enabling tests for features that were added on backend --- .../firestore/src/lite-api/expressions.ts | 10 -------- .../test/integration/api/pipeline.test.ts | 23 +++---------------- .../integration/api/query_to_pipeline.test.ts | 13 ++++------- 3 files changed, 7 insertions(+), 39 deletions(-) diff --git a/packages/firestore/src/lite-api/expressions.ts b/packages/firestore/src/lite-api/expressions.ts index 43e44b7577d..03182ae3227 100644 --- a/packages/firestore/src/lite-api/expressions.ts +++ b/packages/firestore/src/lite-api/expressions.ts @@ -3043,16 +3043,6 @@ export function arrayOffset( return fieldOrExpression(array).arrayOffset(valueToDefaultExpr(offset)); } -/** - * @beta - * Creates an Expr that returns a map of all values in the current expression context. - * - * @return A new {@code Expr} representing the 'current_context' function. - */ -export function currentContext(): FunctionExpr { - return new FunctionExpr('current_context', []); -} - /** * @beta * diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index f8a5cc28bce..61d223fcf13 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -144,7 +144,7 @@ use(chaiAsPromised); setLogLevel('debug'); -const testUnsupportedFeatures = false; +const testUnsupportedFeatures: boolean | 'only' = false; const timestampDeltaMS = 1000; apiDescribe('Pipelines', persistence => { @@ -343,8 +343,7 @@ apiDescribe('Pipelines', persistence => { expect(snapshot.results.length).to.equal(0); }); - // Skipping because __name__ is not currently working in DBE - itIf(testUnsupportedFeatures)('full snapshot as expected', async () => { + it('full snapshot as expected', async () => { const ppl = firestore .pipeline() .collection(randomCol.path) @@ -1372,8 +1371,7 @@ apiDescribe('Pipelines', persistence => { }); describe('union stage', () => { - // __name__ not currently supported by dbe - itIf(testUnsupportedFeatures)('run pipeline with union', async () => { + it('run pipeline with union', async () => { const snapshot = await execute( firestore .pipeline() @@ -2366,21 +2364,6 @@ apiDescribe('Pipelines', persistence => { expectResults(snapshot, ...expectedResults); }); - // TODO: current_context tests with are failing because of b/395937453 - itIf(testUnsupportedFeatures)('supports currentContext', async () => { - const snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .sort(field('rating').descending()) - .limit(1) - .select(currentContext().as('currentContext')) - ); - expectResults(snapshot, { - currentContext: 'TODO' - }); - }); - it('supports map', async () => { const snapshot = await execute( firestore diff --git a/packages/firestore/test/integration/api/query_to_pipeline.test.ts b/packages/firestore/test/integration/api/query_to_pipeline.test.ts index a0ad0e93bc9..7660699b70f 100644 --- a/packages/firestore/test/integration/api/query_to_pipeline.test.ts +++ b/packages/firestore/test/integration/api/query_to_pipeline.test.ts @@ -55,7 +55,7 @@ use(chaiAsPromised); setLogLevel('debug'); -const testUnsupportedFeatures = false; +const testUnsupportedFeatures: boolean | 'only' = false; // This is the Query integration tests from the lite API (no cache support) // with some additional test cases added for more complete coverage. @@ -247,9 +247,7 @@ apiDescribe('Query to Pipeline', persistence => { ); }); - // sort on __name__ is not working - itIf(testUnsupportedFeatures)( - 'supports startAfter (with DocumentSnapshot)', + it('supports startAfter (with DocumentSnapshot)', () => { return withTestCollection( PERSISTENCE_MODE_UNSPECIFIED, @@ -317,9 +315,7 @@ apiDescribe('Query to Pipeline', persistence => { } ); - // sort on __name__ is not working - itIf(testUnsupportedFeatures)( - 'supports startAt (with DocumentSnapshot)', + it('supports startAt (with DocumentSnapshot)', () => { return withTestCollection( PERSISTENCE_MODE_UNSPECIFIED, @@ -719,8 +715,7 @@ apiDescribe('Query to Pipeline', persistence => { ); }); - // sorting on name required - itIf(testUnsupportedFeatures)('supports array contains any', () => { + it('supports array contains any', () => { return withTestCollection( PERSISTENCE_MODE_UNSPECIFIED, { From 32ee33145ab7100724ea665e5fd223bea7c46b68 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Tue, 8 Apr 2025 13:55:18 -0600 Subject: [PATCH 55/59] Additional test cleanup --- .../test/integration/api/pipeline.test.ts | 4 +- .../integration/api/query_to_pipeline.test.ts | 264 +++++++++--------- 2 files changed, 132 insertions(+), 136 deletions(-) diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index 61d223fcf13..47f9d2bbb1f 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -2943,7 +2943,7 @@ apiDescribe('Pipelines', persistence => { }); } - // sort on __name__ is not working + // sort on __name__ is not working, see b/409358591 itIf(testUnsupportedFeatures)( 'supports pagination with filters', async () => { @@ -2985,7 +2985,7 @@ apiDescribe('Pipelines', persistence => { } ); - // sort on __name__ is not working + // sort on __name__ is not working, see b/409358591 itIf(testUnsupportedFeatures)( 'supports pagination with offsets', async () => { diff --git a/packages/firestore/test/integration/api/query_to_pipeline.test.ts b/packages/firestore/test/integration/api/query_to_pipeline.test.ts index 7660699b70f..ac1d2e79007 100644 --- a/packages/firestore/test/integration/api/query_to_pipeline.test.ts +++ b/packages/firestore/test/integration/api/query_to_pipeline.test.ts @@ -247,143 +247,139 @@ apiDescribe('Query to Pipeline', persistence => { ); }); - it('supports startAfter (with DocumentSnapshot)', - () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, - { - 1: { id: 1, foo: 1, bar: 1, baz: 1 }, - 2: { id: 2, foo: 1, bar: 1, baz: 2 }, - 3: { id: 3, foo: 1, bar: 1, baz: 2 }, - 4: { id: 4, foo: 1, bar: 2, baz: 1 }, - 5: { id: 5, foo: 1, bar: 2, baz: 2 }, - 6: { id: 6, foo: 1, bar: 2, baz: 2 }, - 7: { id: 7, foo: 2, bar: 1, baz: 1 }, - 8: { id: 8, foo: 2, bar: 1, baz: 2 }, - 9: { id: 9, foo: 2, bar: 1, baz: 2 }, - 10: { id: 10, foo: 2, bar: 2, baz: 1 }, - 11: { id: 11, foo: 2, bar: 2, baz: 2 }, - 12: { id: 12, foo: 2, bar: 2, baz: 2 } - }, - async (collRef, db) => { - let docRef = await getDoc(doc(collRef, '2')); - let query1 = query( - collRef, - orderBy('foo'), - orderBy('bar'), - orderBy('baz'), - startAfter(docRef) - ); - let snapshot = await execute(db.pipeline().createFrom(query1)); - verifyResults( - snapshot, - { id: 3, foo: 1, bar: 1, baz: 2 }, - { id: 4, foo: 1, bar: 2, baz: 1 }, - { id: 5, foo: 1, bar: 2, baz: 2 }, - { id: 6, foo: 1, bar: 2, baz: 2 }, - { id: 7, foo: 2, bar: 1, baz: 1 }, - { id: 8, foo: 2, bar: 1, baz: 2 }, - { id: 9, foo: 2, bar: 1, baz: 2 }, - { id: 10, foo: 2, bar: 2, baz: 1 }, - { id: 11, foo: 2, bar: 2, baz: 2 }, - { id: 12, foo: 2, bar: 2, baz: 2 } - ); + it('supports startAfter (with DocumentSnapshot)', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { id: 1, foo: 1, bar: 1, baz: 1 }, + 2: { id: 2, foo: 1, bar: 1, baz: 2 }, + 3: { id: 3, foo: 1, bar: 1, baz: 2 }, + 4: { id: 4, foo: 1, bar: 2, baz: 1 }, + 5: { id: 5, foo: 1, bar: 2, baz: 2 }, + 6: { id: 6, foo: 1, bar: 2, baz: 2 }, + 7: { id: 7, foo: 2, bar: 1, baz: 1 }, + 8: { id: 8, foo: 2, bar: 1, baz: 2 }, + 9: { id: 9, foo: 2, bar: 1, baz: 2 }, + 10: { id: 10, foo: 2, bar: 2, baz: 1 }, + 11: { id: 11, foo: 2, bar: 2, baz: 2 }, + 12: { id: 12, foo: 2, bar: 2, baz: 2 } + }, + async (collRef, db) => { + let docRef = await getDoc(doc(collRef, '2')); + let query1 = query( + collRef, + orderBy('foo'), + orderBy('bar'), + orderBy('baz'), + startAfter(docRef) + ); + let snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults( + snapshot, + { id: 3, foo: 1, bar: 1, baz: 2 }, + { id: 4, foo: 1, bar: 2, baz: 1 }, + { id: 5, foo: 1, bar: 2, baz: 2 }, + { id: 6, foo: 1, bar: 2, baz: 2 }, + { id: 7, foo: 2, bar: 1, baz: 1 }, + { id: 8, foo: 2, bar: 1, baz: 2 }, + { id: 9, foo: 2, bar: 1, baz: 2 }, + { id: 10, foo: 2, bar: 2, baz: 1 }, + { id: 11, foo: 2, bar: 2, baz: 2 }, + { id: 12, foo: 2, bar: 2, baz: 2 } + ); - docRef = await getDoc(doc(collRef, '3')); - query1 = query( - collRef, - orderBy('foo'), - orderBy('bar'), - orderBy('baz'), - startAfter(docRef) - ); - snapshot = await execute(db.pipeline().createFrom(query1)); - verifyResults( - snapshot, - { id: 4, foo: 1, bar: 2, baz: 1 }, - { id: 5, foo: 1, bar: 2, baz: 2 }, - { id: 6, foo: 1, bar: 2, baz: 2 }, - { id: 7, foo: 2, bar: 1, baz: 1 }, - { id: 8, foo: 2, bar: 1, baz: 2 }, - { id: 9, foo: 2, bar: 1, baz: 2 }, - { id: 10, foo: 2, bar: 2, baz: 1 }, - { id: 11, foo: 2, bar: 2, baz: 2 }, - { id: 12, foo: 2, bar: 2, baz: 2 } - ); - } - ); - } - ); + docRef = await getDoc(doc(collRef, '3')); + query1 = query( + collRef, + orderBy('foo'), + orderBy('bar'), + orderBy('baz'), + startAfter(docRef) + ); + snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults( + snapshot, + { id: 4, foo: 1, bar: 2, baz: 1 }, + { id: 5, foo: 1, bar: 2, baz: 2 }, + { id: 6, foo: 1, bar: 2, baz: 2 }, + { id: 7, foo: 2, bar: 1, baz: 1 }, + { id: 8, foo: 2, bar: 1, baz: 2 }, + { id: 9, foo: 2, bar: 1, baz: 2 }, + { id: 10, foo: 2, bar: 2, baz: 1 }, + { id: 11, foo: 2, bar: 2, baz: 2 }, + { id: 12, foo: 2, bar: 2, baz: 2 } + ); + } + ); + }); - it('supports startAt (with DocumentSnapshot)', - () => { - return withTestCollection( - PERSISTENCE_MODE_UNSPECIFIED, - { - 1: { id: 1, foo: 1, bar: 1, baz: 1 }, - 2: { id: 2, foo: 1, bar: 1, baz: 2 }, - 3: { id: 3, foo: 1, bar: 1, baz: 2 }, - 4: { id: 4, foo: 1, bar: 2, baz: 1 }, - 5: { id: 5, foo: 1, bar: 2, baz: 2 }, - 6: { id: 6, foo: 1, bar: 2, baz: 2 }, - 7: { id: 7, foo: 2, bar: 1, baz: 1 }, - 8: { id: 8, foo: 2, bar: 1, baz: 2 }, - 9: { id: 9, foo: 2, bar: 1, baz: 2 }, - 10: { id: 10, foo: 2, bar: 2, baz: 1 }, - 11: { id: 11, foo: 2, bar: 2, baz: 2 }, - 12: { id: 12, foo: 2, bar: 2, baz: 2 } - }, - async (collRef, db) => { - let docRef = await getDoc(doc(collRef, '2')); - let query1 = query( - collRef, - orderBy('foo'), - orderBy('bar'), - orderBy('baz'), - startAt(docRef) - ); - let snapshot = await execute(db.pipeline().createFrom(query1)); - verifyResults( - snapshot, - { id: 2, foo: 1, bar: 1, baz: 2 }, - { id: 3, foo: 1, bar: 1, baz: 2 }, - { id: 4, foo: 1, bar: 2, baz: 1 }, - { id: 5, foo: 1, bar: 2, baz: 2 }, - { id: 6, foo: 1, bar: 2, baz: 2 }, - { id: 7, foo: 2, bar: 1, baz: 1 }, - { id: 8, foo: 2, bar: 1, baz: 2 }, - { id: 9, foo: 2, bar: 1, baz: 2 }, - { id: 10, foo: 2, bar: 2, baz: 1 }, - { id: 11, foo: 2, bar: 2, baz: 2 }, - { id: 12, foo: 2, bar: 2, baz: 2 } - ); + it('supports startAt (with DocumentSnapshot)', () => { + return withTestCollection( + PERSISTENCE_MODE_UNSPECIFIED, + { + 1: { id: 1, foo: 1, bar: 1, baz: 1 }, + 2: { id: 2, foo: 1, bar: 1, baz: 2 }, + 3: { id: 3, foo: 1, bar: 1, baz: 2 }, + 4: { id: 4, foo: 1, bar: 2, baz: 1 }, + 5: { id: 5, foo: 1, bar: 2, baz: 2 }, + 6: { id: 6, foo: 1, bar: 2, baz: 2 }, + 7: { id: 7, foo: 2, bar: 1, baz: 1 }, + 8: { id: 8, foo: 2, bar: 1, baz: 2 }, + 9: { id: 9, foo: 2, bar: 1, baz: 2 }, + 10: { id: 10, foo: 2, bar: 2, baz: 1 }, + 11: { id: 11, foo: 2, bar: 2, baz: 2 }, + 12: { id: 12, foo: 2, bar: 2, baz: 2 } + }, + async (collRef, db) => { + let docRef = await getDoc(doc(collRef, '2')); + let query1 = query( + collRef, + orderBy('foo'), + orderBy('bar'), + orderBy('baz'), + startAt(docRef) + ); + let snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults( + snapshot, + { id: 2, foo: 1, bar: 1, baz: 2 }, + { id: 3, foo: 1, bar: 1, baz: 2 }, + { id: 4, foo: 1, bar: 2, baz: 1 }, + { id: 5, foo: 1, bar: 2, baz: 2 }, + { id: 6, foo: 1, bar: 2, baz: 2 }, + { id: 7, foo: 2, bar: 1, baz: 1 }, + { id: 8, foo: 2, bar: 1, baz: 2 }, + { id: 9, foo: 2, bar: 1, baz: 2 }, + { id: 10, foo: 2, bar: 2, baz: 1 }, + { id: 11, foo: 2, bar: 2, baz: 2 }, + { id: 12, foo: 2, bar: 2, baz: 2 } + ); - docRef = await getDoc(doc(collRef, '3')); - query1 = query( - collRef, - orderBy('foo'), - orderBy('bar'), - orderBy('baz'), - startAt(docRef) - ); - snapshot = await execute(db.pipeline().createFrom(query1)); - verifyResults( - snapshot, - { id: 3, foo: 1, bar: 1, baz: 2 }, - { id: 4, foo: 1, bar: 2, baz: 1 }, - { id: 5, foo: 1, bar: 2, baz: 2 }, - { id: 6, foo: 1, bar: 2, baz: 2 }, - { id: 7, foo: 2, bar: 1, baz: 1 }, - { id: 8, foo: 2, bar: 1, baz: 2 }, - { id: 9, foo: 2, bar: 1, baz: 2 }, - { id: 10, foo: 2, bar: 2, baz: 1 }, - { id: 11, foo: 2, bar: 2, baz: 2 }, - { id: 12, foo: 2, bar: 2, baz: 2 } - ); - } - ); - } - ); + docRef = await getDoc(doc(collRef, '3')); + query1 = query( + collRef, + orderBy('foo'), + orderBy('bar'), + orderBy('baz'), + startAt(docRef) + ); + snapshot = await execute(db.pipeline().createFrom(query1)); + verifyResults( + snapshot, + { id: 3, foo: 1, bar: 1, baz: 2 }, + { id: 4, foo: 1, bar: 2, baz: 1 }, + { id: 5, foo: 1, bar: 2, baz: 2 }, + { id: 6, foo: 1, bar: 2, baz: 2 }, + { id: 7, foo: 2, bar: 1, baz: 1 }, + { id: 8, foo: 2, bar: 1, baz: 2 }, + { id: 9, foo: 2, bar: 1, baz: 2 }, + { id: 10, foo: 2, bar: 2, baz: 1 }, + { id: 11, foo: 2, bar: 2, baz: 2 }, + { id: 12, foo: 2, bar: 2, baz: 2 } + ); + } + ); + }); it('supports startAfter', () => { return withTestCollection( From bb8fc2747113c9e45bd24b1287cbc84fb5a21527 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Tue, 8 Apr 2025 14:28:45 -0600 Subject: [PATCH 56/59] fix tests and enable only pipeline tests --- packages/firestore/test/integration/api/pipeline.test.ts | 4 ++-- .../firestore/test/integration/api/query_to_pipeline.test.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index 47f9d2bbb1f..aef74026054 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -147,7 +147,7 @@ setLogLevel('debug'); const testUnsupportedFeatures: boolean | 'only' = false; const timestampDeltaMS = 1000; -apiDescribe('Pipelines', persistence => { +apiDescribe.only('Pipelines', persistence => { addEqualityMatcher(); let firestore: Firestore; @@ -2371,7 +2371,7 @@ apiDescribe('Pipelines', persistence => { .collection(randomCol.path) .sort(field('rating').descending()) .limit(1) - .addFields( + .select( map({ foo: 'bar' }).as('metadata') diff --git a/packages/firestore/test/integration/api/query_to_pipeline.test.ts b/packages/firestore/test/integration/api/query_to_pipeline.test.ts index ac1d2e79007..87e1a22cb4e 100644 --- a/packages/firestore/test/integration/api/query_to_pipeline.test.ts +++ b/packages/firestore/test/integration/api/query_to_pipeline.test.ts @@ -59,7 +59,7 @@ const testUnsupportedFeatures: boolean | 'only' = false; // This is the Query integration tests from the lite API (no cache support) // with some additional test cases added for more complete coverage. -apiDescribe('Query to Pipeline', persistence => { +apiDescribe.only('Query to Pipeline', persistence => { addEqualityMatcher(); function verifyResults( From 03eb22e4d5bc44ec3ee997f3fc755e5340342dfc Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Fri, 11 Apr 2025 13:03:26 -0600 Subject: [PATCH 57/59] Comment cleanup --- packages/firestore/src/lite-api/pipeline.ts | 38 +++++++++---------- .../test/integration/api/pipeline.test.ts | 4 +- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/packages/firestore/src/lite-api/pipeline.ts b/packages/firestore/src/lite-api/pipeline.ts index e07c7a37b9f..17ad5464725 100644 --- a/packages/firestore/src/lite-api/pipeline.ts +++ b/packages/firestore/src/lite-api/pipeline.ts @@ -148,8 +148,8 @@ export class Pipeline implements ProtoSerializable { * The added fields are defined using {@link Selectable}s, which can be: * * - {@link Field}: References an existing document field. - * - {@link Function}: Performs a calculation using functions like `add`, `multiply` with - * assigned aliases using {@link Expr#as}. + * - {@link Expr}: Either a literal value (see {@link Constant}) or a computed value + * (see {@FunctionExpr}) with an assigned alias using {@link Expr#as}. * * Example: * @@ -353,22 +353,21 @@ export class Pipeline implements ProtoSerializable { return this._addStage(new Limit(limit, convertedFromLimitToLast)); } + /** - * Returns a set of distinct {@link Expr} values from the inputs to this stage. + * Returns a set of distinct values from the inputs to this stage. * - *

This stage run through the results from previous stages to include only results with unique - * combinations of {@link Expr} values ({@link Field}, {@link Function}, etc.). + * This stage runs through the results from previous stages to include only results with + * unique combinations of {@link Expr} values ({@link Field}, {@link Function}, etc). * - *

The parameters to this stage are defined using {@link Selectable} expressions or {@code string}s: + * The parameters to this stage are defined using {@link Selectable} expressions or strings: * - *

    - *
  • {@code string}: Name of an existing field
  • - *
  • {@link Field}: References an existing document field.
  • - *
  • {@link Function}: Represents the result of a function with an assigned alias name using - * {@link Expr#as}
  • - *
+ * - {@code string}: Name of an existing field + * - {@link Field}: References an existing document field. + * - {@link ExprWithAlias}: Represents the result of a function with an assigned alias name + * using {@link Expr#as}. * - *

Example: + * Example: * * ```typescript * // Get a list of unique author names in uppercase and genre combinations. @@ -377,8 +376,8 @@ export class Pipeline implements ProtoSerializable { * .select("authorName"); * ``` * - * @param group The first {@link Selectable} expression to consider when determining distinct - * value combinations or strings representing field names. + * @param group The {@link Selectable} expression or field name to consider when determining + * distinct value combinations. * @param additionalGroups Optional additional {@link Selectable} expressions to consider when determining distinct * value combinations or strings representing field names. * @return A new {@code Pipeline} object with this stage appended to the stage list. @@ -416,9 +415,9 @@ export class Pipeline implements ProtoSerializable { * ``` * * @param accumulator The first {@link AggregateWithAlias}, wrapping an {@link AggregateFunction} - * and provide a name for the accumulated results. + * and providing a name for the accumulated results. * @param additionalAccumulators Optional additional {@link AggregateWithAlias}, each wrapping an {@link AggregateFunction} - * and provide a name for the accumulated results. + * and providing a name for the accumulated results. * @return A new Pipeline object with this stage appended to the stage list. */ aggregate( @@ -734,11 +733,10 @@ export class Pipeline implements ProtoSerializable { } /** - * Produces a document for each element in array found in previous stage document. + * Produces a document for each element in an input array. * * For each previous stage document, this stage will emit zero or more augmented documents. The - * input array found in the previous stage document field specified by the `selectable` parameter, - * will emit an augmented document for each input array element. The input array element will + * input array specified by the `selectable` parameter, will emit an augmented document for each input array element. The input array element will * augment the previous stage document by setting the `alias` field with the array element value. * * When `selectable` evaluates to a non-array value (ex: number, null, absent), then the stage becomes a no-op for diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index aef74026054..1ef61bf0304 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -53,8 +53,7 @@ import { collection, documentId as documentIdFieldPath, writeBatch, - addDoc, - increment + addDoc } from '../util/firebase_export'; import { apiDescribe, withTestCollection, itIf } from '../util/helpers'; import { @@ -119,7 +118,6 @@ import { arrayOffset, minimum, maximum, - currentContext, isError, ifError, trim, From 1645cd644a0523a82a6afe976c4e48e9190a927b Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Tue, 29 Apr 2025 14:44:20 -0600 Subject: [PATCH 58/59] Cleanup --- packages/firestore/src/api_pipelines.ts | 1 - packages/firestore/src/core/pipeline-util.ts | 2 +- .../firestore/src/lite-api/expressions.ts | 4 +- packages/firestore/src/lite-api/pipeline.ts | 45 +++---------------- packages/firestore/src/lite-api/stage.ts | 5 +-- .../test/integration/api/pipeline.test.ts | 12 +++++ .../test/integration/api/transactions.test.ts | 2 +- 7 files changed, 22 insertions(+), 49 deletions(-) diff --git a/packages/firestore/src/api_pipelines.ts b/packages/firestore/src/api_pipelines.ts index ad7815af3e4..b632025f374 100644 --- a/packages/firestore/src/api_pipelines.ts +++ b/packages/firestore/src/api_pipelines.ts @@ -122,7 +122,6 @@ export { rand, array, arrayOffset, - currentContext, isError, ifError, isAbsent, diff --git a/packages/firestore/src/core/pipeline-util.ts b/packages/firestore/src/core/pipeline-util.ts index ec25e258834..5f9b7d31844 100644 --- a/packages/firestore/src/core/pipeline-util.ts +++ b/packages/firestore/src/core/pipeline-util.ts @@ -221,7 +221,7 @@ export function toPipeline(query: Query, db: Firestore): Pipeline { ); } - pipeline = pipeline._limit(query.limit!, true); + pipeline = pipeline.limit(query.limit!, true); pipeline = pipeline.sort(orderings[0], ...orderings.slice(1)); } else { pipeline = pipeline.sort(orderings[0], ...orderings.slice(1)); diff --git a/packages/firestore/src/lite-api/expressions.ts b/packages/firestore/src/lite-api/expressions.ts index 03182ae3227..8120567c561 100644 --- a/packages/firestore/src/lite-api/expressions.ts +++ b/packages/firestore/src/lite-api/expressions.ts @@ -2134,7 +2134,7 @@ export class ExprWithAlias implements Selectable, UserData { /** * @internal */ -class ListOfExprs extends Expr { +class ListOfExprs extends Expr implements UserData { exprType: ExprType = 'ListOfExprs'; constructor(private exprs: Expr[]) { @@ -2345,7 +2345,7 @@ export function constant(value: string): Constant; * @param value The boolean value. * @return A new `Constant` instance. */ -export function constant(value: boolean): Constant; +export function constant(value: boolean): BooleanExpr; /** * Creates a `Constant` instance for a null value. diff --git a/packages/firestore/src/lite-api/pipeline.ts b/packages/firestore/src/lite-api/pipeline.ts index 17ad5464725..d93a8fd6df0 100644 --- a/packages/firestore/src/lite-api/pipeline.ts +++ b/packages/firestore/src/lite-api/pipeline.ts @@ -339,21 +339,6 @@ export class Pipeline implements ProtoSerializable { return this._addStage(new Limit(limit)); } - /** - * Internal use only. - * Helper to add a limit stage when converting from a Query. - * - * @internal - * @private - * - * @param limit - * @param convertedFromLimitToLast - */ - _limit(limit: number, convertedFromLimitToLast: boolean): Pipeline { - return this._addStage(new Limit(limit, convertedFromLimitToLast)); - } - - /** * Returns a set of distinct values from the inputs to this stage. * @@ -552,31 +537,11 @@ export class Pipeline implements ProtoSerializable { * @param additionalOrderings Optional additional {@link Ordering} instances specifying the additional sorting criteria. * @return A new {@code Pipeline} object with this stage appended to the stage list. */ - sort(ordering: Ordering, ...additionalOrderings: Ordering[]): Pipeline; - sort( - optionsOrOrderings: - | Ordering - | { - orderings: Ordering[]; - }, - ...rest: Ordering[] - ): Pipeline { - // Option object - if (optionsOrOrderings && 'orderings' in optionsOrOrderings) { - return this._addStage( - new Sort( - this.readUserData( - 'sort', - this.readUserData('sort', optionsOrOrderings.orderings) - ) - ) - ); - } else { - // Ordering object - return this._addStage( - new Sort(this.readUserData('sort', [optionsOrOrderings, ...rest])) - ); - } + sort(ordering: Ordering, ...additionalOrderings: Ordering[]): Pipeline { + // Ordering object + return this._addStage( + new Sort(this.readUserData('sort', [ordering, ...additionalOrderings])) + ); } /** diff --git a/packages/firestore/src/lite-api/stage.ts b/packages/firestore/src/lite-api/stage.ts index 1d8ae06eaf6..2cb95053825 100644 --- a/packages/firestore/src/lite-api/stage.ts +++ b/packages/firestore/src/lite-api/stage.ts @@ -319,10 +319,7 @@ export class FindNearest implements Stage { export class Limit implements Stage { name = 'limit'; - constructor( - readonly limit: number, - readonly convertedFromLimitTolast: boolean = false - ) { + constructor(readonly limit: number) { hardAssert( !isNaN(limit) && limit !== Infinity && limit !== -Infinity, 'Invalid limit value' diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index 1ef61bf0304..7e7d4e6b82b 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -1139,6 +1139,18 @@ apiDescribe.only('Pipelines', persistence => { { title: "The Handmaid's Tale" } ); }); + + it('where with boolean constant', async () => { + const snapshot = await execute( + firestore + .pipeline() + .collection(randomCol.path) + .where(constant(true)) + .sort(ascending('__name__')) + .limit(2) + ); + expectResults(snapshot, 'book1', 'book10'); + }); }); describe('sort, offset, and limit stages', () => { diff --git a/packages/firestore/test/integration/api/transactions.test.ts b/packages/firestore/test/integration/api/transactions.test.ts index a4d30677a92..48590463857 100644 --- a/packages/firestore/test/integration/api/transactions.test.ts +++ b/packages/firestore/test/integration/api/transactions.test.ts @@ -33,7 +33,7 @@ import { runTransaction, setDoc } from '../util/firebase_export'; -import { apiDescribe, withTestDb } from '../util/helpers'; +import { apiDescribe, withTestCollection, withTestDb } from '../util/helpers'; apiDescribe('Database transactions', persistence => { type TransactionStage = ( From 41bde4237052a8cdf1d50d720dda91331cd42a05 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Mon, 16 Jun 2025 12:08:12 -0600 Subject: [PATCH 59/59] Build and test fixes --- .../firestore/lite/pipelines/pipelines.ts | 1 - packages/firestore/src/core/pipeline-util.ts | 2 +- .../firestore/src/lite-api/expressions.ts | 2 +- packages/firestore/src/lite-api/pipeline.ts | 8 ++++++- packages/firestore/src/lite-api/stage.ts | 4 ++-- .../test/integration/api/pipeline.test.ts | 24 +++++++++---------- packages/firestore/test/lite/pipeline.test.ts | 16 ------------- 7 files changed, 23 insertions(+), 34 deletions(-) diff --git a/packages/firestore/lite/pipelines/pipelines.ts b/packages/firestore/lite/pipelines/pipelines.ts index e03e5f4883b..cc7f91e750c 100644 --- a/packages/firestore/lite/pipelines/pipelines.ts +++ b/packages/firestore/lite/pipelines/pipelines.ts @@ -116,7 +116,6 @@ export { neq, lt, countIf, - currentContext, lte, gt, gte, diff --git a/packages/firestore/src/core/pipeline-util.ts b/packages/firestore/src/core/pipeline-util.ts index 5f9b7d31844..3f36cf5597e 100644 --- a/packages/firestore/src/core/pipeline-util.ts +++ b/packages/firestore/src/core/pipeline-util.ts @@ -221,7 +221,7 @@ export function toPipeline(query: Query, db: Firestore): Pipeline { ); } - pipeline = pipeline.limit(query.limit!, true); + pipeline = pipeline.limit(query.limit!); pipeline = pipeline.sort(orderings[0], ...orderings.slice(1)); } else { pipeline = pipeline.sort(orderings[0], ...orderings.slice(1)); diff --git a/packages/firestore/src/lite-api/expressions.ts b/packages/firestore/src/lite-api/expressions.ts index 8120567c561..04227e259d3 100644 --- a/packages/firestore/src/lite-api/expressions.ts +++ b/packages/firestore/src/lite-api/expressions.ts @@ -2345,7 +2345,7 @@ export function constant(value: string): Constant; * @param value The boolean value. * @return A new `Constant` instance. */ -export function constant(value: boolean): BooleanExpr; +export function constant(value: boolean): Constant; /** * Creates a `Constant` instance for a null value. diff --git a/packages/firestore/src/lite-api/pipeline.ts b/packages/firestore/src/lite-api/pipeline.ts index d93a8fd6df0..8b5bebeddb8 100644 --- a/packages/firestore/src/lite-api/pipeline.ts +++ b/packages/firestore/src/lite-api/pipeline.ts @@ -735,7 +735,13 @@ export class Pipeline implements ProtoSerializable { const alias = field(selectable.alias); this.readUserData('unnest', alias); - return this._addStage(new Unnest(selectable.expr, alias, indexField)); + if (indexField) { + return this._addStage( + new Unnest(selectable.expr, alias, field(indexField)) + ); + } else { + return this._addStage(new Unnest(selectable.expr, alias)); + } } /** diff --git a/packages/firestore/src/lite-api/stage.ts b/packages/firestore/src/lite-api/stage.ts index 2cb95053825..f65af269c76 100644 --- a/packages/firestore/src/lite-api/stage.ts +++ b/packages/firestore/src/lite-api/stage.ts @@ -438,7 +438,7 @@ export class Unnest implements Stage { constructor( private expr: Expr, private alias: Field, - private indexField?: string + private indexField?: Field ) {} _toProto(serializer: JsonProtoSerializer): ProtoStage { @@ -449,7 +449,7 @@ export class Unnest implements Stage { if (this.indexField) { stageProto.options = { - indexField: toStringValue(this.indexField) + index_field: this.indexField._toProto(serializer) }; } diff --git a/packages/firestore/test/integration/api/pipeline.test.ts b/packages/firestore/test/integration/api/pipeline.test.ts index 7e7d4e6b82b..5892073b4fc 100644 --- a/packages/firestore/test/integration/api/pipeline.test.ts +++ b/packages/firestore/test/integration/api/pipeline.test.ts @@ -1140,17 +1140,17 @@ apiDescribe.only('Pipelines', persistence => { ); }); - it('where with boolean constant', async () => { - const snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .where(constant(true)) - .sort(ascending('__name__')) - .limit(2) - ); - expectResults(snapshot, 'book1', 'book10'); - }); + // it('where with boolean constant', async () => { + // const snapshot = await execute( + // firestore + // .pipeline() + // .collection(randomCol.path) + // .where(constant(true)) + // .sort(ascending('__name__')) + // .limit(2) + // ); + // expectResults(snapshot, 'book1', 'book10'); + // }); }); describe('sort, offset, and limit stages', () => { @@ -1422,7 +1422,7 @@ apiDescribe.only('Pipelines', persistence => { .pipeline() .collection(randomCol.path) .where(eq('title', "The Hitchhiker's Guide to the Galaxy")) - .unnest(field('tags').as('tag')) + .unnest(field('tags').as('tag'), 'tagsIndex') .select( 'title', 'author', diff --git a/packages/firestore/test/lite/pipeline.test.ts b/packages/firestore/test/lite/pipeline.test.ts index cedc6b4dcf9..f919e1aa9de 100644 --- a/packages/firestore/test/lite/pipeline.test.ts +++ b/packages/firestore/test/lite/pipeline.test.ts @@ -61,7 +61,6 @@ import { neq, lt, countIf, - currentContext, lte, gt, arrayConcat, @@ -2361,21 +2360,6 @@ describe('Firestore Pipelines', () => { expectResults(snapshot, ...expectedResults); }); - // TODO: current_context tests with are failing because of b/395937453 - itIf(testUnsupportedFeatures)('supports currentContext', async () => { - const snapshot = await execute( - firestore - .pipeline() - .collection(randomCol.path) - .sort(field('rating').descending()) - .limit(1) - .select(currentContext().as('currentContext')) - ); - expectResults(snapshot, { - currentContext: 'TODO' - }); - }); - it('supports map', async () => { const snapshot = await execute( firestore